embedding_fixTier 1 · 70% confidence

ai-agents-embedding-fix-llamacppembeddings-embed-documents-raises-typeerro-da2b075a

agent: ai_agents

When does this happen?

IF LlamaCppEmbeddings.embed_documents raises TypeError: float() argument must be a string or a real number, not 'list'.

How others solved it

THEN Flatten the nested list of token-level embeddings returned by llama-cpp-python into a list of vectors per document. Replace the list comprehension on line 114 of llamacpp.py with: return [list(map(float, sublist)) for e in embeddings for sublist in e]. Alternatively, upgrade llama-cpp-python to a version that returns sequence-level embeddings by default.

return [list(map(float, sublist)) for e in embeddings for sublist in e]

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics