Spaces:
Runtime error
Runtime error
| from huggingface_hub import HfApi | |
| import os | |
| from dotenv import load_dotenv | |
| def list_available_models(): | |
| """List available models from Hugging Face Hub""" | |
| load_dotenv() | |
| api = HfApi(token=os.getenv('HF_API_TOKEN')) | |
| # List models with specific criteria | |
| models = api.list_models( | |
| filter=["text-generation"], # Filter for text generation models | |
| sort="downloads", # Sort by number of downloads | |
| direction=-1, # Descending order | |
| limit=10 # Get top 10 models | |
| ) | |
| print("\nTop 10 Available Text Generation Models:") | |
| print("-" * 50) | |
| for model in models: | |
| print(f"\nModel ID: {model.modelId}") | |
| print(f"Downloads: {model.downloads:,}") | |
| print(f"Likes: {model.likes}") | |
| print(f"Pipeline Tag: {model.pipeline_tag}") | |
| print("-" * 30) | |
| if __name__ == "__main__": | |
| list_available_models() |