mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-12 06:42:11 +02:00
fix: align HF embeddings provider with batch embeddings interface
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)
This commit is contained in:
parent
d30857b5c3
commit
b9a0bc4bf2
1 changed files with 5 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue