Spaces:
Sleeping
Sleeping
Download tools/get_weather.py from Negrec23/First_agent_template: direct link, hf CLI and curl.
- Browser
- Download file 547 Bytes
-
https://huggingface.co/spaces/Negrec23/First_agent_template/resolve/main/tools/get_weather.py
- Command line
-
hf download hf://spaces/Negrec23/First_agent_template/tools/get_weather.py
-
curl -L -o get_weather.py https://huggingface.co/spaces/Negrec23/First_agent_template/resolve/main/tools/get_weather.py
547 Bytes
| def get_weather(city: str) -> str: | |
| """Fetches the current weather for a specified city. | |
| Args: | |
| city: The name of the city to fetch the weather for. | |
| """ | |
| api_url = f"http://api.weatherapi.com/v1/current.json?key=YOUR_API_KEY&q={city}" | |
| response = requests.get(api_url) | |
| if response.status_code == 200: | |
| data = response.json() | |
| return f"The weather in {city} is {data['current']['temp_c']}°C with {data['current']['condition']['text']}." | |
| else: | |
| return "Failed to fetch weather data." | |