diff --git a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py index 392f9d32d..ee51283e6 100644 --- a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py +++ b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py @@ -38,5 +38,6 @@ def __init__( self.model = TextEmbedding(model_name=model_name) def embed(self, data: List[List[str]], **kwargs) -> List[List[float]]: - embeddings = list(self.model.embed(data, **kwargs)) + # the embed method returns a Iterable[np.ndarray], so we convert it to a list of lists + embeddings = [np_array.tolist() for np_array in self.model.embed(data, **kwargs)] return embeddings diff --git a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_document_embedder.py b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_document_embedder.py index 03dc301b9..b913b0de4 100644 --- a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_document_embedder.py +++ b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_document_embedder.py @@ -142,6 +142,6 @@ def run(self, documents: List[Document]): ) for doc, emb in zip(documents, embeddings): - doc.embedding = list(emb) + doc.embedding = emb return {"documents": documents} diff --git a/integrations/fastembed/tests/test_fastembed_document_embedder.py b/integrations/fastembed/tests/test_fastembed_document_embedder.py index 6dd1b6e52..597999354 100644 --- a/integrations/fastembed/tests/test_fastembed_document_embedder.py +++ b/integrations/fastembed/tests/test_fastembed_document_embedder.py @@ -248,4 +248,4 @@ def test_run(self): assert isinstance(embedding, list) assert len(embedding) == 384 - assert all(isinstance(emb.item(), float) for emb in embedding) + assert all(isinstance(emb, float) for emb in embedding) diff --git a/integrations/fastembed/tests/test_fastembed_text_embedder.py b/integrations/fastembed/tests/test_fastembed_text_embedder.py index 465f17976..3a7588263 100644 --- a/integrations/fastembed/tests/test_fastembed_text_embedder.py +++ b/integrations/fastembed/tests/test_fastembed_text_embedder.py @@ -186,4 +186,4 @@ def test_run(self): assert isinstance(embedding, list) assert len(embedding) == 384 - assert all(isinstance(emb.item(), float) for emb in embedding) + assert all(isinstance(emb, float) for emb in embedding)