Update app.py
Browse files
app.py
CHANGED
|
@@ -27,26 +27,31 @@ from huggingface_hub import HfApi
|
|
| 27 |
|
| 28 |
username = 'islasher'
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
|
| 35 |
-
|
| 36 |
|
| 37 |
-
#
|
| 38 |
-
api_token =
|
| 39 |
|
| 40 |
# Check if the API token is set
|
| 41 |
if api_token is None:
|
| 42 |
-
raise ValueError(f"Failed to retrieve API token from
|
| 43 |
|
| 44 |
# Authenticate with Hugging Face using the API token
|
| 45 |
-
api = HfApi()
|
| 46 |
api.login(token=api_token)
|
| 47 |
|
| 48 |
|
| 49 |
|
|
|
|
| 50 |
#token_access = HF_API_TOKEN
|
| 51 |
#headers = {"Authorization": f"Bearer {token_access}"}
|
| 52 |
|
|
|
|
| 27 |
|
| 28 |
username = 'islasher'
|
| 29 |
|
| 30 |
+
import os
|
| 31 |
+
from transformers.hf_api import HfApi
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# Authenticate with Hugging Face
|
| 35 |
+
api = HfApi()
|
| 36 |
+
api.login()
|
| 37 |
|
| 38 |
+
# Fetch the API token secret
|
| 39 |
+
secret_name = "HF_API_TOKEN"
|
| 40 |
+
secret_value = api.secrets.get(username, secret_name)
|
| 41 |
|
| 42 |
+
# Retrieve the API token
|
| 43 |
+
api_token = secret_value["value"]
|
| 44 |
|
| 45 |
# Check if the API token is set
|
| 46 |
if api_token is None:
|
| 47 |
+
raise ValueError(f"Failed to retrieve API token from Hugging Face secret {secret_name}")
|
| 48 |
|
| 49 |
# Authenticate with Hugging Face using the API token
|
|
|
|
| 50 |
api.login(token=api_token)
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
+
|
| 55 |
#token_access = HF_API_TOKEN
|
| 56 |
#headers = {"Authorization": f"Bearer {token_access}"}
|
| 57 |
|