Spaces:
Runtime error
Runtime error
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -3,22 +3,33 @@ from huggingface_hub import HfApi, create_repo, upload_file
|
|
3 |
from groq import Groq
|
4 |
import os
|
5 |
|
6 |
-
# Set up API
|
7 |
-
hf_api_key = st.secrets["hf_token"]
|
8 |
groq_api_key = st.secrets["devassistapi"]
|
9 |
-
|
10 |
-
# Initialize Groq client
|
11 |
client = Groq(api_key=groq_api_key)
|
12 |
|
13 |
# App title
|
14 |
st.title("HF DevAssist - Create and Manage Hugging Face Spaces")
|
15 |
|
16 |
-
#
|
|
|
|
|
|
|
17 |
st.subheader("Authenticate with Hugging Face")
|
18 |
-
if
|
19 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
st.stop()
|
21 |
|
|
|
|
|
|
|
22 |
api = HfApi()
|
23 |
try:
|
24 |
user_info = api.whoami(token=hf_api_key)
|
|
|
3 |
from groq import Groq
|
4 |
import os
|
5 |
|
6 |
+
# Set up Groq API key
|
|
|
7 |
groq_api_key = st.secrets["devassistapi"]
|
|
|
|
|
8 |
client = Groq(api_key=groq_api_key)
|
9 |
|
10 |
# App title
|
11 |
st.title("HF DevAssist - Create and Manage Hugging Face Spaces")
|
12 |
|
13 |
+
# Input for Hugging Face token
|
14 |
+
if "hf_token" not in st.session_state:
|
15 |
+
st.session_state["hf_token"] = None
|
16 |
+
|
17 |
st.subheader("Authenticate with Hugging Face")
|
18 |
+
if st.session_state["hf_token"] is None:
|
19 |
+
token_input = st.text_input("Enter your Hugging Face Access Token:", type="password")
|
20 |
+
if token_input:
|
21 |
+
st.session_state["hf_token"] = token_input
|
22 |
+
st.success("Token saved.")
|
23 |
+
else:
|
24 |
+
st.write("Token already saved.")
|
25 |
+
|
26 |
+
if st.session_state["hf_token"] is None:
|
27 |
+
st.error("Please provide a valid Hugging Face token to proceed.")
|
28 |
st.stop()
|
29 |
|
30 |
+
hf_api_key = st.session_state["hf_token"]
|
31 |
+
|
32 |
+
# Authenticate Hugging Face API
|
33 |
api = HfApi()
|
34 |
try:
|
35 |
user_info = api.whoami(token=hf_api_key)
|