
    Ah                     h    S SK JrJr  S SKJr  S SKJrJr  S SKJ	r	  \" SSSS9 " S	 S
\	5      5       r
g)    )AnyUnion)
deprecated)BaseMessageget_buffer_string)BaseChatMemoryz0.3.1z1.0.0z_Please see the migration guide at: https://python.langchain.com/docs/versions/migrating_memory/)sinceremovalmessagec                       \ rS rSr% SrSr\\S'   Sr\\S'   Sr	\\S'   S	r
\\S
'    \S\\\\   4   4S j5       r\S\4S j5       r\S\\   4S j5       r\S\\   4S j5       rS\\\4   S\\\4   4S jrSrg)ConversationBufferWindowMemory	   zUse 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                 T    U R                   (       a  U R                  $ U R                  $ )zString buffer of memory.)return_messagesbuffer_as_messagesbuffer_as_strselfs    V/var/www/html/shao/venv/lib/python3.13/site-packages/langchain/memory/buffer_window.pybuffer%ConversationBufferWindowMemory.buffer   s#     +/*>*>t&&VDDVDVV    c                     U R                   S:  a'  U R                  R                  U R                   * S-  S O/ n[        UU R                  U R
                  S9$ )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   ,ConversationBufferWindowMemory.buffer_as_str#   sT     @Dvvz4##,,dffWq[];r **nn
 	
r!   c                 t    U R                   S:  a'  U R                  R                  U R                   * S-  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   1ConversationBufferWindowMemory.buffer_as_messages-   s7     <@66A:t(($&&17M2Mr!   c                     U R                   /$ )z=Will always return list of memory variables.

:meta private:
)r   r   s    r   memory_variables/ConversationBufferWindowMemory.memory_variables2   s       r!   inputsc                 2    U R                   U R                  0$ )zReturn history buffer.)r   r   )r   r,   s     r   load_memory_variables4ConversationBufferWindowMemory.load_memory_variables:   s    --r!    N)__name__
__module____qualname____firstlineno____doc__r   str__annotations__r   r   r   intpropertyr   listr   r   r   r   r*   dictr   r.   __static_attributes__r0   r!   r   r   r   	   s      L#IsJAsJ0Wc4#445 W W 
s 
 
 ND$5 N N !$s) ! !.DcN .tCH~ .r!   r   N)typingr   r   langchain_core._apir   langchain_core.messagesr   r   langchain.memory.chat_memoryr   r   r0   r!   r   <module>rA      s=     * B 7 
	G	+.^ +.+.r!   