Skip to content

Commit babcc05

Browse files
committed
Resolved merge conflicts between emoji-mood-selector and main
1 parent 8eb322f commit babcc05

File tree

3 files changed

+94
-1
lines changed

3 files changed

+94
-1
lines changed

TalkHeal.py~

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# --- 0. IMPORTS ---
2+
import streamlit as st
3+
import google.generativeai as genai
4+
5+
# --- 1. FIRST COMMAND: PAGE CONFIG ---
6+
from core.config import PAGE_CONFIG
7+
st.set_page_config(**PAGE_CONFIG)
8+
9+
# --- 2. CONTINUED IMPORTS ---
10+
from core.utils import save_conversations, load_conversations, get_current_time, create_new_conversation
11+
from core.config import configure_gemini, get_tone_prompt, get_selected_mood
12+
from css.styles import apply_custom_css
13+
from components.header import render_header
14+
from components.sidebar import render_sidebar
15+
from components.chat_interface import render_chat_interface, handle_chat_input
16+
from components.emergency_page import render_emergency_page
17+
18+
# --- 3. SESSION STATE INITIALIZATION ---
19+
if "chat_history" not in st.session_state:
20+
st.session_state.chat_history = []
21+
if "conversations" not in st.session_state:
22+
st.session_state.conversations = load_conversations()
23+
if "active_conversation" not in st.session_state:
24+
st.session_state.active_conversation = -1
25+
if "show_emergency_page" not in st.session_state:
26+
st.session_state.show_emergency_page = False
27+
if "sidebar_state" not in st.session_state:
28+
st.session_state.sidebar_state = "expanded"
29+
if "mental_disorders" not in st.session_state:
30+
st.session_state.mental_disorders = [
31+
"Depression & Mood Disorders", "Anxiety & Panic Disorders", "Bipolar Disorder",
32+
"PTSD & Trauma", "OCD & Related Disorders", "Eating Disorders",
33+
"Substance Use Disorders", "ADHD & Neurodevelopmental", "Personality Disorders",
34+
"Sleep Disorders"
35+
]
36+
if "selected_tone" not in st.session_state:
37+
st.session_state.selected_tone = "Compassionate Listener"
38+
if "selected_mood" not in st.session_state:
39+
st.session_state.selected_mood = "🙂" # Default emoji mood
40+
41+
# --- 4. STYLES & GEMINI SETUP ---
42+
apply_custom_css()
43+
model = configure_gemini()
44+
45+
# --- 5. SIDEBAR ---
46+
render_sidebar()
47+
48+
# --- 6. MAIN PAGE ROUTING LOGIC ---
49+
main_area = st.container()
50+
51+
# Load conversations or start a new one
52+
if not st.session_state.conversations:
53+
saved_convos = load_conversations()
54+
if saved_convos:
55+
st.session_state.conversations = saved_convos
56+
if st.session_state.active_conversation == -1:
57+
st.session_state.active_conversation = 0
58+
else:
59+
create_new_conversation()
60+
st.session_state.active_conversation = 0
61+
st.rerun()
62+
63+
# --- 7. MAIN VIEW DISPLAY ---
64+
if st.session_state.get("show_emergency_page"):
65+
with main_area:
66+
render_emergency_page()
67+
else:
68+
with main_area:
69+
render_header()
70+
st.subheader(f"🗣️ Current Chatbot Tone: **{st.session_state['selected_tone']}**")
71+
st.markdown(f"**🧠 Mood Selected:** {get_selected_mood()}")
72+
render_chat_interface()
73+
handle_chat_input(model, system_prompt=get_tone_prompt())
74+
75+
# --- 8. AUTO SCROLL SCRIPT ---
76+
st.markdown("""
77+
<script>
78+
function scrollToBottom() {
79+
var chatContainer = document.querySelector('.chat-container');
80+
if (chatContainer) {
81+
chatContainer.scrollTop = chatContainer.scrollHeight;
82+
}
83+
}
84+
setTimeout(scrollToBottom, 100);
85+
</script>
86+
""", unsafe_allow_html=True)

streamlit.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
GEMINI_API_KEY = "AIzaSyDsLJgA58LvgFtnUdVBLFb08GZQV0wXYjQ"
1+
import streamlit as st
2+
3+
GEMINI_API_KEY = st.secrets["GEMINI_API_KEY"]
4+

streamlit.toml~

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import streamlit as st
2+
3+
GEMINI_API_KEY = st.secrets["GEMINI_API_KEY"]
4+

0 commit comments

Comments
 (0)