diff --git a/libs/langchain/langchain/vectorstores/chroma.py b/libs/langchain/langchain/vectorstores/chroma.py index 3b8edc2212e8d..7994e2326dbc0 100644 --- a/libs/langchain/langchain/vectorstores/chroma.py +++ b/libs/langchain/langchain/vectorstores/chroma.py @@ -541,19 +541,28 @@ def update_document(self, document_id: str, document: Document) -> None: document_id (str): ID of the document to update. document (Document): Document to update. """ - text = document.page_content - metadata = document.metadata + return self.update_documents([document_id], [document]) + + def update_documents(self, ids: List[str], documents: List[Document]) -> None: + """Update a document in the collection. + + Args: + ids (List[str]): List of ids of the document to update. + documents (List[Document]): List of documents to update. + """ + text = [document.page_content for document in documents] + metadata = [document.metadata for document in documents] if self._embedding_function is None: raise ValueError( "For update, you must specify an embedding function on creation." ) - embeddings = self._embedding_function.embed_documents([text]) + embeddings = self._embedding_function.embed_documents(text) self._collection.update( - ids=[document_id], + ids=ids, embeddings=embeddings, - documents=[text], - metadatas=[metadata], + documents=text, + metadatas=metadata, ) @classmethod