
    3fiK                     T    d Z ddlmZmZmZmZ ddlmZ ddlm	Z	m
Z
  G d de
e	      Zy)0Simple in memory docstore in the form of a dict.    )DictListOptionalUnion)Document)AddableMixinDocstorec                   r    e Zd ZdZddeeeef      fdZdeeef   ddfdZ	de
ddfd	Zd
edeeef   fdZy)InMemoryDocstorer   N_dictc                 &    ||| _         yi | _         y)zInitialize with dict.Nr   )selfr   s     d/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_community/docstore/in_memory.py__init__zInMemoryDocstore.__init__   s    #/U
R
    textsreturnc                     t        |      j                  | j                        }|rt        d|       i | j                  || _        y)zAdd texts to in memory dictionary.

        Args:
            texts: dictionary of id -> document.

        Returns:
            None
        z%Tried to add ids that already exist: N)setintersectionr   
ValueError)r   r   overlappings      r   addzInMemoryDocstore.add   sG     %j--djj9D[MRSS,

,e,
r   idsc                     t        |      j                  | j                        }|st        d|       |D ]  }| j                  j	                  |        y)z'Deleting IDs from in memory dictionary.z*Tried to delete ids that does not  exist: N)r   r   r   r   pop)r   r   r   _ids       r   deletezInMemoryDocstore.delete   sO    #h++DJJ7I#OPP 	 CJJNN3	 r   searchc                 H    || j                   vrd| dS | j                   |   S )zSearch via direct lookup.

        Args:
            search: id of a document to search for.

        Returns:
            Document if found, else error message.
        zID z not found.r   )r   r!   s     r   r!   zInMemoryDocstore.search'   s.     #,,::f%%r   )N)__name__
__module____qualname____doc__r   r   strr   r   r   r   r    r   r!    r   r   r   r   
   sj    :8htCM':; 8-c8m, - - $  4  &S &U3=%9 &r   r   N)r&   typingr   r   r   r   langchain_core.documentsr   !langchain_community.docstore.baser	   r
   r   r(   r   r   <module>r,      s"    6 . . - D)&x )&r   