feat(affinity-flow): 重构兴趣度评分系统为智能embedding匹配

- 移除传统关键词匹配方式,改用embedding计算智能兴趣匹配度
- 添加异步方法支持机器人兴趣管理器的智能匹配计算
- 增加详细的日志记录和错误处理机制
- 添加数据库关键词提取和降级处理逻辑
- 集成智能兴趣系统初始化到人设构建流程
- 防止回复自身消息的死循环保护机制

BREAKING CHANGE: 兴趣匹配评分机制完全重构,从基于关键词的硬编码匹配改为基于embedding的智能匹配,需要重新初始化兴趣系统
This commit is contained in:
Windpicker-owo
2025-09-16 22:55:38 +08:00
parent cdb2344e41
commit 974de4d25d
9 changed files with 1312 additions and 97 deletions

View File

@@ -298,6 +298,26 @@ class PersonInfo(Base):
)
class BotPersonalityInterests(Base):
"""机器人人格兴趣标签模型"""
__tablename__ = "bot_personality_interests"
id = Column(Integer, primary_key=True, autoincrement=True)
personality_id = Column(get_string_field(100), nullable=False, index=True)
personality_description = Column(Text, nullable=False)
interest_tags = Column(Text, nullable=False) # JSON格式存储的兴趣标签列表
embedding_model = Column(get_string_field(100), nullable=False, default="text-embedding-ada-002")
version = Column(Integer, nullable=False, default=1)
last_updated = Column(DateTime, nullable=False, default=datetime.datetime.now, index=True)
__table_args__ = (
Index("idx_botpersonality_personality_id", "personality_id"),
Index("idx_botpersonality_version", "version"),
Index("idx_botpersonality_last_updated", "last_updated"),
)
class Memory(Base):
"""记忆模型"""