Handle multiple response formats in OllamaEmbeddingEngine

The OllamaEmbeddingEngine is compatible with OpenAI
This commit is contained in:
Gao,Wei 2025-11-05 17:44:08 +08:00 committed by GitHub
parent 1e531385a6
commit 72c20c256d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -124,7 +124,10 @@ class OllamaEmbeddingEngine(EmbeddingEngine):
self.endpoint, json=payload, headers=headers, timeout=60.0
) as response:
data = await response.json()
return data["embeddings"][0]
if "embeddings" in data:
return data["embeddings"][0]
else:
return data["data"][0]["embedding"]
def get_vector_size(self) -> int:
"""