-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path003-multiagent.py
More file actions
105 lines (96 loc) · 3.25 KB
/
003-multiagent.py
File metadata and controls
105 lines (96 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.team.team import Team
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.wikipedia import WikipediaTools
from agno.tools.yfinance import YFinanceTools
from agno.tools.reasoning import ReasoningTools
from config.secrets import OPENAI_API_KEY
# Website Agent
website_agent = Agent(
name="Web Search Agent",
role="Handles web searches and retrieves information from the internet.",
model=OpenAIChat(
id="gpt-4.1-mini",
temperature=0.0,
api_key=OPENAI_API_KEY,
),
tools=[DuckDuckGoTools()],
instructions=[
"You are a web search agent.",
"You can search the web for information and answer questions based on the search results.",
"You can also answer questions based on the current date.",
"If you find relevant information, provide it to the user.",
],
add_datetime_to_instructions=True
)
# Wikipedia Agent
wikipedia_agent = Agent(
name="Wikipedia Agent",
role="Retrieves information from Wikipedia.",
model=OpenAIChat(
id="gpt-4.1-mini",
temperature=0.0,
api_key=OPENAI_API_KEY,
),
tools=[WikipediaTools()],
instructions=[
"You are a Wikipedia agent.",
"You can search Wikipedia for information and answer questions based on the search results.",
"If you find relevant information, provide it to the user.",
],
add_datetime_to_instructions=True
)
# Finance Agent
finance_agent = Agent(
name="Finance Agent",
role="Retrieves financial information and stock market data.",
model=OpenAIChat(
id="gpt-4.1-mini",
temperature=0.0,
api_key=OPENAI_API_KEY,
),
tools=[YFinanceTools()],
instructions=[
"You are a finance agent.",
"You can search for financial information and stock market data.",
"If you find relevant information, provide it to the user.",
],
add_datetime_to_instructions=True
)
# Team of Agents with Reasoning
agent_team = Team(
name="Multi-Agent Team",
mode="coordinate",
model=OpenAIChat(
id="gpt-4.1-mini",
temperature=0.7,
api_key=OPENAI_API_KEY,
),
members=[
website_agent,
wikipedia_agent,
finance_agent
],
tools=[ReasoningTools(add_instructions=True)],
instructions=[
"You are a team of agents working together to answer questions.",
"Each agent has a specific role and can access different tools.",
"Coordinate with each other to provide the best answers.",
"Use reasoning to combine information from different agents if necessary.",
],
markdown=True,
show_members_responses=True,
enable_agentic_context=True,
add_datetime_to_instructions=True,
success_criteria= "Provide accurate and relevant information based on the user's query.",
)
# run the team
if __name__ == "__main__":
print("Multi-Agent Team is starting...")
while True:
user_input = input("\n\nUser: ")
if user_input.lower() in ["exit", "quit"]:
print("Exiting the Multi-Agent Team.")
break
agent_team.print_response(user_input, stream=True, show_full_reasoning=True, stream_intermediate_steps=True)