| from huggingface_hub import HfApi | |
| import os | |
| # Set the correct repository name | |
| repo_id = "AlexCuadron/chai-sft-12b" # Using the correct case | |
| model_path = "./" | |
| # Create API client | |
| api = HfApi() | |
| # First, create the repository if it doesn't exist | |
| print(f"Creating repository {repo_id}...") | |
| try: | |
| api.create_repo( | |
| repo_id=repo_id, | |
| repo_type="model", | |
| private=False # Set to True if you want a private repository | |
| ) | |
| print(f"Repository {repo_id} created successfully!") | |
| except Exception as e: | |
| print(f"Note: {e}") | |
| print("Continuing with upload as the repo might already exist...") | |
| # Then upload the model | |
| print(f"Starting upload to {repo_id}...") | |
| api.upload_folder( | |
| folder_path=model_path, | |
| repo_id=repo_id, | |
| repo_type="model" | |
| ) | |
| print("Upload completed successfully!") | |