update_documents() — langchain Function Reference
Architecture documentation for the update_documents() function in vectorstores.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD f60e8b46_57d7_444f_8f74_649e0a5f3326["update_documents()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab["Chroma"] f60e8b46_57d7_444f_8f74_649e0a5f3326 -->|defined in| d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab ff1e5124_d144_b0ba_680b_5e772180c3fd["update_document()"] ff1e5124_d144_b0ba_680b_5e772180c3fd -->|calls| f60e8b46_57d7_444f_8f74_649e0a5f3326 style f60e8b46_57d7_444f_8f74_649e0a5f3326 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/chroma/langchain_chroma/vectorstores.py lines 1223–1270
def update_documents(self, ids: list[str], documents: list[Document]) -> None:
"""Update a document in the collection.
Args:
ids: List of ids of the document to update.
documents: List of documents to update.
Raises:
ValueError: If the embedding function is not provided.
"""
text = [document.page_content for document in documents]
metadata = [document.metadata for document in documents]
if self._embedding_function is None:
msg = "For update, you must specify an embedding function on creation."
raise ValueError(
msg,
)
embeddings = self._embedding_function.embed_documents(text)
if hasattr(
self._client,
"get_max_batch_size",
) or hasattr( # for Chroma 0.5.1 and above
self._client,
"max_batch_size",
): # for Chroma 0.4.10 and above
from chromadb.utils.batch_utils import create_batches
for batch in create_batches(
api=self._client,
ids=ids,
metadatas=metadata, # type: ignore[arg-type]
documents=text,
embeddings=embeddings, # type: ignore[arg-type]
):
self._collection.update(
ids=batch[0],
embeddings=batch[1],
documents=batch[3],
metadatas=batch[2],
)
else:
self._collection.update(
ids=ids,
embeddings=embeddings, # type: ignore[arg-type]
documents=text,
metadatas=metadata, # type: ignore[arg-type]
)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does update_documents() do?
update_documents() is a function in the langchain codebase, defined in libs/partners/chroma/langchain_chroma/vectorstores.py.
Where is update_documents() defined?
update_documents() is defined in libs/partners/chroma/langchain_chroma/vectorstores.py at line 1223.
What calls update_documents()?
update_documents() is called by 1 function(s): update_document.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free