mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
fix: preserve mapped embedding dimensions
Signed-off-by: Hasnaat Hussain <hasnaat.hussain.2@gmail.com>
This commit is contained in:
parent
01132a7c70
commit
3fab69dd31
2 changed files with 32 additions and 8 deletions
|
|
@ -3752,6 +3752,14 @@ def get_optional_params_embeddings(
|
|||
optional_params = non_default_params
|
||||
else:
|
||||
optional_params = non_default_params
|
||||
if (
|
||||
(litellm.drop_params is True or resolved_drop_params is True)
|
||||
and (custom_llm_provider == "azure" or custom_llm_provider in litellm.openai_compatible_providers)
|
||||
and "text-embedding-3" not in model
|
||||
and "dimensions" in optional_params
|
||||
and "dimensions" not in allowed_openai_params
|
||||
):
|
||||
optional_params.pop("dimensions", None)
|
||||
|
||||
final_params = add_provider_specific_params_to_optional_params(
|
||||
optional_params=optional_params,
|
||||
|
|
@ -3764,14 +3772,6 @@ def get_optional_params_embeddings(
|
|||
if "extra_body" in final_params and len(final_params["extra_body"]) == 0:
|
||||
final_params.pop("extra_body", None)
|
||||
|
||||
if (
|
||||
(litellm.drop_params is True or resolved_drop_params is True)
|
||||
and (custom_llm_provider == "azure" or custom_llm_provider in litellm.openai_compatible_providers)
|
||||
and "text-embedding-3" not in model
|
||||
and "dimensions" not in (allowed_openai_params or ())
|
||||
):
|
||||
final_params.pop("dimensions", None)
|
||||
|
||||
return final_params
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,3 +49,27 @@ def test_embedding_dimensions_drop_params_for_openai_compatible_provider(provide
|
|||
assert explicitly_allowed["dimensions"] == 512
|
||||
finally:
|
||||
litellm.drop_params = previous_drop_params
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("provider", "model"),
|
||||
[
|
||||
("nvidia_nim", "nvidia_nim/nv-embedqa-e5-v5"),
|
||||
("fireworks_ai", "fireworks_ai/nomic-ai/nomic-embed-text-v1.5"),
|
||||
("dashscope", "dashscope/text-embedding-v3"),
|
||||
("hosted_vllm", "hosted_vllm/Qwen/Qwen3-Embedding-0.6B"),
|
||||
],
|
||||
)
|
||||
def test_embedding_dimensions_preserved_for_provider_mappings(provider, model):
|
||||
previous_drop_params = litellm.drop_params
|
||||
try:
|
||||
litellm.drop_params = True
|
||||
optional_params = litellm.utils.get_optional_params_embeddings(
|
||||
model=model,
|
||||
custom_llm_provider=provider,
|
||||
dimensions=128,
|
||||
)
|
||||
finally:
|
||||
litellm.drop_params = previous_drop_params
|
||||
|
||||
assert optional_params["dimensions"] == 128
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue