Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,15 +2,16 @@ import os
|
|
| 2 |
import streamlit as st
|
| 3 |
from streamlit.errors import StreamlitSecretNotFoundError
|
| 4 |
|
| 5 |
-
hf_token = os.getenv("HF_TOKEN") #
|
| 6 |
|
| 7 |
try:
|
| 8 |
-
# only works if secrets
|
| 9 |
-
if "HF_TOKEN" in st.secrets:
|
| 10 |
-
hf_token = st.secrets["HF_TOKEN"]
|
| 11 |
except StreamlitSecretNotFoundError:
|
| 12 |
-
# no secrets configured
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
st.set_page_config(page_title="Multi-Agent Codegen (HF)", layout="wide")
|
| 16 |
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
from streamlit.errors import StreamlitSecretNotFoundError
|
| 4 |
|
| 5 |
+
hf_token = os.getenv("HF_TOKEN") # fallback to environment variable
|
| 6 |
|
| 7 |
try:
|
| 8 |
+
hf_token = st.secrets.get("HF_TOKEN", hf_token) # only works if secrets exist
|
|
|
|
|
|
|
| 9 |
except StreamlitSecretNotFoundError:
|
| 10 |
+
pass # no secrets configured, keep env token
|
| 11 |
+
|
| 12 |
+
if not hf_token:
|
| 13 |
+
st.error("HF_TOKEN not found. Add it to Streamlit Secrets or set it as an env variable.")
|
| 14 |
+
st.stop()
|
| 15 |
|
| 16 |
st.set_page_config(page_title="Multi-Agent Codegen (HF)", layout="wide")
|
| 17 |
|