Conversation Summary Memory
The Conversation Summary Memory node is a component in the system that summarizes conversations and stores the current summary in memory. It’s designed to provide context for language models by maintaining a condensed version of the chat history.
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
- Chat Model
Parameters
Inputs
-
Chat Model
- Type: BaseChatModel
- Description: The language model used for summarizing the conversation
- Description: The language model used for summarizing the conversation
-
Session Id (optional)
-
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
-
Memory Key (optional)
-
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
-
Initialization:
- Creates a ConversationSummaryMemoryExtended object with the provided parameters.
- Connects to the database using the provided DataSource.
-
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).
-
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.