Redis (Remote Dictionary Server) is an open-source in-memory storage, used as a distributed, in-memory key–value database, cache and message broker, with optional durability. Redis
offers low-latency reads and writes. Redis is the most popular NoSQL database, and one of the most popular databases overall.
This notebook demonstrates how to use the RedisChatMessageHistory
class from the langchain-redis package to store and manage chat message history using Redis.
Setup
First, we need to install the required dependencies and ensure we have a Redis instance running.Importing Required Libraries
Basic Usage of RedisChatMessageHistory
Using RedisChatMessageHistory with Language Models
Set OpenAI API key
Advanced Features
Custom Redis Configuration
Searching Messages
Clearing History
Conclusion
This notebook demonstrated the key features ofRedisChatMessageHistory
from the langchain-redis package. It showed how to initialize and use the chat history, integrate it with language models, and utilize advanced features like custom configurations and message searching. Redis provides a fast and scalable solution for managing chat history in AI applications.