afrom_documents() — langchain Function Reference
Architecture documentation for the afrom_documents() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 4ed18cca_a7fc_92c8_c198_a06d26cd571b["afrom_documents()"] 6c336ac6_f55c_1ad7_6db3_73dbd71fb625["VectorStore"] 4ed18cca_a7fc_92c8_c198_a06d26cd571b -->|defined in| 6c336ac6_f55c_1ad7_6db3_73dbd71fb625 755352fa_b98e_ac4a_7fcc_641f75863436["afrom_texts()"] 4ed18cca_a7fc_92c8_c198_a06d26cd571b -->|calls| 755352fa_b98e_ac4a_7fcc_641f75863436 style 4ed18cca_a7fc_92c8_c198_a06d26cd571b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/vectorstores/base.py lines 817–844
async def afrom_documents(
cls,
documents: list[Document],
embedding: Embeddings,
**kwargs: Any,
) -> Self:
"""Async 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 await cls.afrom_texts(texts, embedding, metadatas=metadatas, **kwargs)
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does afrom_documents() do?
afrom_documents() is a function in the langchain codebase, defined in libs/core/langchain_core/vectorstores/base.py.
Where is afrom_documents() defined?
afrom_documents() is defined in libs/core/langchain_core/vectorstores/base.py at line 817.
What does afrom_documents() call?
afrom_documents() calls 1 function(s): afrom_texts.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free