管理 AI 代理的三级记忆系统:短期(滑动窗口)、中期(自动摘要)、长期(向量检索)。
# 初始化记忆系统
python3 scripts/memory_manager.py init
# 添加短期记忆
python3 scripts/memory_manager.py add --type short --content "用户喜欢黑色"
# 查询记忆
python3 scripts/memory_manager.py search "用户的偏好"
| 层级 | 存储位置 | 触发条件 | 用途 |
|---|---|---|---|
| ------ | ---------- | ---------- | ------ |
| 短期 | memory/sliding-window.json | 实时 | 保持当前对话连贯 |
| 中期 | memory/summaries/ | Token 阈值 | 压缩历史,保留大意 |
| 长期 | memory/vector-store/ | 语义检索 | 永久记忆,RAG |
config/window_size(默认 10 条)memory/sliding-window.jsonconfig/summary_threshold(默认 4000)memory/summaries/YYYY-MM-DD.json创建 memory/config.yaml:
memory:
short_term:
enabled: true
window_size: 10
max_tokens: 2000
medium_term:
enabled: true
summary_threshold: 4000
summary_model: "glm-4-flash" # 或 gpt-3.5-turbo
long_term:
enabled: true
backend: "chromadb"
top_k: 3
min_relevance: 0.7
search 长期记忆,注入相关上下文See REFERENCES.md for complete command reference.
共 1 个版本