Alaaeldin commited on
Commit
af8b2d6
Β·
verified Β·
1 Parent(s): f06ec9a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -13
app.py CHANGED
@@ -9,17 +9,13 @@ from huggingface_hub import login
9
  st.set_page_config(page_title="LLaMA Chatbot", page_icon="πŸ¦™")
10
  status_placeholder = st.empty()
11
 
12
- # Try multiple ways to get the token
13
  try:
14
- # Try environment variable first
15
  hf_token = os.environ.get("HF_TOKEN")
16
 
17
  if not hf_token:
18
- # Try Streamlit secrets
19
- hf_token = st.secrets.get("HF_TOKEN")
20
-
21
- if not hf_token:
22
- raise ValueError("Token not found in any location")
23
 
24
  status_placeholder.success("πŸ”‘ Successfully found HF token!")
25
  login(token=hf_token)
@@ -27,12 +23,7 @@ try:
27
 
28
  except Exception as e:
29
  status_placeholder.error(f"🚫 Error with HF token: {str(e)}")
30
- st.error("Please ensure the token is properly set in the Space settings")
31
- st.info("Current search paths for token:")
32
- st.code("""
33
- 1. Environment variable: HF_TOKEN
34
- 2. Streamlit secrets: secrets.toml
35
- """)
36
  st.stop()
37
 
38
  st.title("πŸ¦™ LLaMA Chatbot")
 
9
  st.set_page_config(page_title="LLaMA Chatbot", page_icon="πŸ¦™")
10
  status_placeholder = st.empty()
11
 
12
+ # Try to get the token from public variable
13
  try:
14
+ # Note we changed HF_TOKEN25 to HF_TOKEN to match your variable name
15
  hf_token = os.environ.get("HF_TOKEN")
16
 
17
  if not hf_token:
18
+ raise ValueError("Token not found")
 
 
 
 
19
 
20
  status_placeholder.success("πŸ”‘ Successfully found HF token!")
21
  login(token=hf_token)
 
23
 
24
  except Exception as e:
25
  status_placeholder.error(f"🚫 Error with HF token: {str(e)}")
26
+ st.error("Please ensure the token is properly set as a public variable")
 
 
 
 
 
27
  st.stop()
28
 
29
  st.title("πŸ¦™ LLaMA Chatbot")