{"record":{"id":"27017ab21946ec18","repo":"chroma-core/chroma","slug":"updating-a-chromalangchainembeddingfunction-config","errorCode":null,"errorMessage":"Updating a ChromaLangchainEmbeddingFunction config is not supported. Please recreate the langchain embedding function and pass it to create_langchain_embedding.","messagePattern":"Updating a ChromaLangchainEmbeddingFunction config is not supported\\. Please recreate the langchain embedding function and pass it to create_langchain_embedding\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/chroma_langchain_embedding_function.py","lineNumber":155,"sourceCode":"    ) -> \"EmbeddingFunction[Union[Documents, Images]]\":\n        # This is a placeholder implementation since we can't easily serialize and deserialize\n        # langchain embedding functions. Users will need to recreate the langchain embedding function\n        # and pass it to create_langchain_embedding.\n        raise NotImplementedError(\n            \"Building a ChromaLangchainEmbeddingFunction from config is not supported. \"\n            \"Please recreate the langchain embedding function and pass it to create_langchain_embedding.\"\n        )\n\n    def get_config(self) -> Dict[str, Any]:\n        return {\n            \"embedding_function_class\": self._embedding_function_class,\n            \"note\": \"This is a placeholder config. You will need to recreate the langchain embedding function.\",\n        }\n\n    def validate_config_update(\n        self, old_config: Dict[str, Any], new_config: Dict[str, Any]\n    ) -> None:\n        raise NotImplementedError(\n            \"Updating a ChromaLangchainEmbeddingFunction config is not supported. \"\n            \"Please recreate the langchain embedding function and pass it to create_langchain_embedding.\"\n        )\n\n    @staticmethod\n    def validate_config(config: Dict[str, Any]) -> None:\n        \"\"\"\n        Validate the configuration using the JSON schema.\n\n        Args:\n            config: Configuration to validate\n\n        Raises:\n            ValidationError: If the configuration does not match the schema\n        \"\"\"\n        validate_config_schema(config, \"chroma_langchain\")\n","sourceCodeStart":137,"sourceCodeEnd":172,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/chroma_langchain_embedding_function.py#L137-L172","documentation":"ChromaLangchainEmbeddingFunction wraps an arbitrary LangChain embedding object that cannot be serialized into Chroma's embedding-function config format; get_config() only returns a placeholder. Because the real object exists only at runtime, validate_config_update() unconditionally raises NotImplementedError for any attempted change. Updating a langchain-wrapped embedding function is by design impossible.","triggerScenarios":"Any config-update path that reaches ChromaLangchainEmbeddingFunction.validate_config_update(old_config, new_config) on an embedding function created via chromadb.utils.embedding_functions.create_langchain_embedding() - e.g. collection.modify() with embedding-function config changes. The raise fires regardless of what new_config contains.","commonSituations":"Trying to tweak the wrapped model or credentials on an existing collection instead of recreating it; automation that echoes get_config() output into an update call; migrating a collection from one LangChain embedder to another via the update API.","solutions":["Rebuild the wrapper: create a fresh LangChain embedding object and pass it to chromadb.utils.embedding_functions.create_langchain_embedding(embeddings=...), then use it on a (new) collection.","Create a new collection with the new embedding function and re-embed the data - vectors from different models are not comparable anyway.","If you only need to change collection name/metadata, call collection.modify() with those fields and leave the embedding function untouched."],"exampleFix":"# before\nlangchain_ef.validate_config_update(old_cfg, {'model': 'x'})  # NotImplementedError\n\n# after\nfrom chromadb.utils.embedding_functions import create_langchain_embedding\nfrom langchain_openai import OpenAIEmbeddings\nef = create_langchain_embedding(OpenAIEmbeddings(model='text-embedding-3-small'))\ncol = client.create_collection('docs_v2', embedding_function=ef)  # recreate, don't update","handlingStrategy":"try-catch","validationCode":"cfg = ef.get_config()\nif 'embedding_function_class' in cfg:\n    raise SystemExit('Langchain EF detected: config updates are unsupported; recreate the embedding function instead')","typeGuard":"def is_langchain_ef(ef) -> bool:\n    cfg = ef.get_config() if hasattr(ef, 'get_config') else {}\n    return 'embedding_function_class' in cfg","tryCatchPattern":"try:\n    ef.validate_config_update(old_cfg, new_cfg)\nexcept NotImplementedError:\n    from chromadb.utils.embedding_functions import create_langchain_embedding\n    ef = create_langchain_embedding(build_new_langchain_embeddings())  # recreate instead of update","preventionTips":["Treat langchain-wrapped embedding functions as immutable: change them by recreating, never by config update.","Prefer native Chroma embedding functions (ONNXMiniLM_L6_V2, OpenAI, Cohere) when mutable configs are required.","Never feed get_config() output of a langchain EF back into an update call."],"tags":["chroma","langchain","embedding-function","config-update","not-implemented"],"backgroundTag":"unsupported-config-update","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}