From b1533a55691ad20aaec176c51755b6defbbb4760 Mon Sep 17 00:00:00 2001 From: Cui <530051970@qq.com> Date: Thu, 13 Feb 2025 13:09:36 +0800 Subject: [PATCH 1/2] Update the eviction policy for chat history. --- .../lambda_main/main_utils/online_entries/common_entry.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py b/source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py index 260d7ee0..637b5ef3 100644 --- a/source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py +++ b/source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py @@ -677,7 +677,8 @@ def common_entry(event_body): query = event_body["query"] use_history = chatbot_config["use_history"] max_rounds_in_memory = event_body["chatbot_config"]["max_rounds_in_memory"] - chat_history = event_body["chat_history"][:max_rounds_in_memory] if use_history else [] + # if(len(event_body["chat_history"])<=2*max_rounds_in_memory) + chat_history = event_body["chat_history"] if len(event_body["chat_history"])<=2*max_rounds_in_memory else event_body["chat_history"][-2*max_rounds_in_memory:] if use_history else [] stream = event_body["stream"] message_id = event_body["custom_message_id"] ws_connection_id = event_body["ws_connection_id"] From b4f5ad951d0d579951de8571cb57a81b5ff567c8 Mon Sep 17 00:00:00 2001 From: Cui <530051970@qq.com> Date: Thu, 13 Feb 2025 13:19:24 +0800 Subject: [PATCH 2/2] Update the eviction policy for chat history. --- .../lambda_main/main_utils/online_entries/common_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py b/source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py index 637b5ef3..5956c636 100644 --- a/source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py +++ b/source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py @@ -678,7 +678,7 @@ def common_entry(event_body): use_history = chatbot_config["use_history"] max_rounds_in_memory = event_body["chatbot_config"]["max_rounds_in_memory"] # if(len(event_body["chat_history"])<=2*max_rounds_in_memory) - chat_history = event_body["chat_history"] if len(event_body["chat_history"])<=2*max_rounds_in_memory else event_body["chat_history"][-2*max_rounds_in_memory:] if use_history else [] + chat_history = event_body["chat_history"][-2*max_rounds_in_memory:] if use_history else [] stream = event_body["stream"] message_id = event_body["custom_message_id"] ws_connection_id = event_body["ws_connection_id"]