-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautogen-multi-agent-orchestration.py
More file actions
47 lines (39 loc) · 1.35 KB
/
Copy pathautogen-multi-agent-orchestration.py
File metadata and controls
47 lines (39 loc) · 1.35 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
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.tools import AgentTool
from autogen_agentchat.ui import Console
from autogen_ext.models.ollama import OllamaChatCompletionClient
async def run():
model_client = OllamaChatCompletionClient(model='qwen2.5:0.5b')
math_agent = AssistantAgent(
'math_expert',
model_client=model_client,
model_client_stream=True,
system_message='You are a math expert.',
description='A math expert assistant.',
)
math_agent_tool = AgentTool(
math_agent,
return_value_as_last_message=True
)
chemistry_agent = AssistantAgent(
'chemistry_expert',
model_client=model_client,
model_client_stream=True,
system_message='You are a chemistry expert.',
description='A chemistry expert assistant.',
)
chemistry_agent_tool = AgentTool(
chemistry_agent,
return_value_as_last_message=True
)
agent = AssistantAgent(
'assistant',
model_client=model_client,
model_client_stream=True,
system_message='You are a general assistant. Use expert tools when needed.',
tools=[math_agent_tool, chemistry_agent_tool],
max_tool_iterations=10,
)
await Console(agent.run_stream(task='How much is 2 plus 3?'))
asyncio.run(run())