BaseChatMemory#

class langchain.memory.chat_memory.BaseChatMemory[source]#

Bases: BaseMemory, ABC

Deprecated since version 0.3.1: Please see the migration guide at: https://python.langchain.com/docs/versions/migrating_memory/

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.

param chat_memory: BaseChatMessageHistory [Optional]#
param input_key: str | None = None#
param output_key: str | None = None#
param return_messages: bool = False#
async aclear() None[source]#

Clear memory contents.

Return type:

None

async aload_memory_variables(inputs: dict[str, Any]) dict[str, Any]#

Async return key-value pairs given the text input to the chain.

Parameters:

inputs (dict[str, Any]) – The inputs to the chain.

Returns:

A dictionary of key-value pairs.

Return type:

dict[str, Any]

async asave_context(inputs: Dict[str, Any], outputs: Dict[str, str]) None[source]#

Save context from this conversation to buffer.

Parameters:
  • inputs (Dict[str, Any])

  • outputs (Dict[str, str])

Return type:

None

clear() None[source]#

Clear memory contents.

Return type:

None

abstract load_memory_variables(inputs: dict[str, Any]) dict[str, Any]#

Return key-value pairs given the text input to the chain.

Parameters:

inputs (dict[str, Any]) – The inputs to the chain.

Returns:

A dictionary of key-value pairs.

Return type:

dict[str, Any]

save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) None[source]#

Save context from this conversation to buffer.

Parameters:
  • inputs (Dict[str, Any])

  • outputs (Dict[str, str])

Return type:

None

abstract property memory_variables: list[str]#

The string keys this memory class will add to chain inputs.