Database: ChromaDB
- Purpose:
This module provides a localised wrapper and specialised functionality around the
langchain_chroma.Chromaclass, for interacting with a ChromaDB database.- Platform:
Linux/Windows | Python 3.11+
- Developer:
J Berendt
- Email:
- Comments:
This module uses the
langchain_chroma.Chromaclass, rather than the basechromadblibrary as langchain’s implementation provides theadd_textsmethod which supports GPU processing and parallelisation. This functionality is implemented and accessed through theadd_documents()method.
- class ChromaDB(path: str, collection: str, *, embedding_model_path: str = None, repo_id: str = None, offline: bool = False)[source]
Bases:
ChromaWrapper class around the
chromadblibrary.- Parameters:
path (str) – Path to the chromadb database’s directory.
collection (str) – Collection name.
embedding_model_path (str, optional) – Path to a local embedding model repo of your choosing. Defaults to None. If not provided, the
SentenceTransformersclass be be allowed free reign to download or use the model named in theDEFAULT_EMBEDDING_MODELattribute.repo_id (str, optional) – HuggingFace repository ID for the requested embedding model. Defaults to None.
offline (bool, optional) – Remain offline. Use the local model embedding function model repo rather than obtaining one online. Defaults to False.
- Examples:
Load a new PDF document into ChromaDB:
>>> from docp_dbi import ChromaDB >>> from docp_parsers import PDFParser >>> from langchain_text_splitters import RecursiveCharacterTextSplitter # Parse the PDF document. >>> pdf = PDFParser(path='/path/to/documents/rag-pipelines-how-to.pdf') >>> pdf.extract_text() # Setup a text splitter (for chunking the document). >>> splitter = RecursiveCharacterTextSplitter( ... separators=['\n\n\n', '\n\n', '\n', '.'], ... chunk_size=512, ... chunk_overlap=128 ... ) # Split the document for storage. >>> docs = splitter.split_documents(pdf.doc.documents) # Create a database interface, using an offline, local user-defined embedding model. >>> db = ChromaDB(path='/path/to/databases/chroma/', ... collection='test', ... embedding_model_path=('/path/to/models/sentence-transformers/' 'all-MiniLM-L6-v2'), ... offline=True) # Embed and store the document chunks. >>> db.add_documents(documents=docs) # Run your first query. >>> result = db.collection.query(query_texts=['How do I implement a RAG pipeline?'])
- property client: Client
Accessor to the
chromadb.PersistentClientclass.
- property collection: Collection
Accessor to the chromadb client’s collection object.
- property embedding_function: CustomEmbeddingFunction
Accessor to the embedding function used.
- property path: str
Accessor to the database’s path.
- add_documents(documents: list[Document]) None[source]
Add multiple documents to the collection.
This method overrides the base class’
add_documentsmethod to enable local ID derivation. Knowing how the IDs are derived gives us greater understanding and querying ability of the documents in the database. Each ID is derived locally by the_preproc()method from the file’s basename, page number and page content.Additionally, this method wraps the
langchain_chroma.Chroma.add_texts()method which supports GPU processing and parallelisation.- Parameters:
documents (list[Document]) –
A list of
Documentobjects. These objects can be of either type:langchain_core.documents.Documentdocp_core.objects.documentobject.Document
- show_all(include: list[str] = None) dict[source]
Return the entire contents of the collection.
This is an alias around
.collection.get().- Parameters:
include (list[str], optional) – A list of what to include in the results. Can contain “embeddings”, “metadatas”, “documents”. IDs are always included. Defaults to [“metadatas”, “documents”].
- async aadd_documents(documents: list[Document], **kwargs: Any) list[str]
Async run more documents through the embeddings and add to the VectorStore.
- Parameters:
documents – Documents to add to the VectorStore.
**kwargs – Additional keyword arguments.
- Returns:
List of IDs of the added texts.
- async aadd_texts(texts: Iterable[str], metadatas: list[dict] | None = None, *, ids: list[str] | None = None, **kwargs: Any) list[str]
Async run more texts through the embeddings and add to the VectorStore.
- Parameters:
texts – Iterable of strings to add to the VectorStore.
metadatas – Optional list of metadatas associated with the texts.
ids – Optional list
**kwargs – VectorStore specific parameters.
- Returns:
List of IDs from adding the texts into the VectorStore.
- Raises:
ValueError – If the number of metadatas does not match the number of texts.
ValueError – If the number of IDs does not match the number of texts.
- add_images(uris: list[str], metadatas: list[dict] | None = None, ids: list[str] | None = None) list[str]
Run more images through the embeddings and add to the VectorStore.
- Parameters:
uris – File path to the image.
metadatas – Optional list of metadatas. When querying, you can filter on this metadata.
ids – Optional list of IDs. (Items without IDs will be assigned UUIDs)
- Returns:
List of IDs of the added images.
- Raises:
ValueError – When metadata is incorrect.
- add_texts(texts: Iterable[str], metadatas: list[dict] | None = None, ids: list[str] | None = None, **kwargs: Any) list[str]
Run more texts through the embeddings and add to the VectorStore.
- Parameters:
texts – Texts to add to the VectorStore.
metadatas – Optional list of metadatas. When querying, you can filter on this metadata.
ids – Optional list of IDs. (Items without IDs will be assigned UUIDs)
kwargs – Additional keyword arguments.
- Returns:
List of IDs of the added texts.
- Raises:
ValueError – When metadata is incorrect.
- async adelete(ids: list[str] | None = None, **kwargs: Any) bool | None
Async delete by vector ID or other criteria.
- Parameters:
ids – List of IDs to delete. If None, delete all.
**kwargs – Other keyword arguments that subclasses might use.
- Returns:
- True if deletion is successful, False otherwise, None if not
implemented.
- async classmethod afrom_documents(documents: list[Document], embedding: Embeddings, **kwargs: Any) Self
Async return VectorStore initialized from documents and embeddings.
- Parameters:
documents – List of Document objects to add to the VectorStore.
embedding – Embedding function to use.
**kwargs – Additional keyword arguments.
- Returns:
VectorStore initialized from documents and embeddings.
- async classmethod afrom_texts(texts: list[str], embedding: Embeddings, metadatas: list[dict] | None = None, *, ids: list[str] | None = None, **kwargs: Any) Self
Async return VectorStore initialized from texts and embeddings.
- Parameters:
texts – Texts to add to the VectorStore.
embedding – Embedding function to use.
metadatas – Optional list of metadatas associated with the texts.
ids – Optional list of IDs associated with the texts.
**kwargs – Additional keyword arguments.
- Returns:
VectorStore initialized from texts and embeddings.
- async aget_by_ids(ids: Sequence[str], /) list[Document]
Async get documents by their IDs.
The returned documents are expected to have the ID field set to the ID of the document in the vector store.
Fewer documents may be returned than requested if some IDs are not found or if there are duplicated IDs.
Users should not assume that the order of the returned documents matches the order of the input IDs. Instead, users should rely on the ID field of the returned documents.
This method should NOT raise exceptions if no documents are found for some IDs.
- Parameters:
ids – List of IDs to retrieve.
- Returns:
List of Document objects.
- async amax_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) list[Document]
Async return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents.
- Parameters:
query – Text to look up documents similar to.
k – Number of Document objects to return.
fetch_k – Number of Document objects to fetch to pass to MMR algorithm.
lambda_mult – Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity.
**kwargs – Arguments to pass to the search method.
- Returns:
List of Document objects selected by 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]
Async return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents.
- Parameters:
embedding – Embedding to look up documents similar to.
k – Number of Document objects to return.
fetch_k – Number of Document objects to fetch to pass to MMR algorithm.
lambda_mult – Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity.
**kwargs – Arguments to pass to the search method.
- Returns:
List of Document objects selected by maximal marginal relevance.
- as_retriever(**kwargs: Any) VectorStoreRetriever
Return VectorStoreRetriever initialized from this VectorStore.
- Parameters:
**kwargs –
Keyword arguments to pass to the search function.
Can include:
- search_type: Defines the type of search that the Retriever should
perform. Can be ‘similarity’ (default), ‘mmr’, or ‘similarity_score_threshold’.
search_kwargs: Keyword arguments to pass to the search function.
Can include things like:
k: Amount of documents to return (Default: 4)
- score_threshold: Minimum relevance threshold
for similarity_score_threshold
- fetch_k: Amount of documents to pass to MMR algorithm
(Default: 20)
- lambda_mult: Diversity of results returned by MMR;
1 for minimum diversity and 0 for maximum. (Default: 0.5)
filter: Filter by document metadata
- Returns:
Retriever class for VectorStore.
Examples: ```python # Retrieve more documents with higher diversity # Useful if your dataset has many similar documents docsearch.as_retriever(
search_type=”mmr”, search_kwargs={“k”: 6, “lambda_mult”: 0.25}
)
# Fetch more documents for the MMR algorithm to consider # But only return the top 5 docsearch.as_retriever(search_type=”mmr”, search_kwargs={“k”: 5, “fetch_k”: 50})
# Only retrieve documents that have a relevance score # Above a certain threshold docsearch.as_retriever(
search_type=”similarity_score_threshold”, search_kwargs={“score_threshold”: 0.8},
)
# Only get the single most similar document from the dataset docsearch.as_retriever(search_kwargs={“k”: 1})
# Use a filter to only retrieve documents from a specific paper docsearch.as_retriever(
search_kwargs={“filter”: {“paper_title”: “GPT-4 Technical Report”}}
)
- async asearch(query: str, search_type: str, **kwargs: Any) list[Document]
Async return docs most similar to query using a specified search type.
- Parameters:
query – Input text.
search_type –
Type of search to perform.
Can be ‘similarity’, ‘mmr’, or ‘similarity_score_threshold’.
**kwargs – Arguments to pass to the search method.
- Returns:
List of Document objects most similar to the query.
- Raises:
ValueError – If search_type is not one of ‘similarity’, ‘mmr’, or ‘similarity_score_threshold’.
- async asimilarity_search(query: str, k: int = 4, **kwargs: Any) list[Document]
Async return docs most similar to query.
- Parameters:
query – Input text.
k – Number of Document objects to return.
**kwargs – Arguments to pass to the search method.
- Returns:
List of Document objects most similar to the query.
- async asimilarity_search_by_vector(embedding: list[float], k: int = 4, **kwargs: Any) list[Document]
Async return docs most similar to embedding vector.
- Parameters:
embedding – Embedding to look up documents similar to.
k – Number of Document objects to return.
**kwargs – Arguments to pass to the search method.
- Returns:
List of Document objects most similar to the query vector.
- async asimilarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) list[tuple[Document, float]]
Async return docs and relevance scores in the range [0, 1].
0 is dissimilar, 1 is most similar.
- Parameters:
query – Input text.
k – Number of Document objects to return.
**kwargs –
Kwargs to be passed to similarity search.
Should include score_threshold, an optional floating point value between 0 to 1 to filter the resulting set of retrieved docs.
- Returns:
List of tuples of (doc, similarity_score)
- async asimilarity_search_with_score(*args: Any, **kwargs: Any) list[tuple[Document, float]]
Async run similarity search with distance.
- Parameters:
*args – Arguments to pass to the search method.
**kwargs – Arguments to pass to the search method.
- Returns:
List of tuples of (doc, similarity_score).
- delete(ids: list[str] | None = None, **kwargs: Any) None
Delete by vector IDs.
- Parameters:
ids – List of ids to delete.
kwargs – Additional keyword arguments.
- delete_collection() None
Delete the collection.
- property embeddings: Embeddings | None
Access the query embedding object.
- static encode_image(uri: str) str
Get base64 string from image URI.
- fork(new_name: str) Chroma
Fork this vector store.
- Parameters:
new_name – New name for the forked store.
- Returns:
A new Chroma store forked from this vector store.
- classmethod from_documents(documents: list[Document], embedding: Embeddings | None = None, ids: list[str] | None = None, collection_name: str = 'langchain', persist_directory: str | None = None, host: str | None = None, port: int | None = None, headers: dict[str, str] | None = None, chroma_cloud_api_key: str | None = None, tenant: str | None = None, database: str | None = None, client_settings: Settings | None = None, client: ClientAPI | None = None, collection_metadata: dict | None = None, collection_configuration: CreateCollectionConfiguration | None = None, *, ssl: bool = False, **kwargs: Any) Chroma
Create a Chroma vectorstore from a list of documents.
If a persist_directory is specified, the collection will be persisted there. Otherwise, the data will be ephemeral in-memory.
- Parameters:
collection_name – Name of the collection to create.
persist_directory – Directory to persist the collection.
host – Hostname of a deployed Chroma server.
port – Connection port for a deployed Chroma server. Default is 8000.
ssl – Whether to establish an SSL connection with a deployed Chroma server.
headers – HTTP headers to send to a deployed Chroma server.
chroma_cloud_api_key – Chroma Cloud API key.
tenant – Tenant ID. Required for Chroma Cloud connections. Default is ‘default_tenant’ for local Chroma servers.
database – Database name. Required for Chroma Cloud connections. Default is ‘default_database’.
ids – List of document IDs.
documents – List of documents to add to the VectorStore.
embedding – Embedding function.
client_settings – Chroma client settings.
client – Chroma client. Documentation: https://docs.trychroma.com/reference/python/client
collection_metadata – Collection configurations.
collection_configuration – Index configuration for the collection.
kwargs – Additional keyword arguments to initialize a Chroma client.
- Returns:
Chroma vectorstore.
- Return type:
Chroma
- classmethod from_texts(texts: list[str], embedding: Embeddings | None = None, metadatas: list[dict] | None = None, ids: list[str] | None = None, collection_name: str = 'langchain', persist_directory: str | None = None, host: str | None = None, port: int | None = None, headers: dict[str, str] | None = None, chroma_cloud_api_key: str | None = None, tenant: str | None = None, database: str | None = None, client_settings: Settings | None = None, client: ClientAPI | None = None, collection_metadata: dict | None = None, collection_configuration: CreateCollectionConfiguration | None = None, *, ssl: bool = False, **kwargs: Any) Chroma
Create a Chroma vectorstore from a raw documents.
If a persist_directory is specified, the collection will be persisted there. Otherwise, the data will be ephemeral in-memory.
- Parameters:
texts – List of texts to add to the collection.
collection_name – Name of the collection to create.
persist_directory – Directory to persist the collection.
host – Hostname of a deployed Chroma server.
port – Connection port for a deployed Chroma server. Default is 8000.
ssl – Whether to establish an SSL connection with a deployed Chroma server. Default is False.
headers – HTTP headers to send to a deployed Chroma server.
chroma_cloud_api_key – Chroma Cloud API key.
tenant – Tenant ID. Required for Chroma Cloud connections. Default is ‘default_tenant’ for local Chroma servers.
database – Database name. Required for Chroma Cloud connections. Default is ‘default_database’.
embedding – Embedding function.
metadatas – List of metadatas.
ids – List of document IDs.
client_settings – Chroma client settings.
client – Chroma client. Documentation: https://docs.trychroma.com/reference/python/client
collection_metadata – Collection configurations.
collection_configuration – Index configuration for the collection.
kwargs – Additional keyword arguments to initialize a Chroma client.
- Returns:
Chroma vectorstore.
- Return type:
Chroma
- get(ids: str | list[str] | None = None, where: Where | None = None, limit: int | None = None, offset: int | None = None, where_document: WhereDocument | None = None, include: list[str] | None = None) dict[str, Any]
Gets the collection.
- Parameters:
ids – The ids of the embeddings to get. Optional.
where – A Where type dict used to filter results by. E.g. {“$and”: [{“color”: “red”}, {“price”: 4.20}]} Optional.
limit – The number of documents to return. Optional.
offset – The offset to start returning results from. Useful for paging results with limit. Optional.
where_document – A WhereDocument type dict used to filter by the documents. E.g. {“$contains”: “hello”}. Optional.
include – A list of what to include in the results. Can contain “embeddings”, “metadatas”, “documents”. Ids are always included. Defaults to [“metadatas”, “documents”]. Optional.
- Returns:
A dict with the keys “ids”, “embeddings”, “metadatas”, “documents”.
- get_by_ids(ids: Sequence[str], /) list[Document]
Get documents by their IDs.
The returned documents are expected to have the ID field set to the ID of the document in the vector store.
Fewer documents may be returned than requested if some IDs are not found or if there are duplicated IDs.
Users should not assume that the order of the returned documents matches the order of the input IDs. Instead, users should rely on the ID field of the returned documents.
This method should NOT raise exceptions if no documents are found for some IDs.
- Parameters:
ids – List of ids to retrieve.
- Returns:
List of Document objects.
!!! version-added “Added in 0.2.1”
- hybrid_search(search: Search) list[Document]
Run hybrid search with Chroma.
- Parameters:
search – The Search configuration for hybrid search.
- Returns:
A list of documents resulting from the search operation.
Example
from chromadb import Search, K, Knn, Rrf
# Create RRF ranking with text query hybrid_rank = Rrf(
- ranks=[
Knn(query=”query”, return_rank=True, limit=300), Knn(query=”query learning applications”, key=”sparse_embedding”)
], weights=[2.0, 1.0], # Dense 2x more important k=60
)
# Build complete the search strategy search = (Search()
- .where(
(K(“language”) == “en”) & (K(“year”) >= 2020)
) .rank(hybrid_rank) .limit(10) .select(K.DOCUMENT, K.SCORE, “title”, “year”)
)
results = vector_store.hybrid_search(search)
- max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, filter: dict[str, str] | None = None, where_document: dict[str, str] | None = None, **kwargs: Any) list[Document]
Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents.
- Parameters:
query – Text to look up documents similar to.
k – Number of Documents to return.
fetch_k – Number of Documents to fetch to pass to MMR algorithm.
lambda_mult – Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity.
filter – Filter by metadata.
where_document – dict used to filter by the document contents. e.g. {“$contains”: “hello”}.
kwargs – Additional keyword arguments to pass to Chroma collection query.
- Returns:
List of Document objects selected by maximal marginal relevance.
- Raises:
ValueError – If the embedding function is not provided.
- max_marginal_relevance_search_by_vector(embedding: list[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, filter: dict[str, str] | None = None, where_document: dict[str, str] | None = None, **kwargs: Any) list[Document]
Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents.
- Parameters:
embedding – Embedding to look up documents similar to.
k – Number of Document objects to return.
fetch_k – Number of Document objects to fetch to pass to MMR algorithm.
lambda_mult – Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity.
filter – Filter by metadata.
where_document – dict used to filter by the document contents. e.g. {“$contains”: “hello”}.
kwargs – Additional keyword arguments to pass to Chroma collection query.
- Returns:
List of Document objects selected by maximal marginal relevance.
- reset_collection() None
Resets the collection.
Resets the collection by deleting the collection and recreating an empty one.
- search(query: str, search_type: str, **kwargs: Any) list[Document]
Return docs most similar to query using a specified search type.
- Parameters:
query – Input text.
search_type –
Type of search to perform.
Can be ‘similarity’, ‘mmr’, or ‘similarity_score_threshold’.
**kwargs – Arguments to pass to the search method.
- Returns:
List of Document objects most similar to the query.
- Raises:
ValueError – If search_type is not one of ‘similarity’, ‘mmr’, or ‘similarity_score_threshold’.
- similarity_search(query: str, k: int = 4, filter: dict[str, str] | None = None, **kwargs: Any) list[Document]
Run similarity search with Chroma.
- Parameters:
query – Query text to search for.
k – Number of results to return.
filter – Filter by metadata.
kwargs – Additional keyword arguments to pass to Chroma collection query.
- Returns:
List of documents most similar to the query text.
- similarity_search_by_image(uri: str, k: int = 4, filter: dict[str, str] | None = None, **kwargs: Any) list[Document]
Search for similar images based on the given image URI.
- Parameters:
uri – URI of the image to search for.
k – Number of results to return.
filter – Filter by metadata.
**kwargs – Additional arguments to pass to function.
- Returns:
List of Images most similar to the provided image. Each element in list is a LangChain Document Object. The page content is b64 encoded image, metadata is default or as defined by user.
- Raises:
ValueError – If the embedding function does not support image embeddings.
- similarity_search_by_image_with_relevance_score(uri: str, k: int = 4, filter: dict[str, str] | None = None, **kwargs: Any) list[tuple[Document, float]]
Search for similar images based on the given image URI.
- Parameters:
uri – URI of the image to search for.
k – Number of results to return.
filter – Filter by metadata.
**kwargs – Additional arguments to pass to function.
- Returns:
List of tuples containing documents similar to the query image and their similarity scores. 0th element in each tuple is a LangChain Document Object. The page content is b64 encoded img, metadata is default or defined by user.
- Raises:
ValueError – If the embedding function does not support image embeddings.
- similarity_search_by_vector(embedding: list[float], k: int = 4, filter: dict[str, str] | None = None, where_document: dict[str, str] | None = None, **kwargs: Any) list[Document]
Return docs most similar to embedding vector.
- Parameters:
embedding – Embedding to look up documents similar to.
k – Number of Documents to return.
filter – Filter by metadata.
where_document – dict used to filter by the document contents. E.g. {“$contains”: “hello”}.
kwargs – Additional keyword arguments to pass to Chroma collection query.
- Returns:
List of Document objects most similar to the query vector.
- similarity_search_by_vector_with_relevance_scores(embedding: list[float], k: int = 4, filter: dict[str, str] | None = None, where_document: dict[str, str] | None = None, **kwargs: Any) list[tuple[Document, float]]
Return docs most similar to embedding vector and similarity score.
- Parameters:
embedding (List[float]) – Embedding to look up documents similar to.
k – Number of Documents to return.
filter – Filter by metadata.
where_document – dict used to filter by the documents. E.g. {“$contains”: “hello”}.
kwargs – Additional keyword arguments to pass to Chroma collection query.
- Returns:
List of documents most similar to the query text and relevance score in float for each. Lower score represents more similarity.
- similarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) list[tuple[Document, float]]
Return docs and relevance scores in the range [0, 1].
0 is dissimilar, 1 is most similar.
- Parameters:
query – Input text.
k – Number of Document objects to return.
**kwargs –
Kwargs to be passed to similarity search.
Should include score_threshold, an optional floating point value between 0 to 1 to filter the resulting set of retrieved docs.
- Returns:
List of tuples of (doc, similarity_score).
- similarity_search_with_score(query: str, k: int = 4, filter: dict[str, str] | None = None, where_document: dict[str, str] | None = None, **kwargs: Any) list[tuple[Document, float]]
Run similarity search with Chroma with distance.
- Parameters:
query – Query text to search for.
k – Number of results to return.
filter – Filter by metadata.
where_document – dict used to filter by document contents. E.g. {“$contains”: “hello”}.
kwargs – Additional keyword arguments to pass to Chroma collection query.
- Returns:
List of documents most similar to the query text and distance in float for each. Lower score represents more similarity.
- similarity_search_with_vectors(query: str, k: int = 4, filter: dict[str, str] | None = None, where_document: dict[str, str] | None = None, **kwargs: Any) list[tuple[Document, ndarray]]
Run similarity search with Chroma with vectors.
- Parameters:
query – Query text to search for.
k – Number of results to return.
filter – Filter by metadata.
where_document – dict used to filter by the document contents. E.g. {“$contains”: “hello”}.
kwargs – Additional keyword arguments to pass to Chroma collection query.
- Returns:
List of documents most similar to the query text and embedding vectors for each.
- update_document(document_id: str, document: Document) None
Update a document in the collection.
- Parameters:
document_id – ID of the document to update.
document – Document to update.
- update_documents(ids: list[str], documents: list[Document]) None
Update a document in the collection.
- Parameters:
ids – List of ids of the document to update.
documents – List of documents to update.
- Raises:
ValueError – If the embedding function is not provided.