
    3fi                        d 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 ddlmZ  e	d	d
d       G d dee             Zy)z**Memory** maintains Chain state, incorporating context from past runs.

This module contains memory abstractions from LangChain v0.0.x.

These abstractions are now deprecated and will be removed in LangChain v1.0.0.
    )annotations)ABCabstractmethod)Any)
deprecated)Serializable)run_in_executor)
ConfigDictz0.3.3z1.0.0z_Please see the migration guide at: https://python.langchain.com/docs/versions/migrating_memory/)sinceremovalmessagec                      e Zd ZdZ ed      Zeedd              Zedd       Z	ddZ
edd       Z	 	 	 	 	 	 ddZedd	       Zdd
Zy)
BaseMemorya9  Abstract base class for memory in Chains.

    Memory refers to state in Chains. Memory can be used to store information about
        past executions of a Chain and inject that information into the inputs of
        future executions of the Chain. For example, for conversational Chains Memory
        can be used to store conversations and automatically add them to future model
        prompts so that the model has the necessary context to respond coherently to
        the latest input.

    Example:
        ```python
        class SimpleMemory(BaseMemory):
            memories: dict[str, Any] = dict()

            @property
            def memory_variables(self) -> list[str]:
                return list(self.memories.keys())

            def load_memory_variables(self, inputs: dict[str, Any]) -> dict[str, str]:
                return self.memories

            def save_context(
                self, inputs: dict[str, Any], outputs: dict[str, str]
            ) -> None:
                pass

            def clear(self) -> None:
                pass
        ```
    T)arbitrary_types_allowedc                     y)z;The string keys this memory class will add to chain inputs.N selfs    [/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_classic/base_memory.pymemory_variableszBaseMemory.memory_variables?           c                     y)zReturn key-value pairs given the text input to the chain.

        Args:
            inputs: The inputs to the chain.

        Returns:
            A dictionary of key-value pairs.
        Nr   r   inputss     r   load_memory_variablesz BaseMemory.load_memory_variablesD   r   r   c                L   K   t        d| j                  |       d{   S 7 w)zAsync return key-value pairs given the text input to the chain.

        Args:
            inputs: The inputs to the chain.

        Returns:
            A dictionary of key-value pairs.
        N)r	   r   r   s     r   aload_memory_variablesz!BaseMemory.aload_memory_variablesO   s#      %T4+E+EvNNNNs   $"$c                     y)zSave the context of this chain run to memory.

        Args:
            inputs: The inputs to the chain.
            outputs: The outputs of the chain.
        Nr   r   r   outputss      r   save_contextzBaseMemory.save_contextZ   r   r   c                P   K   t        d| j                  ||       d{    y7 w)zAsync save the context of this chain run to memory.

        Args:
            inputs: The inputs to the chain.
            outputs: The outputs of the chain.
        N)r	   r"   r    s      r   asave_contextzBaseMemory.asave_contextc   s"      dD$5$5vwGGGs   &$&c                     y)zClear memory contents.Nr   r   s    r   clearzBaseMemory.clearn   r   r   c                L   K   t        d| j                         d{    y7 w)zAsync clear memory contents.N)r	   r&   r   s    r   aclearzBaseMemory.aclearr   s     dDJJ///s   $"$N)returnz	list[str])r   dict[str, Any]r)   r*   )r   r*   r!   zdict[str, str]r)   None)r)   r+   )__name__
__module____qualname____doc__r
   model_configpropertyr   r   r   r   r"   r$   r&   r(   r   r   r   r   r      s    >  $L J  J  	O  	H$	H/=	H		H % %0r   r   N)r/   
__future__r   abcr   r   typingr   langchain_core._apir    langchain_core.load.serializabler   langchain_core.runnablesr	   pydanticr
   r   r   r   r   <module>r9      sR    # #  * 9 4  
	G	Y0s Y0Y0r   