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 sys 6 7def add_model_to_collection (collection_slug ,model_id ,note = "" ): 8""" 9Add a model to an existing collection 10 11Args: 12collection_slug: The slug of the collection (e.g., "username/collection-name-12345") 13model_id: The model repository ID (e.g., "username/model-name") 14note: Optional note about the model 15 16Returns: 17True if successful, False if failed 18""" 19 20# Initialize API 21api = HfApi () 22 23try : 24user_info = api .whoami () 25f"ā Authenticated as: { user_info [ 'name' ] } " ) 26 27# Verify the model exists 28f"š Checking if model exists: { model_id } " ) 29try : 30model_info = api .model_info (model_id ) 31except Exception as e : 32f"ā Model not found or not accessible: { model_id } " ) 33f"Error: { e } " ) 34return False 35 36f"š Adding model to collection..." ) 37api .add_collection_item ( 38collection_slug = collection_slug , 39item_id = model_id , 40item_type = "model" , 41note = note 42 ) 43 44f"ā Model added to collection successfully!" ) 45f"š Collection URL: https://huggingface.co/collections/ { collection_slug } " ) 46 47return True 48 49except Exception as e : 50f"ā Error adding model to collection: { e } " ) 51return False 52 53def main (): 54# This script requires that the environment variable HF_TOKEN is set with your 55# Hugging Face API token. 56api = HfApi () 57 58parser = argparse .ArgumentParser (description = 'Add model to a Huggingface Collection' ) 59parser .add_argument ('--collection' ,'-c' ,help = 'The collection slug username/collection-hash' ,required = True ) 60parser .add_argument ('--model' ,'-m' ,help = 'The model to add to the Collection' ,required = True ) 61parser .add_argument ('--note' ,'-n' ,help = 'An optional note/description' ,required = False ) 62args = parser .parse_args () 63 64collection = args .collection 65model = args .model 66note = args .note 67 68success = add_model_to_collection ( 69collection_slug = collection , 70model_id = model , 71note = note 72 ) 73 74if success : 75"\nš Model added successfully!" ) 76else : 77"\nā Failed to add model to collection" ) 78sys .exit (1 ) 79if __name__ == "__main__" : 80main ()