From 0dff64f6ad4ebb1ffd2bb1725fa8edaaf0573321 Mon Sep 17 00:00:00 2001 From: ksztone-huanggonghao <167506358+ksztone-huanggonghao@users.noreply.github.com> Date: Wed, 6 Nov 2024 11:15:00 +0800 Subject: [PATCH] fix: TypeError: only length-1 arrays can be converted to Python scalars (#3211) ### What problem does this PR solve? fix "TypeError: only length-1 arrays can be converted to Python scalars" while using cohere embedding model. ### Type of change - [ ] Bug Fix (non-breaking change which fixes an issue) ![image](https://github.com/user-attachments/assets/2c21a69f-cd76-4d25-b320-058964812db8) --- rag/llm/embedding_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rag/llm/embedding_model.py b/rag/llm/embedding_model.py index ea994746a..fbd93ccee 100644 --- a/rag/llm/embedding_model.py +++ b/rag/llm/embedding_model.py @@ -558,7 +558,7 @@ class CoHereEmbed(Base): input_type="search_query", embedding_types=["float"], ) - return np.array([d for d in res.embeddings.float]), int( + return np.array(res.embeddings.float[0]), int( res.meta.billed_units.input_tokens )