a
    ”˜ëjm  ã                   @  s€   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d�G dd„ deeƒƒZdS )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)Ú
ConfigDict)Ú
deprecated)ÚSerializable)Úrun_in_executorz0.3.3z1.0.0z_Please see the migration guide at: https://python.langchain.com/docs/versions/migrating_memory/)ZsinceZremovalÚmessagec                   @  sœ   e Zd ZdZedd�Zeeddœdd„ƒƒZeddd	œd
d„ƒZ	ddd	œdd„Z
eddddœdd„ƒZddddœdd„Zeddœdd„ƒZddœdd„ZdS )Ú
BaseMemorya–  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:
        .. code-block:: 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)Zarbitrary_types_allowedz	list[str])Úreturnc                 C  s   dS )z;The string keys this memory class will add to chain inputs.N© ©Úselfr   r   úT/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/langchain_core/memory.pyÚmemory_variablesC   s    zBaseMemory.memory_variableszdict[str, Any])Úinputsr   c                 C  s   dS )z½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.
        Nr   ©r   r   r   r   r   Úload_memory_variablesH   s    z BaseMemory.load_memory_variablesc                 Ã  s   t d| j|ƒI dH S )zÃAsync 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   r   r   r   Úaload_memory_variablesS   s    	z!BaseMemory.aload_memory_variableszdict[str, str]ÚNone)r   Úoutputsr   c                 C  s   dS )z¡Save the context of this chain run to memory.

        Args:
            inputs: The inputs to the chain.
            outputs: The outputs of the chain.
        Nr   ©r   r   r   r   r   r   Úsave_context^   s    zBaseMemory.save_contextc                 Ã  s   t d| j||ƒI dH  dS )z§Async 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   r   r   r   Úasave_contextg   s    	zBaseMemory.asave_contextc                 C  s   dS )zClear memory contents.Nr   r   r   r   r   Úclearr   s    zBaseMemory.clearc                 Ã  s   t d| jƒI dH  dS )zAsync clear memory contents.N)r	   r   r   r   r   r   Úaclearv   s    zBaseMemory.aclearN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Zmodel_configÚpropertyr   r   r   r   r   r   r   r   r   r   r   r   r      s    	"ÿ
r   N)r    Ú
__future__r   Úabcr   r   Útypingr   Zpydanticr   Zlangchain_core._apir   Z langchain_core.load.serializabler   Zlangchain_core.runnablesr	   r   r   r   r   r   Ú<module>   s   ü