agent-zero icon indicating copy to clipboard operation
agent-zero copied to clipboard

Title: Support wrapped embedding responses from a custom provider and improve error reporting

Open davidenorton-web opened this issue 1 month ago • 1 comments

I am using “Other OpenAI compatible” for embeddings:

Model: qwen/qwen3-embedding:8b API base URL: https://ai.wormsoft.ru/api/gpt

A direct POST /embeddings request with: { "model": "qwen/qwen3-embedding:8b", "input": ["example"] }

succeeds, but returns: { "data": { "model": "qwen/qwen3-embedding:8b", "object": "list", "usage": {"prompt_tokens": 2, "total_tokens": 2}, "data": [ {"index": 0, "embedding": [0.1, 0.2]} ] } }

The vector above is shortened for illustration.

Agent Zero fails during memory initialization: AttributeError: 'str' object has no attribute 'embedding'

The failing code in LiteLLMEmbeddingWrapper.embed is:

return [ item.get("embedding") if isinstance(item, dict) else item.embedding for item in resp.data ]

The provider also documents POST /embedding (singular), using "content" instead of "input". That endpoint returned: {"data": [{"index": 0, "embedding": [...]}]}

Is there an existing provider adapter or configuration option for this response format?

If not, would you consider an adapter/response normalization option, or at least a clear validation error explaining the unexpected response structure?

davidenorton-web avatar Oct 07 '26 04:10 davidenorton-web

我来处理这个问题。我会在 embedding 响应进入 LangChain wrapper 前兼容带有 data 外层对象的响应,并对缺少 embedding 列表或向量的情况返回明确错误。

JY-M666 avatar Nov 05 '26 11:11 JY-M666