mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
test(utils): cover embedding dimension guard branches
Signed-off-by: Hasnaat Hussain <hasnaat.hussain.2@gmail.com>
This commit is contained in:
parent
32fe2cb73c
commit
76e15655c2
2 changed files with 21 additions and 9 deletions
|
|
@ -3766,15 +3766,11 @@ def get_optional_params_embeddings(
|
|||
final_params.pop("extra_body", None)
|
||||
|
||||
# High-performance check optimized to avoid allocations in hot paths
|
||||
if (litellm.drop_params is True or drop_params is True) and (
|
||||
custom_llm_provider == "azure" or custom_llm_provider in litellm.openai_compatible_providers
|
||||
):
|
||||
if (
|
||||
model is not None
|
||||
and "text-embedding-3" not in model
|
||||
and "dimensions" not in (allowed_openai_params or [])
|
||||
):
|
||||
final_params.pop("dimensions", None)
|
||||
if litellm.drop_params is True or drop_params is True:
|
||||
if custom_llm_provider == "azure" or custom_llm_provider in litellm.openai_compatible_providers:
|
||||
is_legacy_model = model is not None and "text-embedding-3" not in model
|
||||
if is_legacy_model and "dimensions" not in (allowed_openai_params or []):
|
||||
final_params.pop("dimensions", None)
|
||||
|
||||
return final_params
|
||||
|
||||
|
|
|
|||
|
|
@ -761,6 +761,22 @@ def test_embedding_dimensions_drop_params_for_openai_compatible_provider(provide
|
|||
dimensions=512,
|
||||
)
|
||||
assert preserved["dimensions"] == 512
|
||||
|
||||
litellm.drop_params = True
|
||||
model_supported = litellm.utils.get_optional_params_embeddings(
|
||||
model=f"{provider}/text-embedding-3-small",
|
||||
custom_llm_provider=provider,
|
||||
dimensions=512,
|
||||
)
|
||||
assert model_supported["dimensions"] == 512
|
||||
|
||||
explicitly_allowed = litellm.utils.get_optional_params_embeddings(
|
||||
model=f"{provider}/legacy-model",
|
||||
custom_llm_provider=provider,
|
||||
dimensions=512,
|
||||
allowed_openai_params=["dimensions"],
|
||||
)
|
||||
assert explicitly_allowed["dimensions"] == 512
|
||||
finally:
|
||||
litellm.drop_params = previous_drop_params
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue