refactor(profile,llm): 提高用户资料的准确性和系统的稳健性。本次提交引入了多项针对用户资料管理和大语言模型交互的优化,目标是实现更高的准确性、更严格的数据验证以及提升系统可靠性。

- **用户资料管理(`user_profile_tool.py`):**
  - `UserProfileTool` 的描述进行了大幅更新,明确定义了严格的使用场景和绝对禁止的行为,防止误用。
  - 对 `preference_keywords` 和 `key_info` 的值实施了更严格的过滤,确保只记录具体、客观的事实和真实兴趣。
  - 减少了用于上下文的最近聊天消息数量,以更关注相关性更高的近期交互。
  - 修改了好感度计算逻辑,使其更加保守,不容易因日常小互动而改变,需要更有意义的交流才会产生变化。
  - 印象生成提示已更新,严格禁止猜测。
  并强调记录事实观察到的特征。- **关系信息显示(`relationship_fetcher.py`):** - 通过过滤掉一般交互术语来增强用户偏好显示,仅展示真实的爱好和兴趣。- 暂时注释了“关键事实”的显示,以防呈现潜在不准确或推测性的信息。- **大型语言模型交互稳定性(`base_action.py`):** - 在 `should_activate` 方法中引入了 7 秒超时的 LLM 判断调用。- 如果 LLM 判断超时,动作现在默认为“激活”,以防止系统阻塞并确保持续运行。
This commit is contained in:
tt-P607
2025-12-09 22:52:36 +08:00
parent 084192843b
commit 44f85c40bf
3 changed files with 145 additions and 88 deletions

View File

@@ -838,11 +838,20 @@ class BaseAction(ABC):
只需要回答"""",不要有其他内容。
"""
# 调用 LLM 进行判断
response, _ = await llm_judge_model.generate_response_async(prompt=prompt)
response = response.strip().lower()
should_activate = "" in response or "yes" in response or "true" in response
# 调用 LLM 进行判断设置7秒超时避免长时间等待
import asyncio
response = "" # 初始化response变量
try:
response, _ = await asyncio.wait_for(
llm_judge_model.generate_response_async(prompt=prompt),
timeout=7.0
)
response = response.strip().lower()
should_activate = "" in response or "yes" in response or "true" in response
except asyncio.TimeoutError:
logger.warning(f"{self.log_prefix} LLM 判断激活超时7秒默认激活以避免阻塞")
# 超时时默认激活,交给后续决策系统处理
should_activate = True
logger.debug(
f"{self.log_prefix} LLM 判断结果: 响应='{response}', 结果={'激活' if should_activate else '不激活'}"