char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
2758fa10d
char/aliceai-t5-moe
1#!/usr/bin/env python3 2 3from huggingface_hub import HfApi 4import argparse 5import os 6import sys 7 8 9def create_collection (title ,description ,private = False ,namespace = None ,return_slug = False ): 10""" 11Create a new collection on Hugging Face 12 13Args: 14title: Collection title 15description: Collection description 16private: Whether the collection should be private (default: False) 17namespace: Optional namespace (defaults to your username) 18 19Returns: 20Collection object if successful, None if failed 21""" 22 23# Check if HF_TOKEN is available 24token = os .getenv ("HF_TOKEN" )or os .getenv ("HUGGINGFACE_HUB_TOKEN" ) 25if not token : 26"ā No HF_TOKEN or HUGGINGFACE_HUB_TOKEN found in environment variables" ) 27"Please set your Hugging Face token as an environment variable" ) 28return None 29 30# Initialize API 31api = HfApi () 32 33try : 34# Test authentication first 35user_info = api .whoami () 36if not return_slug : 37f"ā Authenticated as: { user_info [ 'name' ] } " ) 38 39# Create the collection 40if not return_slug : 41f"š Creating collection: ' { title } '..." ) 42collection = api .create_collection ( 43title = title , 44description = description , 45private = private , 46namespace = namespace 47 ) 48 49if not return_slug : 50f"ā Collection created successfully!" ) 51f"š Collection slug: { collection . slug } " ) 52f"š Collection URL: https://huggingface.co/collections/ { collection . slug } " ) 53 54return collection 55 56except Exception as e : 57f"ā Error creating collection: { e } " ) 58return None 59 60def main (): 61# This script requires that the environment variable HF_TOKEN is set with your 62# Hugging Face API token. 63api = HfApi () 64 65parser = argparse .ArgumentParser (description = 'Create a Huggingface Collection' ) 66parser .add_argument ('--name' ,'-n' ,help = 'The name/title of the Collection' ,required = True ) 67parser .add_argument ('--description' ,'-d' ,help = 'The description for the Collection' ,required = True ) 68parser .add_argument ('--namespace' ,'-ns' ,help = 'The namespace to add the Collection to' ,required = True ) 69parser .add_argument ('--private' ,'-p' ,help = 'Create a private Collection' ,action = 'store_true' )# Fixed 70parser .add_argument ('--return-slug' ,'-s' ,help = 'Only output the collection slug' ,action = 'store_true' )# Fixed 71 72args = parser .parse_args () 73 74name = args .name 75description = args .description 76private = args .private 77namespace = args .namespace 78return_slug = args .return_slug 79 80if not return_slug : 81"š Creating Hugging Face Collection" ) 82f"Title: { name } " ) 83f"Description: { description } " ) 84f"Namespace: { namespace } " ) 85f"Private: { private } " ) 86 87collection = create_collection ( 88title = name , 89description = description , 90private = private , 91namespace = namespace , 92return_slug = return_slug 93 ) 94 95if collection : 96if return_slug : 97collection .slug ) 98else : 99"\nš Collection created successfully!" ) 100f"Use this slug to add models: { collection . slug } " ) 101else : 102"\nā Failed to create collection" ) 103sys .exit (1 ) 104 105if __name__ == "__main__" : 106main ()