forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_weather.py
More file actions
40 lines (34 loc) · 958 Bytes
/
Copy pathget_weather.py
File metadata and controls
40 lines (34 loc) · 958 Bytes
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
"""Mock weather data tool implementation."""
import random
from .types import WeatherResult
_CONDITIONS = [
"Sunny",
"Partly Cloudy",
"Cloudy",
"Overcast",
"Light Rain",
"Heavy Rain",
"Thunderstorm",
"Snow",
"Foggy",
"Windy",
]
def get_weather_impl(city: str) -> WeatherResult:
"""Return mock weather data for the given city.
Uses a seeded random based on the city name so repeated calls
for the same city return consistent results within a session.
"""
rng = random.Random(city.lower())
temperature = rng.randint(20, 95)
humidity = rng.randint(30, 90)
wind_speed = rng.randint(2, 30)
feels_like = temperature + rng.randint(-5, 5)
conditions = rng.choice(_CONDITIONS)
return WeatherResult(
city=city,
temperature=temperature,
humidity=humidity,
wind_speed=wind_speed,
feels_like=feels_like,
conditions=conditions,
)