Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -355,31 +355,33 @@ class ChatManager:
|
|
355 |
|
356 |
@staticmethod
|
357 |
def _handle_product_name(user_input):
|
358 |
-
st.session_state.
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
st.session_state.
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
|
|
374 |
|
375 |
# Only show message and uploader if waiting for image upload
|
376 |
if st.session_state.awaiting_image_upload:
|
377 |
-
|
378 |
-
st.
|
379 |
-
|
380 |
-
|
|
|
381 |
|
382 |
-
|
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:",
|