增加常驻群长期记忆与成员轻画像输入
This commit is contained in:
@@ -911,8 +911,12 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
memory_hints=memory_hints,
|
||||
)
|
||||
persona = self._compose_dify_persona_text(group_profile, context)
|
||||
group_profile_parts = [
|
||||
self._string_block("群长期记忆(常驻)", context.get("group_long_memory_prompt", "")),
|
||||
self._string_block("群当前画像", context.get("group_profile_prompt", "")),
|
||||
]
|
||||
group_profile_text = self._compact_text(
|
||||
str(context.get("group_profile_prompt", "") or "").strip() or "当前群没有特殊画像。",
|
||||
"\n\n".join([part for part in group_profile_parts if part]).strip() or "当前群没有特殊画像。",
|
||||
max_chars=int(self.prompt_compact_config.get("group_profile_max_chars", 220) or 220),
|
||||
max_lines=int(self.prompt_compact_config.get("group_profile_max_lines", 6) or 6),
|
||||
)
|
||||
@@ -945,6 +949,14 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
max_lines=int(self.prompt_compact_config.get("context_max_lines", 10) or 10),
|
||||
)
|
||||
|
||||
# 成员画像拆成两层:
|
||||
# 1. 常驻轻画像:每次都带,帮助模型理解这个人的提问方式、风格和切口;
|
||||
# 2. 定向增强画像:只有明确 @ / 强定向 / followup 时再额外补,避免平时过度套人设。
|
||||
member_profile_brief_text = self._compact_text(
|
||||
str(context.get("member_profile_brief_prompt", "") or ""),
|
||||
max_chars=int(self.prompt_compact_config.get("member_profile_brief_max_chars", 260) or 260),
|
||||
max_lines=int(self.prompt_compact_config.get("member_profile_brief_max_lines", 6) or 6),
|
||||
)
|
||||
at_member_profile_text = ""
|
||||
if bool(prompt_strategy.get("allow_member_memory")):
|
||||
at_member_profile_text = self._compact_text(
|
||||
@@ -962,6 +974,7 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
member_memory_text = self._remove_overlap_lines(member_memory_text, at_member_profile_text)
|
||||
|
||||
memory_parts = [
|
||||
self._string_block("当前发言人画像(常驻)", member_profile_brief_text),
|
||||
self._string_block("本次@发起者画像(优先)", at_member_profile_text),
|
||||
self._string_block("成员记忆", member_memory_text),
|
||||
self._string_block(
|
||||
@@ -1214,7 +1227,11 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
}
|
||||
|
||||
allow_member_memory = strong_directed or is_followup or returning_state in {"returning_member", "long_absent_member"}
|
||||
allow_social_memory = is_question_like and strong_directed
|
||||
# 群关系记忆继续按需开放,但问答模式下不再必须“强定向”才允许:
|
||||
# 1. 用户希望回答能带上群里的长期背景和互动关系;
|
||||
# 2. 关系记忆仍会经过相关性过滤,所以放宽入口不会直接把无关关系灌进去;
|
||||
# 3. 这样技术问答里也更容易利用“谁经常和谁接话、谁常问哪类问题”的弱背景。
|
||||
allow_social_memory = is_question_like
|
||||
allow_group_facts = reply_mode == "qa_with_context"
|
||||
allow_vector_memory = reply_mode == "qa_with_context" or returning_state == "long_absent_member"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user