mirror of
https://github.com/xszyou/Fay.git
synced 2026-03-12 17:51:28 +08:00
记忆模块
1.暂时屏蔽仿生记忆开关; 2.补充记忆模块的开发文档,以方便ai ide阅读。
This commit is contained in:
39
docs/memory_module.md
Normal file
39
docs/memory_module.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Fay Memory Module
|
||||
|
||||
本说明描述当前默认的认知记忆实现。适用于 `llm/nlp_cognitive_stream.py` + `genagents/modules/memory_stream.py` 这条路径。
|
||||
|
||||
## 记忆节点
|
||||
- 节点类型:`observation`(观察)、`conversation`(对话)、`reflection`(反思)
|
||||
- 字段:
|
||||
- `node_id`: 递增整数
|
||||
- `node_type`: 节点类型
|
||||
- `content`: 记忆内容(纯文本,已去除 `<think>` / `<prestart>`)
|
||||
- `importance`: 整数重要度
|
||||
- `datetime`: 节点创建时间,格式 `YYYY/MM/DD HH:MM:SS`;旧节点可能为空
|
||||
- `created` / `last_retrieved`: 时间步(整型)
|
||||
- `pointer_id`: 反思节点指向的源节点列表 ID
|
||||
- 创建:
|
||||
- 观察:`remember_observation_thread` / `record_observation`
|
||||
- 对话:`remember_conversation_thread`(问答格式:`{user}:{问}\n{agent}:{答}`,其中 `user/user` 会写成“主人”)
|
||||
- 反思:`MemoryStream.reflect` 生成
|
||||
- 写盘策略:即时不落盘,按定时/退出在 `llm/nlp_cognitive_stream.py::save_agent_memory` 才写入
|
||||
- Embedding:`memory_stream._add_node` 创建时生成;维度不符时检索阶段会临时重算(内存中,不立即落盘)
|
||||
|
||||
## 检索与提示词
|
||||
- 检索:`MemoryStream.retrieve` 按 recency/relevance/importance 组合权重取回;关联记忆一步检索 `curr_filter="all"` 后按类型分段展示。
|
||||
- 展示格式:检索结果中若节点有 `datetime`,前缀 `"[{datetime}] "`;无时间则不展示时间。
|
||||
- 关联记忆段落无“关联记忆”标题,直接列出各类型小节(观察、对话、反思)。
|
||||
|
||||
## 配置与隔离
|
||||
- `memory.isolate_by_user`: 打开后记忆目录按用户名隔离。
|
||||
|
||||
## 运行时要点
|
||||
- 文字接口 `no_reply=true` 且有 `observation` 时:只记观察,不回复;无 `messages` 且有 `observation` 会强制 `no_reply=true`。
|
||||
- `no_reply=false` 的普通对话:问题/回答会写入对话记忆;`observation` 若存在也会写入观察记忆。
|
||||
- Prompt 打印:已关闭(`_log_prompt` 是空操作)。
|
||||
|
||||
## 文件位置
|
||||
- 核心逻辑:`llm/nlp_cognitive_stream.py`
|
||||
- 记忆结构:`genagents/modules/memory_stream.py`
|
||||
- 定时保存:`llm/nlp_cognitive_stream.py::save_agent_memory`
|
||||
- 记忆数据:`memory/memory_stream/nodes.json`, `embeddings.json`, `meta.json`
|
||||
File diff suppressed because it is too large
Load Diff
@@ -115,16 +115,12 @@
|
||||
</select></li>
|
||||
<li style="display: flex;"> <span class="font_name" style="line-height: 36px;"> 敏 感 度 :</span>
|
||||
<el-slider style="width: 230px;" v-model="interact_perception_follow" :disabled="!configEditable"></el-slider></li>
|
||||
<li> <span class="font_name">认知隔离:</span>
|
||||
<el-switch v-model="memory_isolate_by_user" :disabled="use_bionic_memory" active-color="#13ce66" inactive-color="#ff4949" @change=saveConfig()></el-switch>
|
||||
<span style="font-size: 12px; color: #666; margin-left: 10px;">开启后每个用户将拥有独立记忆</span>
|
||||
</li>
|
||||
<li> <span class="font_name">仿生记忆:</span>
|
||||
<el-switch v-model="use_bionic_memory" active-color="#13ce66" inactive-color="#ff4949" @change="onBionicMemoryChange"></el-switch>
|
||||
<span style="font-size: 12px; color: #666; margin-left: 10px;">开启后使用仿生记忆系统(试验功能,人格克隆不可用)</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<li> <span class="font_name">认知隔离:</span>
|
||||
<el-switch v-model="memory_isolate_by_user" :disabled="use_bionic_memory" active-color="#13ce66" inactive-color="#ff4949" @change=saveConfig()></el-switch>
|
||||
<span style="font-size: 12px; color: #666; margin-left: 10px;">开启后每个用户将拥有独立记忆</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -175,4 +171,4 @@
|
||||
<script src="{{ url_for('static',filename='js/element.js') }}"></script> <!-- 这里需要确保先引入 Element -->
|
||||
<script src="{{ url_for('static',filename='js/setting.js') }}"></script>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user