
    g3fi}                        d Z ddlmZ ddlmZmZ ddl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 ddlmZ erdd	lmZ  G d
 de      Zdddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)zRetriever tool.    )annotations)TYPE_CHECKINGLiteral)	BaseModelField)	Callbacks)Document)BasePromptTemplatePromptTemplateaformat_documentformat_document)StructuredTool)BaseRetrieverc                  .    e Zd ZU dZ ed      Zded<   y)RetrieverInputzInput to the retriever.zquery to look up in retriever)descriptionstrqueryN)__name__
__module____qualname____doc__r   r   __annotations__     \/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_core/tools/retriever.pyr   r      s    !#BCE3Cr   r   Nz

content)document_promptdocument_separatorresponse_formatc                    |xs t        j                  d      	 d	 	 	 	 	 d fd}	 d	 	 	 	 	 d fd}t        ||||t              S )a  Create a tool to do retrieval of documents.

    Args:
        retriever: The retriever to use for the retrieval
        name: The name for the tool. This will be passed to the language model,
            so should be unique and somewhat descriptive.
        description: The description for the tool. This will be passed to the language
            model, so should be descriptive.
        document_prompt: The prompt to use for the document.
        document_separator: The separator to use between documents.
        response_format: The tool response format.

            If `"content"` then the output of the tool is interpreted as the contents of
            a `ToolMessage`. If `"content_and_artifact"` then the output is expected to
            be a two-tuple corresponding to the `(content, artifact)` of a `ToolMessage`
            (artifact being a list of documents in this case).

    Returns:
        Tool class to pass to an agent.
    z{page_content}c                x    j                  | d|i      }j                  fd|D              }dk(  r||fS |S )N	callbacksconfigc              3  6   K   | ]  }t        |        y wN)r   ).0docdocument_prompt_s     r   	<genexpr>z6create_retriever_tool.<locals>.func.<locals>.<genexpr>B   s      *
7:OC!12*
s   content_and_artifact)invokejoin)r   r#   docsr   r*   r   r    	retrievers       r   funcz#create_retriever_tool.<locals>.func>   sV     {I.FG$)) *
>B*
 
 44T?"r   c           	        K   j                  | d|i       d {   }j                  |D cg c]  }t        |       d {    c}      }dk(  r||fS |S 7 @7 c c}w w)Nr#   r$   r,   )ainvoker.   r   )	r   r#   r/   r)   r   r*   r   r    r0   s	        r   afuncz$create_retriever_tool.<locals>.afuncI   sz      &&uk95M&NN$))FJKs#C)9:::K
 44T?" O:Ks2   A&AA&A!AA!A&A!!A&)namer   r1   	coroutineargs_schemar    r'   )r   r   r#   r   returnz str | tuple[str, list[Document]])r   from_templater   r   )	r0   r5   r   r   r   r    r1   r4   r*   s	   `   ``  @r   create_retriever_toolr:      s    : 'X.*F*FGW*X ,0		(		)	 	 ,0		(		)	 	 "' r   )r0   r   r5   r   r   r   r   zBasePromptTemplate | Noner   r   r    z*Literal['content', 'content_and_artifact']r8   r   )r   
__future__r   typingr   r   pydanticr   r   langchain_core.callbacksr   langchain_core.documentsr	   langchain_core.promptsr
   r   r   r   langchain_core.tools.structuredr   langchain_core.retrieversr   r   r:   r   r   r   <module>rC      s     " ) % / -  ;7DY D 26$BK<<
< <
 /< < @< <r   