Memory
Buffer Memory
The BufferMemory node is a memory component used in conversational AI systems to retrieve and manage chat messages stored in a database. It extends the functionality of Langchain’s BufferMemory class and implements the memory interface.
Node Details
- Name: bufferMemory
- Type: BufferMemory
- Version: 2.0
- Version: 2.0
- Category: Memory
Base Classes
- BufferMemory
- BufferMemoryExtended
Base Classes
- BufferMemory
- BufferMemoryExtended
Parameters
Inputs
- Session Id (optional)
Inputs
-
Session Id (optional)
- Type: string
- Default: ” (empty string)
- Description: Unique identifier for the chat session. If not specified, a random id will be used
- Description: Unique identifier for the chat session. If not specified, a random id will be used
-
Memory Key
- Type: string
- Default: ‘chat_history’
- Description: Key used to store and retrieve the chat history in memory
- Description: Key used to store and retrieve the chat history in memory
Input/Output
This node doesn’t have specific input/output ports. Instead, it initializes a BufferMemoryExtended instance that can be used by other nodes in the flow to manage chat history.
Functionality
-
Initialization:
- Creates a BufferMemoryExtended instance with the provided session ID, memory key, and database connection details.
-
getChatMessages:
- Retrieves chat messages from the database for a given session ID.
- Can optionally return messages as BaseMessage objects or IMessage interfaces.
- Allows prepending additional messages to the retrieved history.
-
addChatMessages and clearChatMessages:
- These methods are placeholders and don’t perform any actions, as message management is handled at the server level.
Database Integration
- Uses TypeORM’s DataSource for database operations.
- Retrieves chat messages from a ‘ChatMessage’ entity in the database.
- Filters messages by session ID and chatflow ID.
- Orders messages by creation date in ascending order.
Use Cases
- Maintaining conversation context in chatbots or conversational AI systems.
- Retrieving past interactions for context-aware responses.
- Supporting multi-turn conversations with persistent memory.
Notes
- This node is designed to work within a larger system that handles the actual storage and management of chat messages.
- It’s part of a modular architecture where memory management is separated from other conversational AI components.
Was this page helpful?
Previous
Conversation Summary Buffer MemoryThe Conversation Summary Buffer Memory node is a specialized memory component used in conversational AI systems. It maintains a summary of the conversation history, automatically summarizing older parts of the conversation when a token limit is reached. This allows for maintaining context over longer conversations without exceeding memory constraints.
Next