配置项修改

pull/937/head
Bakadax 2025-05-13 10:58:44 +08:00
parent 3d4830aeb0
commit 864e8386f4
4 changed files with 116 additions and 32 deletions

View File

@ -277,18 +277,40 @@ class BotConfig:
# experimental
enable_friend_chat: bool = False # 是否启用好友聊天
# enable_think_flow: bool = False # 是否启用思考流程
enable_friend_whitelist: bool = True # 是否启用好友白名单
talk_allowed_private = set()
enable_pfc_chatting: bool = False # 是否启用PFC聊天
enable_pfc_reply_checker: bool = True # 是否开启PFC回复检查
pfc_message_buffer_size: int = (
2 # PFC 聊天消息缓冲数量,有利于使聊天节奏更加紧凑流畅,请根据实际 LLM 响应速度进行调整默认2条
)
api_polling_max_retries: int = 3 # 神秘小功能
rename_person: bool = (
True # 是否启用改名工具,可以让麦麦对唯一名进行更改,可能可以更拟人地称呼他人,但是也可能导致记忆混淆的问题
)
# idle_chat
# pfc
pfc_chatting: bool = False # 是否启用PFC聊天该功能仅作用于私聊与回复模式独立
pfc_message_buffer_size: int = 2 # PFC 聊天消息缓冲数量,有利于使聊天节奏更加紧凑流畅,请根据实际 LLM 响应速度进行调整默认2条
pfc_recent_history_display_count: int = 20 # PFC 对话最大可见上下文
# pfc.checker
enable_pfc_reply_checker: bool = True # 是否启用 PFC 的回复检查器
pfc_max_reply_attempts: int = 3 # 发言最多尝试次数
pfc_max_chat_history_for_checker: int = 50 # checker聊天记录最大可见上文长度
# pfc.emotion
pfc_emotion_update_intensity: float = 0.6 # 情绪更新强度
pfc_emotion_history_count: int = 5 # 情绪更新最大可见上下文长度
# pfc.relationship
pfc_relationship_incremental_interval: int = 10# 关系值增值强度
pfc_relationship_incremental_msg_count: int = 10 # 会话中,关系值判断最大可见上下文
pfc_relationship_incremental_default_change: float = 1.0 # 会话中,关系值默认更新值(当 llm 返回错误时默认采用该值)
pfc_relationship_incremental_max_change: float = 5.0 # 会话中,关系值最大可变值
pfc_relationship_final_msg_count: int = 30 # 会话结束时,关系值判断最大可见上下文
pfc_relationship_final_default_change: float = 5.0 # 会话结束时,关系值默认更新值
pfc_relationship_final_max_change: float = 50.0 # 会话结束时,关系值最大可变值
# pfc.fallback
pfc_historical_fallback_exclude_seconds: int = 7200# pfc 翻看聊天记录排除最近时长
# pfc.idle_chat
enable_idle_chat: bool = False # 是否启用 pfc 主动发言
idle_check_interval: int = 10 # 检查间隔10分钟检查一次
min_cooldown: int = 7200 # 最短冷却时间2小时 (7200秒)
@ -724,30 +746,64 @@ class BotConfig:
config.enable_friend_chat = experimental_config.get("enable_friend_chat", config.enable_friend_chat)
# config.enable_think_flow = experimental_config.get("enable_think_flow", config.enable_think_flow)
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.6.2.4"):
config.enable_friend_whitelist = experimental_config.get("enable_friend_whitelist", config.enable_friend_whitelist)
if config.INNER_VERSION in SpecifierSet(">=1.6.1.5"):
config.api_polling_max_retries = experimental_config.get(
"api_polling_max_retries", config.api_polling_max_retries
)
if config.INNER_VERSION in SpecifierSet(">=1.6.2"):
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 '关闭'}")
config.pfc_message_buffer_size = experimental_config.get(
"pfc_message_buffer_size", config.pfc_message_buffer_size
)
if config.INNER_VERSION in SpecifierSet(">=1.6.2.3"):
config.rename_person = experimental_config.get("rename_person", config.rename_person)
def idle_chat(parent: dict):
idle_chat_config = parent["idle_chat"]
if config.INNER_VERSION in SpecifierSet(">=1.6.1.6"):
config.enable_idle_chat = idle_chat_config.get("enable_idle_chat", config.enable_idle_chat)
config.idle_check_interval = idle_chat_config.get("idle_check_interval", config.idle_check_interval)
config.min_cooldown = idle_chat_config.get("min_cooldown", config.min_cooldown)
config.max_cooldown = idle_chat_config.get("max_cooldown", config.max_cooldown)
def pfc(parent: dict):
if config.INNER_VERSION in SpecifierSet(">=1.6.2.4"):
pfc_config = parent.get("pfc", {})
# 解析 [pfc] 下的直接字段
config.pfc_chatting = pfc_config.get("pfc_chatting", config.pfc_chatting)
config.pfc_message_buffer_size = pfc_config.get("pfc_message_buffer_size", config.pfc_message_buffer_size)
config.pfc_recent_history_display_count = pfc_config.get("pfc_recent_history_display_count", config.pfc_recent_history_display_count)
# 解析 [[pfc.checker]] 子表
checker_list = pfc_config.get("checker", [])
if checker_list and isinstance(checker_list, list):
checker_config = checker_list[0] if checker_list else {}
config.enable_pfc_reply_checker = checker_config.get("enable_pfc_reply_checker", config.enable_pfc_reply_checker)
config.pfc_max_reply_attempts = checker_config.get("pfc_max_reply_attempts", config.pfc_max_reply_attempts)
config.pfc_max_chat_history_for_checker = checker_config.get("pfc_max_chat_history_for_checker", config.pfc_max_chat_history_for_checker)
# 解析 [[pfc.emotion]] 子表
emotion_list = pfc_config.get("emotion", [])
if emotion_list and isinstance(emotion_list, list):
emotion_config = emotion_list[0] if emotion_list else {}
config.pfc_emotion_update_intensity = emotion_config.get("pfc_emotion_update_intensity", config.pfc_emotion_update_intensity)
config.pfc_emotion_history_count = emotion_config.get("pfc_emotion_history_count", config.pfc_emotion_history_count)
# 解析 [[pfc.relationship]] 子表
relationship_list = pfc_config.get("relationship", [])
if relationship_list and isinstance(relationship_list, list):
relationship_config = relationship_list[0] if relationship_list else {}
config.pfc_relationship_incremental_interval = relationship_config.get("pfc_relationship_incremental_interval", config.pfc_relationship_incremental_interval)
config.pfc_relationship_incremental_msg_count = relationship_config.get("pfc_relationship_incremental_msg_count", config.pfc_relationship_incremental_msg_count)
config.pfc_relationship_incremental_default_change = relationship_config.get("pfc_relationship_incremental_default_change", config.pfc_relationship_incremental_default_change)
config.pfc_relationship_incremental_max_change = relationship_config.get("pfc_relationship_incremental_max_change", config.pfc_relationship_incremental_max_change)
config.pfc_relationship_final_msg_count = relationship_config.get("pfc_relationship_final_msg_count", config.pfc_relationship_final_msg_count)
config.pfc_relationship_final_default_change = relationship_config.get("pfc_relationship_final_default_change", config.pfc_relationship_final_default_change)
config.pfc_relationship_final_max_change = relationship_config.get("pfc_relationship_final_max_change", config.pfc_relationship_final_max_change)
# 解析 [[pfc.fallback]] 子表
fallback_list = pfc_config.get("fallback", [])
if fallback_list and isinstance(fallback_list, list):
fallback_config = fallback_list[0] if fallback_list else {}
config.pfc_historical_fallback_exclude_seconds = fallback_config.get("pfc_historical_fallback_exclude_seconds", config.pfc_historical_fallback_exclude_seconds)
# 解析 [[pfc.idle_chat]] 子表
idle_chat_list = pfc_config.get("idle_chat", [])
if idle_chat_list and isinstance(idle_chat_list, list):
idle_chat_config = idle_chat_list[0] if idle_chat_list else {}
config.enable_idle_chat = idle_chat_config.get("enable_idle_chat", config.enable_idle_chat)
config.idle_check_interval = idle_chat_config.get("idle_check_interval", config.idle_check_interval)
config.min_cooldown = idle_chat_config.get("min_cooldown", config.min_cooldown)
config.max_cooldown = idle_chat_config.get("max_cooldown", config.max_cooldown)
# 版本表达式:>=1.0.0,<2.0.0
# 允许字段func: method, support: str, notice: str, necessary: bool
@ -783,7 +839,7 @@ class BotConfig:
"normal_chat": {"func": normal_chat, "support": ">=1.6.0", "necessary": False},
"focus_chat": {"func": focus_chat, "support": ">=1.6.0", "necessary": False},
"group_nickname": {"func": group_nickname, "support": ">=1.6.1.1", "necessary": False},
"idle_chat": {"func": idle_chat, "support": ">=1.6.1.6", "necessary": False},
"pfc": {"func": pfc, "support": ">=1.6.2.4", "necessary": False},
}
# 原地修改,将 字符串版本表达式 转换成 版本对象

View File

@ -669,7 +669,7 @@ async def build_chat_history_text(observation_info: ObservationInfo, private_nam
if hasattr(observation_info, "chat_history_str") and observation_info.chat_history_str:
chat_history_text = observation_info.chat_history_str
elif hasattr(observation_info, "chat_history") and observation_info.chat_history:
history_slice = observation_info.chat_history[-20:]
history_slice = observation_info.chat_history[-global_config.pfc_recent_history_display_count:]
chat_history_text = await build_readable_messages(
history_slice, replace_bot_name=True, merge_messages=False, timestamp_mode="relative", read_mark=0.0
)

View File

@ -67,12 +67,14 @@ class ChatBot:
logger.debug(f"用户{userinfo.user_id}被禁止回复")
return
if groupinfo is None:
if groupinfo is None and global_config.enable_friend_whitelist:
logger.trace("检测到私聊消息,检查")
# 好友黑名单拦截
if userinfo.user_id not in global_config.talk_allowed_private:
logger.debug(f"用户{userinfo.user_id}没有私聊权限")
return
elif not global_config.enable_friend_whitelist:
logger.debug("私聊白名单模式未启用,跳过私聊权限检查。")
# 群聊黑名单拦截
if groupinfo is not None and groupinfo.group_id not in global_config.talk_allowed_groups:

View File

@ -1,5 +1,5 @@
[inner]
version = "1.6.2.3"
version = "1.6.2.4"
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
#如果你想要修改配置文件请在修改后将version的值进行变更
@ -149,7 +149,7 @@ consolidation_similarity_threshold = 0.7 # 相似度阈值
consolidation_check_percentage = 0.01 # 检查节点比例
#不希望记忆的词,已经记忆的不会受到影响
memory_ban_words = [
memory_ban_words = [
# "403","张三"
]
@ -198,14 +198,40 @@ enable = true
[experimental] #实验性功能
enable_friend_chat = false # 是否启用好友聊天
enable_friend_whitelist = true # 是否启用好友聊天白名单
talk_allowed_private = [] # 可以回复消息的QQ号
pfc_chatting = false # 是否启用PFC聊天该功能仅作用于私聊与回复模式独立
api_polling_max_retries = 3
enable_pfc_reply_checker = true # 是否启用 PFC 的回复检查器
pfc_message_buffer_size = 2 # PFC 聊天消息缓冲数量,有利于使聊天节奏更加紧凑流畅,请根据实际 LLM 响应速度进行调整默认2条
rename_person = true # 是否启用改名工具,可以让麦麦对唯一名进行更改,可能可以更拟人地称呼他人,但是也可能导致记忆混淆的问题
[idle_chat]
[pfc]
pfc_chatting = false # 是否启用PFC聊天该功能仅作用于私聊与回复模式独立
pfc_message_buffer_size = 2 # PFC 聊天消息缓冲数量,有利于使聊天节奏更加紧凑流畅,请根据实际 LLM 响应速度进行调整默认2条
pfc_recent_history_display_count = 20 # PFC 对话最大可见上下文
[[pfc.checker]]
enable_pfc_reply_checker = true # 是否启用 PFC 的回复检查器
pfc_max_reply_attempts = 3 # 发言最多尝试次数
pfc_max_chat_history_for_checker = 50 # checker聊天记录最大可见上文长度
[[pfc.emotion]]
pfc_emotion_update_intensity = 0.6 # 情绪更新强度
pfc_emotion_history_count = 5 # 情绪更新最大可见上下文长度
[[pfc.relationship]]
pfc_relationship_incremental_interval = 10 # 关系值增值强度
pfc_relationship_incremental_msg_count = 10 # 会话中,关系值判断最大可见上下文
pfc_relationship_incremental_default_change = 1.0 # 会话中,关系值默认更新值(当 llm 返回错误时默认采用该值)
pfc_relationship_incremental_max_change = 5.0 # 会话中,关系值最大可变值
pfc_relationship_final_msg_count = 30 # 会话结束时,关系值判断最大可见上下文
pfc_relationship_final_default_change =5.0 # 会话结束时,关系值默认更新值
pfc_relationship_final_max_change = 50.0 # 会话结束时,关系值最大可变值
[[pfc.fallback]]
pfc_historical_fallback_exclude_seconds = 7200 # pfc 翻看聊天记录排除最近时长
[[pfc.idle_chat]]
enable_idle_chat = false # 是否启用 pfc 主动发言
idle_check_interval = 10 # 检查间隔10分钟检查一次
min_cooldown = 7200 # 最短冷却时间2小时 (7200秒)