Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1070,14 +1070,18 @@ def transcribe_audio_file(uploaded_audio):
|
|
| 1070 |
def show_main_app():
|
| 1071 |
"""Main DilBot application"""
|
| 1072 |
username = st.session_state.username
|
| 1073 |
-
|
| 1074 |
-
|
|
|
|
|
|
|
| 1075 |
quote_categories = {
|
| 1076 |
"Grief": ["Grief is the price we pay for love.", "Tears are the silent language of grief.", "What we have once enjoyed we can never lose; all that we love deeply becomes a part of us."],
|
| 1077 |
"Motivation": ["Believe in yourself and all that you are.", "Tough times never last, but tough people do.", "The only way to do great work is to love what you do."],
|
| 1078 |
"Healing": ["Every wound has its own time to heal.", "It's okay to take your time to feel better.", "Healing is not linear, and that's perfectly okay."],
|
| 1079 |
"Relationships": ["The best relationships are built on trust.", "Love is not about possession but appreciation.", "Healthy relationships require both people to show up authentically."]
|
| 1080 |
}
|
|
|
|
|
|
|
| 1081 |
# --- ENHANCED CUSTOM CSS FOR MAIN APP ---
|
| 1082 |
st.markdown("""
|
| 1083 |
<style>
|
|
@@ -1251,8 +1255,12 @@ def show_main_app():
|
|
| 1251 |
color: #495057;
|
| 1252 |
margin-bottom: 0.6rem;
|
| 1253 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1254 |
|
| 1255 |
-
|
| 1256 |
[data-testid="stFileUploaderDropzone"] {
|
| 1257 |
border-radius: 12px; /* More rounded */
|
| 1258 |
border: 2px dashed #a0a8b4;
|
|
@@ -1265,15 +1273,18 @@ def show_main_app():
|
|
| 1265 |
border-color: #5d6dbe; /* Highlight on hover */
|
| 1266 |
background-color: #f7f9fb;
|
| 1267 |
}
|
| 1268 |
-
/*
|
| 1269 |
-
[data-testid="stFileUploaderDropzone"]
|
| 1270 |
-
color: black !important;
|
| 1271 |
}
|
| 1272 |
|
| 1273 |
-
/* Hide the redundant 'Drag and drop file here' text */
|
| 1274 |
-
|
|
|
|
|
|
|
| 1275 |
display: none;
|
| 1276 |
-
}
|
|
|
|
| 1277 |
[data-testid="stFileUploaderFileName"] {
|
| 1278 |
font-size: 0.95em;
|
| 1279 |
color: #495057;
|
|
@@ -1288,6 +1299,7 @@ def show_main_app():
|
|
| 1288 |
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
|
| 1289 |
}
|
| 1290 |
|
|
|
|
| 1291 |
/* Information, Success, Error, Warning Boxes */
|
| 1292 |
[data-testid="stAlert"] {
|
| 1293 |
border-radius: 10px;
|
|
@@ -1516,9 +1528,6 @@ def show_main_app():
|
|
| 1516 |
final_input = user_input.strip() or st.session_state.transcribed_text.strip()
|
| 1517 |
|
| 1518 |
# Main interaction button
|
| 1519 |
-
# IMPORTANT: The "Talk to DilBot" button was appearing twice in your original code.
|
| 1520 |
-
# I'm assuming you only want one, and it should trigger the logic.
|
| 1521 |
-
# The one below is the one that correctly triggers the logic.
|
| 1522 |
if st.button("🧠 Talk to DilBot", type="primary", use_container_width=True):
|
| 1523 |
if not final_input:
|
| 1524 |
st.warning("⚠️ Please enter something to share or upload a voice message.")
|
|
@@ -1619,9 +1628,7 @@ Respond as DilBot with warmth, empathy, and understanding. Keep it conversationa
|
|
| 1619 |
"confidence": entry["confidence"]
|
| 1620 |
})
|
| 1621 |
if df_data:
|
| 1622 |
-
# Use pandas DataFrame for better Altair integration
|
| 1623 |
-
import pandas as pd
|
| 1624 |
-
df_chart = pd.DataFrame(df_data)
|
| 1625 |
|
| 1626 |
chart = alt.Chart(df_chart).mark_bar().encode(
|
| 1627 |
x=alt.X('date:N', title='Date', sort=None), # Sort by date ensures correct order
|
|
@@ -1629,7 +1636,6 @@ Respond as DilBot with warmth, empathy, and understanding. Keep it conversationa
|
|
| 1629 |
color=alt.Color('emotion:N', title='Emotion', scale=alt.Scale(range=['#4CAF50', '#FFC107', '#E74C3C', '#3498DB', '#9B59B6', '#1ABC9C'])), # Custom colors
|
| 1630 |
tooltip=['date:N', 'emotion:N', 'count():Q']
|
| 1631 |
).properties(
|
| 1632 |
-
# width=600, # Use use_container_width instead
|
| 1633 |
height=350, # Slightly increased height
|
| 1634 |
title="Your Emotional Journey Over Time"
|
| 1635 |
).interactive() # Make chart interactive for zoom/pan
|
|
@@ -1655,7 +1661,6 @@ Respond as DilBot with warmth, empathy, and understanding. Keep it conversationa
|
|
| 1655 |
|
| 1656 |
st.markdown("---")
|
| 1657 |
st.markdown("<p class='footer-caption'>Built by Members of CSG Hackathon Team | Your data is stored privately and securely</p>", unsafe_allow_html=True)
|
| 1658 |
-
|
| 1659 |
# Main app logic
|
| 1660 |
def main():
|
| 1661 |
if not st.session_state.authenticated:
|
|
|
|
| 1070 |
def show_main_app():
|
| 1071 |
"""Main DilBot application"""
|
| 1072 |
username = st.session_state.username
|
| 1073 |
+
|
| 1074 |
+
st.set_page_config(page_title="DilBot - Emotional AI", page_icon="🧠", layout="wide")
|
| 1075 |
+
|
| 1076 |
+
# --- DEFINE QUOTE CATEGORIES HERE ---
|
| 1077 |
quote_categories = {
|
| 1078 |
"Grief": ["Grief is the price we pay for love.", "Tears are the silent language of grief.", "What we have once enjoyed we can never lose; all that we love deeply becomes a part of us."],
|
| 1079 |
"Motivation": ["Believe in yourself and all that you are.", "Tough times never last, but tough people do.", "The only way to do great work is to love what you do."],
|
| 1080 |
"Healing": ["Every wound has its own time to heal.", "It's okay to take your time to feel better.", "Healing is not linear, and that's perfectly okay."],
|
| 1081 |
"Relationships": ["The best relationships are built on trust.", "Love is not about possession but appreciation.", "Healthy relationships require both people to show up authentically."]
|
| 1082 |
}
|
| 1083 |
+
# --- END QUOTE CATEGORIES DEFINITION ---
|
| 1084 |
+
|
| 1085 |
# --- ENHANCED CUSTOM CSS FOR MAIN APP ---
|
| 1086 |
st.markdown("""
|
| 1087 |
<style>
|
|
|
|
| 1255 |
color: #495057;
|
| 1256 |
margin-bottom: 0.6rem;
|
| 1257 |
}
|
| 1258 |
+
/* FIX: Selectbox selected value text color */
|
| 1259 |
+
.stSelectbox>div>div>div>input[type="text"] {
|
| 1260 |
+
color: black !important;
|
| 1261 |
+
}
|
| 1262 |
|
| 1263 |
+
/* File Uploader */
|
| 1264 |
[data-testid="stFileUploaderDropzone"] {
|
| 1265 |
border-radius: 12px; /* More rounded */
|
| 1266 |
border: 2px dashed #a0a8b4;
|
|
|
|
| 1273 |
border-color: #5d6dbe; /* Highlight on hover */
|
| 1274 |
background-color: #f7f9fb;
|
| 1275 |
}
|
| 1276 |
+
/* FIX: "Drag and drop file here" text color */
|
| 1277 |
+
[data-testid="stFileUploaderDropzone"] span { /* Targeting span within dropzone */
|
| 1278 |
+
color: black !important;
|
| 1279 |
}
|
| 1280 |
|
| 1281 |
+
/* Hide the redundant 'Drag and drop file here' text (your existing rule) */
|
| 1282 |
+
/* This rule often hides the entire paragraph, so if you want to show
|
| 1283 |
+
"Drag and drop file here" in black, you might need to remove this rule */
|
| 1284 |
+
/* [data-testid="stFileUploaderDropzone"] p:first-child {
|
| 1285 |
display: none;
|
| 1286 |
+
} */
|
| 1287 |
+
|
| 1288 |
[data-testid="stFileUploaderFileName"] {
|
| 1289 |
font-size: 0.95em;
|
| 1290 |
color: #495057;
|
|
|
|
| 1299 |
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
|
| 1300 |
}
|
| 1301 |
|
| 1302 |
+
|
| 1303 |
/* Information, Success, Error, Warning Boxes */
|
| 1304 |
[data-testid="stAlert"] {
|
| 1305 |
border-radius: 10px;
|
|
|
|
| 1528 |
final_input = user_input.strip() or st.session_state.transcribed_text.strip()
|
| 1529 |
|
| 1530 |
# Main interaction button
|
|
|
|
|
|
|
|
|
|
| 1531 |
if st.button("🧠 Talk to DilBot", type="primary", use_container_width=True):
|
| 1532 |
if not final_input:
|
| 1533 |
st.warning("⚠️ Please enter something to share or upload a voice message.")
|
|
|
|
| 1628 |
"confidence": entry["confidence"]
|
| 1629 |
})
|
| 1630 |
if df_data:
|
| 1631 |
+
df_chart = pd.DataFrame(df_data) # Use pandas DataFrame for better Altair integration
|
|
|
|
|
|
|
| 1632 |
|
| 1633 |
chart = alt.Chart(df_chart).mark_bar().encode(
|
| 1634 |
x=alt.X('date:N', title='Date', sort=None), # Sort by date ensures correct order
|
|
|
|
| 1636 |
color=alt.Color('emotion:N', title='Emotion', scale=alt.Scale(range=['#4CAF50', '#FFC107', '#E74C3C', '#3498DB', '#9B59B6', '#1ABC9C'])), # Custom colors
|
| 1637 |
tooltip=['date:N', 'emotion:N', 'count():Q']
|
| 1638 |
).properties(
|
|
|
|
| 1639 |
height=350, # Slightly increased height
|
| 1640 |
title="Your Emotional Journey Over Time"
|
| 1641 |
).interactive() # Make chart interactive for zoom/pan
|
|
|
|
| 1661 |
|
| 1662 |
st.markdown("---")
|
| 1663 |
st.markdown("<p class='footer-caption'>Built by Members of CSG Hackathon Team | Your data is stored privately and securely</p>", unsafe_allow_html=True)
|
|
|
|
| 1664 |
# Main app logic
|
| 1665 |
def main():
|
| 1666 |
if not st.session_state.authenticated:
|