langchain-ai/langchain · error · NotImplementedError

`add_texts` has not been implemented for {self.__class__.__n

Error message

`add_texts` has not been implemented for {self.__class__.__name__} 

What it means

`VectorStore.add_texts` is the abstract ingestion primitive in LangChain's vector store base class; when a subclass implements neither `add_texts` nor `add_documents`/`upsert`, the base implementation raises `NotImplementedError` naming the offending class. It signals the store cannot ingest data through this path at all.

Source

Thrown at libs/core/langchain_core/vectorstores/base.py:97

            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)
            ]
            if ids is not None:
                # For backward compatibility
                kwargs["ids"] = ids

            return self.add_documents(docs, **kwargs)
        msg = f"`add_texts` has not been implemented for {self.__class__.__name__} "
        raise NotImplementedError(msg)

    @property
    def embeddings(self) -> Embeddings | None:
        """Access the query embedding object if available."""
        logger.debug(
            "The embeddings property has not been implemented for %s",
            self.__class__.__name__,
        )
        return None

    def delete(self, ids: list[str] | None = None, **kwargs: Any) -> bool | None:
        """Delete by vector ID or other criteria.

        Args:
            ids: List of IDs to delete. If `None`, delete all.
            **kwargs: Other keyword arguments that subclasses might use.

        Returns:

View on GitHub (pinned to e32fa9a52e)

Solutions

  1. Implement `add_texts` in your subclass (returning the list of assigned IDs), or implement `add_documents`/`upsert` so the shim can route.
  2. If the store is read-only by design, guard call sites to never invoke ingestion APIs on it.
  3. For third-party stores, check whether ingestion is exposed under a different method name and adapt.

Example fix

# before
class MyStore(VectorStore):
    def similarity_search(self, query, k=4, **kwargs):
        return []

store.add_texts(["a"])  # NotImplementedError

# after
class MyStore(VectorStore):
    def add_texts(self, texts, metadatas=None, **kwargs):
        return [self._insert(t, m) for t, m in zip(texts, metadatas or [{}] * len(texts))]

    def similarity_search(self, query, k=4, **kwargs):
        return []
Defensive patterns

Strategy: type-guard

Validate before calling

from langchain_core.vectorstores import VectorStore

def supports_ingestion(store: VectorStore) -> bool:
    return (
        type(store).add_texts is not VectorStore.add_texts
        or type(store).add_documents is not VectorStore.add_documents
    )

Type guard

from langchain_core.vectorstores import VectorStore

def can_add_texts(store: VectorStore) -> bool:
    """True if the store implements an ingestion path."""
    return type(store).add_texts is not VectorStore.add_texts

Try / catch

try:
    ids = store.add_texts(texts, metadatas)
except NotImplementedError:
    logger.warning("%s cannot ingest; skipping", type(store).__name__)
    ids = []

Prevention

When it happens

Trigger: Calling `add_texts` (or a higher-level convenience like `VectorStore.from_documents`/`from_texts` that routes to it) on a custom `VectorStore` subclass that only implements read methods (`similarity_search`, etc.) or only `upsert` with a mismatched signature.

Common situations: Writing a read-only wrapper (e.g. over a pre-populated index) and accidentally hitting ingestion APIs; third-party store classes that subclass `VectorStore` for type compatibility without implementing writes; calling `from_texts` on such a store.

Related errors


AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14). Data as JSON: /api/errors/1bffa613e99ef631. Report an issue: GitHub.