saherPervaiz commited on
Commit
ede3059
Β·
verified Β·
1 Parent(s): 9b3b3ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -22
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 conversation-like experience
43
  def chatbot_interface():
44
- st.title("πŸŽ“ Student Well-being Chatbot")
45
- st.write("Hello! I’m here to assist you with well-being advice based on your responses.")
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: Hi there! I'm here to help with your well-being. Let's start! 😊")
67
- st.write("Bot: I'll ask you a few questions about your well-being to give you personalized advice.")
68
- next_step_button = st.button("Start Chat")
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 of 1 to 10, how would you rate your anxiety level?")
78
- anxiety_level = st.slider("Anxiety level (1-10)", 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 of 1 to 10, how would you rate your self-esteem?")
86
- self_esteem = st.slider("Self-esteem level (1-10)", 1, 10, 5)
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
- "Select an option:",
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 of 0 to 2, how would you rate your 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: Here's a summary of your responses: {user_data}")
113
 
114
- # Show a conversational summary of the user's well-being status
115
- st.subheader("πŸ”” Here's Your Personalized 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: I couldn't retrieve specific advice right now, but please check back later.")
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: