issue: #17056 : Add a reason field to the message_replace event (#17195)

Co-authored-by: 聂政 <niezheng@pjlab.org.cn>
This commit is contained in:
just2gooo
2025-04-25 10:08:06 +08:00
committed by GitHub
parent 37e2f73909
commit 5e2b3b34e5
6 changed files with 36 additions and 12 deletions

View File

@@ -684,7 +684,9 @@ class AdvancedChatAppGenerateTaskPipeline:
)
elif isinstance(event, QueueMessageReplaceEvent):
# published by moderation
yield self._message_cycle_manager._message_replace_to_stream_response(answer=event.text)
yield self._message_cycle_manager._message_replace_to_stream_response(
answer=event.text, reason=event.reason
)
elif isinstance(event, QueueAdvancedChatMessageEndEvent):
if not graph_runtime_state:
raise ValueError("graph runtime state not initialized.")
@@ -695,7 +697,8 @@ class AdvancedChatAppGenerateTaskPipeline:
if output_moderation_answer:
self._task_state.answer = output_moderation_answer
yield self._message_cycle_manager._message_replace_to_stream_response(
answer=output_moderation_answer
answer=output_moderation_answer,
reason=QueueMessageReplaceEvent.MessageReplaceReason.OUTPUT_MODERATION,
)
# Save message