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__/combined.cpython-310.pyc
o

���g��@sXddlZddlmZmZmZmZddlmZddlm	Z	ddl
mZGdd�de�ZdS)�N)�Any�Dict�List�Set)�
BaseMemory)�field_validator)�BaseChatMemoryc@s�eZdZUdZeeed<	ed�edeedeefdd���Z	ed�edeedeefdd���Z
edeefd	d
��Z
deeefdeeeffdd
�Zdeeefdeeefddfdd�Zddd�ZdS)�CombinedMemoryz+Combining multiple memories' data together.�memories�value�returncCsBt�}|D]}|�|j�}|rtd|�d���|t|j�O}q|S)NzThe same variables zL are found in multiplememory object, which is not allowed by CombinedMemory.)�set�intersection�memory_variables�
ValueError)�clsr�
all_variables�val�overlap�r�D/usr/local/lib/python3.10/dist-packages/langchain/memory/combined.py�check_repeated_memory_variables
�z-CombinedMemory.check_repeated_memory_variablecCs2|D]}t|t�r|jdurt�d|���q|S)zHCheck that if memories are of type BaseChatMemory that input keys exist.NzWWhen using CombinedMemory, input keys should be so the input is known.  Was not set on )�
isinstancer�	input_key�warnings�warn)rrrrrr�check_input_key!s

���zCombinedMemory.check_input_keycCs"	g}|jD]}|�|j�q|S)z5All the memory variables that this instance provides.)r
�extendr)�selfr�memoryrrrr/s

zCombinedMemory.memory_variables�inputscCsPi}|jD] }|�|�}|��D]\}}||vr td|�d���|||<qq|S)z Load all vars from sub-memories.z
The variable z# is repeated in the CombinedMemory.)r
�load_memory_variables�itemsr)rr �memory_datar�data�keyrrrrr!;s


�
�z$CombinedMemory.load_memory_variables�outputsNcCs|jD]}|�||�qdS)z0Save context from this session for every memory.N)r
�save_context)rr r&rrrrr'Ks
�zCombinedMemory.save_contextcCs|jD]}|��qdS)z1Clear context from this session for every memory.N)r
�clear)rrrrrr(Qs

�zCombinedMemory.clear)rN)�__name__�
__module__�__qualname__�__doc__rr�__annotations__r�classmethodrr�property�strrrrr!r'r(rrrrr	
s&
��"&r	)
r�typingrrrr�langchain_core.memoryr�pydanticr�langchain.memory.chat_memoryrr	rrrr�<module>s