Spaces:
Sleeping
Sleeping
Update app.py
Browse filesfix the secret file error
app.py
CHANGED
|
@@ -148,11 +148,13 @@ with st.sidebar:
|
|
| 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
|
| 156 |
pass
|
| 157 |
|
| 158 |
# 2. Manual Entry Logic
|
|
|
|
| 148 |
|
| 149 |
# 1. SAFELY Check Secrets (Prevents FileNotFoundError)
|
| 150 |
try:
|
| 151 |
+
# We wrap this in a try-except because accessing st.secrets
|
| 152 |
+
# throws an error if the secrets.toml file doesn't exist at all.
|
| 153 |
if "GROQ_API_KEY" in st.secrets:
|
| 154 |
st.session_state['groq_api_key'] = st.secrets["GROQ_API_KEY"]
|
| 155 |
st.session_state['is_key_valid'] = True
|
| 156 |
+
except (FileNotFoundError, Exception):
|
| 157 |
+
# If secrets file is missing, ignore it and fall back to manual entry
|
| 158 |
pass
|
| 159 |
|
| 160 |
# 2. Manual Entry Logic
|