[Bugfix] GPT-OSS Autodrop reasoning in Response API and cleanup (#45048)
Signed-off-by: Yifan Zong <yzong@redhat.com> Co-authored-by: Ben Browning <bbrownin@redhat.com>
This commit is contained in:
@@ -1191,30 +1191,6 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
# instructions are ignored.
|
||||
prev_msgs = self.msg_store[prev_response.id]
|
||||
|
||||
# FIXME(woosuk): The slice-delete-reappend cycle below is
|
||||
# currently a no-op --- it removes messages then puts them all
|
||||
# back unfiltered. It may be intentionally deferred (see FIXME
|
||||
# above) or redundant if the Harmony encoder already strips
|
||||
# analysis messages at render time. If analysis messages need
|
||||
# to be dropped here, add a channel != "analysis" filter when
|
||||
# re-appending, similar to auto_drop_analysis_messages in
|
||||
# harmony_utils.py.
|
||||
if len(prev_msgs) > 0:
|
||||
last_msg = prev_msgs[-1]
|
||||
assert isinstance(last_msg, OpenAIHarmonyMessage)
|
||||
if last_msg.channel == "final":
|
||||
prev_final_msg_idx = -1
|
||||
for i in range(len(prev_msgs) - 2, -1, -1):
|
||||
prev_msg_i = prev_msgs[i]
|
||||
assert isinstance(prev_msg_i, OpenAIHarmonyMessage)
|
||||
if prev_msg_i.channel == "final":
|
||||
prev_final_msg_idx = i
|
||||
break
|
||||
recent_turn_msgs = prev_msgs[prev_final_msg_idx + 1 :]
|
||||
del prev_msgs[prev_final_msg_idx + 1 :]
|
||||
for msg in recent_turn_msgs:
|
||||
assert isinstance(msg, OpenAIHarmonyMessage)
|
||||
prev_msgs.append(msg)
|
||||
messages.extend(prev_msgs)
|
||||
# Append the new input.
|
||||
# Responses API supports simple text inputs without chat format.
|
||||
|
||||
Reference in New Issue
Block a user