a
    agw                     @   s   d dl Z d dlmZ d dlmZmZmZmZ d dlm	Z	 d dl
mZ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dG dd deeZdS )    N)ABC)AnyDictOptionalTuple)
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/)ZsinceZremovalmessagec                   @   s   e Zd ZU dZeedZeed< dZ	e
e ed< dZe
e ed< dZeed< eeef eeef eeef d	d
dZeeef eeef dd	ddZeeef eeef dd	ddZddddZddddZdS )BaseChatMemoryax  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                 C   s   | j d u rt|| j}n| j }| jd u rt|dkrFt| d }qd|v rtd}td| j	j
 d|  d qtd|  dn| j}|| || fS )	N   r   output'z' got multiple output keys: zc. The default 'output' key is being used. If this is not desired, please manually set 'output_key'.zGot multiple output keys: zT, cannot determine which to store in memory. Please set the 'output_key' explicitly.)r   r   Zmemory_variablesr   lenlistkeyswarningswarn	__class____name__
ValueError)selfr   r   Zprompt_input_keyr    r%   j/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain/memory/chat_memory.py_get_input_output+   s$    

z BaseChatMemory._get_input_outputc                 C   s0   |  ||\}}| jt|dt|dg dS z.Save context from this conversation to buffer.)contentN)r'   r   Zadd_messagesr   r   r$   r   r   Z	input_strZ
output_strr%   r%   r&   save_contextF   s    zBaseChatMemory.save_contextc                    s6   |  ||\}}| jt|dt|dgI dH  dS r(   )r'   r   Zaadd_messagesr   r   r*   r%   r%   r&   asave_contextP   s    zBaseChatMemory.asave_context)r   c                 C   s   | j   dS zClear memory contents.N)r   clearr$   r%   r%   r&   r.   \   s    zBaseChatMemory.clearc                    s   | j  I dH  dS r-   )r   aclearr/   r%   r%   r&   r0   `   s    zBaseChatMemory.aclear)r"   
__module____qualname____doc__r   r	   r   r   __annotations__r   r   strr   r   boolr   r   r   r'   r+   r,   r.   r0   r%   r%   r%   r&   r      s    
	

"r   )r   abcr   typingr   r   r   r   Zlangchain_core._apir   Zlangchain_core.chat_historyr   r	   Zlangchain_core.memoryr
   Zlangchain_core.messagesr   r   Zpydanticr   Zlangchain.memory.utilsr   r   r%   r%   r%   r&   <module>   s   