Swarm-readme-16.py
· 461 B · Python
Неформатований
sales_agent = Agent(name="Sales Agent")
def talk_to_sales():
print("Hello, World!")
return Result(
value="Done",
agent=sales_agent,
context_variables={"department": "sales"}
)
agent = Agent(functions=[talk_to_sales])
response = client.run(
agent=agent,
messages=[{"role": "user", "content": "Transfer me to sales"}],
context_variables={"user_name": "John"}
)
print(response.agent.name)
print(response.context_variables)
1 | sales_agent = Agent(name="Sales Agent") |
2 | |
3 | def talk_to_sales(): |
4 | print("Hello, World!") |
5 | return Result( |
6 | value="Done", |
7 | agent=sales_agent, |
8 | context_variables={"department": "sales"} |
9 | ) |
10 | |
11 | agent = Agent(functions=[talk_to_sales]) |
12 | |
13 | response = client.run( |
14 | agent=agent, |
15 | messages=[{"role": "user", "content": "Transfer me to sales"}], |
16 | context_variables={"user_name": "John"} |
17 | ) |
18 | print(response.agent.name) |
19 | print(response.context_variables) |