feat(embeddings): add native embed_batch to 5 embedders (LMStudio, Together, HuggingFace, VertexAI, GoogleGenAI) (#5609)

This commit is contained in:
Alok Tripathi
2026-06-18 16:46:31 +05:30
committed by GitHub
parent 96b31c4bc0
commit 3e2ae734e7
10 changed files with 454 additions and 1 deletions
+13
View File
@@ -29,3 +29,16 @@ class TogetherEmbedding(EmbeddingBase):
"""
return self.client.embeddings.create(model=self.config.model, input=text).data[0].embedding
def embed_batch(self, texts, memory_action="add"):
if not texts:
return []
response = self.client.embeddings.create(model=self.config.model, input=texts)
sorted_data = sorted(response.data, key=lambda x: x.index)
embeddings = [item.embedding for item in sorted_data]
if len(embeddings) != len(texts):
raise ValueError(
f"Together embed_batch() returned {len(embeddings)} embeddings for {len(texts)} texts"
f" using model '{self.config.model}'"
)
return embeddings