From 298a74da644fb5544b6f14ba4bbbe0f8ad3ff1f4 Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Fri, 12 Sep 2025 00:06:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E7=AD=89=E5=BE=85=E5=85=9C=E5=BA=95=EF=BC=9B=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8F=90=E5=8F=8A=E5=BF=85=E5=9B=9E=EF=BC=9B=E7=A7=BB=E9=99=A4?= =?UTF-8?q?subplan=E6=A8=A1=E5=9E=8B=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/heart_flow/heartFC_chat.py | 32 +++++++++++++++++++++++------ src/chat/planner_actions/planner.py | 10 +-------- src/config/api_ada_configs.py | 3 --- src/config/official_configs.py | 3 +++ template/bot_config_template.toml | 3 ++- template/model_config_template.toml | 7 +------ 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/chat/heart_flow/heartFC_chat.py b/src/chat/heart_flow/heartFC_chat.py index 0c5cd23f..68939ca7 100644 --- a/src/chat/heart_flow/heartFC_chat.py +++ b/src/chat/heart_flow/heartFC_chat.py @@ -199,7 +199,7 @@ class HeartFChatting: # !处理no_reply_until_call逻辑 if self.no_reply_until_call: for message in recent_messages_list: - if message.is_mentioned or message.is_at: + if message.is_mentioned or message.is_at or len(recent_messages_list) >= 8 or time.time() - self.last_read_time > 600: self.no_reply_until_call = False break # 没有提到,继续保持沉默 @@ -333,6 +333,31 @@ class HeartFChatting: loop_start_time=self.last_read_time, available_actions=available_actions, ) + + + # !此处使at或者提及必定回复 + metioned_message = None + for message in recent_messages_list: + if (message.is_mentioned or message.is_at) and global_config.chat.mentioned_bot_reply: + metioned_message = message + + has_reply = False + for action in action_to_use_info: + if action.action_type == "reply": + has_reply =True + break + + if not has_reply and metioned_message: + action_to_use_info.append( + ActionPlannerInfo( + action_type="reply", + reasoning="有人提到了你,进行回复", + action_data={}, + action_message=metioned_message, + available_actions=available_actions, + ) + ) + # 3. 并行执行所有动作 action_tasks = [ @@ -350,18 +375,15 @@ class HeartFChatting: reply_text_from_reply = "" action_success = False action_reply_text = "" - action_command = "" for i, result in enumerate(results): if isinstance(result, BaseException): logger.error(f"{self.log_prefix} 动作执行异常: {result}") continue - _cur_action = action_to_use_info[i] if result["action_type"] != "reply": action_success = result["success"] action_reply_text = result["reply_text"] - action_command = result.get("command", "") elif result["action_type"] == "reply": if result["success"]: reply_loop_info = result["loop_info"] @@ -377,7 +399,6 @@ class HeartFChatting: loop_info["loop_action_info"].update( { "action_taken": action_success, - "command": action_command, "taken_time": time.time(), } ) @@ -391,7 +412,6 @@ class HeartFChatting: "loop_action_info": { "action_taken": action_success, "reply_text": action_reply_text, - "command": action_command, "taken_time": time.time(), }, } diff --git a/src/chat/planner_actions/planner.py b/src/chat/planner_actions/planner.py index 7d9f5767..6f967af9 100644 --- a/src/chat/planner_actions/planner.py +++ b/src/chat/planner_actions/planner.py @@ -71,14 +71,6 @@ no_reply_until_call "action": "no_reply_until_call", }} -wait_time -动作描述: -沉默等待时间,等待一段时间后回复 -{{ - "action": "wait_time", - "time":"等待时间", -}} - {action_options_text} 请选择合适的action,并说明触发action的消息id和选择该action的原因。消息id格式:m+数字 @@ -175,7 +167,7 @@ class ActionPlanner: try: action = action_json.get("action", "no_action") reasoning = action_json.get("reason", "未提供原因") - action_data = {key: value for key, value in action_json.items() if key not in ["action", "reasoning"]} + action_data = {key: value for key, value in action_json.items() if key not in ["action", "reason"]} # 非no_action动作需要target_message_id target_message = None diff --git a/src/config/api_ada_configs.py b/src/config/api_ada_configs.py index 60dfd419..bd881bfd 100644 --- a/src/config/api_ada_configs.py +++ b/src/config/api_ada_configs.py @@ -117,9 +117,6 @@ class ModelTaskConfig(ConfigBase): planner: TaskConfig """规划模型配置""" - planner_small: TaskConfig - """副规划模型配置""" - embedding: TaskConfig """嵌入模型配置""" diff --git a/src/config/official_configs.py b/src/config/official_configs.py index b4cdc844..48bce05b 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -72,6 +72,9 @@ class ChatConfig(ConfigBase): planner_size: float = 1.5 """副规划器大小,越小,麦麦的动作执行能力越精细,但是消耗更多token,调大可以缓解429类错误""" + mentioned_bot_reply: bool = True + """是否启用提及必回复""" + at_bot_inevitable_reply: float = 1 """@bot 必然回复,1为100%回复,0为不额外增幅""" diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index 726d6fe2..5f6eba1c 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -50,7 +50,8 @@ expression_groups = [ [chat] #麦麦的聊天设置 -talk_value = 1.5 +talk_value = 1 +mentioned_bot_reply = true # 是否启用提及必回复 max_context_size = 20 # 上下文长度 [relationship] diff --git a/template/model_config_template.toml b/template/model_config_template.toml index 6b85cea3..76f09955 100644 --- a/template/model_config_template.toml +++ b/template/model_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "1.5.0" +version = "1.6.0" # 配置文件版本号迭代规则同bot_config.toml @@ -113,11 +113,6 @@ model_list = ["siliconflow-deepseek-v3"] temperature = 0.3 max_tokens = 800 -[model_task_config.planner_small] #副决策:负责决定麦麦该做什么的模型 -model_list = ["qwen3-30b"] -temperature = 0.3 -max_tokens = 800 - [model_task_config.emotion] #负责麦麦的情绪变化 model_list = ["qwen3-30b"] temperature = 0.7