add_documents() — langchain Function Reference
Architecture documentation for the add_documents() function in parent_document_retriever.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 92bed5c9_a76d_c063_a022_68683b1b371d["add_documents()"] eb3f3ce7_75a2_f5aa_7781_56a2f86f1973["ParentDocumentRetriever"] 92bed5c9_a76d_c063_a022_68683b1b371d -->|defined in| eb3f3ce7_75a2_f5aa_7781_56a2f86f1973 913129df_8767_b41b_518c_6c6d98c8bd9d["_split_docs_for_adding()"] 92bed5c9_a76d_c063_a022_68683b1b371d -->|calls| 913129df_8767_b41b_518c_6c6d98c8bd9d style 92bed5c9_a76d_c063_a022_68683b1b371d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/retrievers/parent_document_retriever.py lines 116–145
def add_documents(
self,
documents: list[Document],
ids: list[str] | None = None,
add_to_docstore: bool = True, # noqa: FBT001,FBT002
**kwargs: Any,
) -> None:
"""Adds documents to the docstore and vectorstores.
Args:
documents: List of documents to add
ids: Optional list of IDs for documents. If provided should be the same
length as the list of documents. Can be provided if parent documents
are already in the document store and you don't want to re-add
to the docstore. If not provided, random UUIDs will be used as
IDs.
add_to_docstore: Boolean of whether to add documents to docstore.
This can be false if and only if `ids` are provided. You may want
to set this to False if the documents are already in the docstore
and you don't want to re-add them.
**kwargs: additional keyword arguments passed to the `VectorStore`.
"""
docs, full_docs = self._split_docs_for_adding(
documents,
ids,
add_to_docstore=add_to_docstore,
)
self.vectorstore.add_documents(docs, **kwargs)
if add_to_docstore:
self.docstore.mset(full_docs)
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does add_documents() do?
add_documents() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/retrievers/parent_document_retriever.py.
Where is add_documents() defined?
add_documents() is defined in libs/langchain/langchain_classic/retrievers/parent_document_retriever.py at line 116.
What does add_documents() call?
add_documents() calls 1 function(s): _split_docs_for_adding.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free