larrysim commited on
Commit
4cb9ef4
·
verified ·
1 Parent(s): fcc2b2d

Update app.py

Browse files

fix the secret file error

Files changed (1) hide show
  1. app.py +4 -2
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.toml doesn't exist, ignore and fall back to manual entry
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