Class for storing chat message history using Redis. Extends the BaseListChatMessageHistory class.
BaseListChatMessageHistory
const chatHistory = new RedisChatMessageHistory({ sessionId: new Date().toISOString(), sessionTTL: 300, url: "redis:});const chain = new ConversationChain({ llm: new ChatOpenAI({ modelName: "gpt-3.5-turbo", temperature: 0 }), memory: { chatHistory },});const response = await chain.invoke({ input: "What did I just say my name was?",});console.log({ response }); Copy
const chatHistory = new RedisChatMessageHistory({ sessionId: new Date().toISOString(), sessionTTL: 300, url: "redis:});const chain = new ConversationChain({ llm: new ChatOpenAI({ modelName: "gpt-3.5-turbo", temperature: 0 }), memory: { chatHistory },});const response = await chain.invoke({ input: "What did I just say my name was?",});console.log({ response });
Adds a new chat message to the Redis database for the current session.
The BaseMessage instance to add.
BaseMessage
Promise resolving when the message has been added.
Deletes all chat messages from the Redis database for the current session.
Promise resolving when the messages have been deleted.
Ensures the Redis client is ready to perform operations. If the client is not ready, it attempts to connect to the Redis database.
Promise resolving to true when the client is ready.
Retrieves all chat messages from the Redis database for the current session.
Promise resolving to an array of BaseMessage instances.
Generated using TypeDoc
Class for storing chat message history using Redis. Extends the
BaseListChatMessageHistory
class.Example