shivanis14
commited on
Commit
•
c8edada
1
Parent(s):
190d1ea
Update app.py
Browse files
app.py
CHANGED
@@ -515,8 +515,8 @@ def show_welcome_message():
|
|
515 |
st.session_state.welcome_shown = True
|
516 |
|
517 |
def handle_product_selection():
|
518 |
-
print(f"DEBUG : st.session_state.similar_products : {st.session_state.similar_products}")
|
519 |
-
print(f"DEBUG : st.session_state.awaiting_selection : {st.session_state.awaiting_selection}")
|
520 |
|
521 |
if st.session_state.similar_products and st.session_state.awaiting_selection:
|
522 |
choice = st.radio(
|
@@ -528,10 +528,10 @@ def handle_product_selection():
|
|
528 |
# Add a confirm button
|
529 |
if st.button("Confirm Selection"):
|
530 |
if choice != "None of the above":
|
|
|
531 |
st.session_state.product_selected = True
|
532 |
st.session_state.awaiting_selection = False
|
533 |
st.session_state.selected_product = choice
|
534 |
-
print(f"Selected choice : {choice}")
|
535 |
_, msg = chatbot_response("", choice, data_extractor_url, system_prompt, extract_info=True)
|
536 |
st.session_state.messages.append({"role": "assistant", "content": msg})
|
537 |
else:
|
@@ -539,8 +539,10 @@ def handle_product_selection():
|
|
539 |
st.session_state.messages.append(
|
540 |
{"role": "assistant", "content": "Please provide the image URL of the product."}
|
541 |
)
|
|
|
542 |
st.session_state.similar_products = [] # Clear the products list
|
543 |
-
|
|
|
544 |
|
545 |
def chat_response(user_input, system_prompt):
|
546 |
if not st.session_state.product_selected:
|
@@ -583,11 +585,6 @@ else:
|
|
583 |
with st.chat_message(message["role"]):
|
584 |
st.markdown(message["content"])
|
585 |
|
586 |
-
# Handle product selection if awaiting
|
587 |
-
#print(f"Are you awaiting_selection ?? : {st.session_state.awaiting_selection}")
|
588 |
-
#if st.session_state.awaiting_selection:
|
589 |
-
# handle_product_selection()
|
590 |
-
|
591 |
# Input Box for User Interaction
|
592 |
user_input = st.chat_input("Enter your message:", key="user_input")
|
593 |
|
@@ -607,6 +604,7 @@ else:
|
|
607 |
print(f"Are you awaiting_selection ?? : {st.session_state.awaiting_selection}")
|
608 |
if st.session_state.awaiting_selection:
|
609 |
handle_product_selection()
|
|
|
610 |
|
611 |
else:
|
612 |
st.session_state.product_selected = False
|
|
|
515 |
st.session_state.welcome_shown = True
|
516 |
|
517 |
def handle_product_selection():
|
518 |
+
print(f"DEBUG Inside handle_product_selection: st.session_state.similar_products : {st.session_state.similar_products}")
|
519 |
+
print(f"DEBUG Inside handle_product_selection: st.session_state.awaiting_selection : {st.session_state.awaiting_selection}")
|
520 |
|
521 |
if st.session_state.similar_products and st.session_state.awaiting_selection:
|
522 |
choice = st.radio(
|
|
|
528 |
# Add a confirm button
|
529 |
if st.button("Confirm Selection"):
|
530 |
if choice != "None of the above":
|
531 |
+
print(f"Selected choice : {choice}")
|
532 |
st.session_state.product_selected = True
|
533 |
st.session_state.awaiting_selection = False
|
534 |
st.session_state.selected_product = choice
|
|
|
535 |
_, msg = chatbot_response("", choice, data_extractor_url, system_prompt, extract_info=True)
|
536 |
st.session_state.messages.append({"role": "assistant", "content": msg})
|
537 |
else:
|
|
|
539 |
st.session_state.messages.append(
|
540 |
{"role": "assistant", "content": "Please provide the image URL of the product."}
|
541 |
)
|
542 |
+
|
543 |
st.session_state.similar_products = [] # Clear the products list
|
544 |
+
#print("DEBUG : Re-running the code")
|
545 |
+
#st.rerun()
|
546 |
|
547 |
def chat_response(user_input, system_prompt):
|
548 |
if not st.session_state.product_selected:
|
|
|
585 |
with st.chat_message(message["role"]):
|
586 |
st.markdown(message["content"])
|
587 |
|
|
|
|
|
|
|
|
|
|
|
588 |
# Input Box for User Interaction
|
589 |
user_input = st.chat_input("Enter your message:", key="user_input")
|
590 |
|
|
|
604 |
print(f"Are you awaiting_selection ?? : {st.session_state.awaiting_selection}")
|
605 |
if st.session_state.awaiting_selection:
|
606 |
handle_product_selection()
|
607 |
+
print("After executing handle_product_selection")
|
608 |
|
609 |
else:
|
610 |
st.session_state.product_selected = False
|