feat(chatter): 整合工具使用并增强主聊天流程中的上下文

此提交为聊天系统引入了若干重大增强,以提高回应质量、上下文感知能力和角色一致性。

**Kokoro 流程中的工具整合:**
- 在主聊天提示中新增了一个 `tool_info` 上下文块。
- `KFCContextBuilder` 现在通过 `ToolExecutor` 执行工具后再生成回复,使聊天模型能够感知实时信息和操作。

**以角色为驱动的用户画像:**
- `update_user_profile` 工具被重构为两阶段过程。工具使用模型提供一个简单的“印象提示”,专门的 `relationship_tracker` 模型将其扩展为丰富且符合角色的一致印象。
- 工具使用提示已更新,明确指示模型在生成工具参数时保持机器人的角色。

**记忆系统改进:**
- 记忆检索判定提示已更新,更加主动地获取长期记忆,目标是为了提供更丰富的上下文。- 记忆查询现在从最近的一组消息中生成,而不是单条消息,从而提高检索的相关性。**其他更改:** - 在上下文构建过程中添加了性能时间日志,以识别瓶颈。- 在响应过滤中进行了小修复,以清理特定前缀,如“,说:”。
This commit is contained in:
tt-P607
2025-12-03 14:04:29 +08:00
parent 9a5ae357b5
commit 39c52490d9
9 changed files with 345 additions and 48 deletions

View File

@@ -957,6 +957,8 @@ def filter_system_format_content(content: str | None) -> str:
last_bracket_index = cleaned_content.rfind("]")
if last_bracket_index != -1:
cleaned_content = cleaned_content[last_bracket_index + 1 :].strip()
# 专门清理 ",说:" 或 "说:"
cleaned_content = re.sub(r"^(|,)说:", "", cleaned_content).strip()
# 在处理完回复格式后,再清理其他简单的格式
# 新增:移除所有残余的 [...] 格式,例如 [at=...] 等