aadd_texts() — langchain Function Reference
Architecture documentation for the aadd_texts() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 08a89237_e844_a3d9_353e_d89cd55c7b6a["aadd_texts()"] 6c336ac6_f55c_1ad7_6db3_73dbd71fb625["VectorStore"] 08a89237_e844_a3d9_353e_d89cd55c7b6a -->|defined in| 6c336ac6_f55c_1ad7_6db3_73dbd71fb625 c79bd583_f243_61a3_9784_31be23df6e6b["aadd_documents()"] c79bd583_f243_61a3_9784_31be23df6e6b -->|calls| 08a89237_e844_a3d9_353e_d89cd55c7b6a c79bd583_f243_61a3_9784_31be23df6e6b["aadd_documents()"] 08a89237_e844_a3d9_353e_d89cd55c7b6a -->|calls| c79bd583_f243_61a3_9784_31be23df6e6b e5cf61af_382b_d2da_c38b_d74628394456["aadd_documents()"] 08a89237_e844_a3d9_353e_d89cd55c7b6a -->|calls| e5cf61af_382b_d2da_c38b_d74628394456 style 08a89237_e844_a3d9_353e_d89cd55c7b6a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/vectorstores/base.py lines 185–232
async def aadd_texts(
self,
texts: Iterable[str],
metadatas: list[dict] | None = None,
*,
ids: list[str] | None = None,
**kwargs: Any,
) -> list[str]:
"""Async run more texts through the embeddings and add to the `VectorStore`.
Args:
texts: Iterable of strings to add to the `VectorStore`.
metadatas: Optional list of metadatas associated with the texts.
ids: Optional list
**kwargs: `VectorStore` specific parameters.
Returns:
List of IDs from adding the texts into the `VectorStore`.
Raises:
ValueError: If the number of metadatas does not match the number of texts.
ValueError: If the number of IDs does not match the number of texts.
"""
if ids is not None:
# For backward compatibility
kwargs["ids"] = ids
if type(self).aadd_documents != VectorStore.aadd_documents:
# This condition is triggered if the subclass has provided
# an implementation of the upsert method.
# The existing add_texts
texts_: Sequence[str] = (
texts if isinstance(texts, (list, tuple)) else list(texts)
)
if metadatas and len(metadatas) != len(texts_):
msg = (
"The number of metadatas must match the number of texts."
f"Got {len(metadatas)} metadatas and {len(texts_)} texts."
)
raise ValueError(msg)
metadatas_ = iter(metadatas) if metadatas else cycle([{}])
ids_: Iterator[str | None] = iter(ids) if ids else cycle([None])
docs = [
Document(id=id_, page_content=text, metadata=metadata_)
for text, metadata_, id_ in zip(texts, metadatas_, ids_, strict=False)
]
return await self.aadd_documents(docs, **kwargs)
return await run_in_executor(None, self.add_texts, texts, metadatas, **kwargs)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does aadd_texts() do?
aadd_texts() is a function in the langchain codebase, defined in libs/core/langchain_core/vectorstores/base.py.
Where is aadd_texts() defined?
aadd_texts() is defined in libs/core/langchain_core/vectorstores/base.py at line 185.
What does aadd_texts() call?
aadd_texts() calls 2 function(s): aadd_documents, aadd_documents.
What calls aadd_texts()?
aadd_texts() is called by 1 function(s): aadd_documents.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free