LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-corechat_historyInMemoryChatMessageHistory
    Class●Since v0.1

    InMemoryChatMessageHistory

    In memory implementation of chat message history.

    Stores messages in a memory list.

    Copy
    InMemoryChatMessageHistory()

    Bases

    BaseChatMessageHistoryBaseModel

    Used in Docs

    • Amazon neptune with cypher integration
    • ChatNVIDIA integration

    Attributes

    attribute
    messages: list[BaseMessage]

    A list of messages stored in memory.

    Methods

    method
    aget_messages

    Async version of getting messages.

    Can over-ride this method to provide an efficient async implementation.

    In general, fetching messages may involve IO to the underlying persistence layer.

    method
    add_message

    Add a self-created message to the store.

    method
    aadd_messages

    Async add messages to the store.

    method
    clear

    Clear all messages from the store.

    method
    aclear

    Async clear all messages from the store.

    Inherited fromBaseChatMessageHistory

    Methods

    Madd_user_message
    —

    Convenience method for adding a human message string to the store.

    Madd_ai_message
    —

    Convenience method for adding an AIMessage string to the store.

    Madd_messages
    —

    Add a list of messages.

    View source on GitHub