GetWeatherTool provides real-time weather data using the WeatherAPI.com service.
Class Signature
Parameters
WeatherAPI.com API key. If not provided, the tool will look for the
WEATHER_API_KEY environment variable.Get your API key at weatherapi.com.Methods
get_current_weather
Retrieve current weather information for a specified location.The location to get weather for. Can be:
- City name (e.g., “London”, “Paris”)
- Coordinates (e.g., “48.8567,2.3508”)
- US zip code (e.g., “10001”)
- UK postcode (e.g., “SW1”)
- IP address (e.g., “100.0.0.1”)
- Location name and country
- Temperature in Celsius and Fahrenheit
- Weather condition description
- Humidity percentage
- Wind speed in km/h
Usage Example
With Agentor Agent
Environment Setup
Error Handling
The tool handles errors gracefully:- Missing API key: Returns an error message directing users to weatherapi.com
- HTTP errors: Returns HTTP status code and error details
- Network errors: Returns descriptive error message
- Invalid location: Returns API error response
API Requirements
This tool requires a free or paid API key from WeatherAPI.com:- Sign up for a free account
- Generate an API key from the dashboard
- Set the
WEATHER_API_KEYenvironment variable or pass it to the constructor
- 1 million calls per month
- Current weather data
- 3-day forecast
/home/daytona/workspace/source/src/agentor/tools/weather.py:9