
    dh	                     R    S r SSKJrJrJr  SSKJr  SSKJrJ	r	J
r
   " S S\5      rg)z+Util that calls OpenWeatherMap using PyOWM.    )AnyDictOptional)get_from_dict_or_env)	BaseModel
ConfigDictmodel_validatorc                       \ rS rSr% SrSr\\S'   Sr\	\
   \S'   \" SS9r\" SS	9\S
\S\4S j5       5       rS\
S\S\
4S jrS\
S\
4S jrSrg)OpenWeatherMapAPIWrapper	   zWrapper for OpenWeatherMap API using PyOWM.

Docs for using:

1. Go to OpenWeatherMap and sign up for an API key
2. Save your API KEY into OPENWEATHERMAP_API_KEY env variable
3. pip install pyowm
Nowmopenweathermap_api_keyforbid)extrabefore)modevaluesreturnc                     [        USS5      n SSKnUR                  U5      nXAS'   U$ ! [         a    [        S5      ef = f)z,Validate that api key exists in environment.r   OPENWEATHERMAP_API_KEYr   NzBpyowm is not installed. Please install it with `pip install pyowm`r   )r   pyowmImportErrorOWM)clsr   r   r   r   s        d/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/utilities/openweathermap.pyvalidate_environment-OpenWeatherMapAPIWrapper.validate_environment   s^     "6,.F"
	 ii./u  	T 	s	   * A locationwc                 .   UR                   nUR                  5       nUR                  nUR                  S5      nUR                  nUR
                  nUR                  n	SU SU SUS    SUS    SU S	US
    SUS    SUS    SUS    SU SU SU	 S3$ )NcelsiuszIn z6, the current weather is as follows:
Detailed status: z
Wind speed: speedz m/s, direction: degu   °
Humidity: z%
Temperature: 
  - Current: tempu   °C
  - High: temp_maxu   °C
  - Low: temp_minu   °C
  - Feels like: 
feels_likeu
   °C
Rain: z
Heat index: z
Cloud cover: %)detailed_statuswindhumiditytemperaturerain
heat_indexclouds)
selfr   r   r)   r*   r+   r,   r-   r.   r/   s
             r   _format_weather_info-OpenWeatherMapAPIWrapper._format_weather_info/   s    ++vvx::mmI.vv\\
 (   /0 1=/):4;- H!
 #'/0 1$Z01 2#J/0 1*<89 :F %, '"81&	
    c                     U R                   R                  5       nUR                  U5      nUR                  nU R	                  X5      $ )z=Get the current weather information for a specified location.)r   weather_managerweather_at_placeweatherr1   )r0   r   mgrobservationr   s        r   runOpenWeatherMapAPIWrapper.runG   s@    hh&&(**84((55r3    )__name__
__module____qualname____firstlineno____doc__r   r   __annotations__r   r   strr   model_configr	   classmethodr   r   r1   r:   __static_attributes__r<   r3   r   r   r   	   s     CO,0HSM0L (#$ 3   $&
S 
S 
S 
06C 6C 6r3   r   N)rA   typingr   r   r   langchain_core.utilsr   pydanticr   r   r	   r   r<   r3   r   <module>rJ      s%    1 & & 5 ; ;D6y D6r3   