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.")