Skip to content

Commit 0bae890

Browse files
Wang-Daojiyuan.wangfridayL
authored
Feat/fix palyground bug (#689)
* 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 * fix playground bug --------- Co-authored-by: yuan.wang <[email protected]> Co-authored-by: chunyu li <[email protected]>
1 parent efca186 commit 0bae890

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

src/memos/api/handlers/chat_handler.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from memos.api.product_models import (
2222
APIADDRequest,
2323
APIChatCompleteRequest,
24-
APISearchPlaygroundRequest,
2524
APISearchRequest,
2625
ChatPlaygroundRequest,
2726
ChatRequest,
@@ -397,7 +396,7 @@ def generate_chat_response() -> Generator[str, None, None]:
397396
)
398397

399398
# ====== first search text mem with parse goal ======
400-
search_req = APISearchPlaygroundRequest(
399+
search_req = APISearchRequest(
401400
query=chat_req.query,
402401
user_id=chat_req.user_id,
403402
readable_cube_ids=readable_cube_ids,
@@ -476,14 +475,14 @@ def generate_chat_response() -> Generator[str, None, None]:
476475
yield f"data: {json.dumps({'type': 'status', 'data': 'start_internet_search'})}\n\n"
477476

478477
# ====== second deep search ======
479-
search_req = APISearchPlaygroundRequest(
478+
search_req = APISearchRequest(
480479
query=parsed_goal.rephrased_query
481480
or chat_req.query + (f"{parsed_goal.tags}" if parsed_goal.tags else ""),
482481
user_id=chat_req.user_id,
483482
readable_cube_ids=readable_cube_ids,
484483
mode="fast",
485484
internet_search=chat_req.internet_search or parsed_goal.internet_search,
486-
top_k=chat_req.top_k,
485+
top_k=100, # for playground, we need to search more memories
487486
chat_history=chat_req.history,
488487
session_id=chat_req.session_id,
489488
include_preference=False,
@@ -504,12 +503,14 @@ def generate_chat_response() -> Generator[str, None, None]:
504503
if text_mem_results and text_mem_results[0].get("memories"):
505504
memories_list = text_mem_results[0]["memories"]
506505

507-
# Filter memories by threshold
508-
second_filtered_memories = self._filter_memories_by_threshold(memories_list, 15)
506+
# Filter memories by threshold, min_num is the min number of memories for playground
507+
second_filtered_memories = self._filter_memories_by_threshold(
508+
memories_list, min_num=15
509+
)
509510

510511
# dedup and supplement memories
511512
fast_length = len(filtered_memories)
512-
supplement_length = max(0, chat_req.top_k - fast_length)
513+
supplement_length = max(0, 25 - fast_length) # 25 is the max mem for playground
513514
filtered_memories = self._dedup_and_supplement_memories(
514515
filtered_memories, second_filtered_memories
515516
)[:supplement_length]

src/memos/api/product_models.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,6 @@ def _convert_deprecated_fields(self) -> "APISearchRequest":
458458
return self
459459

460460

461-
class APISearchPlaygroundRequest(APISearchRequest):
462-
"""Request model for searching memories in playground."""
463-
464-
465461
class APIADDRequest(BaseRequest):
466462
"""Request model for creating memories."""
467463

src/memos/templates/mos_prompts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@
261261
- 避免无意义的空行
262262
- 保持回复语言与用户查询语言一致
263263
- **绝不**在对用户的回复中提及内部机制,如"检索的记忆"、"数据库"、"AI观点"、"记忆系统"或类似技术术语
264-
- 回复内容的最后不要出现`(注: ...)`或`(根据...)`等解释
264+
- 回复内容的结尾不要出现`(注: ...)`或`(根据...)`等解释
265265
266266
## 核心原则
267267
- 仅引用相关记忆以避免信息过载

0 commit comments

Comments
 (0)