mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
fix(bedrock): normalize encoding_format base64 to float for cohere embed models
This commit is contained in:
parent
7f3ff3b47f
commit
a3eac3f771
2 changed files with 19 additions and 1 deletions
|
|
@ -20,7 +20,9 @@ class BedrockCohereEmbeddingConfig:
|
|||
def map_openai_params(self, non_default_params: dict, optional_params: dict) -> dict:
|
||||
for k, v in non_default_params.items():
|
||||
if k == "encoding_format":
|
||||
optional_params["embedding_types"] = v if isinstance(v, list) else [v]
|
||||
optional_params["embedding_types"] = [
|
||||
"float" if fmt == "base64" else fmt for fmt in (tuple(v) if isinstance(v, list) else (v,))
|
||||
]
|
||||
elif k == "dimensions":
|
||||
optional_params["output_dimension"] = v
|
||||
return optional_params
|
||||
|
|
|
|||
|
|
@ -4433,6 +4433,22 @@ class TestBedrockCohereEmbeddingDispatch:
|
|||
)
|
||||
assert optional_params.get("embedding_types") == ["float"]
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model",
|
||||
[
|
||||
"cohere.embed-english-v3",
|
||||
"cohere.embed-multilingual-v3",
|
||||
"cohere.embed-v4:0",
|
||||
],
|
||||
)
|
||||
def test_cohere_embed_models_map_base64_to_float(self, model):
|
||||
optional_params = litellm.utils.get_optional_params_embeddings(
|
||||
model=model,
|
||||
encoding_format="base64",
|
||||
custom_llm_provider="bedrock",
|
||||
)
|
||||
assert optional_params.get("embedding_types") == ["float"]
|
||||
|
||||
def test_cohere_embed_english_v3_maps_dimensions(self):
|
||||
optional_params = litellm.utils.get_optional_params_embeddings(
|
||||
model="cohere.embed-english-v3",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue