添加checker开关为可配置

pull/937/head
114514 2025-05-07 05:38:27 +08:00
parent 92df03376c
commit 04fc32295f
3 changed files with 28 additions and 14 deletions

View File

@ -273,6 +273,7 @@ class BotConfig:
# enable_think_flow: bool = False # 是否启用思考流程
talk_allowed_private = set()
enable_pfc_chatting: bool = False # 是否启用PFC聊天
enable_pfc_reply_checker: bool = True # 是否开启PFC回复检查
# idle_conversation
enable_idle_conversation: bool = False # 是否启用 pfc 主动发言(未完善)
@ -665,6 +666,9 @@ class BotConfig:
config.talk_allowed_private = set(str(user) for user in experimental_config.get("talk_allowed_private", []))
if config.INNER_VERSION in SpecifierSet(">=1.1.0"):
config.enable_pfc_chatting = experimental_config.get("pfc_chatting", config.enable_pfc_chatting)
if config.INNER_VERSION in SpecifierSet(">=1.1.0"):
config.enable_pfc_reply_checker = experimental_config.get("enable_pfc_reply_checker", config.enable_pfc_reply_checker)
logger.info(f"PFC Reply Checker 状态: {'启用' if config.enable_pfc_reply_checker else '关闭'}")
def idle_conversation(parent: dict):
idle_conversation_config = parent["idle_conversation"]

View File

@ -961,6 +961,8 @@ class Conversation:
# retry_count for checker starts from 0
current_retry_for_checker = reply_attempt_count - 1
current_time_value_for_check = "获取时间失败"
if observation_info and hasattr(observation_info, 'current_time_str') and observation_info.current_time_str:
@ -968,19 +970,26 @@ class Conversation:
logger.debug(f"{log_prefix} 调用 ReplyChecker 检查...")
# 调用 ReplyChecker 的 check 方法
is_suitable, check_reason, need_replan_from_checker = await self.reply_checker.check(
reply=generated_content,
goal=current_goal_str,
chat_history=chat_history_for_check, # 传递列表形式的历史记录
chat_history_text=chat_history_text_for_check, # 传递文本形式的历史记录
current_time_str=current_time_value_for_check, # 新增:传递时间字符串
retry_count=current_retry_for_checker,
)
logger.info(
f"{log_prefix} ReplyChecker 结果: 合适={is_suitable}, 原因='{check_reason}', 需重规划={need_replan_from_checker}"
)
# --- 根据配置决定是否执行检查 ---
if global_config.enable_pfc_reply_checker: # <--- 使用配置项
logger.debug(f"{log_prefix} 调用 ReplyChecker 检查 (配置已启用)...")
is_suitable, check_reason, need_replan_from_checker = await self.reply_checker.check(
reply=generated_content,
goal=current_goal_str,
chat_history=chat_history_for_check,
chat_history_text=chat_history_text_for_check,
current_time_str=current_time_value_for_check,
retry_count=current_retry_for_checker,
)
logger.info(
f"{log_prefix} ReplyChecker 结果: 合适={is_suitable}, 原因='{check_reason}', 需重规划={need_replan_from_checker}"
)
else:
# 如果配置为关闭,则默认通过检查
is_suitable = True
check_reason = "ReplyChecker 已通过配置关闭"
need_replan_from_checker = False
logger.info(f"[配置关闭] ReplyChecker 已跳过,默认回复为合适。")
# 如果不合适,记录原因并准备下一次尝试(如果还有次数)
if not is_suitable:
# 记录拒绝原因和内容,供下次生成时参考

View File

@ -1,5 +1,5 @@
[inner]
version = "1.6.4"
version = "1.6.5"
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
#如果你想要修改配置文件请在修改后将version的值进行变更
@ -188,6 +188,7 @@ enable = true
enable_friend_chat = false # 是否启用好友聊天
talk_allowed_private = [] # 可以回复消息的QQ号
pfc_chatting = false # 是否启用PFC聊天该功能仅作用于私聊与回复模式独立
enable_pfc_reply_checker = true # 是否启用 PFC 的回复检查器
[idle_conversation]
enable_idle_conversation = false