构建有效长期记忆系统的实践方法
VirtualWife默认采用短期对话记忆,要实现深度记忆需通过以下步骤:
- 记忆存储配置::
- exist
.env
AddMEMORY_TYPE=json
(默认使用内存易丢失) - indicate clearly and with certainty
MEMORY_FILE_PATH=./memory.json
实现磁盘持久化
- exist
- Key information extraction::
- 示范对话格式:”[记忆]我生日是6月15日”(系统会自动标记关键信息)
- 在角色设定模板中添加记忆提示词,要求AI主动询问用户偏好
- 定期记忆强化::
- 每20次对话后,系统会自动复述之前记录的5条关键信息确认
- utilization
curl -X POST http://localhost/memory/refresh
手动触发记忆重组
高级方案:
连接外部数据库实现结构化记忆:
- modifications
docker-compose.yml
添加PostgreSQL容器 - set up
MEMORY_TYPE=postgres
并配置连接参数 - 记忆数据将按时间标签分类存储,支持复杂查询
This answer comes from the articleVirtualWife: A secondary digital person that supports B-station live streaming and voice interactionThe