[Bugfix] Preserve empty K2 Horizon reasoning in chat responses (#42623)
Co-authored-by: BBuf <1182563586@qq.com>
This commit is contained in:
@@ -2087,6 +2087,7 @@ class OpenAIServingChat(OpenAIServingBase):
|
||||
# First chunk with role
|
||||
if is_firsts.get(index, True):
|
||||
is_firsts[index] = False
|
||||
# K2 templates require preserved thinking, including empty reasoning.
|
||||
yield build_sse_content(
|
||||
chunk_id=content["meta_info"]["id"],
|
||||
created=int(time.time()),
|
||||
@@ -2094,6 +2095,12 @@ class OpenAIServingChat(OpenAIServingBase):
|
||||
index=index,
|
||||
role="assistant",
|
||||
content="",
|
||||
reasoning_content=(
|
||||
""
|
||||
if self.reasoning_parser == "k2_horizon"
|
||||
and request.separate_reasoning
|
||||
else None
|
||||
),
|
||||
)
|
||||
stream_started = True
|
||||
|
||||
@@ -2446,7 +2453,7 @@ class OpenAIServingChat(OpenAIServingBase):
|
||||
role="assistant",
|
||||
content=text if text else "",
|
||||
tool_calls=tool_calls,
|
||||
reasoning_content=reasoning_text if reasoning_text else None,
|
||||
reasoning_content=reasoning_text,
|
||||
),
|
||||
logprobs=choice_logprobs,
|
||||
finish_reason=finish_reason["type"] if finish_reason else None,
|
||||
|
||||
Reference in New Issue
Block a user