Skip to content

Commit b491631

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

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/memos/api/handlers/chat_handler.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def generate_chat_response() -> Generator[str, None, None]:
415415
top_k=5,
416416
chat_history=chat_req.history,
417417
session_id=chat_req.session_id,
418-
include_preference=False,
418+
include_preference=True,
419419
pref_top_k=chat_req.pref_top_k,
420420
filter=chat_req.filter,
421421
search_tool_memory=False,
@@ -440,9 +440,18 @@ def generate_chat_response() -> Generator[str, None, None]:
440440

441441
# Prepare reference data (first search)
442442
reference = prepare_reference_data(filtered_memories)
443+
# get preference string
444+
pref_string = search_response.data.get("pref_string", "")
443445

444446
yield f"data: {json.dumps({'type': 'reference', 'data': reference})}\n\n"
445447

448+
# Prepare preference markdown string
449+
if chat_req.include_preference:
450+
pref_list = search_response.data.get("pref_mem") or []
451+
pref_memories = pref_list[0].get("memories", []) if pref_list else []
452+
pref_md_string = self._build_pref_md_string_for_playground(pref_memories)
453+
yield f"data: {json.dumps({'type': 'pref_md_string', 'data': pref_md_string})}\n\n"
454+
446455
# Use first readable cube ID for scheduler (backward compatibility)
447456
scheduler_cube_id = (
448457
readable_cube_ids[0] if readable_cube_ids else chat_req.user_id
@@ -487,7 +496,7 @@ def generate_chat_response() -> Generator[str, None, None]:
487496
top_k=chat_req.top_k,
488497
chat_history=chat_req.history,
489498
session_id=chat_req.session_id,
490-
include_preference=chat_req.include_preference,
499+
include_preference=False,
491500
pref_top_k=chat_req.pref_top_k,
492501
filter=chat_req.filter,
493502
search_memory_type="All",
@@ -516,19 +525,11 @@ def generate_chat_response() -> Generator[str, None, None]:
516525

517526
# Prepare remain reference data (second search)
518527
reference = prepare_reference_data(filtered_memories)
519-
# get preference string
520-
pref_string = search_response.data.get("pref_string", "")
521528
# get internet reference
522529
internet_reference = self._get_internet_reference(
523530
search_response.data.get("text_mem")[0]["memories"]
524531
)
525532
yield f"data: {json.dumps({'type': 'reference', 'data': reference})}\n\n"
526-
# Prepare preference markdown string
527-
if chat_req.include_preference:
528-
pref_list = search_response.data.get("pref_mem") or []
529-
pref_memories = pref_list[0].get("memories", []) if pref_list else []
530-
pref_md_string = self._build_pref_md_string_for_playground(pref_memories)
531-
yield f"data: {json.dumps({'type': 'pref_md_string', 'data': pref_md_string})}\n\n"
532533

533534
# Step 2: Build system prompt with memories
534535
system_prompt = self._build_enhance_system_prompt(

0 commit comments

Comments
 (0)