Spaces:
Configuration error
Configuration error
Download tools/get_weather_data.py from dbwsky/WeatherAgent: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/dbwsky/WeatherAgent/resolve/main/tools/get_weather_data.py
- Command line
-
hf download hf://spaces/dbwsky/WeatherAgent/tools/get_weather_data.py
-
curl -L -o get_weather_data.py https://huggingface.co/spaces/dbwsky/WeatherAgent/resolve/main/tools/get_weather_data.py
1.22 kB
| from smolagents import Tool | |
| from typing import Any, Optional | |
| class SimpleTool(Tool): | |
| name = "get_weather_data" | |
| description = "Returns sample weather data for a given city." | |
| inputs = {"city":{"type":"string","description":"Name of the city (new york, london, or tokyo)"}} | |
| output_type = "object" | |
| def forward(self, city: str) -> dict: | |
| """ | |
| Returns sample weather data for a given city. | |
| Args: | |
| city: Name of the city (new york, london, or tokyo) | |
| """ | |
| sample_data = { | |
| "new york": { | |
| "temps": [72, 75, 65, 68, 70, 74, 73], | |
| "rain": [0, 0.2, 0.5, 0, 0, 0.1, 0], | |
| "unit": "F" | |
| }, | |
| "london": { | |
| "temps": [15, 14, 16, 13, 15, 17, 16], | |
| "rain": [0.5, 0.2, 0, 0.1, 0.3, 0, 0.2], | |
| "unit": "C" | |
| }, | |
| "tokyo": { | |
| "temps": [22, 24, 23, 25, 26, 25, 22], | |
| "rain": [0, 0, 0.3, 0.2, 0, 0, 0.1], | |
| "unit": "C" | |
| } | |
| } | |
| city_lower = city.lower() | |
| return sample_data.get(city_lower, {"error": f"No data for {city}"}) |