LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • MCP Adapters
    • Overview
    • Agents
    • Callbacks
    • Chains
    • Chat models
    • Embeddings
    • Evaluation
    • Globals
    • Hub
    • Memory
    • Output parsers
    • Retrievers
    • Runnables
    • LangSmith
    • Storage
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    MCP Adapters
    OverviewAgentsCallbacksChainsChat modelsEmbeddingsEvaluationGlobalsHubMemoryOutput parsersRetrieversRunnablesLangSmithStorage
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-classicmemorybufferConversationBufferMemory
    Class●Since v1.0Deprecated

    ConversationBufferMemory

    Copy
    ConversationBufferMemory()

    Bases

    BaseChatMemory

    Used in Docs

    • Bittensor integration
    • Gradio integration
    • Llama2chat integration
    • Memorize integration
    • Reddit search integration

    Attributes

    Methods

    Inherited fromBaseChatMemory

    Attributes

    Achat_memory: BaseChatMessageHistoryAoutput_key: strAinput_key: str | None
    —

    The key from the model Run's inputs to use as the eval input.

    View source on GitHub
    A
    return_messages
    : bool

    Methods

    Msave_context
    —

    Save the context of this chain run to memory.

    Masave_context
    —

    Async save the context of this chain run to memory.

    Mclear
    —

    Clear memory contents.

    Maclear
    —

    Async clear memory contents.

    Inherited fromBaseMemory

    Attributes

    Amodel_config

    Methods

    Msave_context
    —

    Save the context of this chain run to memory.

    Masave_context
    —

    Async save the context of this chain run to memory.

    Mclear
    —

    Clear memory contents.

    Maclear
    —

    Async clear memory contents.

    Inherited fromSerializable(langchain_core)

    Attributes

    Alc_secretsAlc_attributesAmodel_config

    Methods

    Mis_lc_serializableMget_lc_namespaceMlc_idMto_jsonMto_json_not_implemented
    attribute
    human_prefix: str
    attribute
    ai_prefix: str
    attribute
    memory_key: str
    attribute
    buffer: Any

    String buffer of memory.

    attribute
    buffer_as_str: str

    Exposes the buffer as a string in case return_messages is True.

    attribute
    buffer_as_messages: list[BaseMessage]

    Exposes the buffer as a list of messages in case return_messages is False.

    attribute
    memory_variables: list[str]

    Will always return list of memory variables.

    method
    abuffer

    String buffer of memory.

    method
    abuffer_as_str

    Exposes the buffer as a string in case return_messages is True.

    method
    abuffer_as_messages

    Exposes the buffer as a list of messages in case return_messages is False.

    method
    load_memory_variables

    Return history buffer.

    method
    aload_memory_variables

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

    A basic memory implementation that simply stores the conversation history.

    This stores the entire conversation history in memory without any additional processing.

    Note that additional processing may be required in some situations when the conversation history is too large to fit in the context window of the model.