优化自动回复触发逻辑:疑问句默认仅@机器人时触发
变更项: 1. 在 triggers 中新增 question_requires_at 配置,默认要求@机器人才将疑问句升级为 question_trigger。 2. 在 response_planner 中收紧问答兜底策略,疑问句仅在 directed 场景进入模型。 3. 在 config.toml 增加 priority.question_requires_at=true,避免群聊普通疑问句高频误触发。
This commit is contained in:
@@ -86,6 +86,7 @@ recent_followup_window_minutes = 5
|
|||||||
[priority]
|
[priority]
|
||||||
at_bot = 1.0
|
at_bot = 1.0
|
||||||
explicit_question = 0.95
|
explicit_question = 0.95
|
||||||
|
question_requires_at = true
|
||||||
followup = 0.90
|
followup = 0.90
|
||||||
social_call = 0.65
|
social_call = 0.65
|
||||||
light_social = 0.45
|
light_social = 0.45
|
||||||
|
|||||||
@@ -35,7 +35,10 @@ class ResponsePlanner:
|
|||||||
if trigger.get("is_question") and conversation_hints.get("has_recent_human_solver") and flow_state == "idle":
|
if trigger.get("is_question") and conversation_hints.get("has_recent_human_solver") and flow_state == "idle":
|
||||||
return False
|
return False
|
||||||
if trigger.get("is_question"):
|
if trigger.get("is_question"):
|
||||||
return directed or trigger.get("priority", 0) >= 0.9 or flow_state in {"warming", "engaged", "deep_engaged"}
|
# 策略收敛:
|
||||||
|
# 问答类回复只在“明确指向机器人”时触发,防止把群友之间的疑问句当作对机器人提问。
|
||||||
|
# 这层作为兜底,即使上游触发器未来被调整,也不会回到“疑问句高频抢答”的状态。
|
||||||
|
return directed
|
||||||
if trigger.get("is_followup"):
|
if trigger.get("is_followup"):
|
||||||
if directed:
|
if directed:
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ class TriggerRouter:
|
|||||||
def __init__(self, config: Dict):
|
def __init__(self, config: Dict):
|
||||||
self.config = config or {}
|
self.config = config or {}
|
||||||
self.topic_keywords = [str(item).lower() for item in self.config.get("focus", [])]
|
self.topic_keywords = [str(item).lower() for item in self.config.get("focus", [])]
|
||||||
|
# 业务约束说明:
|
||||||
|
# 1) 群内大量“疑问句”其实是群友之间的随口沟通,不是向机器人求助;
|
||||||
|
# 2) 如果把所有疑问句都当成问答触发,会显著提升误触发率,导致“高频答非所问”;
|
||||||
|
# 3) 因此默认要求“必须@机器人”才把疑问句升级为咨询触发,避免抢话。
|
||||||
|
self.question_requires_at = bool(self.config.get("question_requires_at", True))
|
||||||
|
|
||||||
def route(self, message: Dict, memory_hints: Dict, conversation_hints: Dict | None = None) -> TriggerResult:
|
def route(self, message: Dict, memory_hints: Dict, conversation_hints: Dict | None = None) -> TriggerResult:
|
||||||
conversation_hints = conversation_hints or {}
|
conversation_hints = conversation_hints or {}
|
||||||
@@ -47,11 +52,17 @@ class TriggerRouter:
|
|||||||
result.is_directed = True
|
result.is_directed = True
|
||||||
result.reasons.append("is_at")
|
result.reasons.append("is_at")
|
||||||
if self._is_question(content):
|
if self._is_question(content):
|
||||||
if result.priority < float(self.config.get("explicit_question", 0.95)):
|
# 这里把“是否是疑问句”和“是否应该按咨询触发”拆开处理:
|
||||||
result.trigger_type = "question_trigger"
|
# - 疑问句形态用于日志观察;
|
||||||
result.priority = float(self.config.get("explicit_question", 0.95))
|
# - 触发升级只在满足定向条件时才生效,避免群聊里普通问句频繁触发机器人。
|
||||||
result.is_question = True
|
if self.question_requires_at and not message.get("is_at"):
|
||||||
result.reasons.append("question")
|
result.reasons.append("question_detected_but_not_at")
|
||||||
|
else:
|
||||||
|
if result.priority < float(self.config.get("explicit_question", 0.95)):
|
||||||
|
result.trigger_type = "question_trigger"
|
||||||
|
result.priority = float(self.config.get("explicit_question", 0.95))
|
||||||
|
result.is_question = True
|
||||||
|
result.reasons.append("question")
|
||||||
if memory_hints.get("is_followup"):
|
if memory_hints.get("is_followup"):
|
||||||
if result.priority < float(self.config.get("followup", 0.90)):
|
if result.priority < float(self.config.get("followup", 0.90)):
|
||||||
result.trigger_type = "followup_trigger"
|
result.trigger_type = "followup_trigger"
|
||||||
|
|||||||
Reference in New Issue
Block a user