[Refactor][Parser] Unify Response API to use parser.parse() like Chat Completion API (#45190)

Signed-off-by: sfeng33 <4florafeng@gmail.com>
This commit is contained in:
Flora Feng
2026-06-11 04:37:51 +00:00
committed by GitHub
parent f272dfdce1
commit 3a04061701
6 changed files with 101 additions and 211 deletions
+11 -6
View File
@@ -86,6 +86,7 @@ from vllm.entrypoints.openai.responses.streaming_events import (
split_delta,
)
from vllm.entrypoints.openai.responses.utils import (
build_response_output_items,
construct_input_messages,
construct_tool_dicts,
extract_function_tool_names,
@@ -1028,19 +1029,23 @@ class OpenAIServingResponses(OpenAIServing):
top_logprobs=request.top_logprobs,
)
# Use parser to extract and create response output items
# Use parser to extract reasoning, content, and tool calls
if self.parser:
chat_template_kwargs = self._effective_chat_template_kwargs(request)
parser = self.parser(
tokenizer, request.tools, chat_template_kwargs=chat_template_kwargs
)
return parser.extract_response_outputs(
model_output=final_output.text,
model_output_token_ids=final_output.token_ids,
request=request,
reasoning, content, tool_calls = parser.parse(
final_output.text,
request,
enable_auto_tools=self.enable_auto_tools,
tool_call_id_type=self.tool_call_id_type,
)
return build_response_output_items(
reasoning=reasoning,
content=content,
tool_calls=tool_calls,
logprobs=logprobs,
tool_call_id_type=self.tool_call_id_type,
)
# Fallback when no parser is configured