🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -135,7 +135,9 @@ class ActionModifier:
|
|||||||
if global_config.chat.chat_mode != "auto":
|
if global_config.chat.chat_mode != "auto":
|
||||||
if "exit_focus_chat" in self.action_manager.get_using_actions():
|
if "exit_focus_chat" in self.action_manager.get_using_actions():
|
||||||
self.action_manager.remove_action_from_using("exit_focus_chat")
|
self.action_manager.remove_action_from_using("exit_focus_chat")
|
||||||
logger.info(f"{self.log_prefix}移除动作: exit_focus_chat,原因: chat_mode不为auto(当前模式: {global_config.chat.chat_mode})")
|
logger.info(
|
||||||
|
f"{self.log_prefix}移除动作: exit_focus_chat,原因: chat_mode不为auto(当前模式: {global_config.chat.chat_mode})"
|
||||||
|
)
|
||||||
|
|
||||||
# === 第二阶段:激活类型判定 ===
|
# === 第二阶段:激活类型判定 ===
|
||||||
# 如果提供了聊天上下文,则进行激活类型判定
|
# 如果提供了聊天上下文,则进行激活类型判定
|
||||||
@@ -205,7 +207,9 @@ class ActionModifier:
|
|||||||
self.action_manager.add_action_to_using("exit_focus_chat")
|
self.action_manager.add_action_to_using("exit_focus_chat")
|
||||||
logger.debug(f"{self.log_prefix}恢复exit_focus_chat动作")
|
logger.debug(f"{self.log_prefix}恢复exit_focus_chat动作")
|
||||||
else:
|
else:
|
||||||
logger.debug(f"{self.log_prefix}跳过恢复exit_focus_chat动作,原因: chat_mode不为auto(当前模式: {global_config.chat.chat_mode})")
|
logger.debug(
|
||||||
|
f"{self.log_prefix}跳过恢复exit_focus_chat动作,原因: chat_mode不为auto(当前模式: {global_config.chat.chat_mode})"
|
||||||
|
)
|
||||||
|
|
||||||
logger.info(f"{self.log_prefix}激活类型判定完成,最终可用动作: {list(final_activated_actions.keys())}")
|
logger.info(f"{self.log_prefix}激活类型判定完成,最终可用动作: {list(final_activated_actions.keys())}")
|
||||||
|
|
||||||
|
|||||||
@@ -145,10 +145,10 @@ class NoReplyAction(BaseAction):
|
|||||||
|
|
||||||
# 默认超时时间,将由插件在注册时设置
|
# 默认超时时间,将由插件在注册时设置
|
||||||
waiting_timeout = 1200
|
waiting_timeout = 1200
|
||||||
|
|
||||||
# 连续no_reply计数器
|
# 连续no_reply计数器
|
||||||
_consecutive_count = 0
|
_consecutive_count = 0
|
||||||
|
|
||||||
# 分级等待时间
|
# 分级等待时间
|
||||||
_waiting_stages = [10, 60, 600] # 第1、2、3次的等待时间
|
_waiting_stages = [10, 60, 600] # 第1、2、3次的等待时间
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ class NoReplyAction(BaseAction):
|
|||||||
# 增加连续计数
|
# 增加连续计数
|
||||||
NoReplyAction._consecutive_count += 1
|
NoReplyAction._consecutive_count += 1
|
||||||
count = NoReplyAction._consecutive_count
|
count = NoReplyAction._consecutive_count
|
||||||
|
|
||||||
# 计算本次等待时间
|
# 计算本次等待时间
|
||||||
timeout = self._calculate_waiting_time(count)
|
timeout = self._calculate_waiting_time(count)
|
||||||
|
|
||||||
@@ -175,14 +175,14 @@ class NoReplyAction(BaseAction):
|
|||||||
|
|
||||||
# 等待新消息或达到时间上限
|
# 等待新消息或达到时间上限
|
||||||
result = await self.api.wait_for_new_message(timeout)
|
result = await self.api.wait_for_new_message(timeout)
|
||||||
|
|
||||||
# 如果有新消息或者超时,都不重置计数器,因为可能还会继续no_reply
|
# 如果有新消息或者超时,都不重置计数器,因为可能还会继续no_reply
|
||||||
return result
|
return result
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"{self.log_prefix} 不回复动作执行失败: {e}")
|
logger.error(f"{self.log_prefix} 不回复动作执行失败: {e}")
|
||||||
return False, f"不回复动作执行失败: {e}"
|
return False, f"不回复动作执行失败: {e}"
|
||||||
|
|
||||||
def _calculate_waiting_time(self, consecutive_count: int) -> int:
|
def _calculate_waiting_time(self, consecutive_count: int) -> int:
|
||||||
"""根据连续次数计算等待时间"""
|
"""根据连续次数计算等待时间"""
|
||||||
if consecutive_count <= len(self._waiting_stages):
|
if consecutive_count <= len(self._waiting_stages):
|
||||||
@@ -193,7 +193,7 @@ class NoReplyAction(BaseAction):
|
|||||||
else:
|
else:
|
||||||
# 第4次及以后使用WAITING_TIME_THRESHOLD
|
# 第4次及以后使用WAITING_TIME_THRESHOLD
|
||||||
return self.waiting_timeout
|
return self.waiting_timeout
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def reset_consecutive_count(cls):
|
def reset_consecutive_count(cls):
|
||||||
"""重置连续计数器"""
|
"""重置连续计数器"""
|
||||||
@@ -309,10 +309,10 @@ class ChangeToFocusChatAction(BaseAction):
|
|||||||
async def execute(self) -> Tuple[bool, str]:
|
async def execute(self) -> Tuple[bool, str]:
|
||||||
"""执行切换到专注聊天动作"""
|
"""执行切换到专注聊天动作"""
|
||||||
logger.info(f"{self.log_prefix} 决定切换到专注聊天: {self.reasoning}")
|
logger.info(f"{self.log_prefix} 决定切换到专注聊天: {self.reasoning}")
|
||||||
|
|
||||||
# 重置NoReplyAction的连续计数器
|
# 重置NoReplyAction的连续计数器
|
||||||
NoReplyAction.reset_consecutive_count()
|
NoReplyAction.reset_consecutive_count()
|
||||||
|
|
||||||
# 这里只做决策标记,具体切换逻辑由上层管理器处理
|
# 这里只做决策标记,具体切换逻辑由上层管理器处理
|
||||||
return True, "决定切换到专注聊天模式"
|
return True, "决定切换到专注聊天模式"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user