让no_reply在私聊环境下不退出专注,更改部分日志为debug,优化些许prompt

This commit is contained in:
A0000Xz
2025-07-07 16:28:36 +08:00
committed by GitHub
parent 7e1514d20b
commit 3a7a22cb16

View File

@@ -107,7 +107,7 @@ class NoReplyAction(BaseAction):
current_time = time.time() current_time = time.time()
elapsed_time = current_time - start_time elapsed_time = current_time - start_time
if global_config.chat.chat_mode == "auto": if global_config.chat.chat_mode == "auto" and self.is_group:
# 检查是否超时 # 检查是否超时
if elapsed_time >= self._max_timeout: if elapsed_time >= self._max_timeout:
logger.info(f"{self.log_prefix} 达到最大等待时间{self._max_timeout}秒,退出专注模式") logger.info(f"{self.log_prefix} 达到最大等待时间{self._max_timeout}秒,退出专注模式")
@@ -220,6 +220,14 @@ class NoReplyAction(BaseAction):
frequency_block = "" frequency_block = ""
should_skip_llm_judge = False # 是否跳过LLM判断 should_skip_llm_judge = False # 是否跳过LLM判断
# 【新增】如果是私聊环境,跳过疲劳度检查
if not self.is_group:
frequency_block = "你正在和别人私聊,你不会疲惫,正常聊天即可。"
should_skip_llm_judge = False
logger.debug(f"{self.log_prefix} 私聊环境,跳过疲劳度检查")
else:
try: try:
# 获取过去10分钟的所有消息 # 获取过去10分钟的所有消息
past_10min_time = current_time - 600 # 10分钟前 past_10min_time = current_time - 600 # 10分钟前
@@ -294,10 +302,11 @@ class NoReplyAction(BaseAction):
continue # 跳过本次LLM判断继续循环等待 continue # 跳过本次LLM判断继续循环等待
# 构建判断上下文 # 构建判断上下文
chat_context = "QQ群" if self.is_group else "私聊"
judge_prompt = f""" judge_prompt = f"""
{identity_block} {identity_block}
你现在正在QQ群参与聊天,以下是聊天内容: 你现在正在{chat_context}参与聊天,以下是聊天内容:
{context_str} {context_str}
在以上的聊天中,你选择了暂时不回复,现在,你看到了新的聊天消息如下: 在以上的聊天中,你选择了暂时不回复,现在,你看到了新的聊天消息如下:
{messages_text} {messages_text}
@@ -383,11 +392,11 @@ class NoReplyAction(BaseAction):
# 每10秒输出一次等待状态 # 每10秒输出一次等待状态
if elapsed_time < 60: if elapsed_time < 60:
if int(elapsed_time) % 10 == 0 and int(elapsed_time) > 0: if int(elapsed_time) % 10 == 0 and int(elapsed_time) > 0:
logger.info(f"{self.log_prefix} 已等待{elapsed_time:.0f}秒,等待新消息...") logger.debug(f"{self.log_prefix} 已等待{elapsed_time:.0f}秒,等待新消息...")
await asyncio.sleep(1) await asyncio.sleep(1)
else: else:
if int(elapsed_time) % 60 == 0 and int(elapsed_time) > 0: if int(elapsed_time) % 60 == 0 and int(elapsed_time) > 0:
logger.info(f"{self.log_prefix} 已等待{elapsed_time / 60:.0f}分钟,等待新消息...") logger.debug(f"{self.log_prefix} 已等待{elapsed_time / 60:.0f}分钟,等待新消息...")
await asyncio.sleep(1) await asyncio.sleep(1)
# 短暂等待后继续检查 # 短暂等待后继续检查