Spaces:
Runtime error
Runtime error
| from smolagents import Tool | |
| import random | |
| class HubStatsTool(Tool): | |
| name = "hub_stats" | |
| description = ( | |
| "Fetches dummy statistics about influential AI builders " | |
| "from Hugging Face Hub. Use this tool when you need " | |
| "information about AI creators, models, or popularity." | |
| ) | |
| inputs = { | |
| "builder": { | |
| "type": "string", | |
| "description": "The AI builder name to get statistics for." | |
| } | |
| } | |
| output_type = "string" | |
| def forward(self, builder: str): | |
| # Dummy Hugging Face statistics | |
| builders = { | |
| "meta": { | |
| "models": 120, | |
| "followers": 50000 | |
| }, | |
| "mistral": { | |
| "models": 80, | |
| "followers": 30000 | |
| }, | |
| "openai": { | |
| "models": 150, | |
| "followers": 100000 | |
| } | |
| } | |
| if builder.lower() in builders: | |
| data = builders[builder.lower()] | |
| return ( | |
| f"Builder: {builder}\n" | |
| f"Models: {data['models']}\n" | |
| f"Followers: {data['followers']}" | |
| ) | |
| else: | |
| return ( | |
| f"No statistics found for {builder}. " | |
| "Try another AI builder." | |
| ) | |
| hub_stats_tool = HubStatsTool() |