Remove deprecated reasoning_content message field (#33402)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -1437,7 +1437,7 @@ def _parse_chat_message_content(
|
||||
) -> list[ConversationMessage]:
|
||||
role = message["role"]
|
||||
content = message.get("content")
|
||||
reasoning = message.get("reasoning") or message.get("reasoning_content")
|
||||
reasoning = message.get("reasoning")
|
||||
|
||||
if content is None:
|
||||
content = []
|
||||
@@ -1463,9 +1463,6 @@ def _parse_chat_message_content(
|
||||
# Include reasoning if present for interleaved thinking.
|
||||
if reasoning is not None:
|
||||
result_msg["reasoning"] = cast(str, reasoning)
|
||||
result_msg["reasoning_content"] = cast(
|
||||
str, reasoning
|
||||
) # keep compatibility
|
||||
elif role == "tool":
|
||||
parsed_msg = _ToolParser(message)
|
||||
if "tool_call_id" in parsed_msg:
|
||||
|
||||
@@ -61,14 +61,6 @@ class ChatMessage(OpenAIBaseModel):
|
||||
|
||||
# vLLM-specific fields that are not in OpenAI spec
|
||||
reasoning: str | None = None
|
||||
reasoning_content: str | None = None
|
||||
"""Deprecated: use `reasoning` instead."""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def handle_deprecated_reasoning_content(self):
|
||||
"""Copy reasoning to reasoning_content for backward compatibility."""
|
||||
self.reasoning_content = self.reasoning
|
||||
return self
|
||||
|
||||
|
||||
class ChatCompletionLogProb(OpenAIBaseModel):
|
||||
|
||||
@@ -1186,8 +1186,8 @@ class OpenAIServingChat(OpenAIServing):
|
||||
delta_content_parts = []
|
||||
if delta_message.content:
|
||||
delta_content_parts.append(delta_message.content)
|
||||
if delta_message.reasoning_content:
|
||||
reasoning = delta_message.reasoning_content
|
||||
if delta_message.reasoning:
|
||||
reasoning = delta_message.reasoning
|
||||
delta_content_parts.append(f"[reasoning: {reasoning}]")
|
||||
if delta_message.tool_calls:
|
||||
tool_args = "".join(
|
||||
|
||||
@@ -261,16 +261,8 @@ class DeltaMessage(OpenAIBaseModel):
|
||||
role: str | None = None
|
||||
content: str | None = None
|
||||
reasoning: str | None = None
|
||||
reasoning_content: str | None = None
|
||||
"""Deprecated: use `reasoning` instead."""
|
||||
tool_calls: list[DeltaToolCall] = Field(default_factory=list)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def handle_deprecated_reasoning_content(self):
|
||||
"""Copy reasoning to reasoning_content for backward compatibility."""
|
||||
self.reasoning_content = self.reasoning
|
||||
return self
|
||||
|
||||
|
||||
####### Tokens IN <> Tokens OUT #######
|
||||
class GenerateRequest(BaseModel):
|
||||
|
||||
@@ -321,13 +321,9 @@ def parse_chat_input_to_harmony_message(
|
||||
commentary_msg = commentary_msg.with_channel("commentary")
|
||||
msgs.append(commentary_msg)
|
||||
|
||||
reasoning_content = chat_msg.get("reasoning") or chat_msg.get(
|
||||
"reasoning_content"
|
||||
)
|
||||
if reasoning_content:
|
||||
analysis_msg = Message.from_role_and_content(
|
||||
Role.ASSISTANT, reasoning_content
|
||||
)
|
||||
reasoning = chat_msg.get("reasoning")
|
||||
if reasoning:
|
||||
analysis_msg = Message.from_role_and_content(Role.ASSISTANT, reasoning)
|
||||
analysis_msg = analysis_msg.with_channel("analysis")
|
||||
msgs.append(analysis_msg)
|
||||
|
||||
@@ -362,9 +358,9 @@ def parse_chat_input_to_harmony_message(
|
||||
return [msg]
|
||||
|
||||
# Non-tool reasoning content
|
||||
reasoning_content = chat_msg.get("reasoning") or chat_msg.get("reasoning_content")
|
||||
if role == "assistant" and reasoning_content:
|
||||
analysis_msg = Message.from_role_and_content(Role.ASSISTANT, reasoning_content)
|
||||
reasoning = chat_msg.get("reasoning")
|
||||
if role == "assistant" and reasoning:
|
||||
analysis_msg = Message.from_role_and_content(Role.ASSISTANT, reasoning)
|
||||
analysis_msg = analysis_msg.with_channel("analysis")
|
||||
msgs.append(analysis_msg)
|
||||
|
||||
@@ -545,7 +541,7 @@ def _parse_function_call(message: Message, recipient: str) -> list[ResponseOutpu
|
||||
return output_items
|
||||
|
||||
|
||||
def _parse_reasoning_content(message: Message) -> list[ResponseOutputItem]:
|
||||
def _parse_reasoning(message: Message) -> list[ResponseOutputItem]:
|
||||
"""Parse reasoning/analysis content into reasoning items."""
|
||||
output_items = []
|
||||
for content in message.content:
|
||||
@@ -646,7 +642,7 @@ def parse_output_message(message: Message) -> list[ResponseOutputItem]:
|
||||
elif recipient.startswith(("python", "browser", "container")):
|
||||
# Built-in tool recipients (python/browser/container)
|
||||
# generate reasoning output
|
||||
output_items.extend(_parse_reasoning_content(message))
|
||||
output_items.extend(_parse_reasoning(message))
|
||||
|
||||
# All other recipients are MCP calls
|
||||
else:
|
||||
@@ -654,12 +650,12 @@ def parse_output_message(message: Message) -> list[ResponseOutputItem]:
|
||||
|
||||
# No recipient - handle based on channel for non-tool messages
|
||||
elif message.channel == "analysis":
|
||||
output_items.extend(_parse_reasoning_content(message))
|
||||
output_items.extend(_parse_reasoning(message))
|
||||
|
||||
elif message.channel == "commentary":
|
||||
# Per Harmony format, commentary channel can contain preambles to calling
|
||||
# multiple functions - explanatory text with no recipient
|
||||
output_items.extend(_parse_reasoning_content(message))
|
||||
output_items.extend(_parse_reasoning(message))
|
||||
|
||||
elif message.channel == "final":
|
||||
output_items.append(_parse_final_message(message))
|
||||
|
||||
Reference in New Issue
Block a user