description: Stores the conversation in dynamo db table.
DynamoDB Chat Memory
.png)
DynamoDB Chat Memory Node
The DynamoDB Chat Memory node is a component that stores conversation history in an Amazon DynamoDB table. It extends the functionality of the BufferMemory class to provide persistent storage of chat messages using AWS DynamoDB as the backend.
Parameters
-
Credential
Type: credential Credential Names: dynamodbMemoryApi Description: AWS credentials for DynamoDB access
Inputs
-
Table Name
Type: string Description: The name of the DynamoDB table to store chat
-
Partition Key
Type: string Description: The primary key for the DynamoDB table
-
Region
Type: string Description: The AWS region where the DynamoDB table is located Placeholder: us-east-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
-
Memory Key
Type: string Default: ‘chat_history’ Description: Key used to store the chat history in memory
Functionality
The DynamoDB Chat Memory node provides the following key features:
-
Initialization: Sets up the DynamoDB client and creates a BufferMemoryExtended instance with the specified parameters.
-
Message Storage: Stores chat messages (both user inputs and AI responses) in the specified DynamoDB table.
-
Message Retrieval: Fetches stored chat messages from the DynamoDB table.
-
Message Clearing: Allows clearing of all stored messages for a given session.
-
Session Management: Supports multiple chat sessions using unique session IDs.
Usage
This node is particularly useful for applications that require persistent storage of conversation history across sessions or need to scale chat memory storage using AWS DynamoDB. It’s ideal for chatbots, virtual assistants, or any AI application that benefits from maintaining context over time or across multiple interactions.
Implementation Details
- Uses the
text @aws-sdk/client-dynamodbfor interacting with DynamoDB. - Extends the
text BufferMemoryclass from LangChain for compatibility with other LangChain components. - Implements custom methods for adding, retrieving, and clearing messages in DynamoDB.
- Supports credential management for secure AWS authentication.
Note
Ensure that the AWS credentials provided have the necessary permissions to read from and write to the specified DynamoDB table. Also, make sure that the table structure matches the expected format for storing chat messages.
{% hint style="info" %} This section is a work in progress. We appreciate any help you can provide in completing this section. Please check our Contribution Guide to get started. {% endhint %}