Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -677,15 +677,18 @@ class NutritionBot:
|
|
677 |
context += "---\n"
|
678 |
|
679 |
# Print context for debugging purposes
|
680 |
-
st.write("Context: ", context)
|
681 |
|
682 |
# Prepare a prompt combining past context and the current query
|
683 |
prompt = f"""
|
684 |
-
Context:
|
|
|
|
|
685 |
Current customer query: {query}
|
|
|
686 |
Provide a helpful response that takes into account any relevant past interactions.
|
687 |
"""
|
688 |
-
st.write("Context: ", prompt)
|
689 |
|
690 |
# Generate a response using the agent
|
691 |
response = self.agent_executor.invoke({"input": prompt})
|
@@ -764,14 +767,14 @@ 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 |
-
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})
|
|
|
677 |
context += "---\n"
|
678 |
|
679 |
# Print context for debugging purposes
|
680 |
+
#st.write("Context: ", context)
|
681 |
|
682 |
# Prepare a prompt combining past context and the current query
|
683 |
prompt = f"""
|
684 |
+
Context:
|
685 |
+
{context}
|
686 |
+
|
687 |
Current customer query: {query}
|
688 |
+
|
689 |
Provide a helpful response that takes into account any relevant past interactions.
|
690 |
"""
|
691 |
+
#st.write("Context: ", prompt)
|
692 |
|
693 |
# Generate a response using the agent
|
694 |
response = self.agent_executor.invoke({"input": prompt})
|
|
|
767 |
|
768 |
# Check if input is safe based on allowed statuses
|
769 |
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")
|
770 |
+
#st.write("Input is safe.")
|
771 |
try:
|
772 |
if 'chatbot' not in st.session_state:
|
773 |
st.session_state.chatbot = NutritionBot() # Blank #6: Fill in with the chatbot class initialization (e.g., NutritionBot)
|
774 |
+
#st.write("chatbot instantiated - calling handle_customer_query...")
|
775 |
|
776 |
response = st.session_state.chatbot.handle_customer_query(st.session_state.user_id, user_query)
|
777 |
+
#st.write("response is returned.")
|
778 |
# Blank #7: Fill in with the method to handle queries (e.g., handle_customer_query)
|
779 |
st.write(response)
|
780 |
st.session_state.chat_history.append({"role": "assistant", "content": response})
|