kikocis/Based-Agent public
| 1 | from swarm import Swarm, Agent |
| 2 | |
| 3 | client = Swarm() |
| 4 | |
| 5 | |
| 6 | def get_weather(location) -> str: |
| 7 | return "{'temp':67, 'unit':'F'}" |
| 8 | |
| 9 | |
| 10 | agent = Agent( |
| 11 | name="Agent", |
| 12 | instructions="You are a helpful agent.", |
| 13 | functions=[get_weather], |
| 14 | ) |
| 15 | |
| 16 | messages = [{"role": "user", "content": "What's the weather in NYC?"}] |
| 17 | |
| 18 | response = client.run(agent=agent, messages=messages) |
| 19 | print(response.messages[-1]["content"]) |