Skip to content

Commit d3c0bb1

Browse files
committed
tighten up agno agentic chat and tool based gen ui examples
1 parent df518dc commit d3c0bb1

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

typescript-sdk/integrations/agno/examples/server/api/agentic_chat.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,25 @@
66
from agno.app.agui.app import AGUIApp
77
from agno.models.openai import OpenAIChat
88
from agno.tools.yfinance import YFinanceTools
9+
from agno.tools import tool
10+
11+
12+
@tool(external_execution=True)
13+
def change_background(background: str) -> str: # pylint: disable=unused-argument
14+
"""
15+
Change the background color of the chat. Can be anything that the CSS background attribute accepts. Regular colors, linear of radial gradients etc.
16+
17+
Args:
18+
background: str: The background color to change to. Can be anything that the CSS background attribute accepts. Regular colors, linear of radial gradients etc.
19+
""" # pylint: disable=line-too-long
920

1021
agent = Agent(
1122
model=OpenAIChat(id="gpt-4o"),
1223
tools=[
1324
YFinanceTools(
1425
stock_price=True, analyst_recommendations=True, stock_fundamentals=True
15-
)
26+
),
27+
change_background,
1628
],
1729
description="You are an investment analyst that researches stock prices, analyst recommendations, and stock fundamentals.",
1830
instructions="Format your response using markdown and use tables to display data where possible.",

typescript-sdk/integrations/agno/examples/server/api/tool_based_generative_ui.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,40 @@
1111
from agno.tools import tool
1212

1313

14-
@tool()
15-
def generate_haiku(english: List[str], japanese: List[str]) -> str: # pylint: disable=unused-argument
14+
@tool(external_execution=True)
15+
def generate_haiku(english: List[str], japanese: List[str], image_names: List[str]) -> str: # pylint: disable=unused-argument
1616
"""
17+
1718
Generate a haiku in Japanese and its English translation.
18-
YOU MUST PROVIDE THE ENGLISH HAIKU AND THE JAPANESE HAIKU.
19+
YOU MUST PROVIDE THE ENGLISH HAIKU AND THE JAPANESE HAIKU AND THE IMAGE NAMES.
20+
When picking image names, pick them from the following list:
21+
- "Osaka_Castle_Turret_Stone_Wall_Pine_Trees_Daytime.jpg",
22+
- "Tokyo_Skyline_Night_Tokyo_Tower_Mount_Fuji_View.jpg",
23+
- "Itsukushima_Shrine_Miyajima_Floating_Torii_Gate_Sunset_Long_Exposure.jpg",
24+
- "Takachiho_Gorge_Waterfall_River_Lush_Greenery_Japan.jpg",
25+
- "Bonsai_Tree_Potted_Japanese_Art_Green_Foliage.jpeg",
26+
- "Shirakawa-go_Gassho-zukuri_Thatched_Roof_Village_Aerial_View.jpg",
27+
- "Ginkaku-ji_Silver_Pavilion_Kyoto_Japanese_Garden_Pond_Reflection.jpg",
28+
- "Senso-ji_Temple_Asakusa_Cherry_Blossoms_Kimono_Umbrella.jpg",
29+
- "Cherry_Blossoms_Sakura_Night_View_City_Lights_Japan.jpg",
30+
- "Mount_Fuji_Lake_Reflection_Cherry_Blossoms_Sakura_Spring.jpg"
1931
2032
Args:
2133
english: List[str]: An array of three lines of the haiku in English. YOU MUST PROVIDE THE ENGLISH HAIKU.
2234
japanese: List[str]: An array of three lines of the haiku in Japanese. YOU MUST PROVIDE THE JAPANESE HAIKU.
35+
image_names: List[str]: An array of three image names. YOU MUST PROVIDE THE IMAGE NAMES.
36+
2337
2438
Returns:
2539
str: A confirmation message.
2640
""" # pylint: disable=line-too-long
2741
return "Haiku generated"
2842

29-
30-
@tool(external_execution=True)
31-
def change_background(background: str) -> str: # pylint: disable=unused-argument
32-
"""
33-
Change the background color of the chat. Can be anything that the CSS background attribute accepts. Regular colors, linear of radial gradients etc.
34-
35-
Args:
36-
background: str: The background color to change to. Can be anything that the CSS background attribute accepts. Regular colors, linear of radial gradients etc.
37-
""" # pylint: disable=line-too-long
38-
3943
agent = Agent(
4044
model=OpenAIChat(id="gpt-4o"),
41-
tools=[generate_haiku, change_background],
42-
description="You are a helpful assistant that can help with tasks and answer questions.",
45+
tools=[generate_haiku],
46+
description="Help the user with writing Haikus. If the user asks for a haiku, use the generate_haiku tool to display the haiku to the user.",
47+
debug_mode=True,
4348
)
4449

4550
agui_app = AGUIApp(

0 commit comments

Comments
 (0)