Swarm-readme-12.py
· 395 B · Python
Неформатований
def greet(context_variables, language):
user_name = context_variables["user_name"]
greeting = "Hola" if language.lower() == "spanish" else "Hello"
print(f"{greeting}, {user_name}!")
return "Done"
agent = Agent(
functions=[print_hello]
)
client.run(
agent=agent,
messages=[{"role": "user", "content": "Usa greet() por favor."}],
context_variables={"user_name": "John"}
)
1 | def greet(context_variables, language): |
2 | user_name = context_variables["user_name"] |
3 | greeting = "Hola" if language.lower() == "spanish" else "Hello" |
4 | print(f"{greeting}, {user_name}!") |
5 | return "Done" |
6 | |
7 | agent = Agent( |
8 | functions=[print_hello] |
9 | ) |
10 | |
11 | client.run( |
12 | agent=agent, |
13 | messages=[{"role": "user", "content": "Usa greet() por favor."}], |
14 | context_variables={"user_name": "John"} |
15 | ) |