hoduyquocbao commited on
Commit
a1acd02
1 Parent(s): ad80532

fix errors historys

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -410,6 +410,9 @@ def generate(
410
  # Lấy user_id từ trạng thái
411
  user_id = get_user_id(user_state)
412
 
 
 
 
413
  # Xác định hàm nào sẽ được gọi dựa trên tin nhắn của người dùng
414
  function_call = process_query(message)
415
 
@@ -441,8 +444,13 @@ def generate(
441
  )
442
 
443
  for response in response_iterator:
444
- yield response
445
-
 
 
 
 
 
446
  # Định nghĩa các ví dụ để hướng dẫn người dùng
447
  EXAMPLES = [
448
  ["Xin chào! Bạn khỏe không?"],
 
410
  # Lấy user_id từ trạng thái
411
  user_id = get_user_id(user_state)
412
 
413
+ # Thêm tin nhắn của người dùng vào lịch sử cuộc trò chuyện
414
+ chat_history.append((message, ""))
415
+
416
  # Xác định hàm nào sẽ được gọi dựa trên tin nhắn của người dùng
417
  function_call = process_query(message)
418
 
 
444
  )
445
 
446
  for response in response_iterator:
447
+ # Thay thế tin nhắn cuối cùng của người dùng với phản hồi của hệ thống
448
+ chat_history[-1] = (message, response)
449
+ yield chat_history
450
+ # Lưu phản hồi cuối cùng vào Dataset
451
+ save_conversation(user_id, chat_history)
452
+ yield chat_history
453
+
454
  # Định nghĩa các ví dụ để hướng dẫn người dùng
455
  EXAMPLES = [
456
  ["Xin chào! Bạn khỏe không?"],