[Bugfix] [issue-21565] Fix the incompatibility issue with stream and named function calling when Thinking is disabled (#21573)

Signed-off-by: wangzi <3220100013@zju.edu.cn>
Co-authored-by: wangzi <3220100013@zju.edu.cn>
This commit is contained in:
Hongsheng Liu
2025-07-28 13:43:50 +08:00
committed by GitHub
parent 3ea57a56d9
commit 7656cf4cf3
2 changed files with 23 additions and 7 deletions

View File

@@ -623,7 +623,7 @@ class OpenAIServingChat(OpenAIServing):
# handle streaming deltas for tools with named tool_choice
if tool_choice_function_name:
if (self.reasoning_parser
if (self.reasoning_parser and not reasoning_end_arr[i]
and not reasoning_parser.is_reasoning_end(
previous_token_ids)):
assert reasoning_parser is not None
@@ -637,11 +637,18 @@ class OpenAIServingChat(OpenAIServing):
current_token_ids,
output.token_ids,
))
# When encountering think end id in delta_token_ids,
# process the `content`. Only keep 'content',
# remove 'reasoning_content'
# When encountering think end id in delta_token_ids
# or think end id in prompt_token_ids
# i.e {"enable_thinking": False},
# set reasoning status to end.
# Only keep 'content', remove 'reasoning_content'.
if reasoning_parser.is_reasoning_end(
list(output.token_ids)):
list(output.token_ids)) or \
(res.prompt_token_ids and
reasoning_parser.is_reasoning_end(
list(res.prompt_token_ids)
)):
reasoning_end_arr[i] = True
if delta_message and delta_message.content:
# This need to be added to next `delta_text`
current_text = delta_message.content