mindwatch / rag /knowledge_base.py
priyadip's picture
Initial MindWatch deployment
4c423a1 verified
"""
MindWatch β€” Mental Health Knowledge Base
Curated resources from WHO guidelines, psychology best practices, and counseling advice.
"""
KNOWLEDGE_BASE = [
# === DEPRESSION RESOURCES ===
{
"id": "dep_001",
"category": "depression",
"title": "Understanding Depression",
"content": (
"Depression is a common mental health condition that affects how you feel, think, and act. "
"It causes persistent feelings of sadness and loss of interest in activities you once enjoyed. "
"Depression is not a sign of weakness β€” it is a medical condition that can be treated effectively. "
"According to the WHO, more than 280 million people worldwide experience depression."
),
"source": "WHO Mental Health Guidelines",
},
{
"id": "dep_002",
"category": "depression",
"title": "Coping Strategies for Depression",
"content": (
"Evidence-based coping strategies for depression include: "
"1) Behavioral activation β€” gradually increasing engagement in meaningful activities. "
"2) Social connection β€” reaching out to trusted friends, family, or support groups. "
"3) Physical activity β€” regular exercise has been shown to reduce symptoms. "
"4) Sleep hygiene β€” maintaining consistent sleep patterns. "
"5) Mindfulness and meditation β€” practicing present-moment awareness. "
"6) Journaling β€” writing down thoughts to process emotions. "
"7) Professional help β€” therapy (CBT, DBT) and medication when appropriate."
),
"source": "Clinical Psychology Guidelines",
},
{
"id": "dep_003",
"category": "depression",
"title": "When to Seek Professional Help for Depression",
"content": (
"Consider seeking professional help if you experience: persistent sadness lasting more than "
"two weeks, loss of interest in daily activities, significant changes in appetite or sleep, "
"difficulty concentrating, feelings of worthlessness, or thoughts of self-harm. "
"A mental health professional can provide proper diagnosis and create a personalized treatment plan. "
"Treatment options include cognitive behavioral therapy (CBT), interpersonal therapy, and medication."
),
"source": "Mental Health First Aid Guidelines",
},
{
"id": "dep_004",
"category": "depression",
"title": "Daily Routine for Managing Depression",
"content": (
"Building a structured daily routine can help manage depression symptoms. "
"Start with small achievable goals: wake up at a consistent time, take a short walk, "
"eat regular meals, and include one enjoyable activity each day. "
"Avoid isolation by scheduling social interactions, even brief ones. "
"Limit alcohol and avoid substances that can worsen depression. "
"Celebrate small victories β€” every step forward matters."
),
"source": "Behavioral Health Guidelines",
},
# === ANXIETY RESOURCES ===
{
"id": "anx_001",
"category": "anxiety",
"title": "Understanding Anxiety Disorders",
"content": (
"Anxiety is a natural response to stress, but when it becomes overwhelming and persistent, "
"it may indicate an anxiety disorder. Common types include generalized anxiety disorder (GAD), "
"social anxiety disorder, panic disorder, and specific phobias. "
"Physical symptoms can include rapid heartbeat, shortness of breath, muscle tension, and insomnia. "
"Anxiety disorders are highly treatable through therapy and lifestyle changes."
),
"source": "WHO Mental Health Guidelines",
},
{
"id": "anx_002",
"category": "anxiety",
"title": "Grounding Techniques for Anxiety",
"content": (
"Grounding techniques help manage acute anxiety and panic attacks: "
"1) 5-4-3-2-1 technique: Name 5 things you see, 4 you hear, 3 you touch, 2 you smell, 1 you taste. "
"2) Deep breathing: Breathe in for 4 counts, hold for 4, exhale for 6. "
"3) Progressive muscle relaxation: Tense and release each muscle group. "
"4) Anchoring: Focus on a specific object and describe it in detail. "
"5) Cold water: Splash cold water on your face to activate the dive reflex."
),
"source": "Clinical Psychology Guidelines",
},
{
"id": "anx_003",
"category": "anxiety",
"title": "Cognitive Restructuring for Anxious Thoughts",
"content": (
"Cognitive restructuring is a core CBT technique for managing anxiety: "
"1) Identify the anxious thought (e.g., 'Everyone will judge me'). "
"2) Examine the evidence for and against this thought. "
"3) Consider alternative explanations. "
"4) Rate the realistic probability of the feared outcome. "
"5) Develop a more balanced thought. "
"This practice helps break the cycle of catastrophic thinking over time."
),
"source": "Cognitive Behavioral Therapy Manual",
},
{
"id": "anx_004",
"category": "anxiety",
"title": "Lifestyle Changes for Anxiety Management",
"content": (
"Long-term anxiety management through lifestyle modifications: "
"Reduce caffeine and stimulant intake. Exercise regularly β€” even 30 minutes of walking helps. "
"Practice consistent sleep hygiene. Learn to set healthy boundaries. "
"Limit social media consumption which can increase comparison and worry. "
"Build a relaxation practice such as yoga, meditation, or tai chi. "
"Consider joining a support group to connect with others who understand."
),
"source": "Behavioral Health Guidelines",
},
# === STRESS RESOURCES ===
{
"id": "str_001",
"category": "stress",
"title": "Understanding Chronic Stress",
"content": (
"Chronic stress occurs when the body's stress response stays activated for extended periods. "
"It can affect physical health (headaches, digestive issues, weakened immunity), "
"mental health (irritability, difficulty concentrating), and behavior (sleep problems, overeating). "
"Common sources include work pressure, financial difficulties, relationship problems, and major life changes. "
"Recognizing early warning signs is key to preventing burnout."
),
"source": "WHO Stress Management Guidelines",
},
{
"id": "str_002",
"category": "stress",
"title": "Stress Management Techniques",
"content": (
"Effective stress management strategies include: "
"1) Time management β€” prioritize tasks and break large projects into smaller steps. "
"2) Setting boundaries β€” learn to say no to additional commitments. "
"3) Physical activity β€” releases endorphins that counteract stress hormones. "
"4) Social support β€” talk to friends, family, or colleagues about what you're going through. "
"5) Relaxation techniques β€” deep breathing, meditation, progressive muscle relaxation. "
"6) Work-life balance β€” schedule regular breaks and leisure activities."
),
"source": "Occupational Health Guidelines",
},
{
"id": "str_003",
"category": "stress",
"title": "Burnout Prevention and Recovery",
"content": (
"Burnout is a state of emotional, physical, and mental exhaustion caused by prolonged stress. "
"Signs include feeling drained, increased cynicism, and reduced professional efficacy. "
"Prevention strategies: set clear work boundaries, take regular vacations, delegate tasks. "
"Recovery involves: reducing workload, reconnecting with activities you enjoy, "
"seeking professional support if needed, and gradually rebuilding energy reserves. "
"Remember: burnout is not a personal failure β€” it is a response to unsustainable demands."
),
"source": "WHO Guidelines on Mental Health at Work",
},
# === GENERAL WELLBEING ===
{
"id": "gen_001",
"category": "general",
"title": "Building Emotional Resilience",
"content": (
"Emotional resilience can be developed through practice: "
"1) Maintain a strong social network β€” relationships buffer against stress. "
"2) Develop problem-solving skills β€” focus on what you can control. "
"3) Practice self-compassion β€” treat yourself with the kindness you show others. "
"4) Find meaning and purpose β€” connect activities to personal values. "
"5) Embrace change as a natural part of life. "
"6) Take care of your physical health β€” sleep, nutrition, and exercise form the foundation."
),
"source": "Positive Psychology Research",
},
{
"id": "gen_002",
"category": "general",
"title": "Mental Health Resources and Helplines",
"content": (
"If you or someone you know is in crisis, help is available: "
"National Suicide Prevention Lifeline: 988 (US). "
"Crisis Text Line: Text HOME to 741741 (US). "
"Samaritans: 116 123 (UK). "
"iCall: 9152987821 (India). "
"Befrienders Worldwide: www.befrienders.org (International). "
"These services are confidential and available 24/7. You are not alone."
),
"source": "International Crisis Resources",
},
{
"id": "gen_003",
"category": "general",
"title": "Self-Care Fundamentals",
"content": (
"Self-care is not selfish β€” it is essential for mental health. "
"Physical self-care: regular exercise, balanced nutrition, adequate sleep. "
"Emotional self-care: journaling, therapy, creative expression. "
"Social self-care: maintaining relationships, setting boundaries, asking for help. "
"Intellectual self-care: learning new skills, reading, stimulating hobbies. "
"Start small: choose one area to improve this week."
),
"source": "Mental Health Foundation",
},
]
def get_all_documents() -> list:
"""Return all documents in the knowledge base."""
return KNOWLEDGE_BASE
def get_documents_by_category(category: str) -> list:
"""Return documents matching a specific category."""
return [doc for doc in KNOWLEDGE_BASE if doc["category"] == category or doc["category"] == "general"]
def get_document_texts() -> list:
"""Return list of (id, text) tuples for embedding."""
return [(doc["id"], f"{doc['title']}. {doc['content']}") for doc in KNOWLEDGE_BASE]