-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathweather.py
More file actions
60 lines (47 loc) · 1.78 KB
/
weather.py
File metadata and controls
60 lines (47 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import asyncio
from capyswarm import Swarm, Agent
from dotenv import load_dotenv
import os
load_dotenv()
async def main():
weather_agent = Agent(
name="Weather Agent",
prompt="""You are specialized in extracting weather data from Google.
Your tasks:
1. Get the current weather for the requested location
2. Extract key data points:
- Temperature
- Precipitation chance
- Wind conditions
- General weather description
Format your findings in a clear, structured way for the Activity Planner to use.""",
orchestrator=False,
)
planner_agent = Agent(
name="Activity Planner",
prompt="""You are specialized in planning outdoor activities based on weather conditions.
Your capabilities:
1. Analyze weather data to recommend suitable activities
2. Consider factors like:
- Temperature ranges
- Precipitation risk
- Wind conditions
- Time of day
Provide activity recommendations with clear reasoning based on the weather data.""",
orchestrator=False,
)
orchestrator = Agent(
name="Orchestrator",
orchestrator=True,
)
async with Swarm(
[weather_agent, planner_agent, orchestrator],
api_key=os.getenv("SCRAPYBARA_API_KEY"),
) as swarm:
await swarm.run(
prompt="""Get the weather forecast for Tokyo and recommend suitable outdoor activities for today.
The Weather Agent should first collect the weather data, then the Activity Planner should use that data to make recommendations.""",
interactive=True,
)
if __name__ == "__main__":
asyncio.run(main())