Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -764,24 +764,31 @@ def nutrition_disorder_streamlit():
|
|
764 |
# Filter input using Llama Guard
|
765 |
filtered_result = filter_input_with_llama_guard(user_query) # Blank #2: Fill in with the function name for filtering input (e.g., filter_input_with_llama_guard)
|
766 |
#filtered_result = filtered_result.replace("\n", " ") # Normalize the result
|
|
|
|
|
767 |
if filtered_result is None:
|
768 |
-
print("Agent: Sorry, I encountered an error while filtering your input. Please try again.")
|
|
|
769 |
#continue
|
770 |
else:
|
771 |
filtered_result = filtered_result.replace("\n", " ") # Normalize the result
|
772 |
-
print(f"filtered_result (2): {filtered_result}")
|
|
|
773 |
|
774 |
# Check if input is safe based on allowed statuses
|
775 |
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")
|
776 |
-
|
777 |
try:
|
|
|
778 |
if 'chatbot' not in st.session_state:
|
779 |
st.session_state.chatbot = NutritionBot() # Blank #6: Fill in with the chatbot class initialization (e.g., NutritionBot)
|
780 |
-
|
781 |
-
|
782 |
-
|
|
|
|
|
783 |
response = st.session_state.chatbot.handle_customer_query(st.session_state.user_id, user_query)
|
784 |
-
|
785 |
# Blank #7: Fill in with the method to handle queries (e.g., handle_customer_query)
|
786 |
|
787 |
st.write(response)
|
|
|
764 |
# Filter input using Llama Guard
|
765 |
filtered_result = filter_input_with_llama_guard(user_query) # Blank #2: Fill in with the function name for filtering input (e.g., filter_input_with_llama_guard)
|
766 |
#filtered_result = filtered_result.replace("\n", " ") # Normalize the result
|
767 |
+
#print(f"filtered_result (1): {filtered_result}")
|
768 |
+
st.write(f"filtered_result (1): {filtered_result}")
|
769 |
if filtered_result is None:
|
770 |
+
#print("Agent: Sorry, I encountered an error while filtering your input. Please try again.")
|
771 |
+
st.write("Agent: Sorry, I encountered an error while filtering your input. Please try again.")
|
772 |
#continue
|
773 |
else:
|
774 |
filtered_result = filtered_result.replace("\n", " ") # Normalize the result
|
775 |
+
#print(f"filtered_result (2): {filtered_result}")
|
776 |
+
st.write(f"filtered_result (2): {filtered_result}")
|
777 |
|
778 |
# Check if input is safe based on allowed statuses
|
779 |
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")
|
780 |
+
st.write("Input is safe.")
|
781 |
try:
|
782 |
+
|
783 |
if 'chatbot' not in st.session_state:
|
784 |
st.session_state.chatbot = NutritionBot() # Blank #6: Fill in with the chatbot class initialization (e.g., NutritionBot)
|
785 |
+
|
786 |
+
st.write("chatbot is calling handle_customer_query...")
|
787 |
+
st.write("user_id: ", st.session_state.user_id)
|
788 |
+
st.write("user_query: ", user_query)
|
789 |
+
|
790 |
response = st.session_state.chatbot.handle_customer_query(st.session_state.user_id, user_query)
|
791 |
+
st.write("response is returned.")
|
792 |
# Blank #7: Fill in with the method to handle queries (e.g., handle_customer_query)
|
793 |
|
794 |
st.write(response)
|