Spaces:
Runtime error
Runtime error
File size: 1,177 Bytes
20dae79 |
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 |
from smolagents import Tool
from typing import Any, Optional
class SimpleTool(Tool):
name = "get_weather_data"
description = "_summary_"
inputs = {'city': {'type': 'string', 'description': 'Name of the city (new york , london or tokyo)'}}
output_type = "object"
def forward(self, city: str) -> dict:
"""_summary_
Args:
city (str): Name of the city (new york , london or tokyo)
Returns:
Sampel weather data for a given city
"""
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": [72, 75, 65, 68, 70, 74, 73],
"rain": [0, 0.2, 0.5, 0, 0, 0.1, 0],
"unit": "C"
},
"tokyo": {
"temps": [72, 75, 65, 68, 70, 74, 73],
"rain": [0, 0.2, 0.5, 0, 0, 0.1, 0],
"unit": "C"
},
}
city_lower = city.lower()
return sample_data.get(city_lower,{"error":f"No data for {city}"}) |