redis_openai_agents.RedisVectorStore#
- class RedisVectorStore(name, redis_url='redis://localhost:6379', vector_dims=384, distance_metric='COSINE', embeddings_cache=None)[source]#
Vector store for document storage and semantic search.
Uses Redis with RedisVL for high-performance vector similarity search.
Example
>>> store = RedisVectorStore(name="docs", redis_url="redis://localhost:6379") >>> store.add_documents([{"content": "Hello world", "metadata": {"source": "test"}}]) >>> results = store.search(query="greeting", k=5)
- Parameters:
name (str) – Index name in Redis
redis_url (str) – Redis connection URL
vector_dims (int) – Dimension of embedding vectors (default 384 for all-MiniLM-L6-v2)
distance_metric (str) – Distance metric (COSINE, L2, IP)
embeddings_cache (EmbeddingsCache | None)
Initialize the vector store.
- Parameters:
name (str) – Index name in Redis
redis_url (str) – Redis connection URL
vector_dims (int) – Dimension of embedding vectors (384 for all-MiniLM-L6-v2)
distance_metric (str) – Distance metric (COSINE, L2, IP)
embeddings_cache (EmbeddingsCache | None) – Optional RedisVL EmbeddingsCache. When provided, repeated embeddings of identical content are served from the cache rather than re-invoking the vectorizer.
- __init__(name, redis_url='redis://localhost:6379', vector_dims=384, distance_metric='COSINE', embeddings_cache=None)[source]#
Initialize the vector store.
- Parameters:
name (str) – Index name in Redis
redis_url (str) – Redis connection URL
vector_dims (int) – Dimension of embedding vectors (384 for all-MiniLM-L6-v2)
distance_metric (str) – Distance metric (COSINE, L2, IP)
embeddings_cache (EmbeddingsCache | None) – Optional RedisVL EmbeddingsCache. When provided, repeated embeddings of identical content are served from the cache rather than re-invoking the vectorizer.
- Return type:
None
Methods
__init__(name[, redis_url, vector_dims, ...])Initialize the vector store.
aadd_documents(documents)Async version of add_documents().
add_documents(documents)Add documents to the vector store.
ahybrid_search(query[, k, text_weight, ...])Async version of hybrid_search().
asearch(query[, k, filter])Async version of search().
count()Count documents in the store.
delete(ids)Delete documents by ID.
delete_all()Delete all documents and the index.
hybrid_search(query[, k, text_weight, ...])Hybrid search combining vector similarity and BM25 text search.
search(query[, k, filter])Search for similar documents.
Attributes
nameIndex name in Redis.
vectorizer_modelName of the underlying embedding model.