mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-05 07:37:50 +00:00
style: apply ruff format and add test coverage for optional request params
This commit is contained in:
parent
2ba1b5bf50
commit
33f1c58901
3 changed files with 24 additions and 5 deletions
|
|
@ -74,7 +74,10 @@ class HostedVLLMResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
)
|
||||
|
||||
for param in HOSTED_VLLM_RESPONSES_SUPPORTED_PARAMS:
|
||||
if param in response_api_optional_request_params and response_api_optional_request_params[param] is not None:
|
||||
if (
|
||||
param in response_api_optional_request_params
|
||||
and response_api_optional_request_params[param] is not None
|
||||
):
|
||||
request[param] = response_api_optional_request_params[param]
|
||||
elif litellm_params is not None:
|
||||
val = (
|
||||
|
|
|
|||
|
|
@ -339,9 +339,7 @@ class ResponsesAPIRequestUtils:
|
|||
special_params: Final[dict[str, object]] = params.pop("kwargs", {})
|
||||
|
||||
allowed_openai_params: Final = (
|
||||
params.get("allowed_openai_params")
|
||||
or special_params.get("allowed_openai_params")
|
||||
or []
|
||||
params.get("allowed_openai_params") or special_params.get("allowed_openai_params") or []
|
||||
)
|
||||
allowed_set: Final = {p for p in allowed_openai_params if isinstance(p, str)}
|
||||
default_keys: Final = set(valid_keys) | allowed_set
|
||||
|
|
|
|||
|
|
@ -185,7 +185,6 @@ def test_hosted_vllm_validate_environment_custom_api_key():
|
|||
assert headers.get("Authorization") == "Bearer my-custom-key"
|
||||
|
||||
|
||||
|
||||
def test_hosted_vllm_responses_supported_params():
|
||||
"""Test get_supported_openai_params() includes vLLM provider-specific params."""
|
||||
config = HostedVLLMResponsesAPIConfig()
|
||||
|
|
@ -254,3 +253,22 @@ def test_hosted_vllm_responses_transform_request_from_litellm_params():
|
|||
assert request["chat_template_kwargs"] == {"enable_thinking": False}
|
||||
assert request["top_k"] == 50
|
||||
assert request["min_p"] == 0.05
|
||||
|
||||
|
||||
def test_hosted_vllm_responses_transform_request_from_optional_request_params():
|
||||
"""Test transform_responses_api_request forwards provider params from response_api_optional_request_params."""
|
||||
config = HostedVLLMResponsesAPIConfig()
|
||||
|
||||
request = config.transform_responses_api_request(
|
||||
model="Qwen/Qwen3-8B",
|
||||
input="test input",
|
||||
response_api_optional_request_params={
|
||||
"chat_template_kwargs": {"enable_thinking": False},
|
||||
"top_k": 30,
|
||||
},
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
headers={},
|
||||
)
|
||||
|
||||
assert request["chat_template_kwargs"] == {"enable_thinking": False}
|
||||
assert request["top_k"] == 30
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue