shivanis14 commited on
Commit
43ee420
·
verified ·
1 Parent(s): 062ad52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -313,13 +313,16 @@ class ProductSelector:
313
  st.experimental_rerun()
314
 
315
  if (choice == "None of the above" or msg == "product not found because product information in the db is corrupt") and len(st.session_state.uploaded_files) == 0:
316
- st.session_state.messages.append(
317
- {"role": "assistant", "content": "Please provide the images of the product to analyze based on the latest information."}
318
- )
319
- with st.chat_message("assistant"):
320
- st.markdown("Please provide the images of the product to analyze based on the latest information.")
321
- #st.session_state.selected_product = None
 
322
  # Add a file uploader to allow users to upload multiple images
 
 
323
  uploaded_files = st.file_uploader(
324
  "Upload product images here:",
325
  type=["jpg", "jpeg", "png"],
@@ -334,6 +337,7 @@ class ProductSelector:
334
  st.markdown(f"{len(uploaded_files)} images uploaded for analysis.")
335
 
336
  st.session_state.uploaded_files = uploaded_files
 
337
  st.experimental_rerun()
338
 
339
  # Prevent further chat input while awaiting selection
@@ -377,7 +381,7 @@ class ChatManager:
377
  st.session_state.awaiting_image_upload = True
378
 
379
  # Only show message and uploader if waiting for image upload
380
- if st.session_state.awaiting_image_upload:
381
  if user_input:
382
  with st.chat_message("assistant"):
383
  st.markdown(f"Please provide images of the product since {len(st.session_state.similar_products)} similar products found in our database")
 
313
  st.experimental_rerun()
314
 
315
  if (choice == "None of the above" or msg == "product not found because product information in the db is corrupt") and len(st.session_state.uploaded_files) == 0:
316
+ if not st.session_state.awaiting_image_upload:
317
+ st.session_state.messages.append(
318
+ {"role": "assistant", "content": "Please provide the images of the product to analyze based on the latest information."}
319
+ )
320
+ with st.chat_message("assistant"):
321
+ st.markdown("Please provide the images of the product to analyze based on the latest information.")
322
+
323
  # Add a file uploader to allow users to upload multiple images
324
+ st.session_state.awaiting_image_upload = True
325
+
326
  uploaded_files = st.file_uploader(
327
  "Upload product images here:",
328
  type=["jpg", "jpeg", "png"],
 
337
  st.markdown(f"{len(uploaded_files)} images uploaded for analysis.")
338
 
339
  st.session_state.uploaded_files = uploaded_files
340
+ st.session_state.awaiting_image_upload = False
341
  st.experimental_rerun()
342
 
343
  # Prevent further chat input while awaiting selection
 
381
  st.session_state.awaiting_image_upload = True
382
 
383
  # Only show message and uploader if waiting for image upload
384
+ if st.session_state.awaiting_image_upload and len(st.session_state.uploaded_files) == 0:
385
  if user_input:
386
  with st.chat_message("assistant"):
387
  st.markdown(f"Please provide images of the product since {len(st.session_state.similar_products)} similar products found in our database")