feat(relationship): 重构关系信息提取系统并集成聊天流印象

- 在 RelationshipFetcher 中添加 build_chat_stream_impression 方法,支持聊天流印象信息构建
- 扩展数据库模型,为 ChatStreams 表添加聊天流印象相关字段(stream_impression_text、stream_chat_style、stream_topic_keywords、stream_interest_score)
- 为 UserRelationships 表添加用户别名和偏好关键词字段(user_aliases、preference_keywords)
- 在 DefaultReplyer、Prompt 和 S4U PromptBuilder 中集成用户关系信息和聊天流印象的组合输出
- 重构工具系统,为 BaseTool 添加 chat_stream 参数支持上下文感知
- 移除旧的 ChatterRelationshipTracker 及相关关系追踪逻辑,统一使用评分API
- 在 AffinityChatterPlugin 中添加 UserProfileTool 和 ChatStreamImpressionTool 支持
- 优化计划执行器,移除关系追踪相关代码并改进错误处理

BREAKING CHANGE: 移除了 ChatterRelationshipTracker 类及相关的关系追踪功能,现在统一使用 scoring_api 进行关系管理。BaseTool 构造函数现在需要 chat_stream 参数。
This commit is contained in:
Windpicker-owo
2025-10-30 16:58:26 +08:00
parent cfa642cf0a
commit ea7c1f22f9
17 changed files with 1264 additions and 989 deletions

View File

@@ -1109,8 +1109,18 @@ class Prompt:
logger.warning(f"未找到用户 {sender} 的ID跳过信息提取")
return f"你完全不认识{sender}不理解ta的相关信息。"
# 使用关系提取器构建关系信息
return await relationship_fetcher.build_relation_info(person_id, points_num=5)
# 使用关系提取器构建用户关系信息和聊天流印象
user_relation_info = await relationship_fetcher.build_relation_info(person_id, points_num=5)
stream_impression = await relationship_fetcher.build_chat_stream_impression(chat_id)
# 组合两部分信息
info_parts = []
if user_relation_info:
info_parts.append(user_relation_info)
if stream_impression:
info_parts.append(stream_impression)
return "\n\n".join(info_parts) if info_parts else ""
def _get_default_result_for_task(self, task_name: str) -> dict[str, Any]:
"""为超时或失败的异步构建任务提供一个安全的默认返回值.