Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -764,16 +764,19 @@ def nutrition_disorder_streamlit():
|
|
764 |
|
765 |
# Check if input is safe based on allowed statuses
|
766 |
if filtered_result in ["safe", "safe S7", "safe S6"]: # Blanks #3, #4, #5: Fill in with allowed safe statuses (e.g., "safe", "unsafe S7", "unsafe S6")
|
|
|
767 |
try:
|
768 |
if 'chatbot' not in st.session_state:
|
769 |
st.session_state.chatbot = NutritionBot() # Blank #6: Fill in with the chatbot class initialization (e.g., NutritionBot)
|
|
|
770 |
|
771 |
response = st.session_state.chatbot.handle_customer_query(st.session_state.user_id, user_query)
|
|
|
772 |
# Blank #7: Fill in with the method to handle queries (e.g., handle_customer_query)
|
773 |
st.write(response)
|
774 |
st.session_state.chat_history.append({"role": "assistant", "content": response})
|
775 |
except Exception as e:
|
776 |
-
error_msg = f"Sorry, I encountered an error while processing your query. Please try again. Error: {
|
777 |
st.write(error_msg)
|
778 |
st.session_state.chat_history.append({"role": "assistant", "content": error_msg})
|
779 |
else:
|
|
|
764 |
|
765 |
# Check if input is safe based on allowed statuses
|
766 |
if filtered_result in ["safe", "safe S7", "safe S6"]: # Blanks #3, #4, #5: Fill in with allowed safe statuses (e.g., "safe", "unsafe S7", "unsafe S6")
|
767 |
+
st.write("Input is safe.")
|
768 |
try:
|
769 |
if 'chatbot' not in st.session_state:
|
770 |
st.session_state.chatbot = NutritionBot() # Blank #6: Fill in with the chatbot class initialization (e.g., NutritionBot)
|
771 |
+
st.write("chatbot instantiated - calling handle_customer_query...")
|
772 |
|
773 |
response = st.session_state.chatbot.handle_customer_query(st.session_state.user_id, user_query)
|
774 |
+
st.write("response is returned.")
|
775 |
# Blank #7: Fill in with the method to handle queries (e.g., handle_customer_query)
|
776 |
st.write(response)
|
777 |
st.session_state.chat_history.append({"role": "assistant", "content": response})
|
778 |
except Exception as e:
|
779 |
+
error_msg = f"Sorry, I encountered an error while processing your query. Please try again. Error: {e}"
|
780 |
st.write(error_msg)
|
781 |
st.session_state.chat_history.append({"role": "assistant", "content": error_msg})
|
782 |
else:
|