mem1 0.0.9__tar.gz → 0.1.1__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.
- {mem1-0.0.9 → mem1-0.1.1}/.env.example +1 -1
- {mem1-0.0.9 → mem1-0.1.1}/PKG-INFO +17 -7
- {mem1-0.0.9 → mem1-0.1.1}/README.md +16 -6
- {mem1-0.0.9 → mem1-0.1.1}/mem1/__init__.py +1 -1
- {mem1-0.0.9 → mem1-0.1.1}/mem1/memory.py +4 -3
- {mem1-0.0.9 → mem1-0.1.1}/pyproject.toml +1 -1
- {mem1-0.0.9 → mem1-0.1.1}/.gitignore +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/ChatGPTMemoryFeature.md +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/ChatGPTMemoryFeature.pdf +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/docker-compose.yml +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/examples/basic_usage.py +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/examples/batch_import.py +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/examples/image_usage.py +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/examples/langchain_integration.py +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/examples//345/244/251/344/273/267/351/272/273/350/212/261.png" +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/examples//346/231/272/350/203/275/345/256/266/347/224/265/347/235/200/347/201/253-/346/211/253/345/234/260/346/234/272/345/231/250/344/272/272.png" +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/examples//346/231/272/350/203/275/345/256/266/347/224/265/347/235/200/347/201/253-/347/252/227/345/270/230.png" +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/examples//346/231/272/350/203/275/345/256/266/347/224/265/347/235/200/347/201/253-/351/251/254/346/241/266.png" +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/mem1/config.py +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/mem1/langchain_middleware.py +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/mem1/llm.py +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/mem1/memory_md.py +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/mem1/memory_tools.py +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/mem1/prompts.py +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/mem1/storage.py +0 -0
- {mem1-0.0.9 → mem1-0.1.1}/requirements.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mem1
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: 基于云服务的用户记忆系统
|
|
5
5
|
Project-URL: Homepage, https://github.com/sougannkyou/mem1
|
|
6
6
|
Project-URL: Repository, https://github.com/sougannkyou/mem1
|
|
@@ -239,14 +239,24 @@ def search_memory(start_days: int, end_days: int) -> str:
|
|
|
239
239
|
使用 `get_context()` 获取上下文后,建议在 system prompt 中加入以下规则,避免 LLM 编造信息:
|
|
240
240
|
|
|
241
241
|
```
|
|
242
|
-
##
|
|
243
|
-
1.
|
|
244
|
-
2.
|
|
245
|
-
3.
|
|
246
|
-
4.
|
|
247
|
-
5.
|
|
242
|
+
## 严格规则(违反将被标记为错误)
|
|
243
|
+
1. 禁止编造任何未在对话记录中出现的信息
|
|
244
|
+
2. 涉及时间/日期时,必须从对话记录中原样引用,不得推测
|
|
245
|
+
3. 如果对话记录中没有明确的时间信息,回答"对话记录中未提及具体时间"
|
|
246
|
+
4. 需要引用数据时,必须标注来源(如:根据 [对话-003] 的记录)
|
|
247
|
+
5. 涉及数字(金额、数量、百分比等)时,必须从对话记录中原样提取,不得估算
|
|
248
|
+
6. 需要汇总累加时,必须列出计算过程(如:23+31+18+25=97)
|
|
249
|
+
7. 涉及人名、公司名、账号名等实体时,必须使用对话中的原始名称
|
|
248
250
|
```
|
|
249
251
|
|
|
252
|
+
**对话记录格式说明**:
|
|
253
|
+
- 每条对话都有唯一 ID,格式为 `[对话-001]`、`[对话-002]` 等
|
|
254
|
+
- 回答时引用对话 ID 可提高可信度,如:"根据 [对话-003] 的记录,本月处理了97起舆情"
|
|
255
|
+
|
|
256
|
+
**推荐配置**:
|
|
257
|
+
- `MEM1_LLM_TEMPERATURE=0.2`(降低创造性,减少编造)
|
|
258
|
+
- `MEM1_CONTEXT_DAYS_LIMIT=7`(缩小检索范围,提高精准度)
|
|
259
|
+
|
|
250
260
|
## 设计决策:为什么不用向量数据库
|
|
251
261
|
|
|
252
262
|
mem1 选择 ES 时间范围检索而非 Milvus/Pinecone 等向量数据库,核心原因是**对话记忆需要上下文连续性**:
|
|
@@ -214,14 +214,24 @@ def search_memory(start_days: int, end_days: int) -> str:
|
|
|
214
214
|
使用 `get_context()` 获取上下文后,建议在 system prompt 中加入以下规则,避免 LLM 编造信息:
|
|
215
215
|
|
|
216
216
|
```
|
|
217
|
-
##
|
|
218
|
-
1.
|
|
219
|
-
2.
|
|
220
|
-
3.
|
|
221
|
-
4.
|
|
222
|
-
5.
|
|
217
|
+
## 严格规则(违反将被标记为错误)
|
|
218
|
+
1. 禁止编造任何未在对话记录中出现的信息
|
|
219
|
+
2. 涉及时间/日期时,必须从对话记录中原样引用,不得推测
|
|
220
|
+
3. 如果对话记录中没有明确的时间信息,回答"对话记录中未提及具体时间"
|
|
221
|
+
4. 需要引用数据时,必须标注来源(如:根据 [对话-003] 的记录)
|
|
222
|
+
5. 涉及数字(金额、数量、百分比等)时,必须从对话记录中原样提取,不得估算
|
|
223
|
+
6. 需要汇总累加时,必须列出计算过程(如:23+31+18+25=97)
|
|
224
|
+
7. 涉及人名、公司名、账号名等实体时,必须使用对话中的原始名称
|
|
223
225
|
```
|
|
224
226
|
|
|
227
|
+
**对话记录格式说明**:
|
|
228
|
+
- 每条对话都有唯一 ID,格式为 `[对话-001]`、`[对话-002]` 等
|
|
229
|
+
- 回答时引用对话 ID 可提高可信度,如:"根据 [对话-003] 的记录,本月处理了97起舆情"
|
|
230
|
+
|
|
231
|
+
**推荐配置**:
|
|
232
|
+
- `MEM1_LLM_TEMPERATURE=0.2`(降低创造性,减少编造)
|
|
233
|
+
- `MEM1_CONTEXT_DAYS_LIMIT=7`(缩小检索范围,提高精准度)
|
|
234
|
+
|
|
225
235
|
## 设计决策:为什么不用向量数据库
|
|
226
236
|
|
|
227
237
|
mem1 选择 ES 时间范围检索而非 Milvus/Pinecone 等向量数据库,核心原因是**对话记忆需要上下文连续性**:
|
|
@@ -546,13 +546,14 @@ class Mem1Memory:
|
|
|
546
546
|
return summary
|
|
547
547
|
|
|
548
548
|
def _format_conversations_for_llm(self, conversations: List[Dict[str, Any]]) -> str:
|
|
549
|
-
"""
|
|
549
|
+
"""格式化对话记录为文本(带引用 ID)"""
|
|
550
550
|
output = []
|
|
551
|
-
for conv in conversations:
|
|
551
|
+
for idx, conv in enumerate(conversations, start=1):
|
|
552
|
+
conv_id = f"对话-{idx:03d}" # 001, 002, 003...
|
|
552
553
|
timestamp = conv.get("timestamp", "未知时间")
|
|
553
554
|
metadata = conv.get("metadata", {})
|
|
554
555
|
|
|
555
|
-
title = f"### {timestamp}"
|
|
556
|
+
title = f"### [{conv_id}] {timestamp}"
|
|
556
557
|
if metadata:
|
|
557
558
|
tags = " ".join([f"[{k}:{v}]" for k, v in metadata.items()])
|
|
558
559
|
title += f" {tags}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|