Node Details

  • Name: ConversationSummaryMemory
  • Type: Memory
  • Version: 2.0
  • Icon: memory.svg
  • Category: Memory

Description

This node summarizes the conversation and stores the current summary in memory. It’s useful for maintaining context in long conversations without the need to pass the entire chat history to the language model.

Base Classes

  • ConversationSummaryMemory
  • (Additional base classes from ConversationSummaryMemory)

Parameters

Inputs

  1. Chat Model

Parameters

Inputs

  1. Chat Model

    • Type: BaseChatModel
    • Description: The language model used for summarizing the conversation
    • Description: The language model used for summarizing the conversation
  2. Session Id (optional)

  3. Session Id (optional)

    • Type: string
    • Default: ” (empty string)
    • Description: A unique identifier for the conversation session. If not specified, a random id will be used
    • Description: A unique identifier for the conversation session. If not specified, a random id will be used
  4. Memory Key (optional)

  5. Memory Key (optional)

    • Type: string
    • Default: ‘chat_history’
    • Description: The key used to store the summary in memory
    • Description: The key used to store the summary in memory

Functionality

  1. Initialization:

    • Creates a ConversationSummaryMemoryExtended object with the provided parameters.
    • Connects to the database using the provided DataSource.
  2. Get Chat Messages:

    • Retrieves chat messages from the database based on the session ID and chatflow ID.
    • Summarizes the conversation using the provided language model.
    • Returns the summary as a SystemMessage or HumanMessage (for Anthropic models).
  3. Add/Clear Chat Messages:

    • These operations are handled at the server level, not within the node itself.

Usage

This node is particularly useful in chatbots or conversational AI systems where maintaining context is crucial, but passing the entire conversation history would be inefficient. It allows the AI to reference a summary of the previous conversation, enabling more coherent and context-aware responses.

Integration

The node integrates with:

  • AI’s database system for storing and retrieving chat messages.
  • Various language models, including special handling for Anthropic models.
  • AI’s chat system, providing summarized context for conversations.

Note

The effectiveness of this node depends on the quality of the summarization performed by the language model. It’s important to use a model that can generate concise yet informative summaries for optimal performance.