larrysim commited on
Commit
e3f4bab
·
verified ·
1 Parent(s): 48992c5

Update app.py

Browse files

fix the secret file error

Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -144,14 +144,18 @@ def update_metrics(placeholder):
144
 
145
  # --- SIDEBAR ---
146
  with st.sidebar:
147
- st.header("🔐 Authentication")
148
 
149
- # Check Secrets
150
- if "GROQ_API_KEY" in st.secrets:
151
- st.session_state['groq_api_key'] = st.secrets["GROQ_API_KEY"]
152
- st.session_state['is_key_valid'] = True
153
-
154
- # Manual Entry
 
 
 
 
155
  if 'is_key_valid' not in st.session_state:
156
  st.session_state['is_key_valid'] = False
157
 
 
144
 
145
  # --- SIDEBAR ---
146
  with st.sidebar:
147
+ st.header("🔐 Authentication")
148
 
149
+ # 1. SAFELY Check Secrets (Prevents FileNotFoundError)
150
+ try:
151
+ if "GROQ_API_KEY" in st.secrets:
152
+ st.session_state['groq_api_key'] = st.secrets["GROQ_API_KEY"]
153
+ st.session_state['is_key_valid'] = True
154
+ except FileNotFoundError:
155
+ # If secrets.toml doesn't exist, ignore and fall back to manual entry
156
+ pass
157
+
158
+ # 2. Manual Entry Logic
159
  if 'is_key_valid' not in st.session_state:
160
  st.session_state['is_key_valid'] = False
161