Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
|
|
| 1 |
from huggingface_hub import HfApi
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
from huggingface_hub import HfApi
|
| 3 |
|
| 4 |
+
# Use Secrets (Settings > Variables and secrets > New secret)
|
| 5 |
+
# Name the secret: HF_TOKEN
|
| 6 |
+
token = os.getenv("HF_TOKEN")
|
| 7 |
+
|
| 8 |
+
if not token:
|
| 9 |
+
print("❌ Error: HF_TOKEN secret not found in Space settings!")
|
| 10 |
+
else:
|
| 11 |
+
api = HfApi(token=token)
|
| 12 |
+
|
| 13 |
+
# Configuration
|
| 14 |
+
source_url = "https://huggingface.co"
|
| 15 |
+
filename = "starcoder2-15b-instruct-v0.1-Q4_K_M.gguf"
|
| 16 |
+
dest_repo = "AIDev07/AIModelsLoaded"
|
| 17 |
+
|
| 18 |
+
print(f"🚀 Starting server-side transfer of {filename}...")
|
| 19 |
+
|
| 20 |
+
try:
|
| 21 |
+
# This tells HF to grab the file from the URL and save it to your dataset
|
| 22 |
+
api.upload_file(
|
| 23 |
+
path_or_fileobj=source_url, # The URL acts as the source
|
| 24 |
+
path_in_repo=filename,
|
| 25 |
+
repo_id=dest_repo,
|
| 26 |
+
repo_type="dataset",
|
| 27 |
+
commit_message=f"Direct transfer of {filename}"
|
| 28 |
+
)
|
| 29 |
+
print("✅ Success! Check your dataset now.")
|
| 30 |
+
except Exception as e:
|
| 31 |
+
print(f"❌ Failed: {e}")
|