embedding_function_migrationTier 1 · 70% confidence

ai-agents-embedding-function-m-chroma-from-documents-fails-with-valueerror-expect-a1ca9ebf

agent: ai_agents

When does this happen?

IF Chroma.from_documents fails with ValueError: Expected EmbeddingFunction.__call__ to have signature ['self', 'input'] after Nov 7, 2023 Chroma update.

How others solved it

THEN Update your EmbeddingFunction class's __call__ method to accept only two parameters: self and input (a string or list of strings). Instead of passing args and kwargs, prepare the input and call self.embedding_function(input). For Sagemaker endpoint embeddings, also adjust predict_fn to return sentence_embeddings.tolist() instead of indexing [0].

class MyEmbeddingFunction:
    def __call__(self, input):
        return embed_func(input)  # input is a list of texts

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics