mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-12 05:04:51 +00:00
Match litellm.completion supported model parameters with proxy model info (#27720)
* Use base_model for supported optional params * Add test * Formatting
This commit is contained in:
committed by
GitHub
parent
7bb5eb5bac
commit
fc8a9a3406
+5
-1
@@ -1528,7 +1528,11 @@ def completion( # type: ignore # noqa: PLR0915
|
||||
"logit_bias": logit_bias,
|
||||
"user": user,
|
||||
# params to identify the model
|
||||
"model": model,
|
||||
"model": (
|
||||
model_info.get("base_model")
|
||||
if isinstance(model_info, dict) and model_info.get("base_model")
|
||||
else model
|
||||
),
|
||||
"custom_llm_provider": custom_llm_provider,
|
||||
"response_format": response_format,
|
||||
"seed": seed,
|
||||
|
||||
@@ -848,6 +848,45 @@ def test_gpt_5_4_responses_bridge_preserves_reasoning_summary_dict(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model, model_info, expected_model_param",
|
||||
[
|
||||
("gemini/gemini-3.1-pro", None, "gemini-3.1-pro"),
|
||||
(
|
||||
"gemini/gemini-3.1-pro",
|
||||
{"base_model": "gemini-3.1-pro-preview"},
|
||||
"gemini-3.1-pro-preview",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_completion_optional_params_base_model(
|
||||
model: str,
|
||||
model_info: dict | None,
|
||||
expected_model_param: str,
|
||||
):
|
||||
with patch("litellm.main.get_optional_params") as mock_get_optional_params:
|
||||
mock_get_optional_params.return_value = MagicMock()
|
||||
|
||||
import litellm
|
||||
|
||||
kwargs = {
|
||||
"model": model,
|
||||
"messages": [{"role": "user", "content": "What is the capital of France?"}],
|
||||
"api_key": "fake-key",
|
||||
"mock_response": "Hey, how's it going?",
|
||||
}
|
||||
if model_info is not None:
|
||||
kwargs["model_info"] = model_info
|
||||
|
||||
litellm.completion(**kwargs)
|
||||
|
||||
assert mock_get_optional_params.called is True
|
||||
get_optional_params_model_param = mock_get_optional_params.call_args.kwargs[
|
||||
"model"
|
||||
]
|
||||
assert get_optional_params_model_param == expected_model_param
|
||||
|
||||
|
||||
@patch("litellm.completion_extras.responses_api_bridge.completion")
|
||||
def test_gpt_5_4_responses_bridge_merges_reasoning_summary_kwarg_without_tools(
|
||||
mock_responses_completion,
|
||||
|
||||
Reference in New Issue
Block a user