
    g3fi                         d Z ddlmZmZmZmZmZ ddlmZ ddl	m
Z
mZ ddlmZ ddlmZ ddlmZ ddlmZmZ dd	lmZ dd
lmZmZmZmZ ddlmZ  e        G d de             Zy)0Structured prompt template for a language model.    )AsyncIteratorCallableIteratorMappingSequence)Any)	BaseModelField)override)beta)BaseLanguageModel)ChatPromptTemplateMessageLikeRepresentation)PromptTemplateFormat)OtherRunnableRunnableSequenceRunnableSerializable)get_pydantic_field_namesc                   V    e Zd ZU dZeez  ed<   	  ee      Zee	e
f   ed<   	 dddddee   deee   z  dz  dee	e
f   dz  d	ed
e
ddf fdZedee	   fd       Zedee   deez  d
e
defd       Zedee
ef   eee
   gee   f   z  eee
   gee   f   z  ee
gef   z  ee	ee
ef   ee
gef   z  e
z  f   z  deeef   fd       Zdddee
ef   eee
   gee   f   z  eee
   gee   f   z  ee
gef   z  ee	ee
ef   ee
gef   z  e
z  f   z  de	dz  deeef   fdZ xZS )StructuredPromptr   schema_)default_factorystructured_output_kwargsNzf-string)r   template_formatmessagesr   kwargsreturnc                   |xs |j                  dd      }|sd| }t        |      |xs i }t        |      j                  t	        | j
                              D ]  }|j                  |      ||<    t        |   d||||d| y)ao  Create a structured prompt template.

        Args:
            messages: sequence of messages.
            schema_: schema for the structured prompt.
            structured_output_kwargs: additional kwargs for structured output.
            template_format: template format for the prompt.

        Raises:
            ValueError: if schema is not provided.
        schemaNz=Must pass in a non-empty structured output schema. Received: )r   r   r   r    )pop
ValueErrorset
differencer   	__class__super__init__)	selfr   r   r   r   r   err_msgkr'   s	           _/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_core/prompts/structured.pyr)   zStructuredPrompt.__init__#   s    ( 7VZZ$7O)  W%%#;#Ar V''(@(PQ 	8A*0**Q-$Q'	8 	
%=+		

 	
    c                 8    | j                   j                  d      S )zGet the namespace of the LangChain object.

        For example, if the class is `langchain.llms.openai.OpenAI`, then the
        namespace is `["langchain", "llms", "openai"]`

        Returns:
            The namespace of the LangChain object.
        .)
__module__split)clss    r-   get_lc_namespacez!StructuredPrompt.get_lc_namespaceI   s     ~~##C((r.   r!   c                      | ||fi |S )a  Create a chat prompt template from a variety of message formats.

        Examples:
            Instantiation from a list of message templates:

            ```python
            from langchain_core.prompts import StructuredPrompt


            class OutputSchema(BaseModel):
                name: str
                value: int


            template = StructuredPrompt(
                [
                    ("human", "Hello, how are you?"),
                    ("ai", "I'm doing well, thanks!"),
                    ("human", "That's good to hear."),
                ],
                OutputSchema,
            )
            ```
        Args:
            messages: Sequence of message representations.

                A message can be represented using the following formats:

                1. `BaseMessagePromptTemplate`
                2. `BaseMessage`
                3. 2-tuple of `(message type, template)`; e.g.,
                    `("human", "{user_input}")`
                4. 2-tuple of `(message class, template)`
                5. A string which is shorthand for `("human", template)`; e.g.,
                    `"{user_input}"`
            schema: A dictionary representation of function call, or a Pydantic model.
            **kwargs: Any additional kwargs to pass through to
                `ChatModel.with_structured_output(schema, **kwargs)`.

        Returns:
            A structured prompt template
        r"   )r3   r   r!   r   s       r-   from_messages_and_schemaz)StructuredPrompt.from_messages_and_schemaU   s    b 8V.v..r.   otherc                 $    | j                  |      S N)pipe)r*   r7   s     r-   __or__zStructuredPrompt.__or__   s     yyr.   )nameothersr<   c                    |rt        |d   t              st        |d   d      r;t        |  |d   j                  | j
                  fi | j                  g|dd d|iS d}t        |      )am  Pipe the structured prompt to a language model.

        Args:
            others: The language model to pipe the structured prompt to.
            name: The name of the pipeline.

        Returns:
            A RunnableSequence object.

        Raises:
            NotImplementedError: If the first element of `others`
            is not a language model.
        r   with_structured_output   Nr<   z8Structured prompts need to be piped to a language model.)
isinstancer   hasattrr   r?   r   r   NotImplementedError)r*   r<   r=   msgs       r-   r:   zStructuredPrompt.pipe   s    , z&)->?G1I/E
 $0q	00LL$($A$A
    I!#&&r.   r9   ) __name__r1   __qualname____doc__dicttype__annotations__r   r   strr	   r   r   r
   r   r)   classmethodlistr4   r   r6   r   r   r   r   r   r   r   r   r;   r:   __classcell__)r'   s   @r-   r   r      s|   :D[+/4T/Jd38nJ
 26$

 ;?0:$
45$
 Y'$.$

 #'sCx.4"7$
 .$
 $
 
$
L 	)c 	) 	) 0/450/ t0/ 	0/
 
0/ 0/d  U
#
HSM?HUO3
45
M#&'u)==
>? C5%<
 ! #xU
+hue|.DDsJJ
K	L  
dEk	*   "  "'#u*%
HSM?HUO3
45
M#&'u)==
>? C5%<
 ! #xU
+hue|.DDsJJ
K	L"' Dj"' 
dEk	*"'r.   r   N)rG   collections.abcr   r   r   r   r   typingr	   pydanticr
   r   typing_extensionsr   "langchain_core._api.beta_decoratorr   #langchain_core.language_models.baser   langchain_core.prompts.chatr   r   langchain_core.prompts.stringr   langchain_core.runnables.baser   r   r   r   langchain_core.utilsr   r   r"   r.   r-   <module>rY      s[    6 P P & & 3 A ?  : Y') Y' Y'r.   