shivanis14 commited on
Commit
9ae0427
·
verified ·
1 Parent(s): 9cc2186

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -329,6 +329,7 @@ class ProductSelector:
329
  )
330
  with st.chat_message("assistant"):
331
  st.markdown(f"{len(uploaded_files)} images uploaded for analysis.")
 
332
  st.session_state.uploaded_files = uploaded_files
333
  st.experimental_rerun()
334
 
@@ -343,7 +344,7 @@ class ChatManager:
343
  def process_response(user_input):
344
  if not st.session_state.product_selected:
345
  #if "http:/" not in user_input and "https:/" not in user_input:
346
- print(f"DEBUG : st.session_state.uploaded_files : {st.session_state.uploaded_files}")
347
  if len(st.session_state.uploaded_files) == 0:
348
  response, status = ChatManager._handle_product_name(user_input)
349
  else:
@@ -361,7 +362,7 @@ class ChatManager:
361
 
362
  st.session_state.similar_products = similar_products
363
 
364
- if len(similar_products) > 0:
365
  st.session_state.awaiting_selection = True
366
  return "Here are some similar products from our database. Please select:", "no success"
367
 
@@ -382,7 +383,9 @@ class ChatManager:
382
  type=["jpg", "jpeg", "png"],
383
  accept_multiple_files=True
384
  )
385
-
 
 
386
  if uploaded_files:
387
  st.session_state.uploaded_files = uploaded_files
388
  st.session_state.awaiting_image_upload = False
@@ -458,11 +461,12 @@ def main():
458
 
459
  # Process response
460
  response, status = ChatManager.process_response(user_input)
 
461
 
462
- st.session_state.messages.append({"role": "assistant", "content": response})
463
  with st.chat_message("assistant"):
464
  st.markdown(response)
465
-
 
466
  if status == "success":
467
  SessionState.initialize() # Reset states for next product
468
 
 
329
  )
330
  with st.chat_message("assistant"):
331
  st.markdown(f"{len(uploaded_files)} images uploaded for analysis.")
332
+
333
  st.session_state.uploaded_files = uploaded_files
334
  st.experimental_rerun()
335
 
 
344
  def process_response(user_input):
345
  if not st.session_state.product_selected:
346
  #if "http:/" not in user_input and "https:/" not in user_input:
347
+ print(f"DEBUG : st.session_state.uploaded_files inside process_response : {st.session_state.uploaded_files}")
348
  if len(st.session_state.uploaded_files) == 0:
349
  response, status = ChatManager._handle_product_name(user_input)
350
  else:
 
362
 
363
  st.session_state.similar_products = similar_products
364
 
365
+ if len(st.session_state.similar_products) > 0:
366
  st.session_state.awaiting_selection = True
367
  return "Here are some similar products from our database. Please select:", "no success"
368
 
 
383
  type=["jpg", "jpeg", "png"],
384
  accept_multiple_files=True
385
  )
386
+
387
+ print(f"DEBUG : uploaded_files : {uploaded_files}")
388
+
389
  if uploaded_files:
390
  st.session_state.uploaded_files = uploaded_files
391
  st.session_state.awaiting_image_upload = False
 
461
 
462
  # Process response
463
  response, status = ChatManager.process_response(user_input)
464
+ print(f"DEBUG - response from process_response is {response}")
465
 
 
466
  with st.chat_message("assistant"):
467
  st.markdown(response)
468
+ st.session_state.messages.append({"role": "assistant", "content": response})
469
+
470
  if status == "success":
471
  SessionState.initialize() # Reset states for next product
472