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

���g��@sbddlmZmZmZmZddlmZddlmZm	Z	ddl
mZedddd�Gd	d
�d
e��ZdS)�)�Any�Dict�List�Union)�
deprecated)�BaseMessage�get_buffer_string)�BaseChatMemoryz0.3.1z1.0.0z_Please see the migration guide at: https://python.langchain.com/docs/versions/migrating_memory/)�since�removal�messagec@s�eZdZUdZdZeed<dZeed<dZeed<dZ	e
ed	<	ed
eee
effdd��Zed
efd
d��Zed
e
efdd��Zed
e
efdd��Zdeeefd
eeeffdd�ZdS)�ConversationBufferWindowMemoryz�Use to keep track of the last k turns of a conversation.

    If the number of messages in the conversation is more than the maximum number
    of messages to keep, the oldest messages are dropped.
    �Human�human_prefix�AI�	ai_prefix�history�
memory_key��k�returncCs|jr|jS|jS)zString buffer of memory.)�return_messages�buffer_as_messages�
buffer_as_str��self�r�I/usr/local/lib/python3.10/dist-packages/langchain/memory/buffer_window.py�buffersz%ConversationBufferWindowMemory.buffercCs8|jdkr|jj|jdd�ng}t||j|jd�S)z@Exposes the buffer as a string in case return_messages is False.r�N)rr)r�chat_memory�messagesrrr)rr!rrrr#s&�z,ConversationBufferWindowMemory.buffer_as_strcCs&|jdkr|jj|jdd�SgS)zIExposes the buffer as a list of messages in case return_messages is True.rrN)rr r!rrrrr-s&z1ConversationBufferWindowMemory.buffer_as_messagescCs|jgS)zMWill always return list of memory variables.

        :meta private:
        )rrrrr�memory_variables2sz/ConversationBufferWindowMemory.memory_variables�inputscCs|j|jiS)zReturn history buffer.)rr)rr#rrr�load_memory_variables:sz4ConversationBufferWindowMemory.load_memory_variablesN)�__name__�
__module__�__qualname__�__doc__r�str�__annotations__rrr�int�propertyrrrrrrr"rrr$rrrrr
	s 
		&r
N)
�typingrrrr�langchain_core._apir�langchain_core.messagesrr�langchain.memory.chat_memoryr	r
rrrr�<module>s�