use richer member memory in xiaoniu replies
This commit is contained in:
@@ -69,16 +69,49 @@ class ContextBuilder:
|
||||
meta = member_context.get("meta", {}) or {}
|
||||
topics = member_context.get("topics_of_interest", []) or []
|
||||
recent_focus = member_context.get("recent_focus", []) or []
|
||||
skills = ContextBuilder._stringify_items(meta.get("skill_profile", []), 5)
|
||||
stable_traits = ContextBuilder._stringify_items(meta.get("stable_traits", []), 4)
|
||||
habits = ContextBuilder._stringify_items(meta.get("habit_patterns", []), 4)
|
||||
reply_prefs = ContextBuilder._stringify_items(meta.get("long_term_reply_preferences", []), 4)
|
||||
recent_state = ContextBuilder._stringify_items(meta.get("recent_state", []), 4)
|
||||
reply_taboos = ContextBuilder._stringify_items(meta.get("reply_taboos", []), 3)
|
||||
lines = [
|
||||
f"成员摘要:{member_context.get('summary_text', '')}".strip(),
|
||||
f"互动风格:{member_context.get('interaction_style', '')}".strip(),
|
||||
f"回复偏好:{member_context.get('response_style_hint', '')}".strip(),
|
||||
f"长期主题:{', '.join(topics[:5])}" if topics else "",
|
||||
f"近期关注:{', '.join(recent_focus[:4])}" if recent_focus else "",
|
||||
f"技能侧重点:{skills}" if skills else "",
|
||||
f"稳定特征:{stable_traits}" if stable_traits else "",
|
||||
f"习惯模式:{habits}" if habits else "",
|
||||
f"长期回复偏好:{reply_prefs}" if reply_prefs else "",
|
||||
f"近期状态:{recent_state}" if recent_state else "",
|
||||
f"气质倾向:{meta.get('temperament_tendency', '')}".strip(),
|
||||
f"群内角色:{meta.get('group_role', '')}".strip(),
|
||||
f"回复禁忌:{reply_taboos}" if reply_taboos else "",
|
||||
]
|
||||
return "\n".join([line for line in lines if line])
|
||||
|
||||
@staticmethod
|
||||
def _stringify_items(items: List | str, limit: int) -> str:
|
||||
if isinstance(items, str):
|
||||
return items.strip()
|
||||
values: List[str] = []
|
||||
for item in items[:limit]:
|
||||
if isinstance(item, dict):
|
||||
value = str(
|
||||
item.get("name")
|
||||
or item.get("label")
|
||||
or item.get("value")
|
||||
or item.get("text")
|
||||
or ""
|
||||
).strip()
|
||||
else:
|
||||
value = str(item or "").strip()
|
||||
if value and value not in values:
|
||||
values.append(value)
|
||||
return ", ".join(values)
|
||||
|
||||
@staticmethod
|
||||
def _build_vector_memory_prompt(vector_memories: List[Dict]) -> str:
|
||||
if not vector_memories:
|
||||
|
||||
@@ -414,16 +414,16 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
speaker_name = str(context.get("speaker_name_clean", "") or "").strip()
|
||||
trigger_type = str(context.get("trigger_type", "none") or "none")
|
||||
address_style = str(group_profile.get("address_style", "低频称呼,默认直接接话") or "低频称呼,默认直接接话")
|
||||
name_rule = f"13. 称呼风格遵守当前群的要求:{address_style}。默认不要带对方昵称,直接接话。"
|
||||
name_rule = f"15. 称呼风格遵守当前群的要求:{address_style}。默认不要带对方昵称,直接接话。"
|
||||
if speaker_name and trigger_type in {"at_trigger", "directed_question", "social_call"}:
|
||||
name_rule = (
|
||||
f"13. 称呼风格遵守当前群的要求:{address_style}。"
|
||||
f"15. 称呼风格遵守当前群的要求:{address_style}。"
|
||||
f"这次可以视场景偶尔自然带一下对方称呼“{speaker_name}”,但不是必须。"
|
||||
f"如果要带,位置不要固定在句首,也不要每次都带,更不要像客服点名或脚本播报。"
|
||||
)
|
||||
extra_rule = ""
|
||||
if group_profile.get("knowledge_domain") == "dota":
|
||||
extra_rule = "14. 如果对方问的是 Dota2 最近战绩、实时战绩、最新对局数据,你要委婉说明现在没法提取这类数据,只能聊理解和常识,不要硬编。\n"
|
||||
extra_rule = "16. 如果对方问的是 Dota2 最近战绩、实时战绩、最新对局数据,你要委婉说明现在没法提取这类数据,只能聊理解和常识,不要硬编。\n"
|
||||
return (
|
||||
f"当前群聊消息:\n{recent_text}\n\n"
|
||||
f"当前发言:{context.get('current_message', '')}\n"
|
||||
@@ -449,6 +449,8 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
f"10. 把这次回复当作真人聊天里的第一反应,先只给第一层结论,不要主动补第二层解释。\n"
|
||||
f"11. 如果一句话已经够了,就立刻停,不要为了完整而补充。\n"
|
||||
f"12. 回答时优先服从当前群画像里的知识域和回答风格,不要跨领域乱发挥。\n"
|
||||
f"13. 如果成员画像里有对当前问题明显相关的长期兴趣、技能侧重点、回复偏好或近期状态,可以轻微利用这些信息调节措辞、切入角度和详略,但要像你本来就记得这个人,不要表现得像在背资料。\n"
|
||||
f"14. 如果成员画像里出现回复禁忌、对某种沟通方式明显反感,尽量避开那种说法。\n"
|
||||
f"{name_rule}\n"
|
||||
f"{extra_rule}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user