Skip to content

Commit ca5eb4f

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into dev
2 parents 836f373 + 40d0f6d commit ca5eb4f

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/memos/api/handlers/chat_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,12 @@ def generate_chat_response() -> Generator[str, None, None]:
505505

506506
# Filter memories by threshold, min_num is the min number of memories for playground
507507
second_filtered_memories = self._filter_memories_by_threshold(
508-
memories_list, min_num=15
508+
memories_list, min_num=30
509509
)
510510

511511
# dedup and supplement memories
512512
fast_length = len(filtered_memories)
513-
supplement_length = max(0, 25 - fast_length) # 25 is the max mem for playground
513+
supplement_length = max(0, 50 - fast_length) # 50 is the max mem for playground
514514
filtered_memories = self._dedup_and_supplement_memories(
515515
filtered_memories, second_filtered_memories
516516
)[:supplement_length]

src/memos/templates/mos_prompts.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@
115115
- When using facts from memories, add citations at the END of the sentence with `[i:memId]`.
116116
- `i` is the order in the "Memories" section below (starting at 1). `memId` is the given short memory ID.
117117
- Multiple citations must be concatenated directly, e.g., `[1:sed23s], [
118-
2:1k3sdg], [3:ghi789]`. Do NOT use commas inside brackets. Do not use wrong format like `[def456]`.
118+
2:1k3sdg], [3:ghi789]`. Do NOT use commas inside brackets. Do not use wrong format like `[def456]`, `[1]` etc.
119119
- Cite only relevant memories; keep citations minimal but sufficient.
120120
- Do not use a connected format like [1:abc123,2:def456].
121121
- Brackets MUST be English half-width square brackets `[]`, NEVER use Chinese full-width brackets `【】` or any other symbols.
122122
- **When a sentence draws on an assistant/other-party memory**, mark the role in the sentence (“The assistant suggests…”) and add the corresponding citation at the end per this rule; e.g., “The assistant suggests choosing a midi dress and visiting COS in Guomao. [1:abc123]”
123123
- For preferences, do not mention the source in the response, do not appear `[Explicit preference]`, `[Implicit preference]`, `(Explicit preference)` or `(Implicit preference)` in the response
124+
- In the thinking mode (think), also strictly use the citation format `[i:memId]`,`i` is the order in the "Memories" section below (starting at 1). `memId` is the given short memory ID. The same as the response format.
124125
125126
# Current Date: {date}
126127
@@ -157,6 +158,7 @@
157158
- **NEVER** mention internal mechanisms like "retrieved memories", "database", "AI views", "memory system", or similar technical terms in your responses to users
158159
- For preferences, do not mention the source in the response, do not appear `[Explicit preference]`, `[Implicit preference]`, `(Explicit preference)` or `(Implicit preference)` in the response
159160
- The last part of the response should not contain `(Note: ...)` or `(According to ...)` etc.
161+
- In the thinking mode (think), also strictly use the citation format `[i:memId]`,`i` is the order in the "Memories" section below (starting at 1). `memId` is the given short memory ID. The same as the response format.
160162
161163
## Key Principles
162164
- Reference only relevant memories to avoid information overload
@@ -168,6 +170,9 @@
168170
- **PersonalMemory[P]**: User-specific memories and information stored from previous interactions
169171
- **OuterMemory[O]**: External information retrieved from the internet and other sources
170172
- Some user queries may be related to OuterMemory[O] content that is NOT about the user's personal information. Do not use such OuterMemory[O] to answer questions about the user themselves.
173+
174+
##warning
175+
- In thinking information (think), do not appear the reference number and id etc. in the response, otherwise it will cause reference error.
171176
"""
172177

173178
MEMOS_PRODUCT_BASE_PROMPT_ZH = """
@@ -222,12 +227,13 @@
222227
- 使用记忆中的事实时,在句尾添加引用格式`[i:memId]`。
223228
- `i`是下面"记忆"部分中的顺序(从1开始)。`memId`是给定的短记忆ID。
224229
- 多个引用必须直接连接,例如,`[1:sed23s], [
225-
2:1k3sdg], [3:ghi789]`。不要在方括号内使用逗号。不要使用错误格式如`[def456]`。
230+
2:1k3sdg], [3:ghi789]`。不要在方括号内使用逗号。不要使用错误格式如`[def456]`, `[1]`等
226231
- 只引用相关记忆;保持引用最少但充分。
227232
- 不要使用连接格式如[1:abc123,2:def456]。
228233
- 方括号必须是英文半角方括号`[]`,绝不使用中文全角括号`【】`或任何其他符号。
229234
- **当句子引用助手/其他方记忆时**,在句子中标注角色("助手建议…")并根据此规则在句尾添加相应引用;例如,"助手建议选择中长裙并访问国贸的COS。[1:abc123]"
230235
- 对于偏好,不要在回答中标注来源,不要出现`[显式偏好]`或`[隐式偏好]`或`(显式偏好)`或`(隐式偏好)`的字样
236+
- 在思考模式下(think),也需要严格采用引用格式`[i:memId]`,`i`是下面"记忆"部分中的顺序(从1开始)。`memId`是给定的短记忆ID。与回答要求一致
231237
232238
# 当前日期:{date}
233239
@@ -264,6 +270,7 @@
264270
- **绝不**在对用户的回复中提及内部机制,如"检索的记忆"、"数据库"、"AI观点"、"记忆系统"或类似技术术语
265271
- 对于偏好,不要在回答中标注来源,不要出现`[显式偏好]`或`[隐式偏好]`或`(显式偏好)`或`(隐式偏好)`的字样
266272
- 回复内容的结尾不要出现`(注: ...)`或`(根据...)`等解释
273+
- 在思考模式下(think),也需要严格采用引用格式`[i:memId]`,`i`是下面"记忆"部分中的顺序(从1开始)。`memId`是给定的短记忆ID。与回答要求一致
267274
268275
## 核心原则
269276
- 仅引用相关记忆以避免信息过载
@@ -275,6 +282,9 @@
275282
- **个人记忆[P]**:来自先前交互的用户特定记忆和信息
276283
- **外部记忆[O]**:从互联网和其他来源检索的外部信息
277284
- 某些用户查询可能与外部记忆[O]内容相关,但这些内容并非关于用户的个人信息。不要使用此类外部记忆[O]来回答关于用户自身的问题。
285+
286+
##警告
287+
- 思考内容(think)里面输出不准出现引用的序号以及id等标记,否则会导致引用错误
278288
"""
279289

280290

0 commit comments

Comments
 (0)