Parameters
texts (List[str]) – List of texts to add to the vectorstore.
embedding (Embeddings) – Embeddings to use for the vectorstore.
metadatas (Optional[List[dict]], optional) – Optional list of metadata
dicts to add to the vectorstore. Defaults to None.
index_name (Optional[str], optional) – Optional name of the index to
create or add to. Defaults to None.
index_schema (Optional[Union[Dict[str, str], str, os.PathLike]], optional) – Optional fields to index within the metadata. Overrides generated
schema. Defaults to None.
vector_schema (Optional[Dict[str, Union[str, int]]], optional) – Optional
vector schema to use. Defaults to None.
**kwargs (Any) – Additional keyword arguments to pass to the Redis client.
Returns
Tuple of the Redis instance and the keys ofthe newly created documents.
Return type
Tuple[Redis, List[str]]
Raises
ValueError – If the number of metadatas does not match the number of texts.
max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, filter: Optional[RedisFilterExpression] = None, return_metadata: bool = True, distance_threshold: Optional[float] = None, **kwargs: Any) → List[Document][source]¶
Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversityamong selected documents.
Parameters
query (str) – Text to look up documents similar to.
k (int) – Number of Documents to return. Defaults to 4.
fetch_k (int) – Number of Documents to fetch to pass to MMR algorithm.
lambda_mult (float) – Number between 0 and 1 that determines the degree