File size: 658 Bytes
cdf8921
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from smolagents import Tool

from rest_clients.open_weather_client import OpenWeatherClient


class WeatherInfoTool(Tool):
    name = "weather_info"
    description = "Fetches real weather information for a given location using OpenWeatherMap."
    inputs = {
        "location": {
            "type": "string",
            "description": "The location to get weather information for."
        }
    }
    output_type = "string"

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.weather_client = OpenWeatherClient()

    def forward(self, location: str):
        return self.weather_client.get_weather(location)