Skip to content

Commit 07d80d8

Browse files
committed
Merge branch 'release/1.6.0' of https://github.com/agno-agi/agno into release/1.6.0
2 parents bb7480c + d22d9ef commit 07d80d8

File tree

47 files changed

+1157
-828
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1157
-828
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import asyncio
2+
3+
from agno.agent import RunEvent
4+
from agno.agent.agent import Agent
5+
from agno.models.openai.chat import OpenAIChat
6+
from agno.tools.yfinance import YFinanceTools
7+
8+
finance_agent = Agent(
9+
agent_id="finance-agent",
10+
name="Finance Agent",
11+
model=OpenAIChat(id="gpt-4o"),
12+
tools=[YFinanceTools()],
13+
)
14+
15+
16+
async def run_agent_with_events(prompt: str):
17+
content_started = False
18+
async for run_response_event in await finance_agent.arun(
19+
prompt,
20+
stream=True,
21+
stream_intermediate_steps=True,
22+
):
23+
if run_response_event.event in [RunEvent.run_started, RunEvent.run_completed]:
24+
print(f"\nEVENT: {run_response_event.event}")
25+
26+
if run_response_event.event in [RunEvent.tool_call_started]:
27+
print(f"\nEVENT: {run_response_event.event}")
28+
print(f"TOOL CALL: {run_response_event.tool.tool_name}")
29+
print(f"TOOL CALL ARGS: {run_response_event.tool.tool_args}")
30+
31+
if run_response_event.event in [RunEvent.tool_call_completed]:
32+
print(f"\nEVENT: {run_response_event.event}")
33+
print(f"TOOL CALL: {run_response_event.tool.tool_name}")
34+
print(f"TOOL CALL RESULT: {run_response_event.tool.result}")
35+
36+
if run_response_event.event in [RunEvent.run_response_content]:
37+
if not content_started:
38+
print("\nCONTENT:")
39+
content_started = True
40+
else:
41+
print(run_response_event.content, end="")
42+
43+
44+
if __name__ == "__main__":
45+
asyncio.run(
46+
run_agent_with_events(
47+
"What is the price of Apple stock?",
48+
)
49+
)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import asyncio
2+
3+
from agno.agent import RunEvent
4+
from agno.agent.agent import Agent
5+
from agno.models.openai.chat import OpenAIChat
6+
7+
finance_agent = Agent(
8+
model=OpenAIChat(id="gpt-4o"),
9+
reasoning=True,
10+
)
11+
12+
13+
async def run_agent_with_events(prompt: str):
14+
content_started = False
15+
async for run_response_event in await finance_agent.arun(
16+
prompt,
17+
stream=True,
18+
stream_intermediate_steps=True,
19+
):
20+
if run_response_event.event in [RunEvent.run_started, RunEvent.run_completed]:
21+
print(f"\nEVENT: {run_response_event.event}")
22+
23+
if run_response_event.event in [RunEvent.reasoning_started]:
24+
print(f"\nEVENT: {run_response_event.event}")
25+
26+
if run_response_event.event in [RunEvent.reasoning_step]:
27+
print(f"\nEVENT: {run_response_event.event}")
28+
print(f"REASONING CONTENT: {run_response_event.reasoning_content}")
29+
30+
if run_response_event.event in [RunEvent.reasoning_completed]:
31+
print(f"\nEVENT: {run_response_event.event}")
32+
33+
if run_response_event.event in [RunEvent.run_response_content]:
34+
if not content_started:
35+
print("\nCONTENT:")
36+
content_started = True
37+
else:
38+
print(run_response_event.content, end="")
39+
40+
41+
if __name__ == "__main__":
42+
task = (
43+
"Analyze the key factors that led to the signing of the Treaty of Versailles in 1919. "
44+
"Discuss the political, economic, and social impacts of the treaty on Germany and how it "
45+
"contributed to the onset of World War II. Provide a nuanced assessment that includes "
46+
"multiple historical perspectives."
47+
)
48+
asyncio.run(
49+
run_agent_with_events(
50+
task,
51+
)
52+
)

cookbook/examples/streamlit_apps/agentic_rag/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ def main():
300300
run_response = agentic_rag_agent.run(question, stream=True)
301301
for _resp_chunk in run_response:
302302
# Display tool calls if available
303-
if _resp_chunk.tools and len(_resp_chunk.tools) > 0:
304-
display_tool_calls(tool_calls_container, _resp_chunk.tools)
303+
if hasattr(_resp_chunk, "tool") and _resp_chunk.tool:
304+
display_tool_calls(tool_calls_container, [_resp_chunk.tool])
305305

306306
# Display response
307307
if _resp_chunk.content is not None:

cookbook/examples/streamlit_apps/agentic_rag/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file was autogenerated by uv via the following command:
22
# ./generate_requirements.sh
3-
agno==1.4.5
3+
agno==1.6.0
44
# via -r cookbook/examples/apps/agentic_rag/requirements.in
55
altair==5.5.0
66
# via streamlit

cookbook/examples/streamlit_apps/agentic_rag/utils.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import streamlit as st
44
from agentic_rag import get_agentic_rag_agent
55
from agno.agent import Agent
6+
from agno.models.response import ToolExecution
67
from agno.utils.log import logger
78

89

@@ -38,7 +39,7 @@ def export_chat_history():
3839
return ""
3940

4041

41-
def display_tool_calls(tool_calls_container, tools):
42+
def display_tool_calls(tool_calls_container, tools: List[ToolExecution]):
4243
"""Display tool calls in a streamlit container with expandable sections.
4344
4445
Args:
@@ -51,19 +52,10 @@ def display_tool_calls(tool_calls_container, tools):
5152
with tool_calls_container.container():
5253
for tool_call in tools:
5354
# Handle different tool call formats
54-
_tool_name = (
55-
tool_call.get("tool_name") or tool_call.get("name") or "Unknown Tool"
56-
)
57-
_tool_args = tool_call.get("tool_args") or tool_call.get("arguments") or {}
58-
_content = tool_call.get("content") or tool_call.get("result", "")
59-
_metrics = tool_call.get("metrics", {})
60-
61-
# Handle function objects
62-
if hasattr(tool_call, "function") and tool_call.function:
63-
if hasattr(tool_call.function, "name"):
64-
_tool_name = tool_call.function.name
65-
if hasattr(tool_call.function, "arguments"):
66-
_tool_args = tool_call.function.arguments
55+
_tool_name = tool_call.tool_name or "Unknown Tool"
56+
_tool_args = tool_call.tool_args or {}
57+
_content = tool_call.result or ""
58+
_metrics = tool_call.metrics or {}
6759

6860
# Safely create the title with a default if tool name is None
6961
title = f"🛠️ {_tool_name.replace('_', ' ').title() if _tool_name else 'Tool Call'}"
@@ -101,7 +93,9 @@ def display_tool_calls(tool_calls_container, tools):
10193

10294
if _metrics:
10395
st.markdown("**Metrics:**")
104-
st.json(_metrics)
96+
st.json(
97+
_metrics if isinstance(_metrics, dict) else _metrics._to_dict()
98+
)
10599

106100

107101
def rename_session_widget(agent: Agent) -> None:

cookbook/examples/streamlit_apps/answer_engine/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ def main() -> None:
177177
run_response = sage.run(question, stream=True)
178178
for _resp_chunk in run_response:
179179
# Display tool calls if available
180-
if _resp_chunk.tools and len(_resp_chunk.tools) > 0:
181-
display_tool_calls(tool_calls_container, _resp_chunk.tools)
180+
if hasattr(_resp_chunk, "tool") and _resp_chunk.tool:
181+
display_tool_calls(tool_calls_container, [_resp_chunk.tool])
182182

183183
# Display response
184184
if _resp_chunk.content is not None:

cookbook/examples/streamlit_apps/answer_engine/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file was autogenerated by uv via the following command:
22
# ./generate_requirements.sh
3-
agno==1.1.11
3+
agno==1.6.0
44
# via -r cookbook/examples/apps/answer_engine/requirements.in
55
altair==5.5.0
66
# via streamlit

cookbook/examples/streamlit_apps/answer_engine/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import streamlit as st
44
from agents import get_sage
55
from agno.agent.agent import Agent
6+
from agno.models.response import ToolExecution
67
from agno.utils.log import logger
78

89

@@ -39,7 +40,7 @@ def export_chat_history():
3940
return ""
4041

4142

42-
def display_tool_calls(tool_calls_container, tools):
43+
def display_tool_calls(tool_calls_container, tools: List[ToolExecution]):
4344
"""Display tool calls in a streamlit container with expandable sections.
4445
4546
Args:
@@ -49,10 +50,10 @@ def display_tool_calls(tool_calls_container, tools):
4950
try:
5051
with tool_calls_container.container():
5152
for tool_call in tools:
52-
tool_name = tool_call.get("tool_name", "Unknown Tool")
53-
tool_args = tool_call.get("tool_args", {})
54-
content = tool_call.get("content")
55-
metrics = tool_call.get("metrics", {})
53+
tool_name = tool_call.tool_name or "Unknown Tool"
54+
tool_args = tool_call.tool_args or {}
55+
content = tool_call.result or ""
56+
metrics = tool_call.metrics or {}
5657

5758
# Add timing information
5859
execution_time_str = "N/A"

cookbook/examples/streamlit_apps/chess_team/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file was autogenerated by uv via the following command:
22
# ./generate_requirements.sh
3-
agno==1.1.17
3+
agno==1.6.0
44
# via -r cookbook/examples/apps/chess_team/requirements.in
55
altair==5.5.0
66
# via streamlit

cookbook/examples/streamlit_apps/gemini-tutor/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file was autogenerated by uv via the following command:
22
# ./generate_requirements.sh
3-
agno==1.3.2
3+
agno==1.6.0
44
# via -r cookbook/examples/apps/gemini-tutor/requirements.in
55
altair==5.5.0
66
# via streamlit

0 commit comments

Comments
 (0)