Cuong2004 commited on
Commit
167aefc
·
1 Parent(s): db2d0f1

clear history

Browse files
Files changed (3) hide show
  1. .gitignore +1 -1
  2. User_test_bot +1 -0
  3. app/database/mongodb.py +5 -5
.gitignore CHANGED
@@ -59,7 +59,7 @@ out/
59
  tests/
60
 
61
  Admin_bot/
62
-
63
  Pix-Agent/
64
 
65
  # Hugging Face Spaces
 
59
  tests/
60
 
61
  Admin_bot/
62
+ User_test_bot/
63
  Pix-Agent/
64
 
65
  # Hugging Face Spaces
User_test_bot ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit a29ee5023e8346d48cae7104bf516b78f791db07
app/database/mongodb.py CHANGED
@@ -143,16 +143,16 @@ def get_chat_history(user_id, n = 5) -> str:
143
  User: ...
144
  Bot: ...
145
 
146
- Chỉ lấy history sau lệnh /start hoặc /clear_history mới nhất
147
  """
148
  try:
149
- # Tìm session /start hoặc /clear_history mới nhất
150
  reset_session = session_collection.find_one(
151
  {
152
  "user_id": str(user_id),
153
  "$or": [
154
  {"action": "start"},
155
- {"action": "clear_history"}
156
  ]
157
  },
158
  sort=[("created_at_datetime", -1)]
@@ -188,8 +188,8 @@ def get_chat_history(user_id, n = 5) -> str:
188
  message = doc.get("message", "")
189
  response = doc.get("response", "")
190
 
191
- # Bỏ qua lệnh start và clear_history
192
- if action in ["start", "clear_history"]:
193
  continue
194
 
195
  if factor == "user" and action == "asking_freely":
 
143
  User: ...
144
  Bot: ...
145
 
146
+ Chỉ lấy history sau lệnh /start hoặc /clear mới nhất
147
  """
148
  try:
149
+ # Tìm session /start hoặc /clear mới nhất
150
  reset_session = session_collection.find_one(
151
  {
152
  "user_id": str(user_id),
153
  "$or": [
154
  {"action": "start"},
155
+ {"action": "clear"}
156
  ]
157
  },
158
  sort=[("created_at_datetime", -1)]
 
188
  message = doc.get("message", "")
189
  response = doc.get("response", "")
190
 
191
+ # Bỏ qua lệnh start và clear
192
+ if action in ["start", "clear"]:
193
  continue
194
 
195
  if factor == "user" and action == "asking_freely":