Swarm-readme-3.sh
· 474 B · Bash
Raw
```python
from swarm import Swarm, Agent
client = Swarm()
def transfer_to_agent_b():
return agent_b
agent_a = Agent(
name="Agent A",
instructions="You are a helpful agent.",
functions=[transfer_to_agent_b],
)
agent_b = Agent(
name="Agent B",
instructions="Only speak in Haikus.",
)
response = client.run(
agent=agent_a,
messages=[{"role": "user", "content": "I want to talk to agent B."}],
)
print(response.messages[-1]["content"])
```
1 | ```python |
2 | from swarm import Swarm, Agent |
3 | |
4 | client = Swarm() |
5 | |
6 | def transfer_to_agent_b(): |
7 | return agent_b |
8 | |
9 | |
10 | agent_a = Agent( |
11 | name="Agent A", |
12 | instructions="You are a helpful agent.", |
13 | functions=[transfer_to_agent_b], |
14 | ) |
15 | |
16 | agent_b = Agent( |
17 | name="Agent B", |
18 | instructions="Only speak in Haikus.", |
19 | ) |
20 | |
21 | response = client.run( |
22 | agent=agent_a, |
23 | messages=[{"role": "user", "content": "I want to talk to agent B."}], |
24 | ) |
25 | |
26 | print(response.messages[-1]["content"]) |
27 | ``` |