saherPervaiz commited on
Commit
e3e8ff9
·
verified ·
1 Parent(s): 81e495e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -1,9 +1,8 @@
1
  import streamlit as st
2
- import pandas as pd
3
  from groq import Groq
4
 
5
  # Groq API Key (replace with your actual API key)
6
- groq_api_key = "your_groq_api_key"
7
 
8
  # Initialize Groq client
9
  client = Groq(api_key=groq_api_key)
@@ -36,7 +35,7 @@ def stress_level_to_string(stress_level):
36
  def chatbot_interface():
37
  st.title("🎓 Student Well-being Chatbot")
38
  st.write("Hello! I’m here to assist you with well-being advice based on your responses.")
39
-
40
  # Initialize session state
41
  if 'step' not in st.session_state:
42
  st.session_state.step = 0
@@ -51,33 +50,35 @@ def chatbot_interface():
51
 
52
  # Step 0: Welcome message and initial question
53
  if st.session_state.step == 0:
54
- st.write("I'm going to ask you a few questions to understand your well-being. Let's get started!")
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:
61
- anxiety_level = st.text_input("On a scale of 1 to 10, how would you rate your anxiety level?", "")
62
  if anxiety_level:
63
  try:
64
  anxiety_level = int(anxiety_level)
65
  if anxiety_level < 1 or anxiety_level > 10:
66
  raise ValueError
67
  st.session_state.user_data['anxiety_level'] = anxiety_level
 
68
  next_step()
69
  except ValueError:
70
  show_input_error("Please enter a number between 1 and 10 for anxiety level.")
71
 
72
  # Step 2: Ask for self-esteem
73
  elif st.session_state.step == 2:
74
- self_esteem = st.text_input("On a scale of 1 to 10, how would you rate your self-esteem?", "")
75
  if self_esteem:
76
  try:
77
  self_esteem = int(self_esteem)
78
  if self_esteem < 1 or self_esteem > 10:
79
  raise ValueError
80
  st.session_state.user_data['self_esteem'] = self_esteem
 
81
  next_step()
82
  except ValueError:
83
  show_input_error("Please enter a number between 1 and 10 for self-esteem.")
@@ -87,12 +88,14 @@ def chatbot_interface():
87
  mental_health_history = st.selectbox("How would you describe your mental health history?",
88
  ["None", "Minor Issues", "Moderate Issues", "Severe Issues"])
89
  st.session_state.user_data['mental_health_history'] = mental_health_history
 
90
  next_step()
91
 
92
  # Step 4: Ask for stress level
93
  elif st.session_state.step == 4:
94
  stress_level = st.radio("On a scale of 0 to 2, how would you rate your stress level?", [0, 1, 2])
95
  st.session_state.user_data['stress_level'] = stress_level
 
96
  next_step()
97
 
98
  # Step 5: Show advice based on user input
 
1
  import streamlit as st
 
2
  from groq import Groq
3
 
4
  # Groq API Key (replace with your actual API key)
5
+ groq_api_key = "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"
6
 
7
  # Initialize Groq client
8
  client = Groq(api_key=groq_api_key)
 
35
  def chatbot_interface():
36
  st.title("🎓 Student Well-being Chatbot")
37
  st.write("Hello! I’m here to assist you with well-being advice based on your responses.")
38
+
39
  # Initialize session state
40
  if 'step' not in st.session_state:
41
  st.session_state.step = 0
 
50
 
51
  # Step 0: Welcome message and initial question
52
  if st.session_state.step == 0:
53
+ st.write("Hi! I'm here to assist you with well-being advice based on your responses. Let's get started!")
54
  next_step_button = st.button("Start Chat")
55
  if next_step_button:
56
  next_step()
57
 
58
  # Step 1: Ask for anxiety level
59
  elif st.session_state.step == 1:
60
+ anxiety_level = st.text_input("On a scale of 1 to 10, how would you rate your anxiety level?")
61
  if anxiety_level:
62
  try:
63
  anxiety_level = int(anxiety_level)
64
  if anxiety_level < 1 or anxiety_level > 10:
65
  raise ValueError
66
  st.session_state.user_data['anxiety_level'] = anxiety_level
67
+ st.write(f"Got it! Your anxiety level is {anxiety_level}.")
68
  next_step()
69
  except ValueError:
70
  show_input_error("Please enter a number between 1 and 10 for anxiety level.")
71
 
72
  # Step 2: Ask for self-esteem
73
  elif st.session_state.step == 2:
74
+ self_esteem = st.text_input("On a scale of 1 to 10, how would you rate your self-esteem?")
75
  if self_esteem:
76
  try:
77
  self_esteem = int(self_esteem)
78
  if self_esteem < 1 or self_esteem > 10:
79
  raise ValueError
80
  st.session_state.user_data['self_esteem'] = self_esteem
81
+ st.write(f"Got it! Your self-esteem level is {self_esteem}.")
82
  next_step()
83
  except ValueError:
84
  show_input_error("Please enter a number between 1 and 10 for self-esteem.")
 
88
  mental_health_history = st.selectbox("How would you describe your mental health history?",
89
  ["None", "Minor Issues", "Moderate Issues", "Severe Issues"])
90
  st.session_state.user_data['mental_health_history'] = mental_health_history
91
+ st.write(f"Got it! Your mental health history is: {mental_health_history}.")
92
  next_step()
93
 
94
  # Step 4: Ask for stress level
95
  elif st.session_state.step == 4:
96
  stress_level = st.radio("On a scale of 0 to 2, how would you rate your stress level?", [0, 1, 2])
97
  st.session_state.user_data['stress_level'] = stress_level
98
+ st.write(f"Got it! Your stress level is: {stress_level_to_string(stress_level)}.")
99
  next_step()
100
 
101
  # Step 5: Show advice based on user input