Skip to content

Commit 0c11f6a

Browse files
Merge branch 'main' into emoji-mood-selector
2 parents 88aa436 + 9c5b7ff commit 0c11f6a

20 files changed

+985
-50
lines changed

.streamlit/secrets.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GEMINI_API_KEY = "AIzaSyDsLJgA58LvgFtnUdVBLFb08GZQV0wXYjQ"

App.png

-790 KB
Binary file not shown.

README.md

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
* Gemini-powered chatbot for mental health companionship
1616
* Empathetic and encouraging tone—never clinical or diagnostic
1717
* Smart conversation history with multi-threaded support
18-
* Chatbot personality tone selector
19-
18+
* **Chatbot personality tone selector**:
19+
*Compassionate Listener*, *Motivating Coach*, *Wise Friend*, *Neutral Therapist*, *Mindfulness Guide*
20+
2021
### 📘 Resource & Crisis Help
2122

23+
* Emergency Help Button — instantly access local support via Google Maps
24+
* International helpline directory and global mental health resources
2225
* Mental health resource library with live search
23-
* International emergency contacts and helpline shortcuts
24-
* Quick access to location-based therapy centers via Google Maps
26+
27+
### 🧪 Science-Backed Assessments
28+
29+
* Integrated **PsyToolkit**-verified mental health quizzes for self-evaluation
2530

2631
### 💖 Mood Tracking & Journaling
2732

@@ -34,42 +39,60 @@
3439
* Instant-start suggestions like “Feeling overwhelmed” or “How to manage stress?”
3540
* Direct conversion of journal thoughts into chatbot prompts
3641

37-
### 🎨 Clean, Minimal UI
42+
### 🎨 Themes & UI
3843

39-
* Sidebar toggling for focus-driven interaction
40-
* 3D-inspired soft pink and magenta UI, best suited for a mentally soothing and peaceful outlook
44+
* Multiple soothing themes: **Light**, **Calm Blue**, **Mint**, **Lavender**, **Pink**, and **Dark**
45+
* 3D-inspired soft pink and magenta UI for a mentally soothing experience
4146
* Smooth transitions and responsive design for mobile and desktop
4247

4348
---
4449

4550
## 🚀 Live Demo
4651

47-
Experience TalkHeal live here:
48-
👉 [![**TalkHeal**](https://img.shields.io/badge/View-Live%20Demo-brightgreen?style=for-the-badge)](https://www.google.com/search?q=https://TalkHeal.streamlit.app)
49-
50-
<div align="center">
51-
<p>
52-
53-
[![Open Source Love svg1](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)
54-
![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen.svg?style=flat)
55-
![Visitors](https://api.visitorbadge.io/api/Visitors?path=eccentriccoder01%2FTalkHeal%20&countColor=%23263759&style=flat)
56-
![GitHub Forks](https://img.shields.io/github/forks/eccentriccoder01/TalkHeal)
57-
![GitHub Repo Stars](https://img.shields.io/github/stars/eccentriccoder01/TalkHeal)
58-
![GitHub Contributors](https://img.shields.io/github/contributors/eccentriccoder01/TalkHeal)
59-
![GitHub Last Commit](https://img.shields.io/github/last-commit/eccentriccoder01/TalkHeal)
60-
![GitHub Repo Size](https://img.shields.io/github/repo-size/eccentriccoder01/TalkHeal)
61-
![GitHub Total Lines](https://sloc.xyz/github/eccentriccoder01/TalkHeal)
62-
![Github](https://img.shields.io/github/license/eccentriccoder01/TalkHeal)
63-
![GitHub Issues](https://img.shields.io/github/issues/eccentriccoder01/TalkHeal)
64-
![GitHub Closed Issues](https://img.shields.io/github/issues-closed-raw/eccentriccoder01/TalkHeal)
65-
![GitHub Pull Requests](https://img.shields.io/github/issues-pr/eccentriccoder01/TalkHeal)
66-
![GitHub Closed Pull Requests](https://img.shields.io/github/issues-pr-closed/eccentriccoder01/TalkHeal)
67-
</p>
68-
</div>
52+
### 🎯 **Experience TalkHeal live now!**
53+
🔗 [https://TalkHeal.streamlit.app](https://TalkHeal.streamlit.app)
54+
55+
---
56+
57+
## 📊 Project Stats
58+
59+
<p align="center">
60+
<a href="https://github.com/eccentriccoder01/TalkHeal">
61+
<img alt="GitHub Stars" src="https://img.shields.io/github/stars/eccentriccoder01/TalkHeal?style=flat-square" />
62+
</a>
63+
<a href="https://github.com/eccentriccoder01/TalkHeal/fork">
64+
<img alt="GitHub Forks" src="https://img.shields.io/github/forks/eccentriccoder01/TalkHeal?style=flat-square" />
65+
</a>
66+
<a href="https://github.com/eccentriccoder01/TalkHeal/graphs/contributors">
67+
<img alt="Contributors" src="https://img.shields.io/github/contributors/eccentriccoder01/TalkHeal?style=flat-square" />
68+
</a>
69+
<a href="https://github.com/eccentriccoder01/TalkHeal/issues">
70+
<img alt="Open Issues" src="https://img.shields.io/github/issues/eccentriccoder01/TalkHeal?style=flat-square" />
71+
</a>
72+
<a href="https://github.com/eccentriccoder01/TalkHeal/pulls">
73+
<img alt="Open Pull Requests" src="https://img.shields.io/github/issues-pr/eccentriccoder01/TalkHeal?style=flat-square" />
74+
</a>
75+
<a href="https://github.com/eccentriccoder01/TalkHeal/commits/main">
76+
<img alt="Last Commit" src="https://img.shields.io/github/last-commit/eccentriccoder01/TalkHeal?style=flat-square" />
77+
</a>
78+
<a href="https://github.com/eccentriccoder01/TalkHeal/blob/main/LICENSE">
79+
<img alt="License" src="https://img.shields.io/github/license/eccentriccoder01/TalkHeal?style=flat-square" />
80+
</a>
81+
</p>
82+
83+
---
84+
85+
> 💡 **PRs Welcome!** We love contributions. Check out the [Contribution Guidelines](CONTRIBUTING.md) to get started.
6986
7087
## 📸 Screenshots
7188

72-
<div align="center"><img src="App.png"/></div>
89+
<div align="center">
90+
<img src="light_ss.jpg" alt="Main Screenshot" width="600"/>
91+
<br>
92+
<img src="dark_ss.jpg" width="200"/></a>
93+
<img src="blue_ss.jpg" width="200"/></a>
94+
<img src="lav_ss.jpg" width="200"/></a>
95+
</div>
7396

7497
## 📺 Video Explanation
7598

@@ -138,7 +161,6 @@ Report bugs and issues or propose improvements through our GitHub repository.
138161
- Add Screenshots and updated website links to help us understand what changes is all about.
139162

140163
- Check the [CONTRIBUTING.md](CONTRIBUTING.md) for detailed steps...
141-
142164

143165
## Contributing is fun🧡
144166

@@ -147,9 +169,15 @@ Whether it's a new feature, design improvement, or a bug fix — your voice matt
147169

148170
Your insights are invaluable to us. Reach out to us team for any inquiries, feedback, or concerns.
149171

172+
## 👥 Contributors
173+
174+
Thanks to these wonderful people for contributing 💖
175+
176+
[![Contributors](https://contrib.rocks/image?repo=eccentriccoder01/TalkHeal)](https://github.com/eccentriccoder01/TalkHeal/graphs/contributors)
177+
150178
## 📄 License
151179

152-
This project is open-source and available under the MIT License.
180+
This project is open-source and available under the [MIT License](LICENSE).
153181

154182
## 📞 Contact
155183

TalkHeal.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from components.sidebar import render_sidebar
1515
from components.chat_interface import render_chat_interface, handle_chat_input
1616
from components.emergency_page import render_emergency_page
17+
from components.profile import apply_global_font_size
1718

1819
# --- 1. PAGE CONFIG & CSS ---
1920
apply_custom_css()
@@ -39,6 +40,22 @@
3940
"selected_mood": "🙂"
4041
}
4142

43+
# --- 2. SET PAGE CONFIG ---
44+
if "selected_tone" not in st.session_state:
45+
st.session_state.selected_tone = "Compassionate Listener"
46+
47+
apply_global_font_size()
48+
49+
# --- 3. APPLY STYLES & CONFIGURATIONS ---
50+
apply_custom_css()
51+
model = configure_gemini()
52+
53+
# --- 4. TONE SELECTION DROPDOWN IN SIDEBAR ---
54+
TONE_OPTIONS = {
55+
"Compassionate Listener": "You are a compassionate listenersoft, empathetic, patientlike a therapist who listens wit
56+
57+
}
58+
4259
for key, val in default_values.items():
4360
if key not in st.session_state:
4461
st.session_state[key] = val
@@ -70,8 +87,13 @@
7087
render_emergency_page()
7188
else:
7289
render_header()
73-
st.subheader(f"🗣️ Current Chatbot Tone: **{st.session_state['selected_tone']}**")
74-
st.markdown(f"**🧠 Mood Selected:** {get_selected_mood()}")
90+
st.markdown(f"""
91+
<div style="text-align: center; margin: 20px 0;">
92+
<h3>🗣️ Current Chatbot Tone: <strong>{st.session_state['selected_tone']}</strong></h3>
93+
<p><strong>🧠 Mood Selected:</strong> {get_selected_mood()}</p>
94+
</div>
95+
""", unsafe_allow_html=True)
96+
7597
render_chat_interface()
7698
handle_chat_input(model=model, system_prompt=get_tone_prompt())
7799

assets/yoga_animation.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

blue_ss.jpg

161 KB
Loading

components/chat_interface.py

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,41 @@
11
import streamlit as st
2+
import streamlit as st
3+
import streamlit.components.v1 as components
4+
from datetime import datetime
25
from core.utils import save_conversations, get_current_time
36
from core.gemini import get_ai_response
4-
7+
import requests
8+
9+
# --- Set user timezone in session (from main) ---
10+
def set_user_time_in_session():
11+
if "user_time_offset" not in st.session_state:
12+
components.html("""
13+
<script>
14+
const offset = new Date().getTimezoneOffset();
15+
const time = new Date().toLocaleString();
16+
const data = {offset: offset, time: time};
17+
window.parent.postMessage({type: 'USER_TIME', data: data}, '*');
18+
</script>
19+
""", height=0)
20+
21+
st.markdown("""
22+
<script>
23+
window.addEventListener("message", (event) => {
24+
if (event.data.type === "USER_TIME") {
25+
const payload = JSON.stringify(event.data.data);
26+
fetch("/", {
27+
method: "POST",
28+
headers: {"Content-Type": "application/json"},
29+
body: payload
30+
}).then(() => location.reload());
31+
}
32+
});
33+
</script>
34+
""", unsafe_allow_html=True)
35+
36+
set_user_time_in_session()
37+
38+
# --- Chat Interface Renderer ---
539
def render_chat_interface():
640
st.markdown("### 🗨️ TalkHeal Conversation")
741

@@ -12,6 +46,15 @@ def render_chat_interface():
1246

1347
conversation = st.session_state.conversations[active_index]
1448

49+
if not conversation["messages"]:
50+
st.markdown(f"""
51+
<div class="welcome-message">
52+
<strong>Hello! I'm TalkHeal, your mental health companion 🤗</strong><br>
53+
How are you feeling today? You can write below or start a new topic.
54+
<div class="message-time">{get_current_time()}</div>
55+
</div>
56+
""", unsafe_allow_html=True)
57+
1558
for msg in conversation["messages"]:
1659
sender = msg["sender"]
1760
message = msg["message"]
@@ -24,7 +67,6 @@ def render_chat_interface():
2467
with st.chat_message("assistant", avatar="💬"):
2568
st.markdown(f"{message}\n\n<sub>{time}</sub>", unsafe_allow_html=True)
2669

27-
2870
def handle_chat_input(model, system_prompt):
2971
pre_filled = st.session_state.get("pre_filled_chat_input", "")
3072
st.session_state.pre_filled_chat_input = ""
@@ -93,11 +135,25 @@ def format_memory(convo_history, max_turns=10):
93135
"time": get_current_time()
94136
})
95137

138+
except ValueError as e:
139+
st.error("I'm having trouble understanding your message. Could you please rephrase it?")
140+
active_convo["messages"].append({
141+
"sender": "bot",
142+
"message": "I'm having trouble understanding your message. Could you please rephrase it?",
143+
"time": get_current_time()
144+
})
145+
except requests.RequestException as e:
146+
st.error("Network connection issue. Please check your internet connection.")
147+
active_convo["messages"].append({
148+
"sender": "bot",
149+
"message": "I'm having trouble connecting to my services. Please check your internet connection and try again.",
150+
"time": get_current_time()
151+
})
96152
except Exception as e:
97-
st.error(f"An error occurred: {e}")
153+
st.error(f"An unexpected error occurred. Please try again.")
98154
active_convo["messages"].append({
99155
"sender": "bot",
100-
"message": "Im having trouble responding right now. Please try again in a moment.",
156+
"message": "I'm having trouble responding right now. Please try again in a moment.",
101157
"time": get_current_time()
102158
})
103159

components/emergency_page.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from geopy.geocoders import Nominatim
33
import urllib.parse
44
from .sidebar import GLOBAL_RESOURCES
5+
import geopy.exc
6+
import requests
57

68

79
def render_emergency_page():
@@ -41,8 +43,20 @@ def render_emergency_page():
4143
st.error(
4244
f"Could not find a location for '{location_query}'. Please try again.")
4345
st.session_state.pop('location_info', None)
46+
except geopy.exc.GeocoderTimedOut:
47+
st.error("Location search timed out. Please try again with a more specific location.")
48+
st.session_state.pop('location_info', None)
49+
except geopy.exc.GeocoderUnavailable:
50+
st.error("Location service is currently unavailable. Please try again later.")
51+
st.session_state.pop('location_info', None)
52+
except geopy.exc.GeocoderQuotaExceeded:
53+
st.error("Location service quota exceeded. Please try again later.")
54+
st.session_state.pop('location_info', None)
55+
except requests.RequestException as e:
56+
st.error("Network error while searching for location. Please check your internet connection.")
57+
st.session_state.pop('location_info', None)
4458
except Exception as e:
45-
st.error(f"An error occurred during search: {e}")
59+
st.error(f"An unexpected error occurred during search. Please try again.")
4660
st.session_state.pop('location_info', None)
4761
else:
4862
st.warning("Please enter a location to search.")

0 commit comments

Comments
 (0)