from_documents() — langchain Function Reference
Architecture documentation for the from_documents() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d53e755c_f22a_3702_9ca0_af9f8caaa28d["from_documents()"] 6c336ac6_f55c_1ad7_6db3_73dbd71fb625["VectorStore"] d53e755c_f22a_3702_9ca0_af9f8caaa28d -->|defined in| 6c336ac6_f55c_1ad7_6db3_73dbd71fb625 6bba087d_29e7_c047_38e4_a8acc2e8b69d["from_texts()"] d53e755c_f22a_3702_9ca0_af9f8caaa28d -->|calls| 6bba087d_29e7_c047_38e4_a8acc2e8b69d style d53e755c_f22a_3702_9ca0_af9f8caaa28d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/vectorstores/base.py lines 787–814
def from_documents(
cls,
documents: list[Document],
embedding: Embeddings,
**kwargs: Any,
) -> Self:
"""Return `VectorStore` initialized from documents and embeddings.
Args:
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.
"""
texts = [d.page_content for d in documents]
metadatas = [d.metadata for d in documents]
if "ids" not in kwargs:
ids = [doc.id for doc in documents]
# If there's at least one valid ID, we'll assume that IDs
# should be used.
if any(ids):
kwargs["ids"] = ids
return cls.from_texts(texts, embedding, metadatas=metadatas, **kwargs)
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does from_documents() do?
from_documents() is a function in the langchain codebase, defined in libs/core/langchain_core/vectorstores/base.py.
Where is from_documents() defined?
from_documents() is defined in libs/core/langchain_core/vectorstores/base.py at line 787.
What does from_documents() call?
from_documents() calls 1 function(s): from_texts.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free