-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathhierarchical_multi_agent.py
More file actions
64 lines (50 loc) · 1.26 KB
/
hierarchical_multi_agent.py
File metadata and controls
64 lines (50 loc) · 1.26 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
from aser import Agent, Team
from aser.tools import tool
import asyncio
@tool()
def get_btc_price():
"""get bitcoin or btc price"""
return "100,000"
@tool()
def get_eth_price():
"""get eth or ethereum price"""
return "1,000"
@tool()
def get_sol_price():
"""get solana or sol price"""
return "100"
agent_btc = Agent(
name="search_btc_agent",
model="gpt-4o-mini",
description="search bitcoin price",
tools=[get_btc_price],
)
agent_eth = Agent(
name="search_eth_agent",
model="gpt-4o-mini",
description="search ethereum price",
tools=[get_eth_price],
)
agent_sol = Agent(
name="search_sol_agent",
model="gpt-4o-mini",
description="search solana price",
tools=[get_sol_price],
)
agent_write = Agent(
name="write_agent", description="write article, max 100 words", model="gpt-4.1-mini"
)
supervisor = Agent(
name="supervisor_agent", description="supervisor", model="gpt-4.1-mini"
)
agents = Team(
name="agents_team",
members=[agent_btc, agent_eth, agent_sol, agent_write],
supervisor=supervisor,
mode="hierarchical",
)
async def main():
result = await agents.run("write a article about crypto price")
print(result["final_result"])
if __name__ == "__main__":
asyncio.run(main())