File size: 2,052 Bytes
9619394
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
"""
Upload Kai-0 to HuggingFace Hub
==============================

Usage:
    export HF_TOKEN=your_token_here
    python3 upload.py --repo-id belweave/kai-0

Or login first:
    huggingface-cli login
    python3 upload.py --repo-id belweave/kai-0
"""

import argparse
import os
from pathlib import Path

from huggingface_hub import HfApi, create_repo


def upload_model(repo_id: str, local_dir: Path, private: bool = False):
    """Upload the model to HuggingFace Hub."""
    api = HfApi()

    # Check auth
    token = os.environ.get("HF_TOKEN")
    if not token:
        try:
            api.whoami()
            print("✅ Already authenticated with HuggingFace")
        except Exception:
            print("❌ Not authenticated. Run one of these:")
            print("   export HF_TOKEN=your_token")
            print("   OR")
            print("   huggingface-cli login")
            return

    # Create repo if it doesn't exist
    try:
        create_repo(repo_id, repo_type="model", private=private, exist_ok=True)
        print(f"✅ Repo ready: https://huggingface.co/{repo_id}")
    except Exception as e:
        print(f"⚠️  Repo creation issue: {e}")
        return

    # Upload files
    print(f"🔌 Uploading files from {local_dir}...")
    api.upload_folder(
        folder_path=str(local_dir),
        repo_id=repo_id,
        repo_type="model",
    )

    print(f"\n🎉 Upload complete!")
    print(f"   URL: https://huggingface.co/{repo_id}")
    print(f"   Clone: git clone https://huggingface.co/{repo_id}")


def main():
    parser = argparse.ArgumentParser(description="Upload Kai-0 to HuggingFace Hub")
    parser.add_argument("--repo-id", default="belweave/kai-0", help="HF Hub repo ID")
    parser.add_argument("--dir", default=".", help="Local directory to upload")
    parser.add_argument("--private", action="store_true", help="Make repo private")
    args = parser.parse_args()

    upload_model(args.repo_id, Path(args.dir), private=args.private)


if __name__ == "__main__":
    main()