Spaces:
Sleeping
Sleeping
changed to 2.5 API
Browse files- tools/weather.py +2 -2
tools/weather.py
CHANGED
|
@@ -25,7 +25,7 @@ class WeatherTool(Tool):
|
|
| 25 |
location: A string representing a city (e.g., 'New York', 'Paris').
|
| 26 |
|
| 27 |
Returns:
|
| 28 |
-
A
|
| 29 |
"""
|
| 30 |
# Validate that location contains only allowed characters: letters, digits, spaces, and hyphens
|
| 31 |
if not re.fullmatch(r'[A-Za-z0-9\s-]+', location):
|
|
@@ -48,7 +48,7 @@ class WeatherTool(Tool):
|
|
| 48 |
return f"Error: Latitude or longitude not found for location '{location}'."
|
| 49 |
|
| 50 |
# Call the OpenWeatherMap One Call API 3.0 endpoint
|
| 51 |
-
weather_url = f"https://api.openweathermap.org/data/
|
| 52 |
weather_response = requests.get(weather_url)
|
| 53 |
weather_data = weather_response.json()
|
| 54 |
|
|
|
|
| 25 |
location: A string representing a city (e.g., 'New York', 'Paris').
|
| 26 |
|
| 27 |
Returns:
|
| 28 |
+
A JSON blob with the current weather information in imperial units.
|
| 29 |
"""
|
| 30 |
# Validate that location contains only allowed characters: letters, digits, spaces, and hyphens
|
| 31 |
if not re.fullmatch(r'[A-Za-z0-9\s-]+', location):
|
|
|
|
| 48 |
return f"Error: Latitude or longitude not found for location '{location}'."
|
| 49 |
|
| 50 |
# Call the OpenWeatherMap One Call API 3.0 endpoint
|
| 51 |
+
weather_url = f"https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={api_key}&units=imperial"
|
| 52 |
weather_response = requests.get(weather_url)
|
| 53 |
weather_data = weather_response.json()
|
| 54 |
|