[Bug] Fix a corner case in _process_simple_streaming_events (#34754)
Signed-off-by: Shiyan Deng <dsy842974287@meta.com> Co-authored-by: Lu Fang <30275821+houseroad@users.noreply.github.com>
This commit is contained in:
@@ -1364,6 +1364,26 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
for pm in previous_delta_messages
|
||||
if pm.reasoning is not None
|
||||
)
|
||||
|
||||
# delta message could have both reasoning and
|
||||
# content. Include current delta's reasoning in the
|
||||
# finalization since it may carry the tail end of
|
||||
# reasoning text (e.g. when reasoning end and
|
||||
# content start arrive in the same delta).
|
||||
if delta_message.reasoning is not None:
|
||||
yield _increment_sequence_number_and_return(
|
||||
ResponseReasoningTextDeltaEvent(
|
||||
type="response.reasoning_text.delta",
|
||||
sequence_number=-1,
|
||||
content_index=current_content_index,
|
||||
output_index=current_output_index,
|
||||
item_id=current_item_id,
|
||||
delta=delta_message.reasoning,
|
||||
)
|
||||
)
|
||||
reason_content += delta_message.reasoning
|
||||
delta_message = DeltaMessage(content=delta_message.content)
|
||||
|
||||
yield _increment_sequence_number_and_return(
|
||||
ResponseReasoningTextDoneEvent(
|
||||
type="response.reasoning_text.done",
|
||||
|
||||
Reference in New Issue
Block a user