Skip to content

Commit f8431c6

Browse files
authored
Merge branch 'main' into release/v2.2.6
2 parents 9fe5f5a + 2f1bf1d commit f8431c6

File tree

28 files changed

+961
-117
lines changed

28 files changed

+961
-117
lines changed

CONTRIBUTING.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,22 @@ Make sure all tests pass before submitting your pull request. If you add new fea
9595
4. If the Model provider does not support the OpenAI API spec:
9696
- Reach out to us on [Discord](https://discord.gg/4MtYHHrgA8) or open an issue to discuss the best way to integrate your LLM provider.
9797
- Checkout [`agno/models/anthropic/claude.py`](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/models/anthropic/claude.py) or [`agno/models/cohere/chat.py`](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/models/cohere/chat.py) for inspiration.
98-
5. Add a recipe for using your Model provider under `cookbook/models/<your_model>`.
98+
5. Add your model provider to `libs/agno/agno/models/utils.py`:
99+
- Add a new `elif` clause in the `get_model()` function with your provider name
100+
- Use the provider name that matches your module directory (e.g., "meta" for `models/meta/`)
101+
- Import and return your Model class with the provided `model_id`
102+
- This enables users to use the string format: `model="yourprovider:model-name"`
103+
- Example:
104+
```python
105+
elif provider == "yourprovider":
106+
from agno.models.yourprovider import YourModel
107+
return YourModel(id=model_id)
108+
```
109+
6. Add a recipe for using your Model provider under `cookbook/models/<your_model>`.
99110
- Checkout [`agno/cookbook/models/aws/claude`](https://github.com/agno-agi/agno/tree/main/cookbook/models/aws/claude) for an example.
100-
6. Important: Format and validate your code by running `./scripts/format.sh` and `./scripts/validate.sh`.
101-
7. Submit a pull request.
111+
- Show both the model class and string syntax in your examples
112+
7. Important: Format and validate your code by running `./scripts/format.sh` and `./scripts/validate.sh`.
113+
8. Submit a pull request.
102114

103115
## Adding a new Tool.
104116

cookbook/agent_os/agent_with_input_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from typing import List
22

33
from agno.agent import Agent
4+
from agno.db.sqlite import SqliteDb
45
from agno.models.openai import OpenAIChat
56
from agno.os import AgentOS
67
from agno.tools.hackernews import HackerNewsTools
78
from pydantic import BaseModel, Field
8-
from agno.db.sqlite import SqliteDb
99

1010

1111
class ResearchTopic(BaseModel):

cookbook/agent_os/team_with_input_schema.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
from typing import List
1010

1111
from agno.agent import Agent
12+
from agno.db.sqlite import SqliteDb
1213
from agno.models.openai import OpenAIChat
1314
from agno.os import AgentOS
1415
from agno.team.team import Team
1516
from agno.tools.duckduckgo import DuckDuckGoTools
1617
from agno.tools.hackernews import HackerNewsTools
1718
from pydantic import BaseModel, Field
18-
from agno.db.sqlite import SqliteDb
19+
1920

2021
class ResearchProject(BaseModel):
2122
"""Structured research project with validation requirements."""
@@ -28,9 +29,7 @@ class ResearchProject(BaseModel):
2829
depth_level: str = Field(
2930
description="Research depth level", pattern="^(basic|intermediate|advanced)$"
3031
)
31-
max_sources: int = Field(
32-
description="Maximum number of sources to use", default=10
33-
)
32+
max_sources: int = Field(description="Maximum number of sources to use", default=10)
3433
include_recent_only: bool = Field(
3534
description="Whether to focus only on recent sources", default=True
3635
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Example showing how to set the model for an Agent using a model string"""
2+
3+
from agno.agent import Agent
4+
5+
# Model strings follow the format "{provider}:{model_id}", for example:
6+
model_string = "openai:gpt-4o"
7+
8+
agent = Agent(model=model_string, markdown=True)
9+
10+
agent.print_response("Share a 2 sentence horror story")

cookbook/agents/state/session_state_basic.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from agno.agent import Agent
1+
from agno.agent import Agent, RunOutput # noqa
22
from agno.db.sqlite import SqliteDb
33
from agno.models.openai import OpenAIChat
44

@@ -24,3 +24,7 @@ def add_item(session_state, item: str) -> str:
2424
# Example usage
2525
agent.print_response("Add milk, eggs, and bread to the shopping list", stream=True)
2626
print(f"Final session state: {agent.get_session_state()}")
27+
28+
# Alternatively,
29+
# response: RunOutput = agent.run("Add milk, eggs, and bread to the shopping list")
30+
# print(f"Final session state: {response.session_state}")
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from agno.agent import Agent, RunCompletedEvent
2+
from agno.db.sqlite import SqliteDb
3+
from agno.models.openai import OpenAIChat
4+
5+
6+
def add_item(session_state, item: str) -> str:
7+
"""Add an item to the shopping list."""
8+
session_state["shopping_list"].append(item) # type: ignore
9+
return f"The shopping list is now {session_state['shopping_list']}" # type: ignore
10+
11+
12+
# Create an Agent that maintains state
13+
agent = Agent(
14+
model=OpenAIChat(id="gpt-4o-mini"),
15+
# Initialize the session state with a counter starting at 0 (this is the default session state for all users)
16+
session_state={"shopping_list": []},
17+
db=SqliteDb(db_file="tmp/agents.db"),
18+
tools=[add_item],
19+
# You can use variables from the session state in the instructions
20+
instructions="Current state (shopping list) is: {shopping_list}",
21+
markdown=True,
22+
)
23+
24+
# Example usage
25+
response = agent.run(
26+
"Add milk, eggs, and bread to the shopping list", stream=True, stream_events=True
27+
)
28+
for event in response:
29+
if isinstance(event, RunCompletedEvent):
30+
print(f"Session state: {event.session_state}")

cookbook/examples/teams/multi_purpose_team.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123

124124
agent_team = Team(
125125
name="Agent Team",
126-
model=Claude(id="claude-3-5-sonnet-latest"),
126+
model=Claude(id="claude-3-7-sonnet-latest"),
127127
members=[
128128
web_agent,
129129
finance_agent,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from agno.agent import Agent
2+
from agno.team import Team
3+
from agno.tools.duckduckgo import DuckDuckGoTools
4+
5+
# Model strings follow the format "{provider}:{model_id}", for example:
6+
model_string = "openai:gpt-4o-mini"
7+
8+
# Create a research team
9+
team = Team(
10+
model=model_string,
11+
members=[
12+
Agent(
13+
model=model_string,
14+
name="Sarah",
15+
role="Data Researcher",
16+
tools=[DuckDuckGoTools()],
17+
instructions="Focus on gathering and analyzing data",
18+
),
19+
Agent(
20+
model=model_string,
21+
name="Mike",
22+
role="Technical Writer",
23+
instructions="Create clear, concise summaries",
24+
),
25+
],
26+
)
27+
28+
team.print_response(
29+
"Search for latest news about the latest AI models",
30+
)

0 commit comments

Comments
 (0)