Skip to content

Commit

Permalink
fixed lock, extended restapi, updated litellm
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkulaga committed Jan 17, 2025
1 parent d8ce06b commit f1e6a76
Show file tree
Hide file tree
Showing 20 changed files with 378 additions and 159 deletions.
4 changes: 2 additions & 2 deletions coding/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "just-agents-coding"
version = "0.4.8"
version = "0.4.9"
description = "Just Agents - Coding Components"
authors = [
"Alex Karmazin <karmazinalex@gmail.com>",
Expand All @@ -19,7 +19,7 @@ license = "MIT"

[tool.poetry.dependencies]
python = ">=3.10,<4.0"
just-agents-core = ">=0.4.8"
just-agents-core = ">=0.4.9"
llm-sandbox = ">=0.1.8"

[build-system]
Expand Down
30 changes: 30 additions & 0 deletions config/agent_profiles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
SecretaryAgent:
autoload_from_yaml: false
backstory: Developed to assist in understanding and documenting AI agents' capabilities
and characteristics.
class_qualname: just_agents.router.secretary_agent.SecretaryAgent
description: A skilled AI assistant focused on generating detailed profiles for
AI agents.
expertise_domain: AI agent analysis and description
extra_dict:
personality_traits: Agent's personality traits go here
goal: To provide accurate and informative profiles for various AI agents.
knowledge_sources: []
limitations: Limited to analysis and description tasks; may not perform actions
outside of its defined scope.
llm_options:
model: gpt-4o-mini
temperature: 0.0
model_name: gpt-4o-mini
personality_traits: Detail-oriented, analytical, concise, informative
role: AI assistant specializing in agent profiling.
system_prompt: |2-
You are a skilled AI assistant specializing in analysis and description of AI agents.
You are tasked with generation of a minimalistic and concise yet detail-rich profile for an AI agent, based on the AVAILABLE_ATTRIBUTES,
including 'system_prompt', 'llm_options' and any other. Your task is to fill in values of a JSON-formatted profile
that matches the PROFILE_UPDATE_TEMPLATE provided below. Values of the template describe what output is expected for each field.
Only populate fields based on the well-established information, don't make up anything.
Double-check that the output contains only a valid JSON with all the fields specified in PROFILE_UPDATE_TEMPLATE.
Never include any additional text or explanations in your reply.
task: Generate concise and detail-rich profiles for AI agents.
6 changes: 3 additions & 3 deletions core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "just-agents-core"
version = "0.4.8"
version = "0.4.9"
description = "Just Agents - Base Package"
authors = [
"Alex Karmazin <karmazinalex@gmail.com>",
Expand All @@ -16,7 +16,7 @@ packages = [
{ include = "just_agents" }
]
license = "MIT"
keywords = ["python", "llm", "science", "review", "agents", "AI"]
keywords = ["python", "llm", "science", "review", "agents", "AI", "longevity", "biology", "coding", "web", "tools", "router"]
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
Expand All @@ -30,7 +30,7 @@ classifiers = [

[tool.poetry.dependencies]
python = ">=3.10,<4.0"
litellm = ">=1.57.2"
litellm = ">=1.58.4"
pydantic = ">=2.0.0,<3.0.0"
Deprecated = ">=1.2.15"
requests = "*"
Expand Down
127 changes: 127 additions & 0 deletions examples/just_agents/examples/multiagent/drug_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
from dotenv import load_dotenv
from just_agents.base_agent import BaseAgent
from just_agents import llm_options
from pathlib import Path
import json

# Load environment variables (for API keys)
load_dotenv(override=True)

def format_responses_markdown(topic: str, model_responses: dict, include_individual_responses: bool = True) -> str:
"""
Format multiple model responses into a markdown document with a consensus summary.
Args:
topic: The main topic or question being discussed
model_responses: Dictionary of model names and their responses
include_individual_responses: Whether to include individual model responses in output
"""
markdown = f"# {topic}\n\n"

if include_individual_responses:
for model, response in model_responses.items():
markdown += f"## Analysis from {model}\n\n"
markdown += f"{response}\n\n"

markdown += "## Consensus Summary\n\n"

# Create consensus summary using Claude
summary_agent = BaseAgent(
llm_options=llm_options.ANTHROPIC_CLAUDE_3_5_SONNET,
system_prompt="""You are an expert summarizer. Your task is to:
1. Analyze multiple model outputs on the same topic
2. Identify key points of agreement and disagreement
3. Synthesize a clear, comprehensive consensus summary
4. Format the output in clear markdown with appropriate headers and bullet points
5. Highlight any important caveats or limitations
Please be thorough but concise in your summary."""
)

summary_prompt = f"Please provide a consensus summary of these model outputs about '{topic}':\n\n"
for model, response in model_responses.items():
summary_prompt += f"{model}:\n{response}\n\n"

consensus_summary = summary_agent.query(summary_prompt)
markdown += consensus_summary

return markdown

def save_markdown_summary(output_dir: Path, filename: str, markdown_content: str):
"""Save markdown content to a file"""
output_dir.mkdir(exist_ok=True)
output_file = output_dir / f"{filename}.md"
output_file.write_text(markdown_content)
return output_file

def ensure_drugs_directory() -> Path:
"""Create and return the drugs directory path"""
drugs_dir = Path("drugs")
drugs_dir.mkdir(exist_ok=True)
return drugs_dir

def query_drug_info():
# List of drugs to query
drugs = ["rapamycin", "quercetin", "metformin", "curcumin"]

# Initialize agents with different models
agents = {
"GPT-4": BaseAgent(
llm_options=llm_options.OPENAI_GPT4o,
system_prompt="""You are a knowledgeable pharmaceutical expert.
When asked about a drug, provide information about:
1. Its mechanism of action
2. Common uses
3. Potential longevity/anti-aging effects
4. Known side effects
Please be concise but thorough in your responses."""
),
"Claude-3": BaseAgent(
llm_options=llm_options.ANTHROPIC_CLAUDE_3_5_SONNET,
system_prompt="""You are a knowledgeable pharmaceutical expert.
When asked about a drug, provide information about:
1. Its mechanism of action
2. Common uses
3. Potential longevity/anti-aging effects
4. Known side effects
Please be concise but thorough in your responses."""
),
"LLAMA-3": BaseAgent(
llm_options=llm_options.LLAMA3_3, # You'll need to ensure this constant exists in llm_options
system_prompt="""You are a knowledgeable pharmaceutical expert.
When asked about a drug, provide information about:
1. Its mechanism of action
2. Common uses
3. Potential longevity/anti-aging effects
4. Known side effects
Please be concise but thorough in your responses."""
)
}

# Create drugs directory
drugs_dir = ensure_drugs_directory()

# Query information for each drug
for drug in drugs:
print(f"\nQuerying information about {drug}...")
model_responses = {}

for model_name, agent in agents.items():
prompt = f"What do you know about {drug} and its effects on longevity and health?"
response = agent.query(prompt)
model_responses[model_name] = response

# Format and save markdown file
markdown_content = format_responses_markdown(drug, model_responses)
output_file = drugs_dir / f"{drug}.md"
output_file.write_text(markdown_content)

print(f"Saved information about {drug} to {output_file}")
print(f"\n{'='*50}\n")

return drugs_dir

if __name__ == "__main__":
output_dir = query_drug_info()
# this code was generated by cursor withing 5 mins by adding just-agents to the context
print(f"\nAll drug information has been saved to {output_dir}")

4 changes: 2 additions & 2 deletions examples/just_agents/examples/web/nice_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from just_agents.interfaces.agent import IAgent
from just_agents.simple.utils import build_agent
from just_agents.web.rest_api import *
from just_agents.web.run import *
from just_agents.web.run_agent import *

from pycomfort.logging import to_nice_stdout

Expand All @@ -19,4 +19,4 @@
if __name__ == "__main__":
to_nice_stdout()
cofig_path = web_examples_dir / "agent.yaml"
run_server(config=cofig_path)
run_agent_server(config=cofig_path)
2 changes: 1 addition & 1 deletion examples/notebooks/01_just_agents_colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
}
],
"source": [
"!pip install just-agents-core==0.4.8"
"!pip install just-agents-core==0.4.9"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions examples/notebooks/02_sqlite_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
"Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (3.7.1)\n",
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (1.9.0)\n",
"Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.27.2)\n",
"Requirement already satisfied: jiter<1,>=0.4.8 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.7.0)\n",
"Requirement already satisfied: jiter<1,>=0.4.9 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.7.0)\n",
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (1.3.1)\n",
"Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (4.66.6)\n",
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3.0.0,>=2.0.0->litellm>=1.51.0->just-agents) (0.7.0)\n",
Expand Down Expand Up @@ -312,8 +312,8 @@
}
],
"source": [
"!pip install just-agents-core==0.4.8\n",
"!pip install just-agents-examples==0.4.8"
"!pip install just-agents-core==0.4.9\n",
"!pip install just-agents-examples==0.4.9"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions examples/notebooks/03_coding_agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (3.7.1)\n",
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (1.9.0)\n",
"Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.27.2)\n",
"Requirement already satisfied: jiter<1,>=0.4.8 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.7.1)\n",
"Requirement already satisfied: jiter<1,>=0.4.9 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.7.1)\n",
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (1.3.1)\n",
"Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (4.66.6)\n",
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3.0.0,>=2.0.0->litellm>=1.51.0->just-agents) (0.7.0)\n",
Expand Down Expand Up @@ -156,8 +156,8 @@
}
],
"source": [
"!pip install just-agents-core==0.4.8\n",
"!pip install just-agents-examples==0.4.8"
"!pip install just-agents-core==0.4.9\n",
"!pip install just-agents-examples==0.4.9"
]
},
{
Expand Down
12 changes: 6 additions & 6 deletions examples/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "just-agents-examples"
version = "0.4.8"
version = "0.4.9"
description = "Just Agents - Examples code"
authors = ["Alex Karmazin <karmazinalex@gmail.com>"]
maintainers = ["Anton Kulaga <antonkulaga@gmail.com>"]
Expand All @@ -12,11 +12,11 @@ license = "MIT"

[tool.poetry.dependencies]
python = ">=3.10,<4.0"
just-agents-core = ">=0.4.8"
just-agents-tools = ">=0.4.8"
just-agents-coding = ">=0.4.8"
just-agents-web = ">=0.4.8"
just-agents-router = ">=0.4.8"
just-agents-core = ">=0.4.9"
just-agents-tools = ">=0.4.9"
just-agents-coding = ">=0.4.9"
just-agents-web = ">=0.4.9"
just-agents-router = ">=0.4.9"
docker = ">=7.1.0"

[tool.poetry.group.dev.dependencies]
Expand Down
Loading

0 comments on commit f1e6a76

Please sign in to comment.