ConversationStringBufferMemory#

class langchain.memory.buffer.ConversationStringBufferMemory[source]#

Bases: BaseMemory

Buffer for storing conversation memory.

param ai_prefix: str = 'AI'#

Prefix to use for AI generated responses.

param buffer: str = ''#
param human_prefix: str = 'Human'#
param input_key: str | None = None#
param output_key: str | None = None#
async aclear() None[source]#

Async clear memory contents.

Return type:

None

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

Return history buffer.

Parameters:

inputs (Dict[str, Any]) –

Return type:

Dict[str, str]

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

load_memory_variables(inputs: Dict[str, Any]) Dict[str, str][source]#

Return history buffer.

Parameters:

inputs (Dict[str, Any]) –

Return type:

Dict[str, str]

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

property memory_variables: List[str]#

Will always return list of memory variables. :meta private: