优化 ai_auto_response 模型侧定向辱骂响应策略
- 增加 directed abuse 场景识别,只作为模型输入信号,不做本地硬编码回复 - 在触发与规划层为定向挑衅场景单独标记,并强制走 social_short 短回复模式 - 将 abuse_directed 信号写入 Dify control,帮助模型稳定识别被点名挑衅场景 - 优化 Dify 主提示词与保守降级提示词,要求 abuse_directed 时默认短回且不要空掉 - 保持回复仍由模型生成,避免本地模板化回复暴露机器人痕迹
This commit is contained in:
@@ -43,6 +43,7 @@ from .core.reply_formatter import finalize_reply, preview_text
|
||||
from .safety.dedup import DedupManager
|
||||
from .safety.filters import (
|
||||
is_coding_work_request,
|
||||
is_directed_abuse,
|
||||
is_prompt_attack,
|
||||
is_targeting_other_user,
|
||||
should_ignore,
|
||||
@@ -504,6 +505,12 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
image_context=image_context,
|
||||
)
|
||||
context["coding_work_request"] = coding_work_request
|
||||
# 这个标记只作为模型输入信号,不在本地直接生成固定回复。
|
||||
# 这样既能让模型知道“这次是在被点名挑衅”,又不会暴露出模板式机器人痕迹。
|
||||
context["abuse_directed"] = is_directed_abuse(
|
||||
content,
|
||||
directed=bool(trigger.is_directed) or bool(is_at),
|
||||
)
|
||||
|
||||
prompt_strategy = self._build_prompt_strategy(context=context, memory_hints=memory_hints)
|
||||
context["prompt_strategy"] = prompt_strategy
|
||||
@@ -855,6 +862,8 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
control_lines.append("is_at=true")
|
||||
if context.get("is_directed"):
|
||||
control_lines.append("is_directed=true")
|
||||
if context.get("abuse_directed"):
|
||||
control_lines.append("abuse_directed=true")
|
||||
if files:
|
||||
control_lines.append(f"images={len(files)}")
|
||||
return {
|
||||
@@ -892,6 +901,8 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
"能半句说完就别写整句,少解释、少复述、少总结。",
|
||||
"哪怕短回复,也尽量保留一点人格味道,别压成纯功能性短句。",
|
||||
]
|
||||
if context.get("abuse_directed"):
|
||||
lines.append("这次如果是对你的人身挑衅或辱骂,默认短短顶回去,不要沉默,不要长篇说教,也不要爆粗。")
|
||||
if mode in {"robotics", "openclaw"}:
|
||||
lines.append("当前技术群场景:优先结论+一个关键排查点,少铺垫,避免夸张亲昵称呼。")
|
||||
length_rule = str(context.get("reply_mode", "") or "").strip()
|
||||
|
||||
Reference in New Issue
Block a user