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:
|
||||
|
||||
Reference in New Issue
Block a user