
    h8                     B    d dl mZmZ d dlmZ d dlmZ  G d de      Zy)    )CallableUnion)Document)Docstorec                   B    e Zd ZdZdeegeeef   f   fdZdedefdZ	y)
DocstoreFnzDocstore via arbitrary lookup function.

    This is useful when:
     * it's expensive to construct an InMemoryDocstore/dict
     * you retrieve documents from remote sources
     * you just want to reuse existing objects
    	lookup_fnc                     || _         y )N)
_lookup_fn)selfr	   s     g/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/langchain_community/docstore/arbitrary_fn.py__init__zDocstoreFn.__init__   s     $    searchreturnc                     | j                  |      }t        |t              rt        |d|i      S t        |t              r|S t	        dt        |             )zSearch for a document.

        Args:
            search: search string

        Returns:
            Document if found, else error message.
        source)page_contentmetadatazUnexpected type of document )r   
isinstancestrr   
ValueErrortype)r   r   rs      r   r   zDocstoreFn.search   sT     OOF#ah5GHH8$H7QyABBr   N)
__name__
__module____qualname____doc__r   r   r   r   r   r    r   r   r   r      s?    $SE53#778$CS CX Cr   r   N)typingr   r   langchain_core.documentsr   !langchain_community.docstore.baser   r   r   r   r   <module>r#      s    " - 6C Cr   