Node Details

  • Name: bufferMemory
  • Type: BufferMemory
  • Version: 2.0
  • Version: 2.0
  • Category: Memory

Base Classes

  • BufferMemory
  • BufferMemoryExtended

Base Classes

  • BufferMemory
  • BufferMemoryExtended

Parameters

Inputs

  1. Session Id (optional)

Inputs

  1. 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
  2. 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

  1. Initialization:

    • Creates a BufferMemoryExtended instance with the provided session ID, memory key, and database connection details.
  2. 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.
  3. 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.