a
    ”˜ëj  ã                   @   s„   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ eee edœd	d
„Zedddd�G dd„ de
ƒƒZdS )z&[DEPRECATED] Pipeline prompt template.é    )ÚAny)Úmodel_validator)Ú
deprecated)ÚPromptValue)ÚBasePromptTemplate)ÚBaseChatPromptTemplate)ÚinputsÚinput_variablesÚreturnc                    s   ‡ fdd„|D ƒS )Nc                    s   i | ]}|ˆ | “qS © r   )Ú.0Úk©r   r   ú^/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/langchain_core/prompts/pipeline.pyÚ
<dictcomp>   ó    z_get_inputs.<locals>.<dictcomp>r   )r   r	   r   r   r   Ú_get_inputs   s    r   z0.3.22z1.0zJThis class is deprecated in favor of chaining individual prompts together.)ZsinceZremovalÚmessagec                   @   s´   e Zd ZU dZeed< eeeef  ed< e	ee dœdd„ƒZ
edd�e	eed	œd
d„ƒƒZeedœdd„Zeedœdd„Zeedœdd„Zeedœdd„Zeedœdd„ƒZdS )ÚPipelinePromptTemplatea�  Pipeline prompt template.

    This has been deprecated in favor of chaining individual prompts together in your
    code; e.g. using a for loop, you could do:

    .. code-block:: python

        my_input = {"key": "value"}
        for name, prompt in pipeline_prompts:
            my_input[name] = prompt.invoke(my_input).to_string()
        my_output = final_prompt.invoke(my_input)

    Prompt template for composing multiple prompt templates together.

    This can be useful when you want to reuse parts of prompts.

    A PipelinePrompt consists of two main parts:

    - final_prompt: This is the final prompt that is returned
    - pipeline_prompts: This is a list of tuples, consisting
      of a string (``name``) and a Prompt Template.
      Each PromptTemplate will be formatted and then passed
      to future prompt templates as a variable with
      the same name as ``name``

    Úfinal_promptÚpipeline_prompts)r
   c                 C   s   g d¢S )zzGet the namespace of the langchain object.

        Returns:
            ``["langchain", "prompts", "pipeline"]``
        )Z	langchainZpromptsZpipeliner   )Úclsr   r   r   Úget_lc_namespace9   s    z'PipelinePromptTemplate.get_lc_namespaceÚbefore)Úmode)Úvaluesr
   c                 C   sJ   t ƒ }t ƒ }|d D ]\}}| |¡ | |j¡ qt| |¡ƒ|d< |S )zGet input variables.r   r	   )ÚsetÚaddÚupdater	   ÚlistÚ
difference)r   r   Zcreated_variablesZall_variablesr   Úpromptr   r   r   Úget_input_variablesB   s    
z*PipelinePromptTemplate.get_input_variables)Úkwargsr
   c                 K   sp   | j D ]H\}}t||jƒ}t|tƒr:|jf i |¤Ž||< q|jf i |¤Ž||< qt|| jjƒ}| jjf i |¤ŽS ©z³Format the prompt with the inputs.

        Args:
            kwargs: Any arguments to be passed to the prompt template.

        Returns:
            A formatted string.
        )	r   r   r	   Ú
isinstancer   Zformat_messagesÚformatr   Úformat_prompt©Úselfr#   r   r!   r   r   r   r   r'   N   s    	
z$PipelinePromptTemplate.format_promptc                 Ë   s‚   | j D ]T\}}t||jƒ}t|tƒr@|jf i |¤ŽI dH ||< q|jf i |¤ŽI dH ||< qt|| jjƒ}| jjf i |¤ŽI dH S ©z¹Async format the prompt with the inputs.

        Args:
            kwargs: Any arguments to be passed to the prompt template.

        Returns:
            A formatted string.
        N)	r   r   r	   r%   r   Zaformat_messagesÚaformatr   Úaformat_promptr(   r   r   r   r,   `   s    	
z%PipelinePromptTemplate.aformat_promptc                 K   s   | j f i |¤Ž ¡ S r$   )r'   Ú	to_string©r)   r#   r   r   r   r&   r   s    	zPipelinePromptTemplate.formatc                 Ë   s   | j f i |¤ŽI dH  ¡ S r*   )r,   r-   r.   r   r   r   r+   }   s    	zPipelinePromptTemplate.aformatc                 C   s   t ‚d S )N)Ú
ValueError)r)   r   r   r   Ú_prompt_typeˆ   s    z#PipelinePromptTemplate._prompt_typeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   ÚtupleÚstrÚclassmethodr   r   Údictr   r"   r   r'   r,   r&   r+   Úpropertyr0   r   r   r   r   r      s   

r   N)r4   Útypingr   Zpydanticr   Zlangchain_core._api.deprecationr   Zlangchain_core.prompt_valuesr   Zlangchain_core.prompts.baser   Zlangchain_core.prompts.chatr   r9   r   r7   r   r   r   r   r   r   Ú<module>   s   ü