| 1 | import json |
| 2 | |
| 3 | from swarm import Agent |
| 4 | |
| 5 | |
| 6 | def get_weather(location, time="now"): |
| 7 | """Get the current weather in a given location. Location MUST be a city.""" |
| 8 | return json.dumps({"location": location, "temperature": "65", "time": time}) |
| 9 | |
| 10 | |
| 11 | def send_email(recipient, subject, body): |
| 12 | print("Sending email...") |
| 13 | print(f"To: {recipient}") |
| 14 | print(f"Subject: {subject}") |
| 15 | print(f"Body: {body}") |
| 16 | return "Sent!" |
| 17 | |
| 18 | |
| 19 | weather_agent = Agent( |
| 20 | name="Weather Agent", |
| 21 | instructions="You are a helpful agent.", |
| 22 | functions=[get_weather, send_email], |
| 23 | ) |