censAgent commited on
Commit
6523aaf
·
verified ·
1 Parent(s): 77f855f

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +9 -20
src/streamlit_app.py CHANGED
@@ -4,29 +4,18 @@ from supabase.client import create_client
4
  from langchain_google_genai import GoogleGenerativeAIEmbeddings, ChatGoogleGenerativeAI
5
  from streamlit_mic_recorder import speech_to_text
6
 
7
- # Helper function to get secrets from HF or Streamlit
8
- def get_secret(key):
9
- # 1. Try environment variables (Hugging Face default)
10
- value = os.environ.get(key)
11
- if value:
12
- return value
13
- # 2. Try Streamlit Secrets (Hugging Face / Streamlit fallback)
14
- try:
15
- return st.secrets[key]
16
- except Exception:
17
- return None
18
 
19
  # --- 1. SETTINGS & KEYS ---
20
- # --- 1. CONFIG FROM HUGGING FACE SECRETS ---
21
- SUPABASE_URL = st.secrets["SUPABASE_URL"]
22
- SUPABASE_KEY = st.secrets["SUPABASE_KEY"]
23
- GEMINI_KEY = st.secrets["GEMINI_KEY"]
24
 
25
-
26
- # Safety Check: If any are missing, show a clear message in the UI
27
- if not all([SUPABASE_URL, SUPABASE_KEY, GEMINI_KEY]):
28
- st.error("🚨 Configuration Error: Secrets not found in Hugging Face Settings.")
29
- st.info("Check 'Settings -> Variables and secrets' and ensure names match EXACTLY.")
30
  st.stop()
31
 
32
  # --- 2. INITIALIZE CLIENTS ---
 
4
  from langchain_google_genai import GoogleGenerativeAIEmbeddings, ChatGoogleGenerativeAI
5
  from streamlit_mic_recorder import speech_to_text
6
 
7
+ # --- DIRECT ENVIRONMENT ACCESS (Bypasses st.secrets bug) ---
8
+ SUPABASE_URL = os.getenv("SUPABASE_URL")
9
+ SUPABASE_KEY = os.getenv("SUPABASE_KEY")
10
+ GEMINI_KEY = os.getenv("GEMINI_KEY")
 
 
 
 
 
 
 
11
 
12
  # --- 1. SETTINGS & KEYS ---
 
 
 
 
13
 
14
+ # --- DEBUGGING UI (Temporary - helps us see what's wrong) ---
15
+ if not SUPABASE_URL:
16
+ st.error("❌ SUPABASE_URL is missing from Environment Variables.")
17
+ # Lists all variables to see if they are named differently (Safe for debugging)
18
+ # st.write("Available keys:", list(os.environ.keys()))
19
  st.stop()
20
 
21
  # --- 2. INITIALIZE CLIENTS ---