Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -48,13 +48,21 @@ def chatbot_interface():
|
|
48 |
st.error(message)
|
49 |
return False
|
50 |
|
|
|
|
|
|
|
|
|
|
|
51 |
# Step 0: Welcome message and initial question
|
52 |
if st.session_state.step == 0:
|
53 |
st.write("Bot: Hi there! I'm here to help with your well-being. Let's start! π")
|
54 |
st.write("Bot: I'll ask you a few questions about your well-being to give you personalized advice.")
|
55 |
next_step_button = st.button("Start Chat")
|
|
|
56 |
if next_step_button:
|
57 |
next_step()
|
|
|
|
|
58 |
|
59 |
# Step 1: Ask for anxiety level
|
60 |
elif st.session_state.step == 1:
|
@@ -105,9 +113,11 @@ def chatbot_interface():
|
|
105 |
|
106 |
# Option to restart the chat
|
107 |
restart_button = st.button("Start Over")
|
|
|
108 |
if restart_button:
|
109 |
-
|
110 |
-
|
|
|
111 |
|
112 |
# Main function to run the chatbot
|
113 |
def main():
|
|
|
48 |
st.error(message)
|
49 |
return False
|
50 |
|
51 |
+
def clear_data():
|
52 |
+
"""Clear session data and reset to initial step."""
|
53 |
+
st.session_state.step = 0
|
54 |
+
st.session_state.user_data = {}
|
55 |
+
|
56 |
# Step 0: Welcome message and initial question
|
57 |
if st.session_state.step == 0:
|
58 |
st.write("Bot: Hi there! I'm here to help with your well-being. Let's start! π")
|
59 |
st.write("Bot: I'll ask you a few questions about your well-being to give you personalized advice.")
|
60 |
next_step_button = st.button("Start Chat")
|
61 |
+
clear_button = st.button("Clear")
|
62 |
if next_step_button:
|
63 |
next_step()
|
64 |
+
if clear_button:
|
65 |
+
clear_data()
|
66 |
|
67 |
# Step 1: Ask for anxiety level
|
68 |
elif st.session_state.step == 1:
|
|
|
113 |
|
114 |
# Option to restart the chat
|
115 |
restart_button = st.button("Start Over")
|
116 |
+
clear_button = st.button("Clear")
|
117 |
if restart_button:
|
118 |
+
clear_data()
|
119 |
+
if clear_button:
|
120 |
+
clear_data()
|
121 |
|
122 |
# Main function to run the chatbot
|
123 |
def main():
|