feat: 批量生成文本embedding,优化兴趣匹配计算逻辑,支持消息兴趣值的批量更新

This commit is contained in:
Windpicker-owo
2025-11-19 16:30:44 +08:00
parent a11d251ec1
commit 14133410e6
15 changed files with 231 additions and 323 deletions

View File

@@ -40,13 +40,16 @@ class InterestService:
logger.error(f"初始化智能兴趣系统失败: {e}")
self.is_initialized = False
async def calculate_interest_match(self, content: str, keywords: list[str] | None = None):
async def calculate_interest_match(
self, content: str, keywords: list[str] | None = None, message_embedding: list[float] | None = None
):
"""
计算内容与兴趣的匹配度
计算消息与兴趣的匹配度
Args:
content: 消息内容
keywords: 关键列表
keywords: 关键列表
message_embedding: 已经生成的消息embedding可选
Returns:
匹配结果
@@ -57,12 +60,12 @@ class InterestService:
try:
if not keywords:
# 如果没有关键词,尝试从内容提取
# 如果没有关键字,则从内容提取
keywords = self._extract_keywords_from_content(content)
return await bot_interest_manager.calculate_interest_match(content, keywords)
return await bot_interest_manager.calculate_interest_match(content, keywords, message_embedding)
except Exception as e:
logger.error(f"计算兴趣匹配失败: {e}")
logger.error(f"计算兴趣匹配失败: {e}")
return None
def _extract_keywords_from_content(self, content: str) -> list[str]: