2121from 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 ]
0 commit comments