shivanis14 commited on
Commit
fa36771
1 Parent(s): 21f6b2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -430,8 +430,6 @@ def chatbot_response(image_urls_str, product_name_by_user, data_extractor_url, e
430
  else:
431
  return [], "I'm here to analyze food products. Please provide an image URL (Example : http://example.com/image.jpg) or product name (Example : Harvest Gold Bread)"
432
 
433
- import streamlit as st
434
-
435
  # Initialize session state
436
  if "messages" not in st.session_state:
437
  st.session_state.messages = []
@@ -458,8 +456,9 @@ if prompt := st.chat_input("What product would you like to analyze?"):
458
  full_response = ""
459
 
460
  # Simulate stream of response with milliseconds delay
461
- for chunk in chatbot_response(prompt, "", data_extractor_url, extract_info=False):
462
- full_response += chunk + " "
 
463
  message_placeholder.markdown(full_response + "▌")
464
  message_placeholder.markdown(full_response)
465
 
@@ -467,7 +466,6 @@ if prompt := st.chat_input("What product would you like to analyze?"):
467
  st.session_state.messages.append({"role": "assistant", "content": full_response})
468
 
469
  # Product selection (if needed)
470
- similar_products = extract_similar_products(full_response) # You'll need to implement this function
471
  if similar_products and not st.session_state.product_selected:
472
  choice = st.radio("Select a product:", similar_products + ["None of the above"])
473
  if choice != "None of the above":
 
430
  else:
431
  return [], "I'm here to analyze food products. Please provide an image URL (Example : http://example.com/image.jpg) or product name (Example : Harvest Gold Bread)"
432
 
 
 
433
  # Initialize session state
434
  if "messages" not in st.session_state:
435
  st.session_state.messages = []
 
456
  full_response = ""
457
 
458
  # Simulate stream of response with milliseconds delay
459
+ similar_products, _ = chatbot_response(prompt, "", data_extractor_url, extract_info=False):
460
+ for product in similar_products:
461
+ full_response += product + " "
462
  message_placeholder.markdown(full_response + "▌")
463
  message_placeholder.markdown(full_response)
464
 
 
466
  st.session_state.messages.append({"role": "assistant", "content": full_response})
467
 
468
  # Product selection (if needed)
 
469
  if similar_products and not st.session_state.product_selected:
470
  choice = st.radio("Select a product:", similar_products + ["None of the above"])
471
  if choice != "None of the above":