VietCat commited on
Commit
47188f5
·
1 Parent(s): 0d5bd79

adjust parallel search and rerank

Browse files
Files changed (1) hide show
  1. app/message_processor.py +8 -3
app/message_processor.py CHANGED
@@ -147,7 +147,9 @@ class MessageProcessor:
147
 
148
  conv.update({
149
  'originalcommand': command, 'originalcontent': remaining_text, 'originalvehicle': ','.join(keywords),
150
- 'originalaction': ' '.join(tu_khoa_list), 'originalpurpose': muc_dich, 'originalquestion': cau_hoi or ""
 
 
151
  })
152
 
153
  muc_dich_to_use = muc_dich or conv.get('originalpurpose')
@@ -384,7 +386,10 @@ class MessageProcessor:
384
  action_keywords_str = conv.get('originalaction', '')
385
  question = conv.get('originalquestion', '')
386
 
387
- tu_khoa_list = action_keywords_str.split()
 
 
 
388
 
389
  if not tu_khoa_list and not question:
390
  return "Để tra cứu mức phạt, bạn vui lòng cung cấp hành vi vi phạm nhé."
@@ -402,7 +407,7 @@ class MessageProcessor:
402
  seen_ids = set()
403
  for reranked_list in list_of_reranked_results:
404
  for match in reranked_list:
405
- match_id = match.get('id')
406
  if match_id and match_id not in seen_ids:
407
  combined_matches.append(match)
408
  seen_ids.add(match_id)
 
147
 
148
  conv.update({
149
  'originalcommand': command, 'originalcontent': remaining_text, 'originalvehicle': ','.join(keywords),
150
+ # Sửa lỗi: Dùng separator ';;;' để nối các cụm từ khóa,
151
+ # tránh bị tách sai ở bước sau.
152
+ 'originalaction': ';;;'.join(tu_khoa_list), 'originalpurpose': muc_dich, 'originalquestion': cau_hoi or ""
153
  })
154
 
155
  muc_dich_to_use = muc_dich or conv.get('originalpurpose')
 
386
  action_keywords_str = conv.get('originalaction', '')
387
  question = conv.get('originalquestion', '')
388
 
389
+ # Sửa lỗi: Tách các cụm từ khóa bằng separator ';;;' thay vì khoảng trắng.
390
+ # Điều này đảm bảo mỗi từ khóa là một cụm từ hoàn chỉnh.
391
+ # Lọc bỏ các chuỗi rỗng có thể xuất hiện nếu action_keywords_str rỗng.
392
+ tu_khoa_list = [kw.strip() for kw in action_keywords_str.split(';;;') if kw.strip()]
393
 
394
  if not tu_khoa_list and not question:
395
  return "Để tra cứu mức phạt, bạn vui lòng cung cấp hành vi vi phạm nhé."
 
407
  seen_ids = set()
408
  for reranked_list in list_of_reranked_results:
409
  for match in reranked_list:
410
+ match_id = match.get('doc_id')
411
  if match_id and match_id not in seen_ids:
412
  combined_matches.append(match)
413
  seen_ids.add(match_id)