From 33f1c589016439dfdaf8e8a7556175423ffa45fc Mon Sep 17 00:00:00 2001 From: HarshDubey23 Date: Mon, 26 Oct 2026 12:59:55 +0530 Subject: [PATCH] style: apply ruff format and add test coverage for optional request params --- .../hosted_vllm/responses/transformation.py | 5 ++++- litellm/responses/utils.py | 4 +--- .../responses/test_hosted_vllm_responses.py | 20 ++++++++++++++++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/litellm/llms/hosted_vllm/responses/transformation.py b/litellm/llms/hosted_vllm/responses/transformation.py index 9e9254712e8..e35d5a76207 100644 --- a/litellm/llms/hosted_vllm/responses/transformation.py +++ b/litellm/llms/hosted_vllm/responses/transformation.py @@ -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 = ( diff --git a/litellm/responses/utils.py b/litellm/responses/utils.py index 1492ee51963..0f7be714c1b 100644 --- a/litellm/responses/utils.py +++ b/litellm/responses/utils.py @@ -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 diff --git a/tests/unit/llms/hosted_vllm/responses/test_hosted_vllm_responses.py b/tests/unit/llms/hosted_vllm/responses/test_hosted_vllm_responses.py index 2fec0e44b44..2f0302004de 100644 --- a/tests/unit/llms/hosted_vllm/responses/test_hosted_vllm_responses.py +++ b/tests/unit/llms/hosted_vllm/responses/test_hosted_vllm_responses.py @@ -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