改进focus模式下的回复逻辑,理论上现在focus模式下在bot被@ / 提及 时应该会回复了

采用的是在focus模式下移除no_reply动作的方式
同步更新bot_config_template里面的注释
This commit is contained in:
Furina-1013-create
2025-08-19 22:15:13 +08:00
committed by Windpicker-owo
parent 4a3fc57e6f
commit 00eacc7570
3 changed files with 52 additions and 19 deletions

View File

@@ -28,7 +28,7 @@
- 大工程
· 增加一个基于Rust后端daisyui为前端的启动器以下是详细功能
· 增加一个基于Rust后端daisyui为(装饰的)前端的启动器,以下是详细功能
- 一个好看的ui
- 支持所有的非core的插件管理
- 支持一键部署所有环境

View File

@@ -570,21 +570,53 @@ class HeartFChatting:
await self.relationship_builder.build_relation()
await self.expression_learner.trigger_learning_for_chat()
# 群印象构建:仅在群聊中触发
# if self.chat_stream.group_info and getattr(self.chat_stream.group_info, "group_id", None):
# await self.group_relationship_manager.build_relation(
# chat_id=self.stream_id,
# platform=self.chat_stream.platform
# )
available_actions = {}
# 第一步:动作修改
with Timer("动作修改", cycle_timers):
try:
await self.action_modifier.modify_actions()
available_actions = self.action_manager.get_using_actions()
except Exception as e:
logger.error(f"{self.log_prefix} 动作修改失败: {e}")
if random.random() > global_config.chat.focus_value and mode == ChatMode.FOCUS:
#如果激活度没有激活并且聊天活跃度低有可能不进行plan相当于不在电脑前不进行认真思考
actions = [
{
"action_type": "no_reply",
"reasoning": "选择不回复",
"action_data": {},
# 在focus模式下如果你的bot被@/提到了那么就移除no_reply动作
is_mentioned_bot = message_data.get("is_mentioned", False)
at_bot_mentioned = (global_config.chat.mentioned_bot_inevitable_reply and is_mentioned_bot) or \
(global_config.chat.at_bot_inevitable_reply and is_mentioned_bot)
if self.loop_mode == ChatMode.FOCUS and at_bot_mentioned and "no_reply" in available_actions:
logger.info(f"{self.log_prefix} Focus模式下检测到@或提及bot移除no_reply动作以确保回复")
available_actions = {k: v for k, v in available_actions.items() if k != "no_reply"} # 用一个循环来移除no_reply
# 检查是否在normal模式下没有可用动作除了reply相关动作
skip_planner = False
if self.loop_mode == ChatMode.NORMAL:
# 过滤掉reply相关的动作检查是否还有其他动作
non_reply_actions = {
k: v for k, v in available_actions.items() if k not in ["reply", "no_reply", "no_action"]
}
if not non_reply_actions:
skip_planner = True
logger.info(f"{self.log_prefix} Normal模式下没有可用动作直接回复")
# 直接设置为reply动作
action_type = "reply"
reasoning = ""
action_data = {"loop_start_time": loop_start_time}
is_parallel = False
# 构建plan_result用于后续处理
plan_result = {
"action_result": {
"action_type": action_type,
"action_data": action_data,
"reasoning": reasoning,
"timestamp": time.time(),
"is_parallel": is_parallel,
},
"action_prompt": "",
}
]
else:

View File

@@ -1,5 +1,5 @@
[inner]
version = "6.3.8"
version = "6.3.9"
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
#如果你想要修改配置文件请递增version的值
@@ -104,8 +104,9 @@ max_context_size = 25 # 上下文长度
thinking_timeout = 40 # 麦麦一次回复最长思考规划时间超过这个时间的思考会放弃往往是api反应太慢
replyer_random_probability = 0.5 # 首要replyer模型被选择的概率
mentioned_bot_inevitable_reply = true # 提及 bot 大概率回复
at_bot_inevitable_reply = true # @bot 或 提及bot 大概率回复
mentioned_bot_inevitable_reply = true # 提及 bot 必然回复
at_bot_inevitable_reply = true # @bot 或 提及bot 必然回复
# 兼容normal、focus在focus模式下为强制移除no_reply动作
focus_value_adjust = [
["", "8:00,1", "12:00,0.8", "18:00,1", "01:00,0.3"],
@@ -166,8 +167,8 @@ ban_msgs_regex = [
]
[anti_prompt_injection] # LLM反注入系统配置
enabled = true # 是否启用反注入系统
enabled_rules = true # 是否启用规则检测
enabled = false # 是否启用反注入系统
enabled_rules = false # 是否启用规则检测
enabled_LLM = false # 是否启用LLM检测
process_mode = "lenient" # 处理模式strict(严格模式,直接丢弃), lenient(宽松模式,消息加盾), auto(自动模式), counter_attack(反击模式使用LLM反击并丢弃消息)