{"record":{"id":"f2504e3bb7a01a50","repo":"chroma-core/chroma","slug":"nomic-only-supports-text-documents-not-images","errorCode":null,"errorMessage":"Nomic only supports text documents, not images","messagePattern":"Nomic only supports text documents, not images","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/nomic_embedding_function.py","lineNumber":58,"sourceCode":"        try:\n            from nomic import embed\n        except ImportError:\n            raise ValueError(\n                \"The nomic python package is not installed. Please install it with `pip install nomic`\"\n            )\n\n        self.model = model\n        self.task_type = task_type\n        self.api_key_env_var = api_key_env_var\n        self.api_key = os.getenv(api_key_env_var)\n        self.query_config = query_config\n        if not self.api_key:\n            raise ValueError(f\"The {api_key_env_var} environment variable is not set.\")\n        self.embed = embed\n\n    def __call__(self, input: Documents) -> Embeddings:\n        if not all(isinstance(item, str) for item in input):\n            raise ValueError(\"Nomic only supports text documents, not images\")\n        output = self.embed.text(\n            model=self.model,\n            texts=input,\n            task_type=self.task_type,\n        )\n        return [np.array(data.embedding) for data in output.data]\n\n    def embed_query(self, input: Documents) -> Embeddings:\n        if not all(isinstance(item, str) for item in input):\n            raise ValueError(\"Nomic only supports text queries, not images\")\n\n        task_type = (\n            self.query_config.get(\"task_type\") if self.query_config else self.task_type\n        )\n        output = self.embed.text(\n            model=self.model,\n            texts=input,\n            task_type=task_type,","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/nomic_embedding_function.py#L40-L76","documentation":"NomicEmbeddingFunction.__call__ validates that every element of the input documents is a Python str before calling self.embed.text. Chroma's Documents type permits image URIs for multimodal embedding functions, but the Nomic text models only accept strings, so any non-string item (typically an ImageDocument/URI object or bytes) triggers this ValueError. It fires at collection.add/update/query time, i.e. when the EF actually embeds.","triggerScenarios":"Calling collection.add(documents=[...]) where the list mixes str and non-str items; passing a numpy str_ / bytes / PIL object / pathlib.Path instead of a plain str; using a multimodal document loader that yields typed objects (e.g. chromadb.utils.document_loaders ImageLoader results) and feeding them to a Nomic EF; passing a single string instead of a list will fail elsewhere, but a list of Paths fails here.","commonSituations":"Migrating a collection from a multimodal EF (ONNXMiniLM_L6_V2 with images, or OpenCLIP) to Nomic without converting image URIs back to text; data pipelines that emit pathlib.Path or bytes from file scans; JSON payloads decoded with object_hook returning custom classes.","solutions":["Coerce every item to str before add/query: docs = [str(d) if not isinstance(d, str) else d for d in docs]","If your data is images, switch to a multimodal-capable EF (e.g. OpenCLIPEmbeddingFunction) instead of Nomic","Filter or reject non-text items upstream in the ingestion pipeline before they reach the EF"],"exampleFix":"// before\ncollection.add(ids=[\"1\"], documents=[Path(\"cat.png\")])  # ValueError: Nomic only supports text documents, not images\n\n// after\ncollection.add(ids=[\"1\"], documents=[str(p) if not isinstance(p, str) else p for p in [\"hello.txt\"]])","handlingStrategy":"type-guard","validationCode":"docs = [d for d in raw_documents if isinstance(d, str)]\nassert all(isinstance(d, str) for d in docs), \"non-text document in batch\"","typeGuard":"from typing import List\n\ndef is_text_documents(docs: list) -> bool:\n    \"\"\"True when every item is a plain str (Nomic EF requirement).\"\"\"\n    return isinstance(docs, list) and len(docs) > 0 and all(isinstance(d, str) for d in docs)","tryCatchPattern":"try:\n    collection.add(ids=ids, documents=docs)\nexcept ValueError as e:\n    if \"only supports text documents\" in str(e):\n        # coerce/reject the batch, log offending indices, continue\n        bad = [i for i, d in enumerate(docs) if not isinstance(d, str)]\n        raise ValueError(f\"non-str documents at indices {bad}\") from e\n    raise","preventionTips":["Normalize documents to str at ingestion time (str(x) for paths/scalars)","Keep one document pipeline per modality; never feed image-URI lists to a text-only EF","Add a lint step in your loader that asserts all(isinstance(d, str) ...)"],"tags":["nomic","embedding-function","type-validation","documents","chroma"],"backgroundTag":"invalid-input-type","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}