
    3fi                     v    d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
  eddd	       G d
 de
             Zy)    )Any)
deprecated)BaseMessageget_buffer_string)override)BaseChatMemoryz0.3.1z1.0.0z_Please see the migration guide at: https://python.langchain.com/docs/versions/migrating_memory/)sinceremovalmessagec                       e Zd ZU dZdZeed<   dZeed<   dZeed<   dZ	e
ed	<   	 ed
eee   z  fd       Zed
efd       Zed
ee   fd       Zed
ee   fd       Zedeeef   d
eeef   fd       Zy)ConversationBufferWindowMemoryzUse 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returnc                 J    | j                   r| j                  S | j                  S )zString buffer of memory.)return_messagesbuffer_as_messagesbuffer_as_strselfs    d/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_classic/memory/buffer_window.pybufferz%ConversationBufferWindowMemory.buffer   s#     +/*>*>t&&VDDVDVV    c                     | j                   dkD  r'| j                  j                  | j                    dz  d ng }t        || j                  | j
                        S )z@Exposes the buffer as a string in case return_messages is False.r      N)r   r   )r   chat_memorymessagesr   r   r   )r   r#   s     r   r   z,ConversationBufferWindowMemory.buffer_as_str$   sT     @Dvvz4##,,dffWq[];r **nn
 	
r   c                 r    | j                   dkD  r'| j                  j                  | j                    dz  d S g S )zIExposes the buffer as a list of messages in case return_messages is True.r   r!   N)r   r"   r#   r   s    r   r   z1ConversationBufferWindowMemory.buffer_as_messages.   s7     <@66A:t(($&&17M2Mr   c                     | j                   gS )z,Will always return list of memory variables.)r   r   s    r   memory_variablesz/ConversationBufferWindowMemory.memory_variables3   s       r   inputsc                 2    | j                   | j                  iS )zReturn history buffer.)r   r   )r   r'   s     r   load_memory_variablesz4ConversationBufferWindowMemory.load_memory_variables8   s     --r   N)__name__
__module____qualname____doc__r   str__annotations__r   r   r   intpropertylistr   r   r   r   r&   r   dictr   r)    r   r   r   r   
   s      L#IsJAsJ0Wd;// W W 
s 
 
 ND$5 N N !$s) ! ! .DcN .tCH~ . .r   r   N)typingr   langchain_core._apir   langchain_core.messagesr   r   typing_extensionsr   $langchain_classic.memory.chat_memoryr   r   r4   r   r   <module>r:      s@     * B & ? 
	G	).^ ).).r   