RedisVectorStore
features and configurations head to the API reference.
Overview
Integration details
Class | Package | PY support | Version |
---|---|---|---|
RedisVectorStore | @langchain/redis | ✅ |
Setup
To use Redis vector stores, you’ll need to set up a Redis instance and install the@langchain/redis
integration package. You can also install the node-redis
package to initialize the vector store with a specific client instance.
This guide will also use OpenAI embeddings, which require you to install the @langchain/openai
integration package. You can also use other supported embeddings models if you wish.
Credentials
Once you’ve set up an instance, set theREDIS_URL
environment variable:
Instantiation
Manage vector store
Add items to vector store
Query vector store
Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.Query directly
Performing a simple similarity search can be done as follows:Query by turning into retriever
You can also transform the vector store into a retriever for easier usage in your chains.Usage for retrieval-augmented generation
For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:Deleting documents
You can delete documents from the vector store in two ways:Delete all documents
You can delete an entire index and all its documents with the following command:Delete specific documents by ID
You can also delete specific documents by providing their IDs. Note that the configured key prefix will be automatically added to the IDs you provide:Closing connections
Make sure you close the client connection when you are finished to avoid excessive resource consumption:API reference
For detailed documentation of allRedisVectorSearch
features and configurations head to the API reference.