ahmadsanafarooq commited on
Commit
070205b
·
verified ·
1 Parent(s): f94afff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -66
app.py CHANGED
@@ -1068,72 +1068,6 @@ def transcribe_audio_file(uploaded_audio):
1068
  except Exception as e:
1069
  return f"Error: {str(e)}"
1070
 
1071
- My apologies for the persistent issue. It's clear that the previous CSS attempts were not sufficient to override Streamlit's internal styling for those specific elements, especially given the screenshots consistently show white text.
1072
-
1073
- The problem with directly setting color: black !important; on the .streamlit-success and .stInfo classes is that Streamlit's internal components might have even more specific rules or JavaScript that re-applies white color. The key is to target the actual text-holding elements (like p, span, div) within those containers, with higher specificity.
1074
-
1075
- Let's try a more robust and complete CSS solution within your show_main_app function. I will embed the full CSS block, with very targeted and aggressive !important rules for the problematic text colors, and ensure no other styles interfere.
1076
-
1077
- Here's the complete show_main_app function with the most robust CSS fixes for text color.
1078
-
1079
- Python
1080
-
1081
- import streamlit as st
1082
- import os, json, datetime, hashlib
1083
- from langchain_community.vectorstores import FAISS
1084
- from langchain_community.embeddings import HuggingFaceEmbeddings
1085
- from langchain_groq import ChatGroq
1086
- from langchain.chains import LLMChain
1087
- from langchain.prompts import PromptTemplate
1088
- from gtts import gTTS
1089
- from pathlib import Path
1090
- from dotenv import load_dotenv
1091
- from sentence_transformers import SentenceTransformer, util
1092
- import altair as alt
1093
- import speech_recognition as sr
1094
- from transformers import pipeline
1095
- import torch
1096
- import pickle
1097
- import re
1098
- import pandas as pd
1099
-
1100
- # Load environment variables (ensure these are loaded at the top of your script)
1101
- load_dotenv()
1102
- GROQ_API_KEY = os.getenv("GROQ_API_KEY")
1103
- CRISIS_KEYWORDS = ["suicide", "kill myself", "end it all", "worthless", "can't go on", "hurt myself", "self harm", "want to disappear", "no reason to live"]
1104
-
1105
- # Initialize session state (ensure these are at the top of your script)
1106
- if "authenticated" not in st.session_state:
1107
- st.session_state.authenticated = False
1108
- if "username" not in st.session_state:
1109
- st.session_state.username = None
1110
- if "is_admin" not in st.session_state:
1111
- st.session_state.is_admin = False
1112
- if "transcribed_text" not in st.session_state:
1113
- st.session_state.transcribed_text = ""
1114
-
1115
- # Admin configuration (ensure these are at the top of your script)
1116
- ADMIN_USERNAME = os.getenv("ADMIN_USERNAME")
1117
- ADMIN_PASSWORD = os.getenv("ADMIN_PASSWORD")
1118
-
1119
- # Assume these functions are defined elsewhere in your script:
1120
- # login, signup, load_user_journal, save_user_journal,
1121
- # detect_emotion, is_crisis, build_user_vectorstore, load_user_vectorstore,
1122
- # transcribe_audio_file, speak
1123
-
1124
- # Example placeholder functions (REMOVE THESE IF YOU HAVE YOUR ACTUAL FUNCTIONS)
1125
- def login(u, p): return True, "Logged in!", False
1126
- def signup(u, p, e): return True, "Signed up!"
1127
- def load_user_journal(u): return []
1128
- def save_user_journal(u, i, e, c, r): pass
1129
- def detect_emotion(text): return "neutral", 0.8
1130
- def is_crisis(text): return False
1131
- def build_user_vectorstore(u, q): return FAISS.from_texts(q, HuggingFaceEmbeddings())
1132
- def load_user_vectorstore(u): return None
1133
- def transcribe_audio_file(file): return "This is a transcribed voice message."
1134
- def speak(text, username): st.audio(b"", format="audio/ogg") # Placeholder for actual speech
1135
-
1136
-
1137
  def show_main_app():
1138
  """Main DilBot application"""
1139
  username = st.session_state.username
 
1068
  except Exception as e:
1069
  return f"Error: {str(e)}"
1070
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1071
  def show_main_app():
1072
  """Main DilBot application"""
1073
  username = st.session_state.username