Upstash Redis-Backed Chat Memory
The Upstash Redis-Backed Chat Memory node is a component that provides long-term memory storage for chat conversations using Upstash Redis. It summarizes and stores conversation history, allowing for persistent memory across chat sessions.
Node Details
- Name: upstashRedisBackedChatMemory
- Type: UpstashRedisBackedChatMemory
- Version: 2.0
- Category: Memory
Base Classes
- UpstashRedisBackedChatMemory
- BufferMemory (and its base classes)
Parameters
Credential
- Type: credential
- Credential Names: upstashRedisMemoryApi
- Credential Names: upstashRedisMemoryApi
- Description: Configure password authentication for your Upstash Redis instance
Inputs
-
Upstash Redis REST URL
- Type: string
- Description: The base URL for your Upstash Redis instance
- Description: The base URL for your Upstash Redis instance
- Placeholder:
https://<your-url>.upstash.io
-
Session Id (optional)
-
Session Id (optional)
- Type: 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
-
Session Timeouts (optional)
-
Session Timeouts (optional)
- Type: number
- Description: Time-to-live for the session in seconds. Omit this parameter to make sessions never expire
- Description: Time-to-live for the session in seconds. Omit this parameter to make sessions never expire
-
Memory Key
- Type: string
- Default: ‘chat_history’
- Description: Key used to store and retrieve the chat history in Redis
- Description: Key used to store and retrieve the chat history in Redis
Functionality
-
Initialization:
- Creates a Redis client using the provided URL and authentication token.
- Sets up an UpstashRedisChatMessageHistory instance.
- Initializes a BufferMemoryExtended instance with the chat history.
-
Memory Operations:
getChatMessages
: Retrieves stored chat messages from Redis.addChatMessages
: Adds new messages to the Redis storage.clearChatMessages
: Clears all messages for a given session.
Usage
This node is particularly useful in scenarios where you need to maintain conversation context over extended periods or across multiple sessions. It leverages Upstash Redis for efficient and scalable storage of chat history.
Integration
The node can be easily integrated into a larger conversational AI system, providing a robust solution for managing chat memory. It’s designed to work seamlessly with other components and can be configured through the Ardor UI.
Note
Ensure that you have proper credentials and access to an Upstash Redis instance before using this node. The Redis connection is managed as a singleton to optimize resource usage across multiple instances of the node.