saherPervaiz commited on
Commit
67efa1b
·
verified ·
1 Parent(s): 8e315dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -4
app.py CHANGED
@@ -23,26 +23,65 @@ def fetch_health_articles(query):
23
 
24
  def provide_advice_from_articles(data):
25
  advice = []
 
26
  if data['depression'] > 7:
27
- advice.append("Searching for articles related to high depression...")
 
 
 
 
 
 
 
 
28
  articles = fetch_health_articles("high depression")
29
  for article in articles:
30
  advice.append(f"**{article['title']}**\n{article['description']}\n[Read more]({article['url']})")
 
 
31
  elif data['anxiety_level'] > 7:
32
- advice.append("Searching for articles related to high anxiety...")
 
 
 
 
 
 
 
 
33
  articles = fetch_health_articles("high anxiety")
34
  for article in articles:
35
  advice.append(f"**{article['title']}**\n{article['description']}\n[Read more]({article['url']})")
 
 
36
  elif data['stress_level'] > 7:
37
- advice.append("Searching for articles related to high stress...")
 
 
 
 
 
 
 
 
38
  articles = fetch_health_articles("high stress")
39
  for article in articles:
40
  advice.append(f"**{article['title']}**\n{article['description']}\n[Read more]({article['url']})")
 
 
41
  else:
42
- advice.append("Searching for general health advice articles...")
 
 
 
 
 
 
 
43
  articles = fetch_health_articles("mental health")
44
  for article in articles:
45
  advice.append(f"**{article['title']}**\n{article['description']}\n[Read more]({article['url']})")
 
46
  return advice
47
 
48
  def plot_graphs(data):
 
23
 
24
  def provide_advice_from_articles(data):
25
  advice = []
26
+ # High depression
27
  if data['depression'] > 7:
28
+ advice.append("🔴 **High Depression Levels Detected**")
29
+ advice.append("""
30
+ Depression is a serious condition that affects many aspects of life. If you are experiencing high levels of depression, it is important to seek professional help.
31
+ Here are some key steps that might help:
32
+ - **Consider therapy**: Cognitive Behavioral Therapy (CBT) is proven to be effective for managing depression.
33
+ - **Stay active**: Exercise can boost your mood and reduce stress.
34
+ - **Reach out to loved ones**: Isolation can worsen depression, so staying connected with friends and family is crucial.
35
+ - **Practice mindfulness**: Techniques such as deep breathing and meditation can be effective in managing depressive symptoms.
36
+ """)
37
  articles = fetch_health_articles("high depression")
38
  for article in articles:
39
  advice.append(f"**{article['title']}**\n{article['description']}\n[Read more]({article['url']})")
40
+
41
+ # High anxiety
42
  elif data['anxiety_level'] > 7:
43
+ advice.append("🟠 **High Anxiety Levels Detected**")
44
+ advice.append("""
45
+ Anxiety can cause significant distress and impact daily life. Addressing anxiety early can help you regain control over your well-being.
46
+ Here's how you can manage anxiety:
47
+ - **Breathing exercises**: Slow, deep breaths can help calm the mind and body.
48
+ - **Progressive muscle relaxation**: Tense and then relax different muscle groups to reduce physical tension.
49
+ - **Limit stimulants**: Reduce caffeine and sugar, which can increase anxiety.
50
+ - **Journaling**: Writing down your thoughts can help process feelings of anxiety.
51
+ """)
52
  articles = fetch_health_articles("high anxiety")
53
  for article in articles:
54
  advice.append(f"**{article['title']}**\n{article['description']}\n[Read more]({article['url']})")
55
+
56
+ # High stress
57
  elif data['stress_level'] > 7:
58
+ advice.append("🟡 **High Stress Levels Detected**")
59
+ advice.append("""
60
+ Prolonged stress can have adverse effects on both mental and physical health. Managing stress is crucial for maintaining balance and well-being.
61
+ Consider these strategies:
62
+ - **Time management**: Prioritize tasks and break them down into manageable steps to avoid feeling overwhelmed.
63
+ - **Physical activity**: Exercise can act as a natural stress reliever.
64
+ - **Relaxation techniques**: Meditation, yoga, or simply taking breaks during the day can reduce stress.
65
+ - **Sleep hygiene**: Ensure you're getting enough restful sleep by maintaining a regular sleep schedule.
66
+ """)
67
  articles = fetch_health_articles("high stress")
68
  for article in articles:
69
  advice.append(f"**{article['title']}**\n{article['description']}\n[Read more]({article['url']})")
70
+
71
+ # General mental health advice
72
  else:
73
+ advice.append("🟢 **General Health Advice**")
74
+ advice.append("""
75
+ Maintaining mental health is an ongoing process, and it’s important to integrate healthy habits into daily life. Here are some general tips:
76
+ - **Exercise regularly**: Physical activity can significantly boost mood and mental clarity.
77
+ - **Eat a balanced diet**: Nutrition plays a vital role in mental well-being.
78
+ - **Practice gratitude**: Reflecting on things you’re grateful for can shift your focus from stress to positivity.
79
+ - **Social support**: Stay connected with family and friends for emotional support.
80
+ """)
81
  articles = fetch_health_articles("mental health")
82
  for article in articles:
83
  advice.append(f"**{article['title']}**\n{article['description']}\n[Read more]({article['url']})")
84
+
85
  return advice
86
 
87
  def plot_graphs(data):