
    dh                         S SK r S SKJrJrJrJrJrJr  S SKrS SK	J
r
  S SKJr  S SKJrJrJr  S SKJrJrJrJr  S SKJr  \ R0                  " \5      r " S S	\5      rg)
    N)AnyDictListMappingOptionalcast)CallbackManagerForLLMRun)LLM)convert_to_secret_strget_from_dict_or_envpre_init)
ConfigDictField	SecretStrmodel_validator)enforce_stop_tokensc                   2   \ rS rSr% SrSr\\S'    \" \	S9r
\\\4   \S'    Sr\\   \S'   \" S	S
9r\" SS9\S\\\4   S\4S j5       5       r\S\S\4S j5       r\S\\\4   4S j5       r\S\4S j5       r  SS\S\\\      S\\   S\S\4
S jjrSrg)CerebriumAI   a   CerebriumAI large language models.

To use, you should have the ``cerebrium`` python package installed.
You should also have the environment variable ``CEREBRIUMAI_API_KEY``
set with your API key or pass it as a named argument in the constructor.

Any parameters that are valid to be passed to the call can be passed
in, even if not explicitly saved on this class.

Example:
    .. code-block:: python

        from langchain_community.llms import CerebriumAI
        cerebrium = CerebriumAI(endpoint_url="", cerebriumai_api_key="my-api-key")

 endpoint_url)default_factorymodel_kwargsNcerebriumai_api_keyforbid)extrabefore)modevaluesreturnc                 @   [        [        U R                  R                  5       5      5      nUR	                  S0 5      n[        U5       HL  nXB;  d  M
  XC;   a  [        SU S35      e[        R                  U SU S35        UR                  U5      X4'   MN     X1S'   U$ )z>Build extra kwargs from additional params that were passed in.r   zFound z supplied twice.zJ was transferred to model_kwargs.
                    Please confirm that z is what you intended.)	setlistmodel_fieldskeysget
ValueErrorloggerwarningpop)clsr   all_required_field_namesr   
field_names        \/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/llms/cerebriumai.pybuild_extraCerebriumAI.build_extra.   s     $'tC,<,<,A,A,C'D#E 

>2.v,J9&$vj\9I%JKK# %))34JN %+JJz$:! ' "'~    c                 :    [        [        USS5      5      nX!S'   U$ )z?Validate that api key and python package exists in environment.r   CEREBRIUMAI_API_KEY)r   r   )r+   r   r   s      r.   validate_environment CerebriumAI.validate_environmentA   s-     4 )>@UV
 )<$%r1   c                 >    0 SU R                   0ESU R                  0E$ )zGet the identifying parameters.r   r   )r   r   selfs    r.   _identifying_paramsCerebriumAI._identifying_paramsJ   s2    
t001
t001
 	
r1   c                     g)zReturn type of llm.cerebriumai r7   s    r.   	_llm_typeCerebriumAI._llm_typeR   s     r1   promptstoprun_managerkwargsc                 \   [        [        U R                  5      R                  5       SS.nU R                  =(       d    0 nSU0UEUEn[
        R                  " U R                  XuS9nUR                  S:X  a%  UR                  5       n	U	S   n
Ub  [        X5      n
U
$ UR                  5         g)Nzapplication/json)AuthorizationzContent-Typer@   )jsonheaders   resultr   )r   r   r   get_secret_valuer   requestspostr   status_coderF   r   raise_for_status)r8   r@   rA   rB   rC   rG   paramspayloadresponsedatatexts              r.   _callCerebriumAI._callW   s     "433 .	
 ""(bV8v88==!2!2R3&==?D>D +46K%%'r1   r=   )NN)__name__
__module____qualname____firstlineno____doc__r   str__annotations__r   dictr   r   r   r   r   r   r   model_configr   classmethodr/   r   r4   propertyr   r9   r>   r   r	   rT   __static_attributes__r=   r1   r.   r   r      s:   " L##(#>L$sCx.> 04),3L (#c3h C   $" $ 4   
WS#X%6 
 
 3   %):>	 tCy! 67	
  
 r1   r   )loggingtypingr   r   r   r   r   r   rK   langchain_core.callbacksr	   #langchain_core.language_models.llmsr
   langchain_core.utilsr   r   r   pydanticr   r   r   r   langchain_community.llms.utilsr   	getLoggerrV   r(   r   r=   r1   r.   <module>rj      sD     ; ;  = 3 V V B B >			8	$b# br1   