Skip to content

Commit 7f9165c

Browse files
Merge pull request #42 from IqraS-gif/recover-changes
Add quiz section and fix expander issue- In proper branch this time
2 parents a192628 + 060a186 commit 7f9165c

File tree

2 files changed

+89
-23
lines changed

2 files changed

+89
-23
lines changed

TalkHeal.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
import streamlit as st
2+
3+
# ✅ MUST be the first Streamlit command
4+
st.set_page_config(
5+
page_title="TalkHeal",
6+
page_icon="💬",
7+
layout="wide",
8+
initial_sidebar_state=st.session_state.get("sidebar_state", "expanded")
9+
)
10+
211
import google.generativeai as genai
312
from core.utils import save_conversations, load_conversations
413
from core.config import configure_gemini, PAGE_CONFIG
@@ -9,6 +18,7 @@
918
from components.chat_interface import render_chat_interface, handle_chat_input
1019
from components.emergency_page import render_emergency_page
1120

21+
1222
# --- 1. INITIALIZE SESSION STATE ---
1323
if "chat_history" not in st.session_state:
1424
st.session_state.chat_history = []
@@ -31,12 +41,7 @@
3141
st.session_state.selected_tone = "Compassionate Listener"
3242

3343
# --- 2. SET PAGE CONFIG ---
34-
st.set_page_config(
35-
page_title=PAGE_CONFIG["page_title"],
36-
page_icon=PAGE_CONFIG["page_icon"],
37-
layout=PAGE_CONFIG["layout"],
38-
initial_sidebar_state=st.session_state.sidebar_state
39-
)
44+
4045

4146
# --- 3. APPLY STYLES & CONFIGURATIONS ---
4247
apply_custom_css()
@@ -103,4 +108,4 @@ def get_tone_prompt():
103108
}
104109
setTimeout(scrollToBottom, 100);
105110
</script>
106-
""", unsafe_allow_html=True)
111+
""", unsafe_allow_html=True)

components/sidebar.py

Lines changed: 77 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime
44
from core.utils import create_new_conversation, get_current_time
55
from core.theme import get_current_theme, toggle_theme, set_palette, PALETTES
6+
67
# --- Structured Emergency Resources ---
78
GLOBAL_RESOURCES = [
89
{"name": "Befrienders Worldwide", "desc": "Emotional support to prevent suicide worldwide.",
@@ -286,7 +287,7 @@ def render_sidebar():
286287
for i, tab_title in enumerate(mental_health_resources_full.keys()):
287288
with resource_tabs[i]:
288289
topic_data = mental_health_resources_full[tab_title]
289-
st.markdown(f"**{tab_title}**") # fixed typo
290+
st.markdown(f"**{tab_title}**")
290291
st.info(topic_data['description'])
291292
for link in topic_data['links']:
292293
st.markdown(f"• [{link['label']}]({link['url']})")
@@ -336,22 +337,82 @@ def render_sidebar():
336337
):
337338
toggle_theme()
338339

339-
with st.expander("ℹ️ About TalkHeal"):
340+
# Quizzes expander (no longer contains nested expander)
341+
with st.expander("🧪 Take PsyToolkit Verified Quizzes"):
340342
st.markdown("""
341-
**TalkHeal** is your compassionate mental health companion, designed to provide:
342-
343-
• 24/7 emotional support
344-
• Resource guidance
345-
• Crisis intervention
346-
• Professional referrals
347-
348-
**Remember:** This is not a substitute for professional mental health care.
349-
350-
---
343+
Explore scientifically backed quizzes to better understand your mental well-being. These tools are for **self-awareness** and not clinical diagnosis.
344+
""")
351345

352-
**Created with ❤️ by [Eccentric Explorer](https://eccentriccoder01.github.io/Me)**
346+
quizzes = [
347+
{
348+
"name": "GAD-7 (Anxiety Assessment)",
349+
"desc": "Measures severity of generalized anxiety symptoms.",
350+
"url": "https://www.psytoolkit.org/cgi-bin/3.6.0/survey?s=u8bAf",
351+
"score_info": """
352+
Score Interpretation:
353+
GAD-7 score runs from 0 to 21
354+
- 0–4: Minimal anxiety
355+
- 5–9: Mild anxiety
356+
- 10–14: Moderate anxiety
357+
- 15–21: Severe anxiety
358+
"""
359+
},
360+
{
361+
"name": "PHQ-9 (Depression Assessment)",
362+
"desc": "Screens for presence and severity of depression.",
363+
"url": "https://www.psytoolkit.org/cgi-bin/3.6.0/survey?s=Hj32b",
364+
"score_info": """
365+
Score Interpretation:
366+
- 0–4: Mild depression
367+
- 5–9: Moderate depression
368+
- 10–14: Moderately severe depression
369+
- 15–19: Severe depression
370+
"""
371+
},
372+
{
373+
"name": "The WHO-5 Well-Being Index",
374+
"desc": "Five simple non-intrusive questions to assess well-being. Score ranges from 0 (poor) to 100 (excellent).",
375+
"url": "https://www.psytoolkit.org/cgi-bin/3.6.0/survey?s=POqLJ",
376+
"score_info": """
377+
Score Interpretation:
378+
-if your score is 50 or lower you should consider
379+
-further checks on whether you suffer
380+
-from clinical depression
381+
"""
382+
},
383+
{
384+
"name": "Depression Anxiety Stress Scales (DASS)",
385+
"desc": "Measures depression, anxiety, and stress using one combined questionnaire.",
386+
"url": "https://www.psytoolkit.org/cgi-bin/3.6.0/survey?s=HvfDY",
387+
"score_info": "**Score Interpretation (per subscale):**\n\n- **Normal, Mild, Moderate, Severe, Extremely Severe**\n\n| | Depression | Anxiety | Stress |\n|----------|------------|---------|---------|\n| Normal | 0-9 | 0-7 | 0-14 |\n| Mild | 10-13 | 8-9 | 15-18 |\n| Moderate | 14-20 | 10-14 | 19-25 |\n| Severe | 21-27 | 15-19 | 26-33 |\n| Extremely Severe | 28+ | 20+ | 34+ |"
388+
}
389+
]
353390

354-
*"It's absolutely okay not to be okay :)"*
391+
for quiz in quizzes:
392+
st.markdown(f"""
393+
**{quiz['name']}**
394+
*{quiz['desc']}*
395+
[🔗 Take Quiz]({quiz['url']})
396+
{quiz['score_info']}
397+
""")
355398

356-
📅 Enhanced Version - May 2025
357-
""")
399+
# About section moved outside of any expander
400+
st.markdown("---")
401+
st.markdown("""
402+
**ℹ️ About TalkHeal**
403+
Your compassionate mental health companion, designed to provide:
404+
405+
• 24/7 emotional support
406+
• Resource guidance
407+
• Crisis intervention
408+
• Professional referrals
409+
410+
**Remember:** This is not a substitute for professional mental health care.
411+
412+
---
413+
414+
**Created with ❤️ by [Eccentric Explorer](https://eccentriccoder01.github.io/Me)**
415+
*"It's absolutely okay not to be okay :)"*
416+
417+
📅 Enhanced Version - May 2025
418+
""")

0 commit comments

Comments
 (0)