-
-
Notifications
You must be signed in to change notification settings - Fork 15k
[Frontend] Fix default_chat_template_kwargs handling in Responses API #37739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sidsaha-ai
wants to merge
2
commits into
vllm-project:main
Choose a base branch
from
sidsaha-ai:fix/responses-default-chat-template-kwargs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
tests/entrypoints/openai/responses/test_chat_template_kwargs.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
|
||
| import pytest | ||
| import pytest_asyncio | ||
| from openai import OpenAI | ||
|
|
||
| from tests.utils import RemoteOpenAIServer | ||
|
|
||
| from .conftest import BASE_TEST_ENV | ||
|
|
||
| MODEL_NAME = "Qwen/Qwen3-0.6B" | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def server(): | ||
| args = [ | ||
| "--reasoning-parser", | ||
| "qwen3", | ||
| "--dtype", | ||
| "bfloat16", | ||
| "--enforce-eager", | ||
| "--max-model-len", | ||
| "4096", | ||
| "--default-chat-template-kwargs", | ||
| '{"enable_thinking": false}', | ||
| ] | ||
| env_dict = { | ||
| **BASE_TEST_ENV, | ||
| "VLLM_ENABLE_RESPONSES_API_STORE": "1", | ||
| } | ||
| with RemoteOpenAIServer(MODEL_NAME, args, env_dict=env_dict) as remote_server: | ||
| yield remote_server | ||
|
|
||
|
|
||
| @pytest_asyncio.fixture | ||
| async def client(server): | ||
| async with server.get_async_client() as async_client: | ||
| yield async_client | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize("model_name", [MODEL_NAME]) | ||
| async def test_responses_honors_default_chat_template_kwargs( | ||
| client: OpenAI, model_name: str | ||
| ): | ||
| response = await client.responses.create( | ||
| model=model_name, | ||
| input="Compute 17 * 19 and explain briefly.", | ||
| reasoning={"effort": "low"}, | ||
| temperature=0.0, | ||
| ) | ||
|
|
||
| reasoning_items = [item for item in response.output if item.type == "reasoning"] | ||
|
|
||
| assert response.status == "completed" | ||
| assert response.output_text | ||
| assert not reasoning_items | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize("model_name", [MODEL_NAME]) | ||
| async def test_responses_request_chat_template_kwargs_override_server_default( | ||
| client: OpenAI, model_name: str | ||
| ): | ||
| response = await client.responses.create( | ||
| model=model_name, | ||
| input="Compute 23 * 17 and explain briefly.", | ||
| reasoning={"effort": "low"}, | ||
| temperature=0.0, | ||
| extra_body={"chat_template_kwargs": {"enable_thinking": True}}, | ||
| ) | ||
|
|
||
| reasoning_items = [item for item in response.output if item.type == "reasoning"] | ||
|
|
||
| assert response.status == "completed" | ||
| assert response.usage is not None | ||
| assert response.usage.output_tokens_details.reasoning_tokens > 0 | ||
| assert reasoning_items | ||
| assert reasoning_items[0].content |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks~ @sidsaha-ai
This is a known issue. The reason we haven’t implemented it so far is that we wanted to wait and see whether OpenAI would introduce a similar field.
Otherwise, introducing these fields would cause the Responses API to overlap with chat completions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. Should we then wait and close this PR? Or should I go ahead with rebasing and can get approval.