ruff,私聊视为提及了bot
This commit is contained in:
@@ -165,10 +165,15 @@ class ActionManager:
|
||||
# 通过chat_id获取chat_stream
|
||||
chat_manager = get_chat_manager()
|
||||
chat_stream = chat_manager.get_stream(chat_id)
|
||||
|
||||
|
||||
if not chat_stream:
|
||||
logger.error(f"{log_prefix} 无法找到chat_id对应的chat_stream: {chat_id}")
|
||||
return {"action_type": action_name, "success": False, "reply_text": "", "error": "chat_stream not found"}
|
||||
return {
|
||||
"action_type": action_name,
|
||||
"success": False,
|
||||
"reply_text": "",
|
||||
"error": "chat_stream not found",
|
||||
}
|
||||
|
||||
if action_name == "no_action":
|
||||
return {"action_type": "no_action", "success": True, "reply_text": "", "command": ""}
|
||||
@@ -177,7 +182,7 @@ class ActionManager:
|
||||
# 直接处理no_reply逻辑,不再通过动作系统
|
||||
reason = reasoning or "选择不回复"
|
||||
logger.info(f"{log_prefix} 选择不回复,原因: {reason}")
|
||||
|
||||
|
||||
# 存储no_reply信息到数据库
|
||||
await database_api.store_action_info(
|
||||
chat_stream=chat_stream,
|
||||
@@ -396,7 +401,7 @@ class ActionManager:
|
||||
}
|
||||
|
||||
return loop_info, reply_text, cycle_timers
|
||||
|
||||
|
||||
async def send_response(self, chat_stream, reply_set, thinking_start_time, message_data) -> str:
|
||||
"""
|
||||
发送回复内容的具体实现
|
||||
@@ -471,4 +476,4 @@ class ActionManager:
|
||||
typing=True,
|
||||
)
|
||||
|
||||
return reply_text
|
||||
return reply_text
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
PlanGenerator: 负责搜集和汇总所有决策所需的信息,生成一个未经筛选的“原始计划” (Plan)。
|
||||
"""
|
||||
|
||||
import time
|
||||
from typing import Dict
|
||||
|
||||
@@ -35,6 +36,7 @@ class PlanGenerator:
|
||||
chat_id (str): 当前聊天的 ID。
|
||||
"""
|
||||
from src.chat.planner_actions.action_manager import ActionManager
|
||||
|
||||
self.chat_id = chat_id
|
||||
# 注意:ActionManager 可能需要根据实际情况初始化
|
||||
self.action_manager = ActionManager()
|
||||
@@ -52,7 +54,7 @@ class PlanGenerator:
|
||||
Plan: 一个填充了初始上下文信息的 Plan 对象。
|
||||
"""
|
||||
_is_group_chat, chat_target_info_dict = get_chat_type_and_target_info(self.chat_id)
|
||||
|
||||
|
||||
target_info = None
|
||||
if chat_target_info_dict:
|
||||
target_info = TargetPersonInfo(**chat_target_info_dict)
|
||||
@@ -65,7 +67,6 @@ class PlanGenerator:
|
||||
)
|
||||
chat_history = [DatabaseMessages(**msg) for msg in chat_history_raw]
|
||||
|
||||
|
||||
plan = Plan(
|
||||
chat_id=self.chat_id,
|
||||
mode=mode,
|
||||
@@ -86,10 +87,10 @@ class PlanGenerator:
|
||||
Dict[str, "ActionInfo"]: 一个字典,键是动作名称,值是 ActionInfo 对象。
|
||||
"""
|
||||
current_available_actions_dict = self.action_manager.get_using_actions()
|
||||
all_registered_actions: Dict[str, ActionInfo] = component_registry.get_components_by_type( # type: ignore
|
||||
all_registered_actions: Dict[str, ActionInfo] = component_registry.get_components_by_type( # type: ignore
|
||||
ComponentType.ACTION
|
||||
)
|
||||
|
||||
|
||||
current_available_actions = {}
|
||||
for action_name in current_available_actions_dict:
|
||||
if action_name in all_registered_actions:
|
||||
@@ -99,16 +100,13 @@ class PlanGenerator:
|
||||
name="reply",
|
||||
component_type=ComponentType.ACTION,
|
||||
description="系统级动作:选择回复消息的决策",
|
||||
action_parameters={
|
||||
"content": "回复的文本内容",
|
||||
"reply_to_message_id": "要回复的消息ID"
|
||||
},
|
||||
action_parameters={"content": "回复的文本内容", "reply_to_message_id": "要回复的消息ID"},
|
||||
action_require=[
|
||||
"你想要闲聊或者随便附和",
|
||||
"当用户提到你或艾特你时",
|
||||
"当需要回答用户的问题时",
|
||||
"当你想参与对话时",
|
||||
"当用户分享有趣的内容时"
|
||||
"当用户分享有趣的内容时",
|
||||
],
|
||||
activation_type=ActionActivationType.ALWAYS,
|
||||
activation_keywords=[],
|
||||
@@ -131,4 +129,4 @@ class PlanGenerator:
|
||||
)
|
||||
current_available_actions["no_reply"] = no_reply_info
|
||||
current_available_actions["reply"] = reply_info
|
||||
return current_available_actions
|
||||
return current_available_actions
|
||||
|
||||
@@ -109,9 +109,7 @@ class ActionPlanner:
|
||||
self.planner_stats["failed_plans"] += 1
|
||||
return [], None
|
||||
|
||||
async def _enhanced_plan_flow(
|
||||
self, mode: ChatMode, context: StreamContext
|
||||
) -> Tuple[List[Dict], Optional[Dict]]:
|
||||
async def _enhanced_plan_flow(self, mode: ChatMode, context: StreamContext) -> Tuple[List[Dict], Optional[Dict]]:
|
||||
"""执行增强版规划流程"""
|
||||
try:
|
||||
# 1. 生成初始 Plan
|
||||
@@ -137,7 +135,9 @@ class ActionPlanner:
|
||||
# 检查兴趣度是否达到非回复动作阈值
|
||||
non_reply_action_interest_threshold = global_config.affinity_flow.non_reply_action_interest_threshold
|
||||
if score < non_reply_action_interest_threshold:
|
||||
logger.info(f"❌ 兴趣度不足非回复动作阈值: {score:.3f} < {non_reply_action_interest_threshold:.3f},直接返回no_action")
|
||||
logger.info(
|
||||
f"❌ 兴趣度不足非回复动作阈值: {score:.3f} < {non_reply_action_interest_threshold:.3f},直接返回no_action"
|
||||
)
|
||||
logger.info(f"📊 最低要求: {non_reply_action_interest_threshold:.3f}")
|
||||
# 直接返回 no_action
|
||||
from src.common.data_models.info_data_model import ActionPlannerInfo
|
||||
|
||||
Reference in New Issue
Block a user