Returns
Redis VectorStore instance.
Return type
Redis
Raises
ValueError – If the number of metadatas does not match the number of texts.
ImportError – If the redis python package is not installed.
classmethod from_texts_return_keys(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, index_name: Optional[str] = None, index_schema: Optional[Union[Dict[str, str], str, PathLike]] = None, vector_schema: Optional[Dict[str, Union[str, int]]] = None, **kwargs: Any) → Tuple[Redis, List[str]][source]¶
Create a Redis vectorstore from raw documents.
This is a user-friendly interface that:
Embeds documents.
Creates a new Redis index if it doesn’t already exist
Adds the documents to the newly created Redis index.
Returns the keys of the newly created documents once stored.
This method will generate schema based on the metadata passed in
if the index_schema is not defined. If the index_schema is defined,
it will compare against the generated schema and warn if there are
differences. If you are purposefully defining the schema for the
metadata, then you can ignore that warning.
To examine the schema options, initialize an instance of this class
and print out the schema using the Redis.schema` property. This
will include the content and content_vector classes which are
always present in the langchain schema.
Example
from langchain.vectorstores import Redis
from langchain.embeddings import OpenAIEmbeddings
embeddings = OpenAIEmbeddings()
redis, keys = Redis.from_texts_return_keys(
    texts,
    embeddings,
    redis_url="redis://localhost:6379"
)
Parameters
texts (List[str]) – List of texts to add to the vectorstore.