
    dh;                         S SK r S SKJrJrJrJrJ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Jr  S SKJr  \ R.                  " \5      r " S S	\
\5      rg)
    N)AnyDictListMappingOptional)CallbackManagerForLLMRun)LLM)convert_to_secret_strget_from_dict_or_envpre_init)	BaseModel
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)
PipelineAI   a  PipelineAI large language models.

To use, you should have the ``pipeline-ai`` python package installed,
and the environment variable ``PIPELINE_API_KEY`` set with your API key.

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 PipelineAI
        pipeline = PipelineAI(pipeline_key="")
 pipeline_key)default_factorypipeline_kwargsNpipeline_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.zM was transferred to pipeline_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/pipelineai.pybuild_extraPipelineAI.build_extra1   s     $'tC,<,<,A,A,C'D#E 

,b1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   PIPELINE_API_KEY)r
   r   )r+   r   r   s      r.   validate_environmentPipelineAI.validate_environmentD   s-     1 );=OP
 &6!"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PipelineAI._identifying_paramsM   s2    
t001
 $"6"67
 	
r1   c                     g)zReturn type of llm.pipeline_ai r7   s    r.   	_llm_typePipelineAI._llm_typeU   s     r1   promptstoprun_managerkwargsc                 l    SSK Jn  U" U R                  R	                  5       S9nU R
                  =(       d    0 n0 UEUEnUR                  U R                  X/5      n UR                  S   S   n	Ub  [        X5      n	U	$ ! [         a    [        S5      ef = f! [         a    [        SU 35      ef = f)z Call to Pipeline Cloud endpoint.r   )PipelineCloudz^Could not import pipeline-ai python package. Please install it with `pip install pipeline-ai`.)tokenzAA pipeline run should have a `result_preview` attribute.Run was: )pipelinerE   ImportErrorr   get_secret_valuer   run_pipeliner   result_previewAttributeErrorr   )
r8   r@   rA   rB   rC   rE   clientparamsruntexts
             r.   _callPipelineAI._callZ   s    	. T%:%:%K%K%MN%%+%F%f%!!$"3"3f5EF	%%a(+D  't2D+  	D 	  	 5" 	s   B B BB3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   rQ   __static_attributes__r=   r1   r.   r   r      s:    L#.&+D&AOT#s(^A -1hy)0L (#c3h C   $" $ 4   
WS#X%6 
 
 3   %):>	 tCy! 67	
  
 r1   r   )loggingtypingr   r   r   r   r   langchain_core.callbacksr   #langchain_core.language_models.llmsr	   langchain_core.utilsr
   r   r   pydanticr   r   r   r   r   langchain_community.llms.utilsr   	getLoggerrS   r(   r   r=   r1   r.   <module>rg      sI     5 5 = 3 V V  ?			8	$ei er1   