AIDev07 commited on
Commit
523358f
·
verified ·
1 Parent(s): 6221aa6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -11
app.py CHANGED
@@ -1,13 +1,31 @@
 
1
  from huggingface_hub import HfApi
2
 
3
- api = HfApi(token="YOUR_WRITE_TOKEN")
4
-
5
- # This tells HF servers: "Take this file from repo A and put it in repo B"
6
- api.add_file_to_repo(
7
- repo_id="AIDev07/AIModelsLoaded",
8
- repo_type="dataset",
9
- file_path="starcoder2-15b-instruct-v0.1-Q4_K_M.gguf", # Path in your repo
10
- path_in_repo="starcoder2-15b-instruct-v0.1-Q4_K_M.gguf", # Name it should have
11
- # We use a URL to pull it directly into the commit
12
- url="https://huggingface.co"
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}")