from pyowm import OWM from smolagents import tool import os @tool def get_weather(city: str, nation: str) -> str: """ This tool returns the current weather for one specific city. Args: city: The city to search the weather. nation: The nation where the city is located. """ API_KEY = os.getenv("OPENWEATHER_API_KEY") owm = OWM(API_KEY) mgr = owm.weather_manager() location = f'{city}, {nation}' observation = mgr.weather_at_place(location) w = observation.weather temperature = w.temperature('celsius')['temp'] status = w.detailed_status humidity = w.humidity return f"Location: {location}\nStatus: {status}\nTemperature: {temperature}\nHumidity: {humidity}%" if __name__ == "__main__": print(get_weather('Sao Paulo', 'BR'))