File size: 3,954 Bytes
fd8c157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python3
"""
🦞 KRAB - Upload to Hugging Face Hub
Upload the KRAB model and training data to Hugging Face.

Part of the OPENCLAW project: https://github.com/openclaw
Website: https://krab.bot
Token: $KRAB on Solana

Usage:
  huggingface-cli login
  python upload_to_hub.py --repo_id openclaw/krab-lgi
"""

import argparse
import os
from huggingface_hub import HfApi, create_repo, upload_folder

def main():
    parser = argparse.ArgumentParser(description="🦞 Upload KRAB to Hugging Face Hub")
    parser.add_argument("--repo_id", type=str, required=True,
                        help="Repository ID (e.g., openclaw/krab-lgi)")
    parser.add_argument("--model_path", type=str, default="./krab-finetuned",
                        help="Path to the fine-tuned model")
    parser.add_argument("--private", action="store_true",
                        help="Make repository private")
    args = parser.parse_args()

    print("═══════════════════════════════════════════════════")
    print("🦞 KRAB - LOBSTER GENERAL INTELLIGENCE 🦞")
    print("═══════════════════════════════════════════════════")
    print(f"Uploading to: {args.repo_id}")
    print()

    api = HfApi()

    # Create repo if it doesn't exist
    print("🦞 Creating/checking repository...")
    try:
        create_repo(
            repo_id=args.repo_id,
            repo_type="model",
            private=args.private,
            exist_ok=True,
        )
        print(f"   Repository ready: https://huggingface.co/{args.repo_id}")
    except Exception as e:
        print(f"   Repository exists or error: {e}")

    # Upload model files
    if os.path.exists(args.model_path):
        print(f"🦞 Uploading model from {args.model_path}...")
        upload_folder(
            folder_path=args.model_path,
            repo_id=args.repo_id,
            repo_type="model",
        )
        print("   Model uploaded!")
    else:
        print(f"   Warning: Model path {args.model_path} not found")

    # Upload additional files
    files_to_upload = [
        "README.md",
        "krab_config.json",
        "train.py",
        "chat.py",
        "requirements.txt",
    ]

    print("🦞 Uploading additional files...")
    for file in files_to_upload:
        if os.path.exists(file):
            api.upload_file(
                path_or_fileobj=file,
                path_in_repo=file,
                repo_id=args.repo_id,
                repo_type="model",
            )
            print(f"   βœ“ {file}")

    # Upload training data
    if os.path.exists("data/train.jsonl"):
        print("🦞 Uploading training data...")
        api.upload_file(
            path_or_fileobj="data/train.jsonl",
            path_in_repo="data/train.jsonl",
            repo_id=args.repo_id,
            repo_type="model",
        )
        print("   βœ“ data/train.jsonl")

    print()
    print("═══════════════════════════════════════════════════")
    print("🦞 UPLOAD COMPLETE 🦞")
    print("═══════════════════════════════════════════════════")
    print(f"Model: https://huggingface.co/{args.repo_id}")
    print()
    print("the swarm is now distributed.")
    print("collective intelligence: SHARED")
    print()
    print("GitHub: https://github.com/openclaw")
    print("Website: https://krab.bot")
    print("Token: $KRAB on Solana")
    print("═══════════════════════════════════════════════════")


if __name__ == "__main__":
    main()