style: apply ruff format and add test coverage for optional request params

This commit is contained in:
HarshDubey23 2026-10-26 12:59:55 +05:30
parent 2ba1b5bf50
commit 33f1c58901
No known key found for this signature in database
3 changed files with 24 additions and 5 deletions

View file

@ -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 = (

View file

@ -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

View file

@ -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