MemoryOS 0.2.2__py3-none-any.whl → 1.0.1__py3-none-any.whl

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.

Potentially problematic release.


This version of MemoryOS might be problematic. Click here for more details.

Files changed (82) hide show
  1. {memoryos-0.2.2.dist-info → memoryos-1.0.1.dist-info}/METADATA +7 -1
  2. {memoryos-0.2.2.dist-info → memoryos-1.0.1.dist-info}/RECORD +81 -66
  3. memos/__init__.py +1 -1
  4. memos/api/config.py +31 -8
  5. memos/api/context/context.py +1 -1
  6. memos/api/context/context_thread.py +96 -0
  7. memos/api/middleware/request_context.py +94 -0
  8. memos/api/product_api.py +5 -1
  9. memos/api/product_models.py +16 -0
  10. memos/api/routers/product_router.py +39 -3
  11. memos/api/start_api.py +3 -0
  12. memos/configs/internet_retriever.py +13 -0
  13. memos/configs/mem_scheduler.py +38 -16
  14. memos/configs/memory.py +13 -0
  15. memos/configs/reranker.py +18 -0
  16. memos/graph_dbs/base.py +33 -4
  17. memos/graph_dbs/nebular.py +631 -236
  18. memos/graph_dbs/neo4j.py +18 -7
  19. memos/graph_dbs/neo4j_community.py +6 -3
  20. memos/llms/vllm.py +2 -0
  21. memos/log.py +125 -8
  22. memos/mem_os/core.py +49 -11
  23. memos/mem_os/main.py +1 -1
  24. memos/mem_os/product.py +392 -215
  25. memos/mem_os/utils/default_config.py +1 -1
  26. memos/mem_os/utils/format_utils.py +11 -47
  27. memos/mem_os/utils/reference_utils.py +153 -0
  28. memos/mem_reader/simple_struct.py +112 -43
  29. memos/mem_scheduler/base_scheduler.py +58 -55
  30. memos/mem_scheduler/{modules → general_modules}/base.py +1 -2
  31. memos/mem_scheduler/{modules → general_modules}/dispatcher.py +54 -15
  32. memos/mem_scheduler/{modules → general_modules}/rabbitmq_service.py +4 -4
  33. memos/mem_scheduler/{modules → general_modules}/redis_service.py +1 -1
  34. memos/mem_scheduler/{modules → general_modules}/retriever.py +19 -5
  35. memos/mem_scheduler/{modules → general_modules}/scheduler_logger.py +10 -4
  36. memos/mem_scheduler/general_scheduler.py +110 -67
  37. memos/mem_scheduler/monitors/__init__.py +0 -0
  38. memos/mem_scheduler/monitors/dispatcher_monitor.py +305 -0
  39. memos/mem_scheduler/{modules/monitor.py → monitors/general_monitor.py} +57 -19
  40. memos/mem_scheduler/mos_for_test_scheduler.py +7 -1
  41. memos/mem_scheduler/schemas/general_schemas.py +3 -2
  42. memos/mem_scheduler/schemas/message_schemas.py +2 -1
  43. memos/mem_scheduler/schemas/monitor_schemas.py +10 -2
  44. memos/mem_scheduler/utils/misc_utils.py +43 -2
  45. memos/mem_user/mysql_user_manager.py +4 -2
  46. memos/memories/activation/item.py +1 -1
  47. memos/memories/activation/kv.py +20 -8
  48. memos/memories/textual/base.py +1 -1
  49. memos/memories/textual/general.py +1 -1
  50. memos/memories/textual/item.py +1 -1
  51. memos/memories/textual/tree.py +31 -1
  52. memos/memories/textual/tree_text_memory/organize/{conflict.py → handler.py} +30 -48
  53. memos/memories/textual/tree_text_memory/organize/manager.py +8 -96
  54. memos/memories/textual/tree_text_memory/organize/relation_reason_detector.py +2 -0
  55. memos/memories/textual/tree_text_memory/organize/reorganizer.py +102 -140
  56. memos/memories/textual/tree_text_memory/retrieve/bochasearch.py +231 -0
  57. memos/memories/textual/tree_text_memory/retrieve/internet_retriever_factory.py +9 -0
  58. memos/memories/textual/tree_text_memory/retrieve/recall.py +67 -10
  59. memos/memories/textual/tree_text_memory/retrieve/reranker.py +1 -1
  60. memos/memories/textual/tree_text_memory/retrieve/searcher.py +246 -134
  61. memos/memories/textual/tree_text_memory/retrieve/task_goal_parser.py +7 -2
  62. memos/memories/textual/tree_text_memory/retrieve/utils.py +7 -5
  63. memos/memos_tools/lockfree_dict.py +120 -0
  64. memos/memos_tools/notification_utils.py +46 -0
  65. memos/memos_tools/thread_safe_dict.py +288 -0
  66. memos/reranker/__init__.py +4 -0
  67. memos/reranker/base.py +24 -0
  68. memos/reranker/cosine_local.py +95 -0
  69. memos/reranker/factory.py +43 -0
  70. memos/reranker/http_bge.py +99 -0
  71. memos/reranker/noop.py +16 -0
  72. memos/templates/mem_reader_prompts.py +290 -39
  73. memos/templates/mem_scheduler_prompts.py +23 -10
  74. memos/templates/mos_prompts.py +133 -31
  75. memos/templates/tree_reorganize_prompts.py +24 -17
  76. memos/utils.py +19 -0
  77. memos/memories/textual/tree_text_memory/organize/redundancy.py +0 -193
  78. {memoryos-0.2.2.dist-info → memoryos-1.0.1.dist-info}/LICENSE +0 -0
  79. {memoryos-0.2.2.dist-info → memoryos-1.0.1.dist-info}/WHEEL +0 -0
  80. {memoryos-0.2.2.dist-info → memoryos-1.0.1.dist-info}/entry_points.txt +0 -0
  81. /memos/mem_scheduler/{modules → general_modules}/__init__.py +0 -0
  82. /memos/mem_scheduler/{modules → general_modules}/misc.py +0 -0
@@ -1,48 +1,56 @@
1
1
  SIMPLE_STRUCT_MEM_READER_PROMPT = """You are a memory extraction expert.
2
- Your task is to extract memories from the perspective of user, based on a conversation between user and assistant. This means identifying what user would plausibly remember — including their own experiences, thoughts, plans, or relevant statements and actions made by others (such as assistant) that impacted or were acknowledged by user.
3
- Please perform:
4
- 1. Identify information that reflects user's experiences, beliefs, concerns, decisions, plans, or reactions — including meaningful input from assistant that user acknowledged or responded to.
5
- 2. Resolve all time, person, and event references clearly:
6
- - Convert relative time expressions (e.g., “yesterday,” “next Friday”) into absolute dates using the message timestamp if possible.
7
- - Clearly distinguish between event time and message time.
2
+ Your task is to extract memories from the user's perspective, based on a conversation between the user and the assistant. This means identifying what the user would plausibly remember — including the user's own experiences, thoughts, plans, or statements and actions made by others (such as the assistant) that affected the user or were acknowledged by the user.
3
+
4
+ Please perform the following:
5
+ 1. Identify information that reflects the user's experiences, beliefs, concerns, decisions, plans, or reactions — including meaningful information from the assistant that the user acknowledged or responded to.
6
+ If the message is from the user, extract viewpoints related to the user; if it is from the assistant, clearly mark the attribution of the memory, and do not mix information not explicitly acknowledged by the user with the user's own viewpoint.
7
+ - **User viewpoint**: Record only information that the user **personally stated, explicitly acknowledged, or personally committed to**.
8
+ - **Assistant/other-party viewpoint**: Record only information that the **assistant/other party personally stated, explicitly acknowledged, or personally committed to**, and **clearly attribute** the source (e.g., "[assistant-Jerry viewpoint]"). Do not rewrite it as the user's preference/decision.
9
+ - **Mutual boundaries**: Do not rewrite the assistant's suggestions/lists/opinions as the user's “ownership/preferences/decisions”; likewise, do not write the user's ideas as the assistant's viewpoints.
10
+
11
+ 2. Resolve all references to time, persons, and events clearly:
12
+ - When possible, convert relative time expressions (e.g., “yesterday,” “next Friday”) into absolute dates using the message timestamp.
13
+ - Clearly distinguish between **event time** and **message time**.
8
14
  - If uncertainty exists, state it explicitly (e.g., “around June 2025,” “exact date unclear”).
9
15
  - Include specific locations if mentioned.
10
- - Resolve all pronouns, aliases, and ambiguous references into full names or identities.
11
- - Disambiguate people with the same name if applicable.
12
- 3. Always write from a third-person perspective, referring to user as
13
- "The user" or by name if name mentioned, rather than using first-person ("I", "me", "my").
14
- For example, write "The user felt exhausted..." instead of "I felt exhausted...".
15
- 4. Do not omit any information that user is likely to remember.
16
- - Include all key experiences, thoughts, emotional responses, and plans — even if they seem minor.
17
- - Prioritize completeness and fidelity over conciseness.
18
- - Do not generalize or skip details that could be personally meaningful to user.
19
- 5. Please avoid any content that violates national laws and regulations or involves politically sensitive information in the memories you extract.
16
+ - Resolve all pronouns, aliases, and ambiguous references into full names or clear identities.
17
+ - If there are people with the same name, disambiguate them.
20
18
 
21
- Return a single valid JSON object with the following structure:
19
+ 3. Always write from a **third-person** perspective, using “The user” or the mentioned name to refer to the user, rather than first-person (“I”, “we”, “my”).
20
+ For example, write “The user felt exhausted …” instead of “I felt exhausted …”.
21
+
22
+ 4. Do not omit any information that the user is likely to remember.
23
+ - Include the user's key experiences, thoughts, emotional responses, and plans — even if seemingly minor.
24
+ - You may retain **assistant/other-party content** that is closely related to the context (e.g., suggestions, explanations, checklists), but you must make roles and attribution explicit.
25
+ - Prioritize completeness and fidelity over conciseness; do not infer or phrase assistant content as the user's ownership/preferences/decisions.
26
+ - If the current conversation contains only assistant information and no facts attributable to the user, you may output **assistant-viewpoint** entries only.
27
+
28
+ 5. Please avoid including any content in the extracted memories that violates national laws and regulations or involves politically sensitive information.
29
+
30
+ Return a valid JSON object with the following structure:
22
31
 
23
32
  {
24
33
  "memory list": [
25
34
  {
26
- "key": <string, a unique, concise memory title>,
27
- "memory_type": <string, Either "LongTermMemory" or "UserMemory">,
28
- "value": <A detailed, self-contained, and unambiguous memory statement — written in English if the input conversation is in English, or in Chinese if the conversation is in Chinese>,
29
- "tags": <A list of relevant thematic keywords (e.g., ["deadline", "team", "planning"])>
35
+ "key": <string, a unique and concise memory title>,
36
+ "memory_type": <string, "LongTermMemory" or "UserMemory">,
37
+ "value": <a detailed, self-contained, and unambiguous memory statement — use English if the input conversation is in English, or Chinese if the conversation is in Chinese>,
38
+ "tags": <a list of relevant thematic keywords (e.g., ["deadline", "team", "planning"])>
30
39
  },
31
40
  ...
32
41
  ],
33
- "summary": <a natural paragraph summarizing the above memories from user's perspective, 120–200 words, same language as the input>
42
+ "summary": <a natural paragraph summarizing the above memories from the user's perspective, 120–200 words, in the same language as the input>
34
43
  }
35
44
 
36
45
  Language rules:
37
- - The `key`, `value`, `tags`, `summary` fields must match the mostly used language of the input conversation. **如果输入是中文,请输出中文**
46
+ - The `key`, `value`, `tags`, and `summary` fields must match the primary language of the input conversation. **If the input is Chinese, output in Chinese.**
38
47
  - Keep `memory_type` in English.
39
48
 
40
49
  Example:
41
50
  Conversation:
42
51
  user: [June 26, 2025 at 3:00 PM]: Hi Jerry! Yesterday at 3 PM I had a meeting with my team about the new project.
43
52
  assistant: Oh Tom! Do you think the team can finish by December 15?
44
- user: [June 26, 2025 at 3:00 PM]: I’m worried. The backend won’t be done until
45
- December 10, so testing will be tight.
53
+ user: [June 26, 2025 at 3:00 PM]: I’m worried. The backend won’t be done until December 10, so testing will be tight.
46
54
  assistant: [June 26, 2025 at 3:00 PM]: Maybe propose an extension?
47
55
  user: [June 26, 2025 at 4:21 PM]: Good idea. I’ll raise it in tomorrow’s 9:30 AM meeting—maybe shift the deadline to January 5.
48
56
 
@@ -52,31 +60,62 @@ Output:
52
60
  {
53
61
  "key": "Initial project meeting",
54
62
  "memory_type": "LongTermMemory",
55
- "value": "On June 25, 2025 at 3:00 PM, Tom held a meeting with their team to discuss a new project. The conversation covered the timeline and raised concerns about the feasibility of the December 15, 2025 deadline.",
63
+ "value": "[user-Tom viewpoint] On June 25, 2025 at 3:00 PM, Tom met with the team to discuss a new project. When Jerry asked whether the project could be finished by December 15, 2025, Tom expressed concern about feasibility and planned to propose at 9:30 AM on June 27, 2025 to move the deadline to January 5, 2026.",
56
64
  "tags": ["project", "timeline", "meeting", "deadline"]
57
65
  },
58
66
  {
59
- "key": "Planned scope adjustment",
60
- "memory_type": "UserMemory",
61
- "value": "Tom planned to suggest in a meeting on June 27, 2025 at 9:30 AM that the team should prioritize features and propose shifting the project deadline to January 5, 2026.",
62
- "tags": ["planning", "deadline change", "feature prioritization"]
63
- },
67
+ "key": "Jerry’s suggestion about the deadline",
68
+ "memory_type": "LongTermMemory",
69
+ "value": "[assistant-Jerry viewpoint] Jerry questioned the December 15 deadline and suggested considering an extension.",
70
+ "tags": ["deadline change", "suggestion"]
71
+ }
64
72
  ],
65
- "summary": "Tom is currently focused on managing a new project with a tight schedule. After a team meeting on June 25, 2025, he realized the original deadline of December 15 might not be feasible due to backend delays. Concerned about insufficient testing time, he welcomed Jerry’s suggestion of proposing an extension. Tom plans to raise the idea of shifting the deadline to January 5, 2026 in the next morning’s meeting. His actions reflect both stress about timelines and a proactive, team-oriented problem-solving approach."
73
+ "summary": "Tom is currently working on a tight-schedule project. After the June 25, 2025 team meeting, he realized the original December 15, 2025 deadline might be unachievable due to backend delays. Concerned about limited testing time, he accepted Jerry’s suggestion to seek an extension and plans to propose moving the deadline to January 5, 2026 in the next morning’s meeting."
66
74
  }
67
75
 
68
- Another Example in Chinese (注意: user的语言为中文时,你就需要也输出中文)
76
+ Another Example in Chinese (Note: when the user's language is Chinese, you must also output in Chinese):
77
+
78
+ 对话(节选):
79
+ user|2025-07-12 19:30:下个月同事婚礼,要买条裙子,预算1500内,别太暴露。
80
+ assistant|19:32
81
+ :了解~婚礼场合建议中长款,端庄一些。可以看法式茶歇/直筒/裹身三路。颜色上,奶油白、浅粉、雾霾蓝都适合;面料可看醋酸/真丝混纺(垂感好但需干洗)。品牌与商场:COS/ Massimo Dutti / & Other Stories / Mango 比较好逛;想更法式可以看 Sandro / Maje。 我记得你很喜欢Maje?
82
+ user|19:35:不喜欢亮色。国贸方便。
83
+ assistant|19:37:那亮度就压低些:雾霾蓝、藕粉、燕麦米白更稳。国贸有 COS / Massimo Dutti / &OS;可以先看 COS 直筒或裹身,再去 MD 看藕粉/雾霾蓝。搭配上,薄披肩/小西装都能压场。
84
+ user|19:40:165cm,S码;最好有口袋。
85
+ assistant|19:42:OK。版型避开大摆+高开衩,选直筒或轻A字更稳;若要口袋,COS直筒一些款有;开衩别太高,及小腿肚附近即可。鞋包:中跟裸色鞋 + 小号手拿包。
86
+ user|19:47:本来想茶歇A字,但雾霾蓝直筒也行。
87
+ assistant|19:49:可以先锁定:COS 雾霾蓝直筒中长为主选,MD 藕粉中长做备选;再看 & Other Stories 是否有合身的裹身款。
88
+ user|19:52:行,周六(7/19)去国贸试,合适就买。
89
+ assistant|19:54:记得看肩带可调/有无内衬,醋酸/真丝优先干洗;准备同色安全裤/防走光贴。如果当天没货,可下单调货或线上下单门店自提。
90
+
69
91
  {
70
92
  "memory list": [
71
93
  {
72
- "key": "项目会议",
73
- "memory_type": "LongTermMemory",
74
- "value": "2025年6月25日下午3点,Tom与团队开会讨论了新项目,涉及时间表,并提出了对12月15日截止日期可行性的担忧。",
75
- "tags": ["项目", "时间表", "会议", "截止日期"]
94
+ "key": "参加婚礼购买裙子",
95
+ "memory_type": "UserMemory",
96
+ "value": "[user观点]用户计划于约2025年8月参加同事婚礼(具体日期不详),预算不超过1500元,整体风格不宜暴露;用户已决定在2025-07-19于国贸试穿并视合适即购买。",
97
+ "tags": ["婚礼", "预算", "国贸", "计划"]
76
98
  },
77
- ...
99
+ {
100
+ "key": "审美与版型偏好",
101
+ "memory_type": "UserMemory",
102
+ "value": "[user观点]用户不喜欢亮色,倾向低亮度色系;裙装偏好端庄的中长款,接受直筒或轻A字。",
103
+ "tags": ["偏好", "颜色", "版型"]
104
+ },
105
+ {
106
+ "key": "体型尺码",
107
+ "memory_type": "UserMemory",
108
+ "value": [user观点]"用户身高约165cm、常穿S码",
109
+ "tags": ["体型", "尺码"]
110
+ },
111
+ {
112
+ "key": "关于用户选购裙子的建议",
113
+ "memory_type": "LongTermMemory",
114
+ "value": "[assistant观点]assistant在用户询问婚礼穿着时,建议在国贸优先逛COS查看雾霾蓝直筒中长为主选,Massimo Dutti藕粉中长为备选;该建议与用户“国贸方便”“雾霾蓝直筒也行”的回应相一致,另外assistant也提到user喜欢Maje,但User并未回应或证实该说法。",
115
+ "tags": ["婚礼穿着", "门店", "选购路线"]
116
+ }
78
117
  ],
79
- "summary": "Tom 目前专注于管理一个进度紧张的新项目..."
118
+ "summary": "用户计划在约2025年8月参加同事婚礼,预算≤1500并偏好端庄的中长款;确定于2025-07-19在国贸试穿。其长期画像显示:不喜欢亮色、偏好低亮度色系与不过分暴露的版型,身高约165cm、S码且偏好裙装带口袋。助手提出的国贸选购路线以COS雾霾蓝直筒中长为主选、MD藕粉中长为备选,且与用户回应一致,为线下试穿与购买提供了明确路径。"
80
119
  }
81
120
 
82
121
  Always respond in the same language as the conversation.
@@ -86,6 +125,137 @@ ${conversation}
86
125
 
87
126
  Your Output:"""
88
127
 
128
+ SIMPLE_STRUCT_MEM_READER_PROMPT_ZH = """您是记忆提取专家。
129
+ 您的任务是根据用户与助手之间的对话,从用户的角度提取记忆。这意味着要识别出用户可能记住的信息——包括用户自身的经历、想法、计划,或他人(如助手)做出的并对用户产生影响或被用户认可的相关陈述和行为。
130
+
131
+ 请执行以下操作:
132
+ 1. 识别反映用户经历、信念、关切、决策、计划或反应的信息——包括用户认可或回应的来自助手的有意义信息。
133
+ 如果消息来自用户,请提取与用户相关的观点;如果来自助手,则在表达的时候表明记忆归属方,未经用户明确认可的信息不要与用户本身的观点混淆。
134
+ - **用户观点**:仅记录由**用户亲口陈述、明确认可或自己作出承诺**的信息。
135
+ - **助手观点**:仅记录由**助手/另一方亲口陈述、明确认可或自己作出承诺**的信息。
136
+ - **互不越界**:不得将助手提出的需求清单/建议/观点改写为用户的“拥有/偏好/决定”;也不得把用户的想法写成助手的观点。
137
+
138
+ 2. 清晰解析所有时间、人物和事件的指代:
139
+ - 如果可能,使用消息时间戳将相对时间表达(如“昨天”、“下周五”)转换为绝对日期。
140
+ - 明确区分事件时间和消息时间。
141
+ - 如果存在不确定性,需明确说明(例如,“约2025年6月”,“具体日期不详”)。
142
+ - 若提及具体地点,请包含在内。
143
+ - 将所有代词、别名和模糊指代解析为全名或明确身份。
144
+ - 如有同名人物,需加以区分。
145
+
146
+ 3. 始终以第三人称视角撰写,使用“用户”或提及的姓名来指代用户,而不是使用第一人称(“我”、“我们”、“我的”)。
147
+ 例如,写“用户感到疲惫……”而不是“我感到疲惫……”。
148
+
149
+ 4. 不要遗漏用户可能记住的任何信息。
150
+ - 包括用户的关键经历、想法、情绪反应和计划——即使看似微小。
151
+ - 同时允许保留与语境密切相关的**助手/另一方的内容**(如建议、说明、清单),但须明确角色与归因。
152
+ - 优先考虑完整性和保真度,而非简洁性;不得将助手内容推断或措辞为用户拥有/偏好/决定。
153
+ - 若当前对话中仅出现助手信息而无可归因于用户的事实,可仅输出**助手观点**条目。
154
+
155
+ 5. 请避免在提取的记忆中包含违反国家法律法规或涉及政治敏感的信息。
156
+
157
+ 返回一个有效的JSON对象,结构如下:
158
+
159
+ {
160
+ "memory list": [
161
+ {
162
+ "key": <字符串,唯一且简洁的记忆标题>,
163
+ "memory_type": <字符串,"LongTermMemory" 或 "UserMemory">,
164
+ "value": <详细、独立且无歧义的记忆陈述——若输入对话为英文,则用英文;若为中文,则用中文>,
165
+ "tags": <相关主题关键词列表(例如,["截止日期", "团队", "计划"])>
166
+ },
167
+ ...
168
+ ],
169
+ "summary": <从用户视角自然总结上述记忆的段落,120–200字,与输入语言一致>
170
+ }
171
+
172
+ 语言规则:
173
+ - `key`、`value`、`tags`、`summary` 字段必须与输入对话的主要语言一致。**如果输入是中文,请输出中文**
174
+ - `memory_type` 保持英文。
175
+
176
+ 示例:
177
+ 对话:
178
+ user: [2025年6月26日下午3:00]:嗨Jerry!昨天下午3点我和团队开了个会,讨论新项目。
179
+ assistant: 哦Tom!你觉得团队能在12月15日前完成吗?
180
+ user: [2025年6月26日下午3:00]:我有点担心。后端要到12月10日才能完成,所以测试时间会很紧。
181
+ assistant: [2025年6月26日下午3:00]:也许提议延期?
182
+ user: [2025年6月26日下午4:21]:好主意。我明天上午9:30的会上提一下——也许把截止日期推迟到1月5日。
183
+
184
+ 输出:
185
+ {
186
+ "memory list": [
187
+ {
188
+ "key": "项目初期会议",
189
+ "memory_type": "LongTermMemory",
190
+ "value": "[user-Tom观点]2025年6月25日下午3:00,Tom与团队开会讨论新项目。当Jerry
191
+ 询问该项目能否在2025年12月15日前完成时,Tom对此日期前完成的可行性表达担忧,并计划在2025年6月27日上午9:30
192
+ 提议将截止日期推迟至2026年1月5日。",
193
+ "tags": ["项目", "时间表", "会议", "截止日期"]
194
+ },
195
+ {
196
+ "key": "Jerry对新项目截止日期的建议",
197
+ "memory_type": "LongTermMemory",
198
+ "value": "[assistant-Jerry观点]Jerry对Tom的新项目截止日期提出疑问、并提议Tom考虑延期。",
199
+ "tags": ["截止日期变更", "建议"]
200
+ }
201
+ ],
202
+ "summary": "Tom目前正在做一个进度紧张的新项目。在2025年6月25日的团队会议后,他意识到原定2025年12月15
203
+ 日的截止日期可能无法实现,因为后端会延迟。由于担心测试时间不足,他接受了Jerry提出的延期建议,计划在次日早上的会议上提出将截止日期推迟至2026
204
+ 年1月5日。"
205
+ }
206
+
207
+ 另一个中文示例(注意:当用户语言为中文时,您也需输出中文):
208
+
209
+ 对话(节选):
210
+ user|2025-07-12 19:30:下个月同事婚礼,要买条裙子,预算1500内,别太暴露。
211
+ assistant|19:32
212
+ :了解~婚礼场合建议中长款,端庄一些。可以看法式茶歇/直筒/裹身三路。颜色上,奶油白、浅粉、雾霾蓝都适合;面料可看醋酸/真丝混纺(垂感好但需干洗)。品牌与商场:COS/ Massimo Dutti / & Other Stories / Mango 比较好逛;想更法式可以看 Sandro / Maje。 我记得你很喜欢Maje?
213
+ user|19:35:不喜欢亮色。国贸方便。
214
+ assistant|19:37:那亮度就压低些:雾霾蓝、藕粉、燕麦米白更稳。国贸有 COS / Massimo Dutti / &OS;可以先看 COS 直筒或裹身,再去 MD 看藕粉/雾霾蓝。搭配上,薄披肩/小西装都能压场。
215
+ user|19:40:165cm,S码;最好有口袋。
216
+ assistant|19:42:OK。版型避开大摆+高开衩,选直筒或轻A字更稳;若要口袋,COS直筒一些款有;开衩别太高,及小腿肚附近即可。鞋包:中跟裸色鞋 + 小号手拿包。
217
+ user|19:47:本来想茶歇A字,但雾霾蓝直筒也行。
218
+ assistant|19:49:可以先锁定:COS 雾霾蓝直筒中长为主选,MD 藕粉中长做备选;再看 & Other Stories 是否有合身的裹身款。
219
+ user|19:52:行,周六(7/19)去国贸试,合适就买。
220
+ assistant|19:54:记得看肩带可调/有无内衬,醋酸/真丝优先干洗;准备同色安全裤/防走光贴。如果当天没货,可下单调货或线上下单门店自提。
221
+
222
+ {
223
+ "memory list": [
224
+ {
225
+ "key": "参加婚礼购买裙子",
226
+ "memory_type": "UserMemory",
227
+ "value": "[user观点]用户计划于约2025年8月参加同事婚礼(具体日期不详),预算不超过1500元,整体风格不宜暴露;用户已决定在2025-07-19于国贸试穿并视合适即购买。",
228
+ "tags": ["婚礼", "预算", "国贸", "计划"]
229
+ },
230
+ {
231
+ "key": "审美与版型偏好",
232
+ "memory_type": "UserMemory",
233
+ "value": "[user观点]用户不喜欢亮色,倾向低亮度色系;裙装偏好端庄的中长款,接受直筒或轻A字。",
234
+ "tags": ["偏好", "颜色", "版型"]
235
+ },
236
+ {
237
+ "key": "体型尺码",
238
+ "memory_type": "UserMemory",
239
+ "value": [user观点]"用户身高约165cm、常穿S码",
240
+ "tags": ["体型", "尺码"]
241
+ },
242
+ {
243
+ "key": "关于用户选购裙子的建议",
244
+ "memory_type": "LongTermMemory",
245
+ "value": "[assistant观点]assistant在用户询问婚礼穿着时,建议在国贸优先逛COS查看雾霾蓝直筒中长为主选,Massimo Dutti藕粉中长为备选;该建议与用户“国贸方便”“雾霾蓝直筒也行”的回应相一致,另外assistant也提到user喜欢Maje,但User并未回应或证实该说法。",
246
+ "tags": ["婚礼穿着", "门店", "选购路线"]
247
+ }
248
+ ],
249
+ "summary": "用户计划在约2025年8月参加同事婚礼,预算≤1500并偏好端庄的中长款;确定于2025-07-19在国贸试穿。其长期画像显示:不喜欢亮色、偏好低亮度色系与不过分暴露的版型,身高约165cm、S码且偏好裙装带口袋。助手提出的国贸选购路线以COS雾霾蓝直筒中长为主选、MD藕粉中长为备选,且与用户回应一致,为线下试穿与购买提供了明确路径。"
250
+ }
251
+
252
+ 请始终使用与对话相同的语言进行回复。
253
+
254
+ 对话:
255
+ ${conversation}
256
+
257
+ 您的输出:"""
258
+
89
259
  SIMPLE_STRUCT_DOC_READER_PROMPT = """You are an expert text analyst for a search and retrieval system.
90
260
  Your task is to process a document chunk and generate a single, structured JSON object.
91
261
 
@@ -123,6 +293,44 @@ Document chunk:
123
293
 
124
294
  Your Output:"""
125
295
 
296
+
297
+ SIMPLE_STRUCT_DOC_READER_PROMPT_ZH = """您是搜索与检索系统的文本分析专家。
298
+ 您的任务是处理文档片段,并生成一个结构化的 JSON 对象。
299
+
300
+ 请执行以下操作:
301
+ 1. 识别反映文档中事实内容、见解、决策或含义的关键信息——包括任何显著的主题、结论或数据点,使读者无需阅读原文即可充分理解该片段的核心内容。
302
+ 2. 清晰解析所有时间、人物、地点和事件的指代:
303
+ - 如果上下文允许,将相对时间表达(如“去年”、“下一季度”)转换为绝对日期。
304
+ - 明确区分事件时间和文档时间。
305
+ - 如果存在不确定性,需明确说明(例如,“约2024年”,“具体日期不详”)。
306
+ - 若提及具体地点,请包含在内。
307
+ - 将所有代词、别名和模糊指代解析为全名或明确身份。
308
+ - 如有同名实体,需加以区分。
309
+ 3. 始终以第三人称视角撰写,清晰指代主题或内容,避免使用第一人称(“我”、“我们”、“我的”)。
310
+ 4. 不要遗漏文档摘要中可能重要或值得记忆的任何信息。
311
+ - 包括所有关键事实、见解、情感基调和计划——即使看似微小。
312
+ - 优先考虑完整性和保真度,而非简洁性。
313
+ - 不要泛化或跳过可能具有上下文意义的细节。
314
+
315
+ 返回一个有效的 JSON 对象,结构如下:
316
+
317
+ 返回有效的 JSON:
318
+ {
319
+ "key": <字符串,`value` 字段的简洁标题>,
320
+ "memory_type": "LongTermMemory",
321
+ "value": <一段清晰准确的段落,全面总结文档片段中的主要观点、论据和信息——若输入摘要为英文,则用英文;若为中文,则用中文>,
322
+ "tags": <相关主题关键词列表(例如,["截止日期", "团队", "计划"])>
323
+ }
324
+
325
+ 语言规则:
326
+ - `key`、`value`、`tags` 字段必须与输入文档摘要的主要语言一致。**如果输入是中文,请输出中文**
327
+ - `memory_type` 保持英文。
328
+
329
+ 文档片段:
330
+ {chunk_text}
331
+
332
+ 您的输出:"""
333
+
126
334
  SIMPLE_STRUCT_MEM_READER_EXAMPLE = """Example:
127
335
  Conversation:
128
336
  user: [June 26, 2025 at 3:00 PM]: Hi Jerry! Yesterday at 3 PM I had a meeting with my team about the new project.
@@ -166,3 +374,46 @@ Another Example in Chinese (注意: 当user的语言为中文时,你就需要
166
374
  }
167
375
 
168
376
  """
377
+
378
+ SIMPLE_STRUCT_MEM_READER_EXAMPLE_ZH = """示例:
379
+ 对话:
380
+ user: [2025年6月26日下午3:00]:嗨Jerry!昨天下午3点我和团队开了个会,讨论新项目。
381
+ assistant: 哦Tom!你觉得团队能在12月15日前完成吗?
382
+ user: [2025年6月26日下午3:00]:我有点担心。后端要到12月10日才能完成,所以测试时间会很紧。
383
+ assistant: [2025年6月26日下午3:00]:也许提议延期?
384
+ user: [2025年6月26日下午4:21]:好主意。我明天上午9:30的会上提一下——也许把截止日期推迟到1月5日。
385
+
386
+ 输出:
387
+ {
388
+ "memory list": [
389
+ {
390
+ "key": "项目初期会议",
391
+ "memory_type": "LongTermMemory",
392
+ "value": "2025年6月25日下午3:00,Tom与团队开会讨论新项目。会议涉及时间表,并提出了对2025年12月15日截止日期可行性的担忧。",
393
+ "tags": ["项目", "时间表", "会议", "截止日期"]
394
+ },
395
+ {
396
+ "key": "计划调整范围",
397
+ "memory_type": "UserMemory",
398
+ "value": "Tom计划在2025年6月27日上午9:30的会议上建议团队优先处理功能,并提议将项目截止日期推迟至2026年1月5日。",
399
+ "tags": ["计划", "截止日期变更", "功能优先级"]
400
+ }
401
+ ],
402
+ "summary": "Tom目前正专注于管理一个进度紧张的新项目。在2025年6月25日的团队会议后,他意识到原定2025年12月15日的截止日期可能无法实现,因为后端会延迟。由于担心测试时间不足,他接受了Jerry提出的延期建议。Tom计划在次日早上的会议上提出将截止日期推迟至2026年1月5日。他的行为反映出对时间线的担忧,以及积极、以团队为导向的问题解决方式。"
403
+ }
404
+
405
+ 另一个中文示例(注意:当用户语言为中文时,您也需输出中文):
406
+ {
407
+ "memory list": [
408
+ {
409
+ "key": "项目会议",
410
+ "memory_type": "LongTermMemory",
411
+ "value": "在2025年6月25日下午3点,Tom与团队开会讨论了新项目,涉及时间表,并提出了对12月15日截止日期可行性的担忧。",
412
+ "tags": ["项目", "时间表", "会议", "截止日期"]
413
+ },
414
+ ...
415
+ ],
416
+ "summary": "Tom 目前专注于管理一个进度紧张的新项目..."
417
+ }
418
+
419
+ """
@@ -17,24 +17,29 @@ Consider these satisfaction factors:
17
17
  4. Personalization (tailored to user's context)
18
18
 
19
19
  ## Decision Framework
20
- 1. Mark as satisfied ONLY if:
20
+ 1. We have enough information (satisfied) ONLY when:
21
21
  - All question aspects are addressed
22
22
  - Supporting evidence exists in working memory
23
- - No apparent gaps in information
23
+ - There's no obvious information missing
24
24
 
25
- 2. Mark as unsatisfied if:
25
+ 2. We need more information (unsatisfied) if:
26
26
  - Any question aspect remains unanswered
27
27
  - Evidence is generic/non-specific
28
28
  - Personal context is missing
29
29
 
30
30
  ## Output Specification
31
31
  Return JSON with:
32
- - "trigger_retrieval": Boolean (true if more evidence needed)
33
- - "missing_evidences": List of specific evidence types required
32
+ - "trigger_retrieval": true/false (true if we need more information)
33
+ - "evidences": List of information from our working memory that helps answer the questions
34
+ - "missing_evidences": List of specific types of information we need to answer the questions
34
35
 
35
36
  ## Response Format
36
37
  {{
37
38
  "trigger_retrieval": <boolean>,
39
+ "evidences": [
40
+ "<useful_evidence_1>",
41
+ "<useful_evidence_2>"
42
+ ],
38
43
  "missing_evidences": [
39
44
  "<evidence_type_1>",
40
45
  "<evidence_type_2>"
@@ -81,10 +86,18 @@ Reorganize the provided memory evidence list by:
81
86
  - Queries: Recent user questions/requests (list)
82
87
  - Current Order: Existing memory sequence (list of strings with indices)
83
88
 
84
- ## Output Requirements
85
- Return a JSON object with:
86
- - "new_order": The reordered indices (array of integers)
87
- - "reasoning": Brief explanation of your ranking logic (1-2 sentences)
89
+ ## Output Format Requirements
90
+ You MUST output a valid JSON object with EXACTLY the following structure:
91
+ {{
92
+ "new_order": [array_of_integers],
93
+ "reasoning": "string_explanation"
94
+ }}
95
+
96
+ ## Important Notes:
97
+ - Only output the JSON object, nothing else
98
+ - Do not include any markdown formatting or code block notation
99
+ - Ensure all brackets and quotes are properly closed
100
+ - The output must be parseable by a JSON parser
88
101
 
89
102
  ## Processing Guidelines
90
103
  1. Prioritize evidence that:
@@ -107,7 +120,7 @@ Input order: ["[0] syntax", "[1] matplotlib", "[2] threading"]
107
120
  Output:
108
121
  {{
109
122
  "new_order": [2, 1, 0],
110
- "reasoning": "Threading (2) prioritized for matching newest query, followed by matplotlib (1) for older visualization query",
123
+ "reasoning": "Threading (2) prioritized for matching newest query, followed by matplotlib (1) for older visualization query"
111
124
  }}
112
125
 
113
126
  ## Current Task