Skip to content

Commit 58f2de7

Browse files
franchbclaude
andauthored
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>
1 parent 0bb5ca4 commit 58f2de7

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

hindsight-api/hindsight_api/engine/embeddings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ async def initialize(self) -> None:
794794
"model": self.model,
795795
"input": ["test"],
796796
"api_key": self.api_key,
797+
"encoding_format": "float",
797798
}
798799
if self.api_base:
799800
embed_kwargs["api_base"] = self.api_base
@@ -840,6 +841,7 @@ def encode(self, texts: list[str]) -> list[list[float]]:
840841
"model": self.model,
841842
"input": batch,
842843
"api_key": self.api_key,
844+
"encoding_format": "float",
843845
}
844846
if self.api_base:
845847
embed_kwargs["api_base"] = self.api_base

hindsight-api/tests/test_litellm_sdk_embeddings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ async def test_initialization_success(self, mock_litellm):
8585
model="cohere/embed-english-v3.0",
8686
input=["test"],
8787
api_key="test_key",
88+
encoding_format="float",
8889
)
8990

9091
async def test_initialization_missing_package(self):
@@ -137,6 +138,7 @@ async def test_encode_single_text(self, embeddings, mock_litellm):
137138
model="cohere/embed-english-v3.0",
138139
input=["Hello world"],
139140
api_key="test_key",
141+
encoding_format="float",
140142
)
141143

142144
async def test_encode_multiple_texts(self, embeddings, mock_litellm):

0 commit comments

Comments
 (0)