Source code for langchain_community.tools.openweathermap.tool
"""Tool for the OpenWeatherMap API."""fromtypingimportOptionalfromlangchain_core.callbacksimportCallbackManagerForToolRunfromlangchain_core.toolsimportBaseToolfrompydanticimportFieldfromlangchain_community.utilities.openweathermapimportOpenWeatherMapAPIWrapper
[docs]classOpenWeatherMapQueryRun(BaseTool):# type: ignore[override]"""Tool that queries the OpenWeatherMap API."""api_wrapper:OpenWeatherMapAPIWrapper=Field(default_factory=OpenWeatherMapAPIWrapper# type: ignore[arg-type])name:str="open_weather_map"description:str=("A wrapper around OpenWeatherMap API. ""Useful for fetching current weather information for a specified location. ""Input should be a location string (e.g. London,GB).")def_run(self,location:str,run_manager:Optional[CallbackManagerForToolRun]=None)->str:"""Use the OpenWeatherMap tool."""returnself.api_wrapper.run(location)