Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,11 +7,19 @@ from pylint import lint
|
|
| 7 |
from io import StringIO
|
| 8 |
import sys
|
| 9 |
import torch
|
| 10 |
-
from huggingface_hub import hf_hub_url, cached_download, HfApi
|
| 11 |
import base64
|
| 12 |
|
| 13 |
-
|
|
|
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# Add the new HTML code below
|
| 16 |
custom_html = '''
|
| 17 |
<div style='position:fixed;bottom:0;left:0;width:100%;'>
|
|
@@ -34,7 +42,7 @@ markdown_with_custom_html(markdown_text, custom_html)
|
|
| 34 |
# Set your Hugging Face API key here
|
| 35 |
# hf_token = "YOUR_HUGGING_FACE_API_KEY" # Replace with your actual token
|
| 36 |
# Get Hugging Face token from secrets.toml - this line should already be in the main code
|
| 37 |
-
|
| 38 |
|
| 39 |
HUGGING_FACE_REPO_URL = "https://huggingface.co/spaces/acecalisto3/DevToolKit"
|
| 40 |
PROJECT_ROOT = "projects"
|
|
@@ -593,7 +601,7 @@ def add_file_to_dictionary(files, file_path):
|
|
| 593 |
if agent._hf_api and agent.has_valid_hf_token():
|
| 594 |
agent.deploy_built_space_to_hf()
|
| 595 |
# Use the hf_token to interact with the Hugging Face API
|
| 596 |
-
api = HfApi(token="
|
| 597 |
# Function to create a Space on Hugging Face
|
| 598 |
def create_space(api, name, description, public, files, entrypoint="launch.py"):
|
| 599 |
url = f"{hf_hub_url()}spaces/{name}/prepare-repo"
|
|
|
|
| 7 |
from io import StringIO
|
| 8 |
import sys
|
| 9 |
import torch
|
| 10 |
+
from huggingface_hub import hf_hub_url, cached_download, HfApi, InferenceClient
|
| 11 |
import base64
|
| 12 |
|
| 13 |
+
# Set environment variable for Hugging Face token
|
| 14 |
+
os.environ["HUGGINGFACE_TOKEN"] = "your_token_here"
|
| 15 |
|
| 16 |
+
# Load .env file to set additional environment variables
|
| 17 |
+
load_dotenv()
|
| 18 |
+
|
| 19 |
+
# Use the HUGGINGFACE_TOKEN in your code
|
| 20 |
+
HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
|
| 21 |
+
print(HUGGINGFACE_TOKEN)
|
| 22 |
+
r
|
| 23 |
# Add the new HTML code below
|
| 24 |
custom_html = '''
|
| 25 |
<div style='position:fixed;bottom:0;left:0;width:100%;'>
|
|
|
|
| 42 |
# Set your Hugging Face API key here
|
| 43 |
# hf_token = "YOUR_HUGGING_FACE_API_KEY" # Replace with your actual token
|
| 44 |
# Get Hugging Face token from secrets.toml - this line should already be in the main code
|
| 45 |
+
hf_token = os.environ.get("HUGGINGFACE_TOKEN")("key")
|
| 46 |
|
| 47 |
HUGGING_FACE_REPO_URL = "https://huggingface.co/spaces/acecalisto3/DevToolKit"
|
| 48 |
PROJECT_ROOT = "projects"
|
|
|
|
| 601 |
if agent._hf_api and agent.has_valid_hf_token():
|
| 602 |
agent.deploy_built_space_to_hf()
|
| 603 |
# Use the hf_token to interact with the Hugging Face API
|
| 604 |
+
api = HfApi(token="HUGGINGFACE_TOKEN")
|
| 605 |
# Function to create a Space on Hugging Face
|
| 606 |
def create_space(api, name, description, public, files, entrypoint="launch.py"):
|
| 607 |
url = f"{hf_hub_url()}spaces/{name}/prepare-repo"
|