feat(chat): 实现多重回复功能,允许单轮处理多条消息
本次更新引入了核心的多重回复功能,使得 Bot 能够在单次规划中响应多条不同的未读消息。这显著提升了其在活跃群聊中的交互效率和上下文处理能力。 主要变更包括: - **Planner Prompts 更新**: - 增加了明确的指令和示例,引导 LLM 在检测到多个需要回应的消息时,生成一个包含多个 `reply` 动作的 `actions` 列表。 - **PlanExecutor 逻辑增强**: - `_execute_reply_actions` 方法被重构,以串行方式执行计划中的所有回复动作。 - 引入了新的控制逻辑,确保只有在执行完最后一个 `reply` 动作后,才会清除未读消息队列。 - **ActionManager 功能扩展**: - `execute_action` 方法新增 `clear_unread_messages` 参数(默认为 `True`),允许调用方控制是否在动作执行后清空未读消息。 - `PlanExecutor` 在调用非 `reply` 动作或非最后一个 `reply` 动作时,会显式将此参数设为 `False`,防止过早清除消息。
This commit is contained in:
@@ -145,6 +145,7 @@ class ChatterActionManager:
|
||||
action_data: Optional[dict] = None,
|
||||
thinking_id: Optional[str] = None,
|
||||
log_prefix: str = "",
|
||||
clear_unread_messages: bool = True,
|
||||
) -> Any:
|
||||
"""
|
||||
执行单个动作的通用函数
|
||||
@@ -217,7 +218,8 @@ class ChatterActionManager:
|
||||
if success:
|
||||
await self._record_action_to_message(chat_stream, action_name, target_message, action_data)
|
||||
# 自动清空所有未读消息
|
||||
await self._clear_all_unread_messages(chat_stream.stream_id, action_name)
|
||||
if clear_unread_messages:
|
||||
await self._clear_all_unread_messages(chat_stream.stream_id, action_name)
|
||||
# 重置打断计数
|
||||
await self._reset_interruption_count_after_action(chat_stream.stream_id)
|
||||
|
||||
@@ -262,8 +264,8 @@ class ChatterActionManager:
|
||||
# 记录回复动作到目标消息
|
||||
await self._record_action_to_message(chat_stream, "reply", target_message, action_data)
|
||||
|
||||
# 自动清空所有未读消息
|
||||
await self._clear_all_unread_messages(chat_stream.stream_id, "reply")
|
||||
if clear_unread_messages:
|
||||
await self._clear_all_unread_messages(chat_stream.stream_id, "reply")
|
||||
|
||||
# 回复成功,重置打断计数
|
||||
await self._reset_interruption_count_after_action(chat_stream.stream_id)
|
||||
|
||||
Reference in New Issue
Block a user