chainmem 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
chainmem-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ChainMem Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,322 @@
1
+ Metadata-Version: 2.2
2
+ Name: chainmem
3
+ Version: 0.3.0
4
+ Summary: ChainMem(链忆)— 链式 + 向量混合记忆系统,让 AI 拥有像人一样的联想式回忆
5
+ Author: yabolee-kkk
6
+ Project-URL: Homepage, https://github.com/yabolee-kkk/chainmem
7
+ Project-URL: Repository, https://github.com/yabolee-kkk/chainmem
8
+ Project-URL: Documentation, https://github.com/yabolee-kkk/chainmem#readme
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: sentence-transformers>=3.0
21
+ Requires-Dist: faiss-cpu>=1.8
22
+ Requires-Dist: typer>=0.12
23
+ Requires-Dist: rich>=13.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0; extra == "dev"
26
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
27
+
28
+ <p align="center">
29
+ <img src="assets/logo.svg" width="200" alt="ChainMem Logo">
30
+ </p>
31
+
32
+ <p align="center">
33
+ <img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python 3.10+">
34
+ <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="MIT License">
35
+ <img src="https://img.shields.io/github/v/release/yabolee-kkk/chainmem" alt="GitHub Release">
36
+ <img src="https://img.shields.io/github/stars/yabolee-kkk/chainmem" alt="GitHub Stars">
37
+ </p>
38
+
39
+ <h1 align="center">🧵 ChainMem(链忆)</h1>
40
+ <p align="center"><b>链式 + 向量混合记忆系统 — 让 AI 拥有像人一样的联想式回忆</b></p>
41
+
42
+ <p align="center">
43
+ <i>你给它一个"线头",它还你一件"毛衣"。</i>
44
+ </p>
45
+
46
+ <p align="center">
47
+ 🌐 <a href="README.en.md">English</a> · 中文
48
+ </p>
49
+
50
+ ---
51
+
52
+ ## 🧠 为什么需要 ChainMem?
53
+
54
+ ### 人的记忆是什么样?
55
+
56
+ > 你听到一首歌的前奏 → 想起整首歌 → 想起那个夏天 → 想起那个人...
57
+
58
+ 人的记忆是**链式的**——一个线索能引出整段完整的记忆。你不需要"搜索"过去,你只需要一个**线头**。
59
+
60
+ ### AI 的记忆是什么样?
61
+
62
+ 现有的 AI 记忆系统(向量数据库)本质上是**图书馆模式**:
63
+
64
+ ```
65
+ 你搜"股票" → 返回 10 个孤立片段:
66
+ [片段A] "...股票..."
67
+ [片段B] "...股票投资..."
68
+ [片段C] "...关于股票..."
69
+ ...
70
+ 但凑不出"当时到底说了什么"
71
+ ```
72
+
73
+ 每条记忆是独立的**点**——能搜到碎片,但**凑不出一段完整的、前后连贯的记忆**。
74
+
75
+ ### ChainMem 的答案
76
+
77
+ ChainMem 用**链式结构**模拟人脑的联想回忆:
78
+
79
+ ```
80
+ 你搜"股票" → 找到链头 → 沿指针遍历 → 整段对话一字不差重现:
81
+ "其实我的想法是股票投资..."
82
+ "应该分散风险"
83
+ "所以我选了消费、科技、医疗三个板块..."
84
+ "每个板块配比大约是..."
85
+ ```
86
+
87
+ **不是搜索碎片,而是还原整段记忆。**
88
+
89
+ ---
90
+
91
+ ## ✨ 核心特性
92
+
93
+ | 特性 | 说明 |
94
+ |------|------|
95
+ | 🧵 **链式记忆** | 双向指针串联,线头一扯整件毛衣出来 |
96
+ | 🔍 **语义搜索** | FAISS 向量检索兜底,记不清原话也能搜到 |
97
+ | 🎯 **子串匹配** | 短查询也能精确命中 |
98
+ | ⚡ **毫秒级响应** | 查询 ~22ms,增量添加 ~132ms |
99
+ | 🚀 **秒级启动** | FAISS 索引持久化,重启从 60s → 1s |
100
+ | 🏷️ **标签分类** | 按项目/主题组织记忆 |
101
+ | 🔌 **MCP 协议** | 原生支持 Hermes Agent 等 AI Agent 集成 |
102
+ | 🐍 **Python SDK** | 一句话集成到你的项目 |
103
+
104
+ ---
105
+
106
+ ## ⚡ 快速开始
107
+
108
+ ```bash
109
+ pip install chainmem
110
+ ```
111
+
112
+ ```python
113
+ from chainmem import ChainMemory
114
+
115
+ # 初始化
116
+ cm = ChainMemory(db_path="~/.chainmem/data.db").open()
117
+
118
+ # 结链:把一段对话存为记忆
119
+ chain = cm.ingest(
120
+ "其实我的想法是把每一次的记忆包括一次对话全部变成一个链条",
121
+ source="demo",
122
+ tags=["讨论", "记忆系统", "架构"],
123
+ )
124
+ print(f"链 ID: {chain.id}, 节点数: {chain.node_count}")
125
+
126
+ # 追溯:输入几个字,拉出整段记忆
127
+ result = cm.retrieve("其实我的想法")
128
+ print("".join(result)) # → 完整记忆复原
129
+
130
+ # 统计
131
+ print(cm.stats())
132
+
133
+ cm.close()
134
+ ```
135
+
136
+ ### CLI 模式
137
+
138
+ ```bash
139
+ # 结链
140
+ chainmem ingest "其实我的想法是把每一次的记忆包括一次对话全部变成一个链条" --source demo --tags 讨论,记忆系统
141
+
142
+ # 追溯
143
+ chainmem retrieve "其实我的想法"
144
+
145
+ # 统计
146
+ chainmem stats
147
+
148
+ # 启动 MCP 服务器(用于 AI Agent 集成)
149
+ chainmem serve --socket /tmp/chainmem.sock
150
+ ```
151
+
152
+ ---
153
+
154
+ ## 🔬 工作原理
155
+
156
+ ### 结链(Ingestion)
157
+
158
+ ![ChainMem Architecture](assets/architecture-preview.png)
159
+
160
+ ```
161
+ 原始文本
162
+
163
+
164
+ ┌─────────────┐
165
+ │ 语义切块 │ 按标点/语义切成短语块(6-18字)
166
+ └──────┬──────┘
167
+
168
+
169
+ ┌─────────────┐
170
+ │ 向量嵌入 │ sentence-transformers 编码
171
+ └──────┬──────┘
172
+
173
+
174
+ ┌─────────────┐ ┌──────────────────┐
175
+ │ 链式串联 │────▶│ Node_A → Node_B │
176
+ │ prev/next │ │ → Node_C │
177
+ │ 双向指针 │ └──────────────────┘
178
+ └──────┬──────┘
179
+
180
+
181
+ ┌─────────────┐
182
+ │ SQLite 存储 │ 零依赖持久化
183
+ └─────────────┘
184
+ ```
185
+
186
+ ### 追溯(Retrieval)
187
+
188
+ ```
189
+ 用户查询("股票")
190
+
191
+
192
+ ┌─────────────┐ ┌──────────────────┐
193
+ │ FAISS 语义 │ │ 子串精确匹配 │
194
+ │ 搜索 (TOP10) │────▶│ +0.20 加分 │
195
+ └──────┬──────┘ └──────────────────┘
196
+
197
+
198
+ ┌─────────────┐
199
+ │ 候选排序 │ 语义分 + 子串分 + 标签分
200
+ └──────┬──────┘
201
+
202
+
203
+ ┌─────────────┐ ┌──────────────────┐
204
+ │ 指针链遍历 │────▶│ Node_A → Node_B │
205
+ │ next_id │ │ → Node_C │
206
+ │ 忠实还原 │ │ → 完整对话输出 │
207
+ └─────────────┘ └──────────────────┘
208
+ ```
209
+
210
+ ---
211
+
212
+ ## 📊 性能对比
213
+
214
+ | 指标 | 传统向量搜索 | ChainMem |
215
+ |:-----|:----------:|:--------:|
216
+ | **检索速度** | ~50ms | **~22ms** |
217
+ | **结果完整性** | 碎片 | **100% 原始记忆** |
218
+ | **启动时间** | ~60s(全量重建) | **~1s**(磁盘加载) |
219
+ | **增量添加** | 全量重建 | **~132ms**(仅编新节点) |
220
+ | **中文支持** | 一般 | **优秀**(trigram FTS5) |
221
+ | **检索精度** | 语义近似 | **语义 + 子串 + 标签** 混合 |
222
+
223
+ ---
224
+
225
+ ## 🔧 与 AI Agent 集成
226
+
227
+ ### Hermes Agent(MCP 协议)
228
+
229
+ 配置 `~/.hermes/config.yaml`:
230
+
231
+ ```yaml
232
+ mcp_servers:
233
+ chainmem:
234
+ command: chainmem
235
+ args: ["serve", "--socket", "/tmp/chainmem.sock"]
236
+ ```
237
+
238
+ 启动后,Hermes 自动获得三个工具:
239
+
240
+ | 工具 | 功能 |
241
+ |:-----|:-----|
242
+ | `chainmem_ingest(text, source, tags)` | 结链:存储记忆 |
243
+ | `chainmem_retrieve(query, tags)` | 追溯:检索记忆(支持标签过滤) |
244
+ | `chainmem_stats()` | 统计:查看记忆库状态 |
245
+
246
+ ---
247
+
248
+ ## 🗺️ 路线图
249
+
250
+ ```
251
+ Phase 1 ✅ 核心闭环
252
+ ├─ 结链(文本 → 切块 → 嵌入 → 存储)
253
+ ├─ 追溯(语义搜索 + 子串匹配 + 指针遍历)
254
+ ├─ MCP 服务器持久化
255
+ ├─ FAISS 索引持久化(秒级启动)
256
+ └─ 增量索引(毫秒级添加)
257
+
258
+ Phase 2 🏗️ 类人记忆机制
259
+ ├─ 衰减曲线(Forgetting Curve)
260
+ ├─ 联想增强(检索A时推荐相关链)
261
+ ├─ 自动结链(对话中自动记忆)
262
+ └─ 分支消歧(相同前缀不同下文)
263
+
264
+ Phase 3 🎯 真正的"人脑记忆"
265
+ ├─ 分层记忆(工作记忆 + 短期 + 长期)
266
+ ├─ 记忆整合(多条记忆→知识归纳)
267
+ ├─ 跨 Agent 记忆共享
268
+ └─ 睡眠压缩(像人脑睡觉时整理记忆)
269
+ ```
270
+
271
+ ---
272
+
273
+ ## 🤝 如何贡献
274
+
275
+ 我们欢迎所有形式的贡献!详细指南请参见 [CONTRIBUTING.md](CONTRIBUTING.md)。
276
+
277
+ **新手友好任务:**
278
+ - 📖 完善文档和示例
279
+ - 🐛 修复 Bug
280
+ - ✅ 增加测试覆盖
281
+ - 🌍 国际化(i18n)
282
+ - 💡 提出新功能建议
283
+
284
+ ---
285
+
286
+ ## 📦 项目结构
287
+
288
+ ```
289
+ chainmem/
290
+ ├── pyproject.toml # 项目配置
291
+ ├── README.md # 本文件
292
+ ├── LICENSE # MIT License
293
+ ├── CONTRIBUTING.md # 贡献指南
294
+ ├── src/chainmem/
295
+ │ ├── __init__.py # ChainMemory 主入口
296
+ │ ├── core/node.py # 数据模型(ChainNode, Chain)
297
+ │ ├── store/sqlite_store.py # SQLite 持久化
298
+ │ ├── pipeline/
299
+ │ │ ├── ingester.py # 结链(切块 → 嵌入 → 串联)
300
+ │ │ └── retriever.py # 追溯(FAISS + 子串 + 指针)
301
+ │ └── cli/app.py # Typer CLI(含 MCP server)
302
+ ├── scripts/
303
+ │ ├── chainmem_server.py # 持久化 MCP 服务
304
+ │ └── benchmark.py # 性能基准测试
305
+ └── tests/
306
+ └── test_core.py # 核心测试
307
+ ```
308
+
309
+ ---
310
+
311
+ ## 📄 License
312
+
313
+ [MIT License](LICENSE) © 2025 yabolee-kkk
314
+
315
+ ---
316
+
317
+ <p align="center">
318
+ <b>ChainMem — 让 AI 的记忆,像人一样。</b><br>
319
+ <a href="https://github.com/yabolee-kkk/chainmem">GitHub</a> ·
320
+ <a href="https://github.com/yabolee-kkk/chainmem/issues">报告问题</a> ·
321
+ <a href="https://github.com/yabolee-kkk/chainmem/discussions">讨论区</a>
322
+ </p>
@@ -0,0 +1,295 @@
1
+ <p align="center">
2
+ <img src="assets/logo.svg" width="200" alt="ChainMem Logo">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python 3.10+">
7
+ <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="MIT License">
8
+ <img src="https://img.shields.io/github/v/release/yabolee-kkk/chainmem" alt="GitHub Release">
9
+ <img src="https://img.shields.io/github/stars/yabolee-kkk/chainmem" alt="GitHub Stars">
10
+ </p>
11
+
12
+ <h1 align="center">🧵 ChainMem(链忆)</h1>
13
+ <p align="center"><b>链式 + 向量混合记忆系统 — 让 AI 拥有像人一样的联想式回忆</b></p>
14
+
15
+ <p align="center">
16
+ <i>你给它一个"线头",它还你一件"毛衣"。</i>
17
+ </p>
18
+
19
+ <p align="center">
20
+ 🌐 <a href="README.en.md">English</a> · 中文
21
+ </p>
22
+
23
+ ---
24
+
25
+ ## 🧠 为什么需要 ChainMem?
26
+
27
+ ### 人的记忆是什么样?
28
+
29
+ > 你听到一首歌的前奏 → 想起整首歌 → 想起那个夏天 → 想起那个人...
30
+
31
+ 人的记忆是**链式的**——一个线索能引出整段完整的记忆。你不需要"搜索"过去,你只需要一个**线头**。
32
+
33
+ ### AI 的记忆是什么样?
34
+
35
+ 现有的 AI 记忆系统(向量数据库)本质上是**图书馆模式**:
36
+
37
+ ```
38
+ 你搜"股票" → 返回 10 个孤立片段:
39
+ [片段A] "...股票..."
40
+ [片段B] "...股票投资..."
41
+ [片段C] "...关于股票..."
42
+ ...
43
+ 但凑不出"当时到底说了什么"
44
+ ```
45
+
46
+ 每条记忆是独立的**点**——能搜到碎片,但**凑不出一段完整的、前后连贯的记忆**。
47
+
48
+ ### ChainMem 的答案
49
+
50
+ ChainMem 用**链式结构**模拟人脑的联想回忆:
51
+
52
+ ```
53
+ 你搜"股票" → 找到链头 → 沿指针遍历 → 整段对话一字不差重现:
54
+ "其实我的想法是股票投资..."
55
+ "应该分散风险"
56
+ "所以我选了消费、科技、医疗三个板块..."
57
+ "每个板块配比大约是..."
58
+ ```
59
+
60
+ **不是搜索碎片,而是还原整段记忆。**
61
+
62
+ ---
63
+
64
+ ## ✨ 核心特性
65
+
66
+ | 特性 | 说明 |
67
+ |------|------|
68
+ | 🧵 **链式记忆** | 双向指针串联,线头一扯整件毛衣出来 |
69
+ | 🔍 **语义搜索** | FAISS 向量检索兜底,记不清原话也能搜到 |
70
+ | 🎯 **子串匹配** | 短查询也能精确命中 |
71
+ | ⚡ **毫秒级响应** | 查询 ~22ms,增量添加 ~132ms |
72
+ | 🚀 **秒级启动** | FAISS 索引持久化,重启从 60s → 1s |
73
+ | 🏷️ **标签分类** | 按项目/主题组织记忆 |
74
+ | 🔌 **MCP 协议** | 原生支持 Hermes Agent 等 AI Agent 集成 |
75
+ | 🐍 **Python SDK** | 一句话集成到你的项目 |
76
+
77
+ ---
78
+
79
+ ## ⚡ 快速开始
80
+
81
+ ```bash
82
+ pip install chainmem
83
+ ```
84
+
85
+ ```python
86
+ from chainmem import ChainMemory
87
+
88
+ # 初始化
89
+ cm = ChainMemory(db_path="~/.chainmem/data.db").open()
90
+
91
+ # 结链:把一段对话存为记忆
92
+ chain = cm.ingest(
93
+ "其实我的想法是把每一次的记忆包括一次对话全部变成一个链条",
94
+ source="demo",
95
+ tags=["讨论", "记忆系统", "架构"],
96
+ )
97
+ print(f"链 ID: {chain.id}, 节点数: {chain.node_count}")
98
+
99
+ # 追溯:输入几个字,拉出整段记忆
100
+ result = cm.retrieve("其实我的想法")
101
+ print("".join(result)) # → 完整记忆复原
102
+
103
+ # 统计
104
+ print(cm.stats())
105
+
106
+ cm.close()
107
+ ```
108
+
109
+ ### CLI 模式
110
+
111
+ ```bash
112
+ # 结链
113
+ chainmem ingest "其实我的想法是把每一次的记忆包括一次对话全部变成一个链条" --source demo --tags 讨论,记忆系统
114
+
115
+ # 追溯
116
+ chainmem retrieve "其实我的想法"
117
+
118
+ # 统计
119
+ chainmem stats
120
+
121
+ # 启动 MCP 服务器(用于 AI Agent 集成)
122
+ chainmem serve --socket /tmp/chainmem.sock
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 🔬 工作原理
128
+
129
+ ### 结链(Ingestion)
130
+
131
+ ![ChainMem Architecture](assets/architecture-preview.png)
132
+
133
+ ```
134
+ 原始文本
135
+
136
+
137
+ ┌─────────────┐
138
+ │ 语义切块 │ 按标点/语义切成短语块(6-18字)
139
+ └──────┬──────┘
140
+
141
+
142
+ ┌─────────────┐
143
+ │ 向量嵌入 │ sentence-transformers 编码
144
+ └──────┬──────┘
145
+
146
+
147
+ ┌─────────────┐ ┌──────────────────┐
148
+ │ 链式串联 │────▶│ Node_A → Node_B │
149
+ │ prev/next │ │ → Node_C │
150
+ │ 双向指针 │ └──────────────────┘
151
+ └──────┬──────┘
152
+
153
+
154
+ ┌─────────────┐
155
+ │ SQLite 存储 │ 零依赖持久化
156
+ └─────────────┘
157
+ ```
158
+
159
+ ### 追溯(Retrieval)
160
+
161
+ ```
162
+ 用户查询("股票")
163
+
164
+
165
+ ┌─────────────┐ ┌──────────────────┐
166
+ │ FAISS 语义 │ │ 子串精确匹配 │
167
+ │ 搜索 (TOP10) │────▶│ +0.20 加分 │
168
+ └──────┬──────┘ └──────────────────┘
169
+
170
+
171
+ ┌─────────────┐
172
+ │ 候选排序 │ 语义分 + 子串分 + 标签分
173
+ └──────┬──────┘
174
+
175
+
176
+ ┌─────────────┐ ┌──────────────────┐
177
+ │ 指针链遍历 │────▶│ Node_A → Node_B │
178
+ │ next_id │ │ → Node_C │
179
+ │ 忠实还原 │ │ → 完整对话输出 │
180
+ └─────────────┘ └──────────────────┘
181
+ ```
182
+
183
+ ---
184
+
185
+ ## 📊 性能对比
186
+
187
+ | 指标 | 传统向量搜索 | ChainMem |
188
+ |:-----|:----------:|:--------:|
189
+ | **检索速度** | ~50ms | **~22ms** |
190
+ | **结果完整性** | 碎片 | **100% 原始记忆** |
191
+ | **启动时间** | ~60s(全量重建) | **~1s**(磁盘加载) |
192
+ | **增量添加** | 全量重建 | **~132ms**(仅编新节点) |
193
+ | **中文支持** | 一般 | **优秀**(trigram FTS5) |
194
+ | **检索精度** | 语义近似 | **语义 + 子串 + 标签** 混合 |
195
+
196
+ ---
197
+
198
+ ## 🔧 与 AI Agent 集成
199
+
200
+ ### Hermes Agent(MCP 协议)
201
+
202
+ 配置 `~/.hermes/config.yaml`:
203
+
204
+ ```yaml
205
+ mcp_servers:
206
+ chainmem:
207
+ command: chainmem
208
+ args: ["serve", "--socket", "/tmp/chainmem.sock"]
209
+ ```
210
+
211
+ 启动后,Hermes 自动获得三个工具:
212
+
213
+ | 工具 | 功能 |
214
+ |:-----|:-----|
215
+ | `chainmem_ingest(text, source, tags)` | 结链:存储记忆 |
216
+ | `chainmem_retrieve(query, tags)` | 追溯:检索记忆(支持标签过滤) |
217
+ | `chainmem_stats()` | 统计:查看记忆库状态 |
218
+
219
+ ---
220
+
221
+ ## 🗺️ 路线图
222
+
223
+ ```
224
+ Phase 1 ✅ 核心闭环
225
+ ├─ 结链(文本 → 切块 → 嵌入 → 存储)
226
+ ├─ 追溯(语义搜索 + 子串匹配 + 指针遍历)
227
+ ├─ MCP 服务器持久化
228
+ ├─ FAISS 索引持久化(秒级启动)
229
+ └─ 增量索引(毫秒级添加)
230
+
231
+ Phase 2 🏗️ 类人记忆机制
232
+ ├─ 衰减曲线(Forgetting Curve)
233
+ ├─ 联想增强(检索A时推荐相关链)
234
+ ├─ 自动结链(对话中自动记忆)
235
+ └─ 分支消歧(相同前缀不同下文)
236
+
237
+ Phase 3 🎯 真正的"人脑记忆"
238
+ ├─ 分层记忆(工作记忆 + 短期 + 长期)
239
+ ├─ 记忆整合(多条记忆→知识归纳)
240
+ ├─ 跨 Agent 记忆共享
241
+ └─ 睡眠压缩(像人脑睡觉时整理记忆)
242
+ ```
243
+
244
+ ---
245
+
246
+ ## 🤝 如何贡献
247
+
248
+ 我们欢迎所有形式的贡献!详细指南请参见 [CONTRIBUTING.md](CONTRIBUTING.md)。
249
+
250
+ **新手友好任务:**
251
+ - 📖 完善文档和示例
252
+ - 🐛 修复 Bug
253
+ - ✅ 增加测试覆盖
254
+ - 🌍 国际化(i18n)
255
+ - 💡 提出新功能建议
256
+
257
+ ---
258
+
259
+ ## 📦 项目结构
260
+
261
+ ```
262
+ chainmem/
263
+ ├── pyproject.toml # 项目配置
264
+ ├── README.md # 本文件
265
+ ├── LICENSE # MIT License
266
+ ├── CONTRIBUTING.md # 贡献指南
267
+ ├── src/chainmem/
268
+ │ ├── __init__.py # ChainMemory 主入口
269
+ │ ├── core/node.py # 数据模型(ChainNode, Chain)
270
+ │ ├── store/sqlite_store.py # SQLite 持久化
271
+ │ ├── pipeline/
272
+ │ │ ├── ingester.py # 结链(切块 → 嵌入 → 串联)
273
+ │ │ └── retriever.py # 追溯(FAISS + 子串 + 指针)
274
+ │ └── cli/app.py # Typer CLI(含 MCP server)
275
+ ├── scripts/
276
+ │ ├── chainmem_server.py # 持久化 MCP 服务
277
+ │ └── benchmark.py # 性能基准测试
278
+ └── tests/
279
+ └── test_core.py # 核心测试
280
+ ```
281
+
282
+ ---
283
+
284
+ ## 📄 License
285
+
286
+ [MIT License](LICENSE) © 2025 yabolee-kkk
287
+
288
+ ---
289
+
290
+ <p align="center">
291
+ <b>ChainMem — 让 AI 的记忆,像人一样。</b><br>
292
+ <a href="https://github.com/yabolee-kkk/chainmem">GitHub</a> ·
293
+ <a href="https://github.com/yabolee-kkk/chainmem/issues">报告问题</a> ·
294
+ <a href="https://github.com/yabolee-kkk/chainmem/discussions">讨论区</a>
295
+ </p>
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0,<77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "chainmem"
7
+ version = "0.3.0"
8
+ description = "ChainMem(链忆)— 链式 + 向量混合记忆系统,让 AI 拥有像人一样的联想式回忆"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ authors = [
12
+ {name = "yabolee-kkk"},
13
+ ]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
22
+ "Topic :: Software Development :: Libraries :: Python Modules",
23
+ ]
24
+ dependencies = [
25
+ "sentence-transformers>=3.0",
26
+ "faiss-cpu>=1.8",
27
+ "typer>=0.12",
28
+ "rich>=13.0",
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/yabolee-kkk/chainmem"
33
+ Repository = "https://github.com/yabolee-kkk/chainmem"
34
+ Documentation = "https://github.com/yabolee-kkk/chainmem#readme"
35
+
36
+ [project.scripts]
37
+ chainmem = "chainmem.cli.app:app"
38
+
39
+ [project.optional-dependencies]
40
+ dev = [
41
+ "pytest>=7.0",
42
+ "pytest-cov>=4.0",
43
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+