优化自动回复对群摘要的结构化利用

This commit is contained in:
liuwei
2026-04-24 16:16:30 +08:00
parent 2b8a5d0ce6
commit 8a813df4a3
4 changed files with 480 additions and 22 deletions

View File

@@ -26,10 +26,16 @@ class GroupProfileResolver:
configured_domain = str(profile.get("knowledge_domain", "general") or "general")
inferred_domain = str(group_memory_profile.get("inferred_domain", "general") or "general")
inferred_style = group_memory_profile.get("style_profile", {}) or {}
structured_summary = group_memory_profile.get("structured_summary", {}) or {}
effective_domain = configured_domain
if configured_domain in {"", "general", "casual"} and inferred_domain not in {"", "general"}:
effective_domain = inferred_domain
# 群摘要不再只是“一段文案”:
# 1. 这里把群长期聚合后的稳定主题一起并到 focus 里;
# 2. 这样群画像后续传给 prompt 时LLM 能拿到更干净的字段,而不是自己再拆 markdown
# 3. 同时只保留去重后的短项,避免群摘要字段把配置 focus 全冲掉。
inferred_focus = list(group_memory_profile.get("focus_topics", []))
inferred_focus.extend(structured_summary.get("stable_topics", []) or [])
merged_focus = []
for item in focus + inferred_focus:
if item and item not in merged_focus:
@@ -63,5 +69,8 @@ class GroupProfileResolver:
"group_memory_domain": inferred_domain,
"group_memory_summary": group_memory_profile.get("summary_text", ""),
"group_memory_sample_count": group_memory_profile.get("message_sample_count", 0),
"group_memory_summary_days": group_memory_profile.get("summary_source_count", 0),
"group_memory_structured": structured_summary,
"group_memory_timeline": group_memory_profile.get("summary_timeline", []) or [],
"group_memory_style": inferred_style,
}