diff --git a/changelogs/changelog.md b/changelogs/changelog.md index 92d59d18c..8fe8c5e32 100644 --- a/changelogs/changelog.md +++ b/changelogs/changelog.md @@ -2,8 +2,21 @@ ## [0.8.1] - 2025-6-27 +功能更新: + +- normal现在和focus一样支持tool +- focus现在和normal一样每次调用lpmm +- 移除人格表达 + +优化和修复: + - 修复表情包配置无效问题 - 合并normal和focus的prompt构建 +- 非TTY环境禁用console_input_loop +- 修复过滤消息仍被存储至数据库的问题 +- 私聊强制开启focus模式 +- 支持解析reply_to和at +- 修复focus冷却时间导致的固定沉默 diff --git a/src/chat/heart_flow/sub_heartflow.py b/src/chat/heart_flow/sub_heartflow.py index 03bb71c62..d255061fb 100644 --- a/src/chat/heart_flow/sub_heartflow.py +++ b/src/chat/heart_flow/sub_heartflow.py @@ -137,27 +137,31 @@ class SubHeartflow: self.normal_chat_instance = None # 启动/初始化失败,清理实例 return False - async def _handle_switch_to_focus_request(self) -> None: + async def _handle_switch_to_focus_request(self) -> bool: """ 处理来自NormalChat的切换到focus模式的请求 Args: stream_id: 请求切换的stream_id + Returns: + bool: 切换成功返回True,失败返回False """ logger.info(f"{self.log_prefix} 收到NormalChat请求切换到focus模式") # 检查是否在focus冷却期内 if self.is_in_focus_cooldown(): logger.info(f"{self.log_prefix} 正在focus冷却期内,忽略切换到focus模式的请求") - return + return False # 切换到focus模式 current_state = self.chat_state.chat_status if current_state == ChatState.NORMAL: await self.change_chat_state(ChatState.FOCUSED) logger.info(f"{self.log_prefix} 已根据NormalChat请求从NORMAL切换到FOCUSED状态") + return True else: logger.warning(f"{self.log_prefix} 当前状态为{current_state.value},无法切换到FOCUSED状态") + return False async def _handle_stop_focus_chat_request(self) -> None: """ diff --git a/src/chat/normal_chat/normal_chat.py b/src/chat/normal_chat/normal_chat.py index c7edbff3b..a53a3d185 100644 --- a/src/chat/normal_chat/normal_chat.py +++ b/src/chat/normal_chat/normal_chat.py @@ -124,8 +124,6 @@ class NormalChat: self._chat_task: Optional[asyncio.Task] = None self._disabled = False # 停用标志 - self.on_switch_to_focus_callback = on_switch_to_focus_callback - # 新增:回复模式和优先级管理器 self.reply_mode = self.chat_stream.context.get_priority_mode() if self.reply_mode == "priority": @@ -729,10 +727,14 @@ class NormalChat: # 新增:在auto模式下检查是否需要直接切换到focus模式 if global_config.chat.chat_mode == "auto": if await self._check_should_switch_to_focus(): - logger.info(f"[{self.stream_name}] 检测到切换到focus聊天模式的条件,直接执行切换") + logger.info(f"[{self.stream_name}] 检测到切换到focus聊天模式的条件,尝试执行切换") if self.on_switch_to_focus_callback: - await self.on_switch_to_focus_callback() - return + switched_successfully = await self.on_switch_to_focus_callback() + if switched_successfully: + logger.info(f"[{self.stream_name}] 成功切换到focus模式,中止NormalChat处理") + return + else: + logger.info(f"[{self.stream_name}] 切换到focus模式失败(可能在冷却中),继续NormalChat处理") else: logger.warning(f"[{self.stream_name}] 没有设置切换到focus聊天模式的回调函数,无法执行切换")