File size: 1,106 Bytes
2015699
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from huggingface_hub import HfApi

# Initialize HfApi
api = HfApi()

# Define the repository
repo_id = "NexaAIDev/octopus-v4-gguf"
repo_type = "model"

# Get the list of all files already uploaded in the repo
existing_files = api.list_repo_files(repo_id=repo_id, repo_type=repo_type)

# Directory to check for .gguf files
local_directory = "./"  # Adjust this path as needed

# Loop through all .gguf files in the local directory
for filename in os.listdir(local_directory):
    if filename.endswith(".gguf"):
        # Check if the file is already in the repository
        if filename not in existing_files:
            print(f"Uploading {filename}...")
            api.upload_file(
                path_or_fileobj=os.path.join(local_directory, filename),
                path_in_repo=filename,
                repo_id=repo_id,
                repo_type=repo_type,
            )
            print(f"Uploaded {filename}.")
        else:
            print(f"{filename} already exists in the repository.")
    else:
        print(f"{filename} is not a .gguf file.")

print("Operation completed.")