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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -201,6 +201,7 @@ def chatbot_response(images_list, product_name_by_user, extract_info = True):
201
  elif extract_info == True:
202
  with st.spinner("Analyzing product using data from 3,000+ peer-reviewed journal papers..."):
203
  st.caption("This may take a few minutes")
 
204
 
205
  product_info_raw = get_product_info(product_name_by_user)
206
  print(f"DEBUG product_info_raw from name: {type(product_info_raw)} {product_info_raw}")
@@ -225,7 +226,9 @@ def chatbot_response(images_list, product_name_by_user, extract_info = True):
225
  # if "http:/" in url.lower() or "https:/" in url.lower():
226
  # image_urls.append(url)
227
 
228
- with st.spinner("Analyzing the product... This may take a moment."):
 
 
229
  product_info_raw = extract_data_from_product_image(images_list)
230
  print(f"DEBUG product_info_raw from image : {product_info_raw}")
231
  if 'error' not in product_info_raw.keys():
@@ -309,7 +312,7 @@ class ProductSelector:
309
  st.session_state.welcome_msg = "What product would you like me to analyze next?"
310
  st.experimental_rerun()
311
 
312
- if choice == "None of the above" or msg == "product not found because product information in the db is corrupt":
313
  st.session_state.messages.append(
314
  {"role": "assistant", "content": "Please provide the images of the product to analyze based on the latest information."}
315
  )
@@ -355,7 +358,7 @@ class ChatManager:
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(
 
201
  elif extract_info == True:
202
  with st.spinner("Analyzing product using data from 3,000+ peer-reviewed journal papers..."):
203
  st.caption("This may take a few minutes")
204
+ st.chat_input("Please wait ...", disabled=True)
205
 
206
  product_info_raw = get_product_info(product_name_by_user)
207
  print(f"DEBUG product_info_raw from name: {type(product_info_raw)} {product_info_raw}")
 
226
  # if "http:/" in url.lower() or "https:/" in url.lower():
227
  # image_urls.append(url)
228
 
229
+ with st.spinner("Analyzing product using data from 3,000+ peer-reviewed journal papers..."):
230
+ st.caption("This may take a few minutes")
231
+ st.chat_input("Please wait ...", disabled=True)
232
  product_info_raw = extract_data_from_product_image(images_list)
233
  print(f"DEBUG product_info_raw from image : {product_info_raw}")
234
  if 'error' not in product_info_raw.keys():
 
312
  st.session_state.welcome_msg = "What product would you like me to analyze next?"
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
  )
 
358
 
359
  @staticmethod
360
  def _handle_product_name(user_input):
361
+ if not st.session_state.awaiting_image_upload and user_input:
362
  st.session_state.product_shared = True
363
  st.session_state.current_user_input = user_input
364
  similar_products, _ = chatbot_response(