Swarm-readme-10.py
· 365 B · Python
Brut
def instructions(context_variables):
user_name = context_variables["user_name"]
return f"Help the user, {user_name}, do whatever they want."
agent = Agent(
instructions=instructions
)
response = client.run(
agent=agent,
messages=[{"role":"user", "content": "Hi!"}],
context_variables={"user_name":"John"}
)
print(response.messages[-1]["content"])
1 | def instructions(context_variables): |
2 | user_name = context_variables["user_name"] |
3 | return f"Help the user, {user_name}, do whatever they want." |
4 | |
5 | agent = Agent( |
6 | instructions=instructions |
7 | ) |
8 | response = client.run( |
9 | agent=agent, |
10 | messages=[{"role":"user", "content": "Hi!"}], |
11 | context_variables={"user_name":"John"} |
12 | ) |
13 | print(response.messages[-1]["content"]) |