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.
Files changed (26) hide show
  1. {mem1-0.0.9 → mem1-0.1.1}/.env.example +1 -1
  2. {mem1-0.0.9 → mem1-0.1.1}/PKG-INFO +17 -7
  3. {mem1-0.0.9 → mem1-0.1.1}/README.md +16 -6
  4. {mem1-0.0.9 → mem1-0.1.1}/mem1/__init__.py +1 -1
  5. {mem1-0.0.9 → mem1-0.1.1}/mem1/memory.py +4 -3
  6. {mem1-0.0.9 → mem1-0.1.1}/pyproject.toml +1 -1
  7. {mem1-0.0.9 → mem1-0.1.1}/.gitignore +0 -0
  8. {mem1-0.0.9 → mem1-0.1.1}/ChatGPTMemoryFeature.md +0 -0
  9. {mem1-0.0.9 → mem1-0.1.1}/ChatGPTMemoryFeature.pdf +0 -0
  10. {mem1-0.0.9 → mem1-0.1.1}/docker-compose.yml +0 -0
  11. {mem1-0.0.9 → mem1-0.1.1}/examples/basic_usage.py +0 -0
  12. {mem1-0.0.9 → mem1-0.1.1}/examples/batch_import.py +0 -0
  13. {mem1-0.0.9 → mem1-0.1.1}/examples/image_usage.py +0 -0
  14. {mem1-0.0.9 → mem1-0.1.1}/examples/langchain_integration.py +0 -0
  15. {mem1-0.0.9 → mem1-0.1.1}/examples//345/244/251/344/273/267/351/272/273/350/212/261.png" +0 -0
  16. {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
  17. {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
  18. {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
  19. {mem1-0.0.9 → mem1-0.1.1}/mem1/config.py +0 -0
  20. {mem1-0.0.9 → mem1-0.1.1}/mem1/langchain_middleware.py +0 -0
  21. {mem1-0.0.9 → mem1-0.1.1}/mem1/llm.py +0 -0
  22. {mem1-0.0.9 → mem1-0.1.1}/mem1/memory_md.py +0 -0
  23. {mem1-0.0.9 → mem1-0.1.1}/mem1/memory_tools.py +0 -0
  24. {mem1-0.0.9 → mem1-0.1.1}/mem1/prompts.py +0 -0
  25. {mem1-0.0.9 → mem1-0.1.1}/mem1/storage.py +0 -0
  26. {mem1-0.0.9 → mem1-0.1.1}/requirements.txt +0 -0
@@ -19,7 +19,7 @@
19
19
  MEM1_LLM_API_KEY=your-api-key
20
20
  MEM1_LLM_BASE_URL=https://api.deepseek.com
21
21
  MEM1_LLM_MODEL=deepseek-chat
22
- MEM1_LLM_TEMPERATURE=0.7
22
+ MEM1_LLM_TEMPERATURE=0.2
23
23
 
24
24
  # ES 配置(必填)
25
25
  MEM1_ES_HOSTS=http://localhost:9200
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mem1
3
- Version: 0.0.9
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. 需要汇总累加时,必须列出计算过程(如:23+31+18+25=97)
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. 需要汇总累加时,必须列出计算过程(如:23+31+18+25=97)
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 等向量数据库,核心原因是**对话记忆需要上下文连续性**:
@@ -3,7 +3,7 @@ Mem1 - 用户记忆系统(支持可插拔存储后端)
3
3
  """
4
4
  import logging
5
5
 
6
- __version__ = "0.0.9"
6
+ __version__ = "0.1.1"
7
7
 
8
8
  # 屏蔽第三方库的详细日志(必须在导入前设置)
9
9
  logging.getLogger("elastic_transport").setLevel(logging.WARNING)
@@ -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}"
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "mem1"
7
- version = "0.0.9"
7
+ version = "0.1.1"
8
8
  description = "基于云服务的用户记忆系统"
9
9
  authors = [
10
10
  { name = "Song" }
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