Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ def get_personalized_advice(user_data):
|
|
17 |
- Mental health history: {user_data['mental_health_history']}
|
18 |
- Stress level: {user_data['stress_level']}
|
19 |
|
20 |
-
Please provide personalized mental health advice tailored to these responses.
|
21 |
"""
|
22 |
|
23 |
try:
|
@@ -39,11 +39,11 @@ def stress_level_to_string(stress_level):
|
|
39 |
else:
|
40 |
return "High"
|
41 |
|
42 |
-
# Chatbot interface for
|
43 |
def chatbot_interface():
|
44 |
-
st.title("π Student Well-being Chatbot")
|
45 |
-
st.write("
|
46 |
-
|
47 |
# Initialize session state
|
48 |
if 'step' not in st.session_state:
|
49 |
st.session_state.step = 0
|
@@ -63,10 +63,10 @@ def chatbot_interface():
|
|
63 |
|
64 |
# Step 0: Welcome message and initial question
|
65 |
if st.session_state.step == 0:
|
66 |
-
st.write("Bot:
|
67 |
-
st.write("Bot:
|
68 |
-
next_step_button = st.button("Start
|
69 |
-
clear_button = st.button("Clear")
|
70 |
if next_step_button:
|
71 |
next_step()
|
72 |
if clear_button:
|
@@ -74,16 +74,16 @@ def chatbot_interface():
|
|
74 |
|
75 |
# Step 1: Ask for anxiety level
|
76 |
elif st.session_state.step == 1:
|
77 |
-
st.write("Bot: On a scale
|
78 |
-
anxiety_level = st.slider("Anxiety
|
79 |
if anxiety_level:
|
80 |
st.session_state.user_data['anxiety_level'] = anxiety_level
|
81 |
next_step()
|
82 |
|
83 |
# Step 2: Ask for self-esteem
|
84 |
elif st.session_state.step == 2:
|
85 |
-
st.write("Bot: On a scale
|
86 |
-
self_esteem = st.slider("Self-esteem
|
87 |
if self_esteem:
|
88 |
st.session_state.user_data['self_esteem'] = self_esteem
|
89 |
next_step()
|
@@ -92,7 +92,7 @@ def chatbot_interface():
|
|
92 |
elif st.session_state.step == 3:
|
93 |
st.write("Bot: How would you describe your mental health history?")
|
94 |
mental_health_history = st.selectbox(
|
95 |
-
"
|
96 |
["None", "Minor Issues", "Moderate Issues", "Severe Issues"]
|
97 |
)
|
98 |
st.session_state.user_data['mental_health_history'] = mental_health_history
|
@@ -100,28 +100,28 @@ def chatbot_interface():
|
|
100 |
|
101 |
# Step 4: Ask for stress level
|
102 |
elif st.session_state.step == 4:
|
103 |
-
st.write("Bot: On a scale
|
104 |
-
stress_level = st.radio("Stress
|
105 |
st.session_state.user_data['stress_level'] = stress_level
|
106 |
next_step()
|
107 |
|
108 |
# Step 5: Show advice based on user input
|
109 |
elif st.session_state.step == 5:
|
110 |
-
st.write("Bot: Thank you for providing the information
|
111 |
user_data = st.session_state.user_data
|
112 |
-
st.write(f"Bot:
|
113 |
|
114 |
-
# Show
|
115 |
-
st.subheader("π
|
116 |
advice = get_personalized_advice(user_data)
|
117 |
if advice:
|
118 |
st.write(f"Bot: {advice}")
|
119 |
else:
|
120 |
-
st.write("Bot: I couldn't retrieve specific advice
|
121 |
|
122 |
# Option to restart the chat
|
123 |
restart_button = st.button("Start Over")
|
124 |
-
clear_button = st.button("Clear")
|
125 |
if restart_button:
|
126 |
clear_data()
|
127 |
if clear_button:
|
|
|
17 |
- Mental health history: {user_data['mental_health_history']}
|
18 |
- Stress level: {user_data['stress_level']}
|
19 |
|
20 |
+
Please provide professional, personalized mental health advice tailored to these responses.
|
21 |
"""
|
22 |
|
23 |
try:
|
|
|
39 |
else:
|
40 |
return "High"
|
41 |
|
42 |
+
# Chatbot interface for professional user experience
|
43 |
def chatbot_interface():
|
44 |
+
st.title("π Professional Student Well-being Chatbot")
|
45 |
+
st.write("Welcome to the Student Well-being Chatbot. Iβm here to assist you in improving your mental well-being based on your responses. Please answer the following questions.")
|
46 |
+
|
47 |
# Initialize session state
|
48 |
if 'step' not in st.session_state:
|
49 |
st.session_state.step = 0
|
|
|
63 |
|
64 |
# Step 0: Welcome message and initial question
|
65 |
if st.session_state.step == 0:
|
66 |
+
st.write("Bot: Thank you for choosing to take this well-being assessment. We will gather some insights to provide personalized advice.")
|
67 |
+
st.write("Bot: Please answer the following questions as accurately as possible.")
|
68 |
+
next_step_button = st.button("Start Assessment")
|
69 |
+
clear_button = st.button("Clear All")
|
70 |
if next_step_button:
|
71 |
next_step()
|
72 |
if clear_button:
|
|
|
74 |
|
75 |
# Step 1: Ask for anxiety level
|
76 |
elif st.session_state.step == 1:
|
77 |
+
st.write("Bot: On a scale from 1 to 10, how would you rate your current anxiety level?")
|
78 |
+
anxiety_level = st.slider("Anxiety Level", 1, 10, 5)
|
79 |
if anxiety_level:
|
80 |
st.session_state.user_data['anxiety_level'] = anxiety_level
|
81 |
next_step()
|
82 |
|
83 |
# Step 2: Ask for self-esteem
|
84 |
elif st.session_state.step == 2:
|
85 |
+
st.write("Bot: On a scale from 1 to 10, how would you rate your current self-esteem?")
|
86 |
+
self_esteem = st.slider("Self-esteem Level", 1, 10, 5)
|
87 |
if self_esteem:
|
88 |
st.session_state.user_data['self_esteem'] = self_esteem
|
89 |
next_step()
|
|
|
92 |
elif st.session_state.step == 3:
|
93 |
st.write("Bot: How would you describe your mental health history?")
|
94 |
mental_health_history = st.selectbox(
|
95 |
+
"Please select the option that best represents your mental health history:",
|
96 |
["None", "Minor Issues", "Moderate Issues", "Severe Issues"]
|
97 |
)
|
98 |
st.session_state.user_data['mental_health_history'] = mental_health_history
|
|
|
100 |
|
101 |
# Step 4: Ask for stress level
|
102 |
elif st.session_state.step == 4:
|
103 |
+
st.write("Bot: On a scale from 0 to 2, how would you rate your current stress level?")
|
104 |
+
stress_level = st.radio("Stress Level (0 = Low, 1 = Moderate, 2 = High)", [0, 1, 2])
|
105 |
st.session_state.user_data['stress_level'] = stress_level
|
106 |
next_step()
|
107 |
|
108 |
# Step 5: Show advice based on user input
|
109 |
elif st.session_state.step == 5:
|
110 |
+
st.write("Bot: Thank you for providing the information.")
|
111 |
user_data = st.session_state.user_data
|
112 |
+
st.write(f"Bot: Based on your inputs, here is a summary of your responses: {user_data}")
|
113 |
|
114 |
+
# Show professional, personalized advice
|
115 |
+
st.subheader("π Professional Well-being Advice:")
|
116 |
advice = get_personalized_advice(user_data)
|
117 |
if advice:
|
118 |
st.write(f"Bot: {advice}")
|
119 |
else:
|
120 |
+
st.write("Bot: Unfortunately, I couldn't retrieve specific advice at this moment, but feel free to try again later.")
|
121 |
|
122 |
# Option to restart the chat
|
123 |
restart_button = st.button("Start Over")
|
124 |
+
clear_button = st.button("Clear All")
|
125 |
if restart_button:
|
126 |
clear_data()
|
127 |
if clear_button:
|