From b9a0bc4bf200430a11371d68148d07c053712dfb Mon Sep 17 00:00:00 2001 From: Azizultra32 Date: Tue, 24 Mar 2026 16:26:04 -0700 Subject: [PATCH] fix: align HF embeddings provider with batch embeddings interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The batch embeddings refactor (PR #668) changed the EmbeddingsRequest schema from `text: str` to `texts: list[str]` and updated the base class to call `on_embeddings(request.texts, model=model)`. The Ollama and FastEmbed providers were updated to match, but the HuggingFace provider was missed: - Parameter was still named `text` (singular) instead of `texts` - `embed_documents([text])` wrapped the already-list input in another list, causing `embed_documents([["text1", "text2"]])` — a list containing a list instead of a list of strings This produces: AttributeError: 'list' object has no attribute 'replace' Fix aligns the HF provider with Ollama/FastEmbed: - Rename param `text` → `texts` - Remove redundant `[text]` wrapping - Add empty-list guard (consistent with other providers) --- trustgraph-embeddings-hf/trustgraph/embeddings/hf/hf.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/trustgraph-embeddings-hf/trustgraph/embeddings/hf/hf.py b/trustgraph-embeddings-hf/trustgraph/embeddings/hf/hf.py index 8c4d571b..a999d22e 100755 --- a/trustgraph-embeddings-hf/trustgraph/embeddings/hf/hf.py +++ b/trustgraph-embeddings-hf/trustgraph/embeddings/hf/hf.py @@ -45,14 +45,17 @@ class Processor(EmbeddingsService): else: logger.debug(f"Using cached model: {model_name}") - async def on_embeddings(self, text, model=None): + async def on_embeddings(self, texts, model=None): + + if not texts: + return [] use_model = model or self.default_model # Reload model if it has changed self._load_model(use_model) - embeds = self.embeddings.embed_documents([text]) + embeds = self.embeddings.embed_documents(texts) logger.debug("Embeddings generation complete") return embeds