HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/langchain/memory/__pycache__/chat_memory.cpython-310.pyc
o

���gw
�@s�ddlZddlmZddlmZmZmZmZddlm	Z	ddl
mZmZddl
mZddlmZmZddlmZdd	lmZe	d
ddd
�Gdd�dee��ZdS)�N)�ABC)�Any�Dict�Optional�Tuple)�
deprecated)�BaseChatMessageHistory�InMemoryChatMessageHistory)�
BaseMemory)�	AIMessage�HumanMessage)�Field)�get_prompt_input_keyz0.3.1z1.0.0z_Please see the migration guide at: https://python.langchain.com/docs/versions/migrating_memory/)�since�removal�messagec@s�eZdZUdZeed�Zeed<dZ	e
eed<dZe
eed<dZ
eed<d	eeefd
eeefdeeeffdd
�Zd	eeefd
eeefddfdd�Zd	eeefd
eeefddfdd�Zddd�Zddd�ZdS)�BaseChatMemoryaxAbstract base class for chat memory.

    **ATTENTION** This abstraction was created prior to when chat models had
        native tool calling capabilities.
        It does **NOT** support native tool calling capabilities for chat models and
        will fail SILENTLY if used with a chat model that has native tool calling.

    DO NOT USE THIS ABSTRACTION FOR NEW CODE.
    )�default_factory�chat_memoryN�
output_key�	input_keyF�return_messages�inputs�outputs�returncCs�|jdurt||j�}n|j}|jdurDt|�dkr#t|���d}n$d|vr:d}t�d|j	j
�d|���d��n
td|���d���|j}||||fS)	N�r�output�'z' got multiple output keys: zc. The default 'output' key is being used. If this is not desired, please manually set 'output_key'.zGot multiple output keys: zT, cannot determine which to store in memory. Please set the 'output_key' explicitly.)rr�memory_variablesr�len�list�keys�warnings�warn�	__class__�__name__�
ValueError)�selfrr�prompt_input_keyr�r)�G/usr/local/lib/python3.10/dist-packages/langchain/memory/chat_memory.py�_get_input_output+s$

���z BaseChatMemory._get_input_outputcCs0|�||�\}}|j�t|d�t|d�g�dS�z.Save context from this conversation to buffer.)�contentN)r+r�add_messagesrr�r'rr�	input_str�
output_strr)r)r*�save_contextFs��zBaseChatMemory.save_contextc�s8�|�||�\}}|j�t|d�t|d�g�IdHdSr,)r+r�
aadd_messagesrrr/r)r)r*�
asave_contextPs���zBaseChatMemory.asave_contextcCs|j��dS�zClear memory contents.N)r�clear�r'r)r)r*r6\szBaseChatMemory.clearc�s�|j��IdHdSr5)r�aclearr7r)r)r*r8`s�zBaseChatMemory.aclear)rN)r%�
__module__�__qualname__�__doc__r
r	rr�__annotations__rr�strrr�boolrrrr+r2r4r6r8r)r)r)r*rs2
	
�
�
�

�&

�
�
�
r)r"�abcr�typingrrrr�langchain_core._apir�langchain_core.chat_historyrr	�langchain_core.memoryr
�langchain_core.messagesrr�pydanticr
�langchain.memory.utilsrrr)r)r)r*�<module>s�