File size: 1,360 Bytes
2148c4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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()