adrinavaz commited on
Commit
31a904b
Β·
verified Β·
1 Parent(s): 0712158
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -45,11 +45,33 @@ def get_top_chunk(query):
45
 
46
  return best_chunk
47
 
48
- print(get_top_chunk("How can I manage test anxiety?"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
  def respond(message, history):
51
 
 
 
 
52
  relevant_chunk = get_top_chunk(message)
 
53
 
54
  messages = [
55
  {
 
45
 
46
  return best_chunk
47
 
48
+ mental_health_keywords = [ # we implement a list of keywords to ensure chatbot only assists with mental health
49
+ "stress", "stressed", "anxiety", "anxious",
50
+ "sad", "sadness", "depressed", "depression",
51
+ "lonely", "alone", "angry", "anger",
52
+ "overwhelmed", "burnout", "burned out",
53
+ "school", "grades", "homework", "test", "exam",
54
+ "family", "parents", "siblings",
55
+ "friend", "friends", "friendship",
56
+ "relationship", "breakup",
57
+ "sleep", "tired", "exhausted",
58
+ "panic", "worried", "worry",
59
+ "mental", "emotion", "emotional",
60
+ "feel", "feeling", "feelings",
61
+ "coping", "calm",
62
+ "therapy", "therapist", "counselor",
63
+ "motivation", "confidence", "self-esteem",
64
+ "crying", "numb", "overthinking",
65
+ "focus", "concentrate", "concentration"
66
+ ]
67
 
68
  def respond(message, history):
69
 
70
+ if not any(word in message.lower() for word in mental_health_keywords):
71
+ return "I'm mainly here to support teen mental wellness. Try asking me about stress, anxiety, school pressure, friendships, emotions, sleep, or coping strategies."
72
+
73
  relevant_chunk = get_top_chunk(message)
74
+ print("Retrieved chunk:", relevant_chunk) # we are using this line to test RAG system (the terminal will showwhat knowledge chunk chatbot used)
75
 
76
  messages = [
77
  {