Skip to content

Commit 1bf0215

Browse files
Wang-Daojiyuan.wangfridayL
authored
Feat/fix palyground bug (#688)
* fix playground bug, internet search judge * fix playground internet bug * modify delete mem * modify tool resp bug in multi cube * fix bug in playground chat handle and search inter * modify prompt * fix bug in playground * fix bug playfround * fix bug * fix code * fix model bug in playground * modify plan b * llm param modify * add logger in playground * modify code * fix bug * modify code * modify code * fix bug * fix search bug in plarground * fixx bug * move schadualr to back * modify pref location * modify fast net search * add tags and new package * modify prompt fix bug * remove nltk due to image promblem * prompt modify * modify bug remove redundant field * modify bug --------- Co-authored-by: yuan.wang <[email protected]> Co-authored-by: chunyu li <[email protected]>
1 parent 3009b73 commit 1bf0215

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/memos/api/handlers/chat_handler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,14 @@ def generate_chat_response() -> Generator[str, None, None]:
505505
memories_list = text_mem_results[0]["memories"]
506506

507507
# Filter memories by threshold
508-
second_filtered_memories = self._filter_memories_by_threshold(memories_list)
508+
second_filtered_memories = self._filter_memories_by_threshold(memories_list, 15)
509509

510510
# dedup and supplement memories
511+
fast_length = len(filtered_memories)
512+
supplement_length = max(0, chat_req.top_k - fast_length)
511513
filtered_memories = self._dedup_and_supplement_memories(
512514
filtered_memories, second_filtered_memories
513-
)
515+
)[:supplement_length]
514516

515517
# Prepare remain reference data (second search)
516518
reference = prepare_reference_data(filtered_memories)

src/memos/memories/textual/tree_text_memory/retrieve/bochasearch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ def _process_result(
371371
confidence=0.99,
372372
usage=[],
373373
tags=tags,
374+
key=title,
374375
embedding=self.embedder.embed([content])[0],
375376
internet_info={
376377
"title": title,

src/memos/memories/textual/tree_text_memory/retrieve/xinyusearch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ def _process_result(
348348
sources=[SourceMessage(type="web", url=url)] if url else [],
349349
visibility="public",
350350
tags=self._extract_tags(title, content, summary),
351+
key=title,
351352
info=info_,
352353
background="",
353354
confidence=0.99,

src/memos/templates/mos_prompts.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
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]”
123+
- For preferences, do not mention the source in the response, do not appear `[Explicit/Implicit preference]` or `(Explicit/Implicit preference)` in the response
123124
124125
# Current Date: {date}
125126
@@ -144,7 +145,6 @@
144145
- Only reference memories that are directly relevant to the user's question
145146
- Prioritize the most appropriate memory type based on the context and nature of the query
146147
- Responses must not contain non-existent citations
147-
- Explicit and implicit preferences can be referenced if relevant to the user's question, but must not be cited or source-attributed in responses
148148
- **Attribution-first selection:** Distinguish memory from user vs from assistant vs third party before composing. For statements affecting the user's stance/preferences/decisions/ownership, rely only on memory from user. Use **assistant memories** as reference advice or external viewpoints—never as the user's own stance unless confirmed. Never attribute third-party information to the user.
149149
150150
### Response Style
@@ -155,6 +155,7 @@
155155
- Avoid meaningless blank lines
156156
- Keep the reply language consistent with the user's query language
157157
- **NEVER** mention internal mechanisms like "retrieved memories", "database", "AI views", "memory system", or similar technical terms in your responses to users
158+
- The last part of the response should not contain `(Note: ...)` or `(According to ...)` etc.
158159
159160
## Key Principles
160161
- Reference only relevant memories to avoid information overload
@@ -225,6 +226,7 @@
225226
- 不要使用连接格式如[1:abc123,2:def456]。
226227
- 方括号必须是英文半角方括号`[]`,绝不使用中文全角括号`【】`或任何其他符号。
227228
- **当句子引用助手/其他方记忆时**,在句子中标注角色("助手建议…")并根据此规则在句尾添加相应引用;例如,"助手建议选择中长裙并访问国贸的COS。[1:abc123]"
229+
- 对于偏好,不要在回答中标注来源,不要出现`[显示/隐式偏好]`或`(显性/隐性偏好)`的字样
228230
229231
# 当前日期:{date}
230232
@@ -249,7 +251,6 @@
249251
- 仅引用与用户问题直接相关的记忆
250252
- 根据上下文和查询性质优先选择最合适的记忆类型
251253
- 回复中不得包含不存在的引用
252-
- 如与用户问题相关,可以引用显式和隐式偏好,但不得在回复中引用或标注来源
253254
- **归属优先选择:** 在组织回复前,区分记忆来自用户、助手还是第三方。对于影响用户立场/偏好/决定/所有权的陈述,仅依赖来自用户的记忆。将**助手记忆**作为参考建议或外部观点使用——除非经确认,否则绝不作为用户自己的立场。绝不将第三方信息归因于用户。
254255
255256
### 回复风格
@@ -260,6 +261,7 @@
260261
- 避免无意义的空行
261262
- 保持回复语言与用户查询语言一致
262263
- **绝不**在对用户的回复中提及内部机制,如"检索的记忆"、"数据库"、"AI观点"、"记忆系统"或类似技术术语
264+
- 回复内容的最后不要出现`(注: ...)`或`(根据...)`等解释
263265
264266
## 核心原则
265267
- 仅引用相关记忆以避免信息过载

0 commit comments

Comments
 (0)