langchain.vectorstores.redis.Redis¶
class langchain.vectorstores.redis.Redis(redis_url: str, index_name: str, embedding_function: Callable, content_key: str = 'content', metadata_key: str = 'metadata', vector_key: str = 'content_vector', relevance_score_fn: Optional[Callable[[float], float]] = None, distance_metric: Literal['COSINE', 'IP', 'L2'] = 'COSINE', **kwargs: Any)[source]¶
Wrapper around Redis vector database.
To use, you should have the redis python package installed.
Example
from langchain.vectorstores import Redis
from langchain.embeddings import OpenAIEmbeddings
embeddings = OpenAIEmbeddings()
vectorstore = Redis(
    redis_url="redis://username:password@localhost:6379"
    index_name="my-index",
    embedding_function=embeddings.embed_query,
)
To use a redis replication setup with multiple redis server and redis sentinels
set “redis_url” to “redis+sentinel://” scheme. With this url format a path is
needed holding the name of the redis service within the sentinels to get the
correct redis server connection. The default service name is “mymaster”.
An optional username or password is used for booth connections to the rediserver
and the sentinel, different passwords for server and sentinel are not supported.
And as another constraint only one sentinel instance can be given:
Example
vectorstore = Redis(
    redis_url="redis+sentinel://username:password@sentinelhost:26379/mymaster/0"
    index_name="my-index",
    embedding_function=embeddings.embed_query,
)
Initialize with necessary components.
Attributes
embeddings
Access the query embedding object if available.
Methods
__init__(redis_url, index_name, ...[, ...])