§
    æ˜ºhV  ã                   ó¸   — d dl Z d dlmZmZmZmZmZ d dlmZ d dl	m
Z
 d dlmZmZmZmZmZ d dlmZmZ d dlmZ  e j        e¦  «        Z G d„ d	e
e¦  «        ZdS )
é    N)ÚAnyÚDictÚListÚMappingÚOptional)ÚCallbackManagerForLLMRun)ÚLLM)Ú	BaseModelÚExtraÚFieldÚ	SecretStrÚroot_validator©Úconvert_to_secret_strÚget_from_dict_or_env)Úenforce_stop_tokensc                   óž  — e Zd ZU dZdZeed<   	  ee¬¦  «        Z	e
eef         ed<   	 dZee         ed<    G d„ d	¦  «        Z ed
¬¦  «        de
eef         de
eef         fd„¦   «         Z e¦   «         de
de
fd„¦   «         Zedeeef         fd„¦   «         Zedefd„¦   «         Z	 	 ddedeee                  dee         dedef
d„ZdS )Ú
PipelineAIaÙ  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_keyc                   ó    — e Zd ZdZej        ZdS )úPipelineAI.Configz'Configuration for this pydantic config.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚforbidÚextra© ó    úk/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/langchain_community/llms/pipelineai.pyÚConfigr   -   s   € € € € € Ø5Ð5à”ˆˆˆr#   r%   T)ÚpreÚvaluesÚreturnc                 óL  — d„ | j                              ¦   «         D ¦   «         }|                     di ¦  «        }t          |¦  «        D ]U}||vrO||v rt	          d|› d�¦  «        ‚t
                               |› d|› d�¦  «         |                     |¦  «        ||<   ŒV||d<   |S )z>Build extra kwargs from additional params that were passed in.c                 ó   — h | ]	}|j         ’Œ
S r"   )Úalias)Ú.0Úfields     r$   ú	<setcomp>z)PipelineAI.build_extra.<locals>.<setcomp>5   s   € Ð#UÐ#UÐ#U°E E¤KÐ#UÐ#UÐ#Ur#   r   zFound z supplied twice.zM was transferred to pipeline_kwargs.
                    Please confirm that z is what you intended.)Ú
__fields__r'   ÚgetÚlistÚ
ValueErrorÚloggerÚwarningÚpop)Úclsr'   Úall_required_field_namesr!   Ú
field_names        r$   Úbuild_extrazPipelineAI.build_extra2   sä   € ð $VÐ#U¸S¼^×=RÒ=RÑ=TÔ=TÐ#UÑ#UÔ#UÐ à—
’
Ð,¨bÑ1Ô1ˆÝ˜v™,œ,ð 	;ð 	;ˆJØÐ!9Ð9Ð9Ø Ð&Ð&Ý$Ð%J¨jÐ%JÐ%JÐ%JÑKÔKÐKÝ—’Ø#ð Nð NØ)3ðNð Nð Nñô ð ð %+§J¢J¨zÑ$:Ô$:��jÑ!øØ$)ˆÐ Ñ!Øˆr#   c                 óL   — t          t          |dd¦  «        ¦  «        }||d<   |S )z?Validate that api key and python package exists in environment.r   ÚPIPELINE_API_KEYr   )r6   r'   r   s      r$   Úvalidate_environmentzPipelineAI.validate_environmentD   s7   € õ 1Ý  Ð);Ð=OÑPÔPñ
ô 
Ðð &6ˆÐ!Ñ"Øˆr#   c                 ó*   — i d| j         i¥d| j        i¥S )zGet the identifying parameters.r   r   )r   r   ©Úselfs    r$   Ú_identifying_paramszPipelineAI._identifying_paramsM   s,   € ð
Ø˜tÔ0Ð1ð
à  $Ô"6Ð7ð
ð 	
r#   c                 ó   — dS )zReturn type of llm.Úpipeline_air"   r>   s    r$   Ú	_llm_typezPipelineAI._llm_typeU   s	   € ð ˆ}r#   ÚpromptÚstopÚrun_managerÚkwargsc                 ó|  — 	 ddl m} n# t          $ r t          d¦  «        ‚w xY w || j                             ¦   «         ¬¦  «        }| j        pi }i |¥|¥}|                     | j        ||g¦  «        }	 |j        d         d         }	n # t          $ r t          d|› �¦  «        ‚w xY w|�t          |	|¦  «        }	|	S )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: )ÚpipelinerI   ÚImportErrorr   Úget_secret_valuer   Úrun_pipeliner   Úresult_previewÚAttributeErrorr   )
r?   rD   rE   rF   rG   rI   ÚclientÚparamsÚrunÚtexts
             r$   Ú_callzPipelineAI._callZ   s!  € ð	Ø.Ð.Ð.Ð.Ð.Ð.Ð.øÝð 	ð 	ð 	ÝðDñô ð ð	øøøð
 � TÔ%:×%KÒ%KÑ%MÔ%MÐNÑNÔNˆØÔ%Ð+¨ˆØ%�FÐ%˜fÐ%ˆà×!Ò! $Ô"3°f¸fÐ5EÑFÔFˆð	ØÔ% aÔ(¨Ô+ˆDˆDøÝð 	ð 	ð 	Ý ð"Øð"ð "ñô ð ð	øøøð
 Ðõ ' t¨TÑ2Ô2ˆDØˆs   ‚	 ‰#Á6B
 Â
B')NN)r   r   r   r   r   ÚstrÚ__annotations__r   Údictr   r   r   r   r   r   r%   r   r9   r<   Úpropertyr   r@   rC   r   r   rU   r"   r#   r$   r   r      sÙ  € € € € € € ðð ð €L�#ÐÐÑØ.à&+ e¸DÐ&AÑ&AÔ&A€O�T˜#˜s˜(”^ÐAÐAÑAðð -1Ð�h˜yÔ)Ð0Ð0Ñ0ðð ð ð ð ñ ô ð ð
 €^˜ÐÑÔð  c¨3 h¤ð °D¸¸c¸´Nð ð ð ñ Ôðð" €^ÑÔð¨$ð °4ð ð ð ñ Ôðð ð
 W¨S°#¨XÔ%6ð 
ð 
ð 
ñ „Xð
ð ð˜3ð ð ð ñ „Xðð %)Ø:>ð	ð àðð �t˜C”yÔ!ðð Ð6Ô7ð	ð
 ðð 
ðð ð ð ð ð r#   r   )ÚloggingÚtypingr   r   r   r   r   Úlangchain_core.callbacksr   Ú#langchain_core.language_models.llmsr	   Úlangchain_core.pydantic_v1r
   r   r   r   r   Úlangchain_core.utilsr   r   Úlangchain_community.llms.utilsr   Ú	getLoggerr   r3   r   r"   r#   r$   ú<module>rb      s!  ðØ €€€Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5à =Ð =Ð =Ð =Ð =Ð =Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3ðð ð ð ð ð ð ð ð ð ð ð ð ð ð MÐ LÐ LÐ LÐ LÐ LÐ LÐ Là >Ð >Ð >Ð >Ð >Ð >à	ˆÔ	˜8Ñ	$Ô	$€ðeð eð eð eð e��iñ eô eð eð eð er#   