shivanis14 commited on
Commit
9f9e3ac
·
verified ·
1 Parent(s): 18866dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -405,11 +405,11 @@ class ChatManager:
405
  def _handle_product_url():
406
  #is_valid_url = (".jpeg" in user_input or ".jpg" in user_input) and \
407
  # ("http:/" in user_input or "https:/" in user_input)
408
- image_len = len(st.session_state.uploaded_files)
409
  if not st.session_state.product_shared:
410
  return "Please provide the product name first"
411
 
412
- if image_len > 1 and st.session_state.product_shared:
413
  _, msg = chatbot_response(
414
  st.session_state.uploaded_files, "", extract_info=True
415
  )
@@ -426,7 +426,7 @@ class ChatManager:
426
 
427
  return response, status
428
 
429
- #return "Please provide valid image URL of the product.", "no success"
430
  return "Please provide more than 1 images of the product to capture complete information.", "no success"
431
 
432
  def main():
@@ -459,7 +459,8 @@ def main():
459
  if not selection_in_progress:
460
  user_input = st.chat_input("Enter your message:", key="user_input")
461
  print(f"DEBUG - user_input : {user_input}")
462
- if user_input:
 
463
  # Add user message to chat
464
  st.session_state.messages.append({"role": "user", "content": user_input})
465
  with st.chat_message("user"):
@@ -469,7 +470,7 @@ def main():
469
  print(f"DEBUG - Calling process_response with user_input : {user_input}")
470
  response, status = ChatManager.process_response(user_input)
471
  print(f"DEBUG - response from process_response is {response}")
472
-
473
  with st.chat_message("assistant"):
474
  st.markdown(response)
475
  st.session_state.messages.append({"role": "assistant", "content": response})
@@ -483,11 +484,9 @@ def main():
483
  for key in keys_to_delete:
484
  del st.session_state[key]
485
  st.session_state.welcome_msg = "What product would you like me to analyze next?"
486
-
487
- #else:
488
- # print(f"DEBUG : st.session_state.awaiting_selection : {st.session_state.awaiting_selection}")
489
- print("Re-running...")
490
- st.experimental_rerun()
491
  else:
492
  # Disable chat input while selection is in progress
493
  st.chat_input("Please confirm your selection above first...", disabled=True)
 
405
  def _handle_product_url():
406
  #is_valid_url = (".jpeg" in user_input or ".jpg" in user_input) and \
407
  # ("http:/" in user_input or "https:/" in user_input)
408
+
409
  if not st.session_state.product_shared:
410
  return "Please provide the product name first"
411
 
412
+ if len(st.session_state.uploaded_files) > 1 and st.session_state.product_shared:
413
  _, msg = chatbot_response(
414
  st.session_state.uploaded_files, "", extract_info=True
415
  )
 
426
 
427
  return response, status
428
 
429
+ st.session_state.uploaded_files = []
430
  return "Please provide more than 1 images of the product to capture complete information.", "no success"
431
 
432
  def main():
 
459
  if not selection_in_progress:
460
  user_input = st.chat_input("Enter your message:", key="user_input")
461
  print(f"DEBUG - user_input : {user_input}")
462
+
463
+ if user_input or len(st.session_state.uploaded_files) > 0:
464
  # Add user message to chat
465
  st.session_state.messages.append({"role": "user", "content": user_input})
466
  with st.chat_message("user"):
 
470
  print(f"DEBUG - Calling process_response with user_input : {user_input}")
471
  response, status = ChatManager.process_response(user_input)
472
  print(f"DEBUG - response from process_response is {response}")
473
+
474
  with st.chat_message("assistant"):
475
  st.markdown(response)
476
  st.session_state.messages.append({"role": "assistant", "content": response})
 
484
  for key in keys_to_delete:
485
  del st.session_state[key]
486
  st.session_state.welcome_msg = "What product would you like me to analyze next?"
487
+
488
+ print("Re-running...")
489
+ st.experimental_rerun()
 
 
490
  else:
491
  # Disable chat input while selection is in progress
492
  st.chat_input("Please confirm your selection above first...", disabled=True)