fix: pass encoding_format="float" in LiteLLM embedding calls (#434)

DeepInfra rejects requests when encoding_format is null. LiteLLM sets
it to None by default, so we explicitly pass "float" — the only format
compatible with our list[list[float]] return type.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Eliah Rusin 2026-02-25 12:32:05 +03:00 committed by GitHub
parent 0bb5ca4caf
commit 58f2de70fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -794,6 +794,7 @@ class LiteLLMSDKEmbeddings(Embeddings):
"model": self.model,
"input": ["test"],
"api_key": self.api_key,
"encoding_format": "float",
}
if self.api_base:
embed_kwargs["api_base"] = self.api_base
@ -840,6 +841,7 @@ class LiteLLMSDKEmbeddings(Embeddings):
"model": self.model,
"input": batch,
"api_key": self.api_key,
"encoding_format": "float",
}
if self.api_base:
embed_kwargs["api_base"] = self.api_base

View file

@ -85,6 +85,7 @@ class TestLiteLLMSDKEmbeddings:
model="cohere/embed-english-v3.0",
input=["test"],
api_key="test_key",
encoding_format="float",
)
async def test_initialization_missing_package(self):
@ -137,6 +138,7 @@ class TestLiteLLMSDKEmbeddings:
model="cohere/embed-english-v3.0",
input=["Hello world"],
api_key="test_key",
encoding_format="float",
)
async def test_encode_multiple_texts(self, embeddings, mock_litellm):