Returns
List of IDs of the added texts.
Return type
List[str]
add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, collection_name: Optional[str] = '', drop_old: Optional[bool] = False, **kwargs: Any) → List[str][source]¶
Embed texts and add them to the database.
Parameters
texts (Iterable[str]) – The texts to embed.
metadatas (Optional[List[dict]]) – Metadata dicts
attached to each of the texts. Defaults to None.
collection_name (Optional[str]) – Which collection to use.
Defaults to “langchain_collection”.
If provided, default collection name will be set as well.
drop_old (Optional[bool]) – Whether to drop the previous collection
and create a new one. Defaults to False.
Returns
List of ids of the added texts.
async classmethod afrom_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶
Return VectorStore initialized from documents and embeddings.
async classmethod afrom_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → VST¶
Return VectorStore initialized from texts and embeddings.
async amax_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶
Return docs selected using the maximal marginal relevance.
async amax_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶
Return docs selected using the maximal marginal relevance.