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-classicmemoryentityConversationEntityMemory
    Class●Since v1.0Deprecated

    ConversationEntityMemory

    Copy
    ConversationEntityMemory()

    Bases

    BaseChatMemory

    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

    Masave_context
    —

    Async save the context of this chain run to memory.

    Maclear
    —

    Async clear memory contents.

    Inherited fromBaseMemory

    Attributes

    Amodel_config

    Methods

    Maload_memory_variables
    —

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

    Masave_context
    —

    Async save the context of this chain run to memory.

    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
    llm: BaseLanguageModel
    attribute
    entity_extraction_prompt: BasePromptTemplate
    attribute
    entity_summarization_prompt: BasePromptTemplate
    attribute
    entity_cache: list[str]
    attribute
    k: int
    attribute
    chat_history_key: str
    attribute
    entity_store: BaseEntityStore
    attribute
    buffer: list[BaseMessage]

    Access chat memory messages.

    attribute
    memory_variables: list[str]

    Will always return list of memory variables.

    method
    load_memory_variables

    Load memory variables.

    Returns chat history and all generated entities with summaries if available, and updates or clears the recent entity cache.

    New entity name can be found when calling this method, before the entity summaries are generated, so the entity cache values may be empty if no entity descriptions are generated yet.

    method
    save_context

    Save context from this conversation history to the entity store.

    Generates a summary for each entity in the entity cache by prompting the model, and saves these summaries to the entity store.

    method
    clear

    Clear memory contents.

    Entity extractor & summarizer memory.

    Extracts named entities from the recent chat history and generates summaries. With a swappable entity store, persisting entities across conversations. Defaults to an in-memory entity store, and can be swapped out for a Redis, SQLite, or other entity store.