o
    Zh                     @   s|   d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZmZ edd	d
dG dd deeZdS )z!Wrapper around Solar chat models.    )Dict)
deprecated)get_from_dict_or_envpre_init)
ConfigDictField)
ChatOpenAI)SOLAR_SERVICE_URL_BASESolarCommonz0.0.34z1.0zlangchain_upstage.ChatUpstage)ZsinceZremovalZalternative_importc                   @   sH   e Zd ZU dZeddZeed< eddddZ	e
ded	efd
dZdS )	SolarChata  Wrapper around Solar large language models.
    To use, you should have the ``openai`` python package installed, and the
    environment variable ``SOLAR_API_KEY`` set with your API key.
    (Solar's chat API is compatible with OpenAI's SDK.)
    Referenced from https://console.upstage.ai/services/solar
    Example:
        .. code-block:: python

            from langchain_community.chat_models.solar import SolarChat

            solar = SolarChat(model="solar-mini")
    i   )default
max_tokensTignore)Zpopulate_by_nameZarbitrary_types_allowedextravaluesreturnc                 C   s   t |dd|d< zddl}W n ty   tdw |d d|v r%|d ntd}|ds:|jd
i |jj|d< |d	sK|jd
i |jj|d	< |S )z2Validate that the environment is set up correctly.Zsolar_api_keyZSOLAR_API_KEYr   NzTCould not import openai python package. Please install it with `pip install openai`.base_url)Zapi_keyr   clientZasync_client )	r   openaiImportErrorr	   getZOpenAIZchatZcompletionsZAsyncOpenAI)clsr   r   Zclient_paramsr   r   \/var/www/html/lang_env/lib/python3.10/site-packages/langchain_community/chat_models/solar.pyvalidate_environment'   s,   

zSolarChat.validate_environmentN)__name__
__module____qualname____doc__r   r   int__annotations__r   Zmodel_configr   r   r   r   r   r   r   r      s   
 r   N)r   typingr   Zlangchain_core._apir   Zlangchain_core.utilsr   r   Zpydanticr   r   Zlangchain_community.chat_modelsr   Zlangchain_community.llms.solarr	   r
   r   r   r   r   r   <module>   s    