
    D_i}                        S r SSKJr  SSKJrJr  SSKJrJr  SSK	J
r
  SSKJr  SSKJrJrJrJr  SSKJr  \(       a  SS	KJr   " S
 S\5      rSSSS.             SS jjrg)zRetriever tool.    )annotations)TYPE_CHECKINGLiteral)	BaseModelField)	Callbacks)Document)BasePromptTemplatePromptTemplateaformat_documentformat_document)StructuredTool)BaseRetrieverc                  0    \ rS rSr% Sr\" SS9rS\S'   Srg)	RetrieverInput   zInput to the retriever.zquery to look up in retriever)descriptionstrquery N)	__name__
__module____qualname____firstlineno____doc__r   r   __annotations____static_attributes__r       X/home/james-whalen/.local/lib/python3.13/site-packages/langchain_core/tools/retriever.pyr   r      s    !#BCE3Cr   r   Nz

content)document_promptdocument_separatorresponse_formatc          	        ^ ^^^ U=(       d    [         R                  " S5      m S     SUUUU 4S jjjn S     SUUUU 4S jjjn[        UUUU[        TS9$ )aw  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                t   > TR                  U SU0S9nTR                  U4S jU 5       5      nTS:X  a  X24$ U$ )N	callbacksconfigc              3  <   >#    U  H  n[        UT5      v   M     g 7fN)r   ).0docdocument_prompt_s     r   	<genexpr>6create_retriever_tool.<locals>.func.<locals>.<genexpr>B   s      *
>BsOC!122ds   content_and_artifact)invokejoin)r   r&   docsr    r-   r"   r#   	retrievers       r   func#create_retriever_tool.<locals>.func>   sT     {I.FG$)) *
>B*
 
 44?"r   c           	        >#    TR                  U SU0S9I S h  vN nTR                  U Vs/ s H  n[        UT5      I S h  vN PM     sn5      nTS:X  a  XB4$ U$  NC Ns  snf 7f)Nr&   r'   r0   )ainvoker2   r   )	r   r&   r3   r,   r    r-   r"   r#   r4   s	        r   afunc$create_retriever_tool.<locals>.afuncI   sz      &&uk95M&NN$))FJKds#C)9:::dK
 44?" O:Ks2   A&AA&A!AA!A&A!!A&)namer   r5   	coroutineargs_schemar#   r*   )r   r   r&   r   returnz str | tuple[str, list[Document]])r   from_templater   r   )	r4   r;   r   r!   r"   r#   r5   r9   r-   s	   `   ``  @r   create_retriever_toolr@      s    : 'X.*F*FGW*X ,0		(		)	 	 ,0		(		)	 	 "' r   )r4   r   r;   r   r   r   r!   zBasePromptTemplate | Noner"   r   r#   z*Literal['content', 'content_and_artifact']r>   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>rI      s     " ) % / -  ;7DY D 26$BK<<
< <
 /< < @< <r   