Spaces:
Sleeping
Sleeping
Update app.py
Browse filesfix the secret file error
app.py
CHANGED
|
@@ -144,14 +144,18 @@ def update_metrics(placeholder):
|
|
| 144 |
|
| 145 |
# --- SIDEBAR ---
|
| 146 |
with st.sidebar:
|
| 147 |
-
|
| 148 |
|
| 149 |
-
# Check Secrets
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|