VietCat commited on
Commit
316fdae
·
1 Parent(s): 511991a

fix duplicate message

Browse files
Files changed (1) hide show
  1. app/main.py +11 -11
app/main.py CHANGED
@@ -178,7 +178,7 @@ async def process_message(message_data: Dict[str, Any]):
178
  'conversation_id': None,
179
  'user_id': sender_id,
180
  'page_id': page_id,
181
- 'message': message_text,
182
  'command': '',
183
  'content': '',
184
  'attachments': attachments,
@@ -186,7 +186,7 @@ async def process_message(message_data: Dict[str, Any]):
186
  'action': '',
187
  'purpose': '',
188
  'timestamp': [timestamp],
189
- 'is_done': False
190
  }
191
 
192
  logger.info(f"[DEBUG] Message cơ bản: {log_kwargs}")
@@ -209,7 +209,7 @@ async def process_message(message_data: Dict[str, Any]):
209
  'conversation_id': row.get('conversation_id'),
210
  'user_id': row.get('recipient_id'),
211
  'page_id': row.get('page_id'),
212
- 'message': row.get('originaltext'),
213
  'command': row.get('originalcommand'),
214
  'content': row.get('originalcontent'),
215
  'attachments': row.get('originalattachments'),
@@ -217,7 +217,7 @@ async def process_message(message_data: Dict[str, Any]):
217
  'action': row.get('originalaction'),
218
  'purpose': row.get('originalpurpose'),
219
  'timestamp': row_timestamps,
220
- 'is_done': row.get('isdone')
221
  }
222
  else:
223
  # 2. Ghi conversation mới NGAY LẬP TỨC với thông tin cơ bản
@@ -279,7 +279,7 @@ async def process_message(message_data: Dict[str, Any]):
279
  'conversation_id': conv['conversation_id'],
280
  'user_id': sender_id,
281
  'page_id': page_id,
282
- 'message': message_text,
283
  'command': command,
284
  'content': remaining_text,
285
  'attachments': attachments,
@@ -287,7 +287,7 @@ async def process_message(message_data: Dict[str, Any]):
287
  'action': hanh_vi_vi_pham,
288
  'purpose': muc_dich,
289
  'timestamp': conv['timestamp'],
290
- 'is_done': False
291
  }
292
 
293
  for key, value in update_kwargs.items():
@@ -309,7 +309,7 @@ async def process_business_logic(log_kwargs: Dict[str, Any], page_token: str) ->
309
  command = log_kwargs.get('command', '')
310
  vehicle = log_kwargs.get('vehicle', '')
311
  action = log_kwargs.get('action', '')
312
- message = log_kwargs.get('message', '')
313
 
314
  # Tách vehicle thành list keywords
315
  keywords = [kw.strip() for kw in vehicle.split(',') if kw.strip()]
@@ -330,11 +330,11 @@ async def process_business_logic(log_kwargs: Dict[str, Any], page_token: str) ->
330
  response = await format_search_results(message, matches)
331
  else:
332
  response = "Xin lỗi, tôi không tìm thấy thông tin phù hợp."
333
- log_kwargs['is_done'] = True
334
  else:
335
  # Không có thông tin phương tiện
336
  response = "Vui lòng cho biết loại phương tiện bạn cần tìm (xe máy, ô tô...)"
337
- log_kwargs['is_done'] = False
338
  else:
339
  # Có command
340
  if command == "xong":
@@ -345,10 +345,10 @@ async def process_business_logic(log_kwargs: Dict[str, Any], page_token: str) ->
345
  response = f"Bài viết đã được tạo thành công! Bạn có thể xem tại: {post_url}"
346
  else:
347
  response = "Đã xảy ra lỗi khi tạo bài viết. Vui lòng thử lại sau."
348
- log_kwargs['is_done'] = True
349
  else:
350
  response = "Vui lòng cung cấp thêm thông tin và gõ lệnh \\xong khi hoàn tất."
351
- log_kwargs['is_done'] = False
352
 
353
  return response
354
 
 
178
  'conversation_id': None,
179
  'user_id': sender_id,
180
  'page_id': page_id,
181
+ 'originaltext': message_text,
182
  'command': '',
183
  'content': '',
184
  'attachments': attachments,
 
186
  'action': '',
187
  'purpose': '',
188
  'timestamp': [timestamp],
189
+ 'isdone': False
190
  }
191
 
192
  logger.info(f"[DEBUG] Message cơ bản: {log_kwargs}")
 
209
  'conversation_id': row.get('conversation_id'),
210
  'user_id': row.get('recipient_id'),
211
  'page_id': row.get('page_id'),
212
+ 'originaltext': row.get('originaltext'),
213
  'command': row.get('originalcommand'),
214
  'content': row.get('originalcontent'),
215
  'attachments': row.get('originalattachments'),
 
217
  'action': row.get('originalaction'),
218
  'purpose': row.get('originalpurpose'),
219
  'timestamp': row_timestamps,
220
+ 'isdone': row.get('isdone')
221
  }
222
  else:
223
  # 2. Ghi conversation mới NGAY LẬP TỨC với thông tin cơ bản
 
279
  'conversation_id': conv['conversation_id'],
280
  'user_id': sender_id,
281
  'page_id': page_id,
282
+ 'originaltext': message_text,
283
  'command': command,
284
  'content': remaining_text,
285
  'attachments': attachments,
 
287
  'action': hanh_vi_vi_pham,
288
  'purpose': muc_dich,
289
  'timestamp': conv['timestamp'],
290
+ 'isdone': False
291
  }
292
 
293
  for key, value in update_kwargs.items():
 
309
  command = log_kwargs.get('command', '')
310
  vehicle = log_kwargs.get('vehicle', '')
311
  action = log_kwargs.get('action', '')
312
+ message = log_kwargs.get('originaltext', '')
313
 
314
  # Tách vehicle thành list keywords
315
  keywords = [kw.strip() for kw in vehicle.split(',') if kw.strip()]
 
330
  response = await format_search_results(message, matches)
331
  else:
332
  response = "Xin lỗi, tôi không tìm thấy thông tin phù hợp."
333
+ log_kwargs['isdone'] = True
334
  else:
335
  # Không có thông tin phương tiện
336
  response = "Vui lòng cho biết loại phương tiện bạn cần tìm (xe máy, ô tô...)"
337
+ log_kwargs['isdone'] = False
338
  else:
339
  # Có command
340
  if command == "xong":
 
345
  response = f"Bài viết đã được tạo thành công! Bạn có thể xem tại: {post_url}"
346
  else:
347
  response = "Đã xảy ra lỗi khi tạo bài viết. Vui lòng thử lại sau."
348
+ log_kwargs['isdone'] = True
349
  else:
350
  response = "Vui lòng cung cấp thêm thông tin và gõ lệnh \\xong khi hoàn tất."
351
+ log_kwargs['isdone'] = False
352
 
353
  return response
354