fix(main.py): pass custom_llm_provider to get_litellm_params in embedding/transcription/speech

This commit is contained in:
Constantine 2026-04-14 23:36:56 +03:00
parent 0e43050a01
commit fab407005c
No known key found for this signature in database
2 changed files with 33 additions and 4 deletions

View file

@ -4797,7 +4797,9 @@ def embedding( # noqa: PLR0915
}
)
litellm_params_dict = get_litellm_params(**kwargs)
litellm_params_dict = get_litellm_params(
custom_llm_provider=custom_llm_provider, **kwargs
)
logging: LiteLLMLoggingObj = litellm_logging_obj # type: ignore
logging.update_environment_variables(
@ -6488,7 +6490,9 @@ def transcription(
**non_default_params,
)
litellm_params_dict = get_litellm_params(**kwargs)
litellm_params_dict = get_litellm_params(
custom_llm_provider=custom_llm_provider, **kwargs
)
litellm_logging_obj.update_environment_variables(
model=model,
@ -6717,7 +6721,9 @@ def speech( # noqa: PLR0915
if max_retries is None:
max_retries = litellm.num_retries or openai.DEFAULT_MAX_RETRIES
litellm_params_dict = get_litellm_params(**kwargs)
litellm_params_dict = get_litellm_params(
custom_llm_provider=custom_llm_provider, **kwargs
)
# Get provider-specific text-to-speech config and map parameters
text_to_speech_provider_config = (

View file

@ -95,6 +95,30 @@ class TestGetLitellmParamsBaseModel:
assert result["base_model"] is None
class TestGetLitellmParamsCustomLlmProvider:
"""Verify custom_llm_provider handling — explicit value vs kwargs."""
def test_explicit_custom_llm_provider(self):
"""Explicit custom_llm_provider should appear in result."""
result = get_litellm_params(custom_llm_provider="hosted_vllm")
assert result["custom_llm_provider"] == "hosted_vllm"
def test_custom_llm_provider_not_in_kwargs(self):
"""When custom_llm_provider is not passed, it defaults to None.
This mirrors the bug in embedding()/transcription()/speech() where
custom_llm_provider was extracted as a named parameter and thus
removed from **kwargs before being passed to get_litellm_params().
"""
result = get_litellm_params(**{"api_key": "test"})
assert result["custom_llm_provider"] is None
def test_explicit_custom_llm_provider_with_kwargs(self):
"""Explicit custom_llm_provider should not be overridden by kwargs."""
result = get_litellm_params(custom_llm_provider="hosted_vllm", api_key="test")
assert result["custom_llm_provider"] == "hosted_vllm"
class TestGetLitellmParamsExplicitFields:
"""Verify explicit parameters are always present in the result."""
@ -125,4 +149,3 @@ class TestGetLitellmParamsExplicitFields:
def test_no_log_from_explicit_param(self):
result = get_litellm_params(no_log=True)
assert result["no-log"] is True