
    gh|                         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 ded	ee         d
efdZ eddd           G d de
                      ZdS )z&[DEPRECATED] Pipeline prompt template.    )Any)model_validator)
deprecated)PromptValue)BasePromptTemplate)BaseChatPromptTemplateinputsinput_variablesreturnc                        fd|D             S )Nc                 "    i | ]}||         S  r   ).0kr	   s     \/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/langchain_core/prompts/pipeline.py
<dictcomp>z_get_inputs.<locals>.<dictcomp>   s    222QAvay222    r   )r	   r
   s   ` r   _get_inputsr      s    2222/2222r   z0.3.22z1.0zThis class is deprecated. Please see the docstring below or at the link for a replacement option: https://python.langchain.com/api_reference/core/prompts/langchain_core.prompts.pipeline.PipelinePromptTemplate.html)sinceremovalmessagec                      e Zd ZU dZeed<   	 eeeef                  ed<   	 e	dee         fd            Z
 ed          e	dedefd	                        Zd
edefdZd
edefdZd
edefdZd
edefdZedefd            ZdS )PipelinePromptTemplatea  [DEPRECATED] 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_promptsr   c                 
    g dS )z*Get the namespace of the langchain object.)	langchainpromptspipeliner   )clss    r   get_lc_namespacez'PipelinePromptTemplate.get_lc_namespace9   s     4333r   before)modevaluesc                    t                      }t                      }|d         D ]4\  }}|                    |           |                    |j                   5t	          |                    |                    |d<   |S )zGet input variables.r   r
   )setaddupdater
   list
difference)r    r$   created_variablesall_variablesr   prompts         r   get_input_variablesz*PipelinePromptTemplate.get_input_variables>   s      EE 23 	9 	9IAv!!!$$$  !78888$()A)ABS)T)T$U$U !r   kwargsc                 
   | j         D ]P\  }}t          ||j                  }t          |t                    r |j        di |||<   @ |j        di |||<   Qt          || j        j                  } | j        j        di |S zFormat the prompt with the inputs.

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

        Returns:
            A formatted string.
        r   )	r   r   r
   
isinstancer   format_messagesformatr   format_promptselfr/   r   r-   _inputss        r   r5   z$PipelinePromptTemplate.format_promptJ   s     . 	5 	5IAv!&&*@AAG&"899 52F2==W==q		)FM44G44q		fd&7&GHH.t .99999r   c                 2  K   | j         D ]\\  }}t          ||j                  }t          |t                    r |j        di | d{V ||<   F |j        di | d{V ||<   ]t          || j        j                  } | j        j        di | d{V S zAsync format the prompt with the inputs.

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

        Returns:
            A formatted string.
        Nr   )	r   r   r
   r2   r   aformat_messagesaformatr   aformat_promptr6   s        r   r=   z%PipelinePromptTemplate.aformat_prompt\   s       . 	< 	<IAv!&&*@AAG&"899 <"9&"9"D"DG"D"DDDDDDDq		"0&.";";7";";;;;;;;q		fd&7&GHH5T&5@@@@@@@@@@@r   c                 @     | j         di |                                S r1   )r5   	to_stringr7   r/   s     r   r4   zPipelinePromptTemplate.formatn   s)     "t!++F++55777r   c                 P   K    | j         di | d{V                                 S r:   )r=   r?   r@   s     r   r<   zPipelinePromptTemplate.aformaty   s?       *d)33F33333333>>@@@r   c                     t           )N)
ValueError)r7   s    r   _prompt_typez#PipelinePromptTemplate._prompt_type   s    r   N)__name__
__module____qualname____doc__r   __annotations__r)   tuplestrclassmethodr!   r   dictr   r.   r   r5   r=   r4   r<   propertyrD   r   r   r   r   r      sz         2 %$$$,5&8!89::::R4c 4 4 4 [4 _(### #    [ $#:c :k : : : :$AS A[ A A A A$	8s 	8s 	8 	8 	8 	8	Ac 	Ac 	A 	A 	A 	A c    X  r   r   N)rH   typingr   pydanticr   langchain_core._api.deprecationr   langchain_core.prompt_valuesr   langchain_core.prompts.baser   langchain_core.prompts.chatr   rM   r)   rK   r   r   r   r   r   <module>rU      s   , ,       $ $ $ $ $ $ 6 6 6 6 6 6 4 4 4 4 4 4 : : : : : : > > > > > >3 3tCy 3T 3 3 3 3 
	~	  l l l l l/ l l l l lr   