shivanis14 commited on
Commit
0150e5f
·
verified ·
1 Parent(s): b47d089

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -21
app.py CHANGED
@@ -355,31 +355,33 @@ class ChatManager:
355
 
356
  @staticmethod
357
  def _handle_product_name(user_input):
358
- st.session_state.product_shared = True
359
- st.session_state.current_user_input = user_input
360
- similar_products, _ = chatbot_response(
361
- [], user_input, extract_info=False
362
- )
363
-
364
- st.session_state.similar_products = similar_products
365
-
366
- if len(st.session_state.similar_products) > 0:
367
- st.session_state.awaiting_selection = True
368
- return "Here are some similar products from our database. Please select:", "no success"
369
-
370
-
371
- # Add a file uploader to allow users to upload multiple images
372
- # No similar products found
373
- st.session_state.awaiting_image_upload = True
 
374
 
375
  # Only show message and uploader if waiting for image upload
376
  if st.session_state.awaiting_image_upload:
377
- with st.chat_message("assistant"):
378
- st.markdown(f"Please provide images of the product since {len(st.session_state.similar_products)} similar products found in our database")
379
- # Append the message to session state for chat history
380
- st.session_state.messages.append({"role": "assistant", "content": f"Please provide images of the product since {len(st.session_state.similar_products)} similar products found in our database"})
 
381
 
382
- st.chat_input("Please upload files ...", disabled=True)
383
 
384
  uploaded_files = st.file_uploader(
385
  "Upload product images here:",
 
355
 
356
  @staticmethod
357
  def _handle_product_name(user_input):
358
+ if not st.session_state.awaiting_image_upload:
359
+ st.session_state.product_shared = True
360
+ st.session_state.current_user_input = user_input
361
+ similar_products, _ = chatbot_response(
362
+ [], user_input, extract_info=False
363
+ )
364
+
365
+ st.session_state.similar_products = similar_products
366
+
367
+ if len(st.session_state.similar_products) > 0:
368
+ st.session_state.awaiting_selection = True
369
+ return "Here are some similar products from our database. Please select:", "no success"
370
+
371
+
372
+ # Add a file uploader to allow users to upload multiple images
373
+ # No similar products found
374
+ st.session_state.awaiting_image_upload = True
375
 
376
  # Only show message and uploader if waiting for image upload
377
  if st.session_state.awaiting_image_upload:
378
+ if user_input:
379
+ with st.chat_message("assistant"):
380
+ st.markdown(f"Please provide images of the product since {len(st.session_state.similar_products)} similar products found in our database")
381
+ # Append the message to session state for chat history
382
+ st.session_state.messages.append({"role": "assistant", "content": f"Please provide images of the product since {len(st.session_state.similar_products)} similar products found in our database"})
383
 
384
+ st.chat_input("Please upload files ...", disabled=True)
385
 
386
  uploaded_files = st.file_uploader(
387
  "Upload product images here:",