fix:无动作时卡入no_reply

This commit is contained in:
SengokuCola
2025-07-13 00:04:57 +08:00
parent 58ef00865d
commit 16c2a8b68e
5 changed files with 221 additions and 26 deletions

View File

@@ -19,7 +19,7 @@ from src.chat.focus_chat.hfc_utils import get_recent_message_stats
from src.person_info.person_info import get_person_info_manager
from src.plugin_system.apis import generator_api,send_api,message_api
from src.chat.willing.willing_manager import get_willing_manager
from .priority_manager import PriorityManager
from ...mais4u.mais4u_chat.priority_manager import PriorityManager
from src.chat.utils.chat_message_builder import get_raw_msg_by_timestamp_with_chat
@@ -448,18 +448,10 @@ class HeartFChatting:
return False, "", ""
async def shutdown(self):
"""优雅关闭HeartFChatting实例取消活动循环任务"""
logger.info(f"{self.log_prefix} 正在关闭HeartFChatting...")
self.running = False # <-- 在开始关闭时设置标志位
# 记录最终的消息统计
if self._message_count > 0:
logger.info(f"{self.log_prefix} 本次focus会话共发送了 {self._message_count} 条消息")
if self._fatigue_triggered:
logger.info(f"{self.log_prefix} 因疲惫而退出focus模式")
# 取消循环任务
if self._loop_task and not self._loop_task.done():
logger.info(f"{self.log_prefix} 正在取消HeartFChatting循环任务")
@@ -477,10 +469,7 @@ class HeartFChatting:
# 清理状态
self.running = False
self._loop_task = None
# 重置消息计数器,为下次启动做准备
self.reset_message_count()
logger.info(f"{self.log_prefix} HeartFChatting关闭完成")

View File

@@ -45,9 +45,6 @@ class SubHeartflow:
"""异步初始化方法,创建兴趣流并确定聊天类型"""
await self.heart_fc_instance.start()
async def _stop_heart_fc_chat(self):
"""停止并清理 HeartFChatting 实例"""
if self.heart_fc_instance.running:

View File

@@ -103,15 +103,13 @@ class ActionPlanner:
logger.warning(f"{self.log_prefix}使用中的动作 {action_name} 未在已注册动作中找到")
# 如果没有可用动作或只有no_reply动作直接返回no_reply
if not current_available_actions or (
len(current_available_actions) == 1 and "no_reply" in current_available_actions
):
action = "no_reply"
reasoning = "没有可用的动作" if not current_available_actions else "只有no_reply动作可用跳过规划"
if not current_available_actions:
if mode == "focus":
action = "no_reply"
else:
action = "no_action"
reasoning = "没有可用的动作"
logger.info(f"{self.log_prefix}{reasoning}")
logger.debug(
f"{self.log_prefix}[focus]沉默后恢复到默认动作集, 当前可用: {list(self.action_manager.get_using_actions().keys())}"
)
return {
"action_result": {"action_type": action, "action_data": action_data, "reasoning": reasoning},
}

View File

@@ -116,10 +116,10 @@ class ImageManager:
if image_base64_processed is None:
logger.warning("GIF转换失败无法获取描述")
return "[表情包(GIF处理失败)]"
prompt = "这是一个动态图表情包每一张图代表了动态图的某一帧黑色背景代表透明使用1-2个词描述一下表情包表达的情感和内容简短一些输出一段平文本不超过15个字"
prompt = "这是一个动态图表情包每一张图代表了动态图的某一帧黑色背景代表透明使用1-2个词描述一下表情包表达的情感和内容简短一些输出一段平文本只输出1-2个词就好不要输出其他内容"
description, _ = await self._llm.generate_response_for_image(prompt, image_base64_processed, "jpg")
else:
prompt = "图片是一个表情包请用使用1-2个词描述一下表情包所表达的情感和内容简短一些输出一段平文本不超过15个字"
prompt = "图片是一个表情包请用使用1-2个词描述一下表情包所表达的情感和内容简短一些输出一段平文本只输出1-2个词就好不要输出其他内容"
description, _ = await self._llm.generate_response_for_image(prompt, image_base64, image_format)
if description is None: