Created
September 27, 2024 23:36
-
-
Save elijahbenizzy/b687de29b2a91f06115e49b307015967 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _weather_tool(latitude: float, longitude: float) -> dict: | |
"""Queries the weather for a given latitude and longitude.""" | |
api_key = os.environ.get("TOMORROW_API_KEY") | |
url = f"https://api.tomorrow.io/v4/weather/forecast?location={latitude},{longitude}&apikey={api_key}" | |
response = requests.get(url) | |
# Check if the request was successful | |
if response.status_code == 200: | |
return response.json() | |
else: | |
# Handle errors (e.g., invalid API key, rate limiting, etc.) | |
return {"error": f"Failed to get weather data. Status code: {response.status_code}"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment