reasoning_content -> reasoning (#27752)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -778,11 +778,11 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
logger.exception("Error in reasoning parser creation.")
|
||||
raise e
|
||||
|
||||
reasoning_content, content = reasoning_parser.extract_reasoning_content(
|
||||
reasoning, content = reasoning_parser.extract_reasoning(
|
||||
final_output.text, request=request
|
||||
)
|
||||
else:
|
||||
reasoning_content = None
|
||||
reasoning = None
|
||||
content = final_output.text
|
||||
|
||||
# Log complete response if output logging is enabled
|
||||
@@ -790,8 +790,8 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
output_text = ""
|
||||
if content:
|
||||
output_text = content
|
||||
elif reasoning_content:
|
||||
output_text = f"[reasoning: {reasoning_content}]"
|
||||
elif reasoning:
|
||||
output_text = f"[reasoning: {reasoning}]"
|
||||
|
||||
if output_text:
|
||||
self.request_logger.log_outputs(
|
||||
@@ -805,15 +805,13 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
|
||||
reasoning_item = None
|
||||
message_item = None
|
||||
if reasoning_content:
|
||||
if reasoning:
|
||||
reasoning_item = ResponseReasoningItem(
|
||||
id=f"rs_{random_uuid()}",
|
||||
summary=[],
|
||||
type="reasoning",
|
||||
content=[
|
||||
ResponseReasoningTextContent(
|
||||
text=reasoning_content, type="reasoning_text"
|
||||
)
|
||||
ResponseReasoningTextContent(text=reasoning, type="reasoning_text")
|
||||
],
|
||||
status=None, # NOTE: Only the last output item has status.
|
||||
)
|
||||
@@ -1208,15 +1206,13 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
if ctx.last_output.outputs:
|
||||
output = ctx.last_output.outputs[0]
|
||||
if reasoning_parser:
|
||||
delta_message = (
|
||||
reasoning_parser.extract_reasoning_content_streaming(
|
||||
previous_text=previous_text,
|
||||
current_text=previous_text + output.text,
|
||||
delta_text=output.text,
|
||||
previous_token_ids=previous_token_ids,
|
||||
current_token_ids=previous_token_ids + output.token_ids,
|
||||
delta_token_ids=output.token_ids,
|
||||
)
|
||||
delta_message = reasoning_parser.extract_reasoning_streaming(
|
||||
previous_text=previous_text,
|
||||
current_text=previous_text + output.text,
|
||||
delta_text=output.text,
|
||||
previous_token_ids=previous_token_ids,
|
||||
current_token_ids=previous_token_ids + output.token_ids,
|
||||
delta_token_ids=output.token_ids,
|
||||
)
|
||||
else:
|
||||
delta_message = DeltaMessage(
|
||||
@@ -1228,7 +1224,7 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
continue
|
||||
if not first_delta_sent:
|
||||
current_item_id = str(uuid.uuid4())
|
||||
if delta_message.reasoning_content:
|
||||
if delta_message.reasoning:
|
||||
yield _increment_sequence_number_and_return(
|
||||
ResponseOutputItemAddedEvent(
|
||||
type="response.output_item.added",
|
||||
@@ -1280,15 +1276,15 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
# same as content or reasoning content
|
||||
if (
|
||||
previous_delta_messages
|
||||
and previous_delta_messages[-1].reasoning_content is not None
|
||||
and previous_delta_messages[-1].reasoning is not None
|
||||
and delta_message.content is not None
|
||||
):
|
||||
# from reasoning to normal content, send done
|
||||
# event for reasoning
|
||||
reason_content = "".join(
|
||||
pm.reasoning_content
|
||||
pm.reasoning
|
||||
for pm in previous_delta_messages
|
||||
if pm.reasoning_content is not None
|
||||
if pm.reasoning is not None
|
||||
)
|
||||
yield _increment_sequence_number_and_return(
|
||||
ResponseReasoningTextDoneEvent(
|
||||
@@ -1356,7 +1352,7 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
# reset previous delta messages
|
||||
previous_delta_messages = []
|
||||
|
||||
if delta_message.reasoning_content is not None:
|
||||
if delta_message.reasoning is not None:
|
||||
yield _increment_sequence_number_and_return(
|
||||
ResponseReasoningTextDeltaEvent(
|
||||
type="response.reasoning_text.delta",
|
||||
@@ -1364,7 +1360,7 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
content_index=current_content_index,
|
||||
output_index=current_output_index,
|
||||
item_id=current_item_id,
|
||||
delta=delta_message.reasoning_content,
|
||||
delta=delta_message.reasoning,
|
||||
)
|
||||
)
|
||||
elif delta_message.content is not None:
|
||||
@@ -1392,11 +1388,11 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
|
||||
previous_delta_messages.append(delta_message)
|
||||
if previous_delta_messages:
|
||||
if previous_delta_messages[-1].reasoning_content is not None:
|
||||
if previous_delta_messages[-1].reasoning is not None:
|
||||
reason_content = "".join(
|
||||
pm.reasoning_content
|
||||
pm.reasoning
|
||||
for pm in previous_delta_messages
|
||||
if pm.reasoning_content is not None
|
||||
if pm.reasoning is not None
|
||||
)
|
||||
yield _increment_sequence_number_and_return(
|
||||
ResponseReasoningTextDoneEvent(
|
||||
|
||||
Reference in New Issue
Block a user