anhkhoiphan commited on
Commit
680f51d
·
1 Parent(s): d796362

Tự động điền string ' ' nếu chat text empty

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -285,7 +285,7 @@ class ChatService:
285
  else:
286
  # For text messages, use form-data format as expected by API
287
  data = {
288
- "message": message,
289
  "session_id": state.session_id,
290
  "debug": "Normal",
291
  "product_model_search": str(state.product_model_search).lower(),
@@ -1064,13 +1064,15 @@ async def main(message: cl.Message):
1064
  image_path = element.path
1065
  break
1066
 
 
 
1067
  # Create initial message for animation
1068
  msg = cl.Message(content="", author="assistant")
1069
  await msg.send()
1070
 
1071
  # Create concurrent tasks for animation and API call
1072
  animation_task = asyncio.create_task(run_typing_animation(msg))
1073
- api_task = asyncio.create_task(ChatService.respond_to_chat(app_state, message.content, image_path))
1074
 
1075
  try:
1076
  # Wait for API response (this will complete first usually)
 
285
  else:
286
  # For text messages, use form-data format as expected by API
287
  data = {
288
+ "message": message if message and message.strip() else " ",
289
  "session_id": state.session_id,
290
  "debug": "Normal",
291
  "product_model_search": str(state.product_model_search).lower(),
 
1064
  image_path = element.path
1065
  break
1066
 
1067
+ user_message = message.content if message.content and message.content.strip() else " "
1068
+
1069
  # Create initial message for animation
1070
  msg = cl.Message(content="", author="assistant")
1071
  await msg.send()
1072
 
1073
  # Create concurrent tasks for animation and API call
1074
  animation_task = asyncio.create_task(run_typing_animation(msg))
1075
+ api_task = asyncio.create_task(ChatService.respond_to_chat(app_state, user_message, image_path))
1076
 
1077
  try:
1078
  # Wait for API response (this will complete first usually)