
    Ah                         S SK r S SKJr  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KJrJr  S SKJr  S S	KJr  \" S
SSS9 " S S\\5      5       rg)    N)ABC)AnyOptional)
deprecated)BaseChatMessageHistoryInMemoryChatMessageHistory)
BaseMemory)	AIMessageHumanMessage)Field)get_prompt_input_keyz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9r\\	S'   Sr
\\   \	S'   Sr\\   \	S'   Sr\\	S	'   S
\\\4   S\\\4   S\\\4   4S jrS
\\\4   S\\\4   SS4S jrS
\\\4   S\\\4   SS4S jrSS jrSS jrSrg)BaseChatMemory   a`  Abstract 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returnc                    U R                   c  [        XR                  5      nOU R                   nU R                  c  [	        U5      S:X  a#  [        [        UR                  5       5      5      nOrSU;   aA  Sn[        R                  " SU R                  R                   SUR                  5        S3SS9  O+SUR                  5        S	3n[        U5      eU R                  nX   X$   4$ )
N   output'z' got multiple output keys: zc. The default 'output' key is being used. If this is not desired, please manually set 'output_key'.   )
stacklevelzGot multiple output keys: zT, cannot determine which to store in memory. Please set the 'output_key' explicitly.)r   r   memory_variablesr   lennextiterkeyswarningswarn	__class____name__
ValueError)selfr   r   prompt_input_keyr   msgs         T/var/www/html/shao/venv/lib/python3.13/site-packages/langchain/memory/chat_memory.py_get_input_output BaseChatMemory._get_input_output+   s    
 >>!3F<Q<QR#~~??"7|q !$w||~"67
W$%
//0 1' (QR  !	 10@ A/ 0 
 !o%J')<<<    c                     U R                  X5      u  p4U R                  R                  [        US9[	        US9/5        gz.Save context from this conversation to buffer.)contentN)r0   r   add_messagesr   r
   r,   r   r   	input_str
output_strs        r/   save_contextBaseChatMemory.save_contextJ   s>     $ 6 6v G	%%Y/*-	
r2   c                    #    U R                  X5      u  p4U R                  R                  [        US9[	        US9/5      I Sh  vN   g N7fr4   )r0   r   aadd_messagesr   r
   r7   s        r/   asave_contextBaseChatMemory.asave_contextT   sM      !% 6 6v G	,,Y/*-
 	
 	
s   AAA
Ac                 8    U R                   R                  5         gzClear memory contents.N)r   clearr,   s    r/   rB   BaseChatMemory.clearb   s     r2   c                 T   #    U R                   R                  5       I Sh  vN   g N7frA   )r   aclearrC   s    r/   rF   BaseChatMemory.aclearf   s     %%'''s   (&( )r   N)r*   
__module____qualname____firstlineno____doc__r   r   r   r   __annotations__r   r   strr   r   booldictr   tupler0   r:   r>   rB   rF   __static_attributes__rH   r2   r/   r   r      s     +02+K'  !%J$#Ix}#!OT!=S#X= c3h= 
sCx	=>
4S> 
DcN 
t 

S#X
 c3h
 
	
!(r2   r   )r'   abcr   typingr   r   langchain_core._apir   langchain_core.chat_historyr   r   langchain_core.memoryr	   langchain_core.messagesr
   r   pydanticr   langchain.memory.utilsr   r   rH   r2   r/   <module>r[      sU        * - ;  7 
	G	O(Z O(O(r2   