jatinror commited on
Commit
2148c4a
·
verified ·
1 Parent(s): 914bbc0
Files changed (1) hide show
  1. tools/hub_stats_tool.py +61 -0
tools/hub_stats_tool.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+ import random
3
+
4
+
5
+ class HubStatsTool(Tool):
6
+
7
+ name = "hub_stats"
8
+
9
+ description = (
10
+ "Fetches dummy statistics about influential AI builders "
11
+ "from Hugging Face Hub. Use this tool when you need "
12
+ "information about AI creators, models, or popularity."
13
+ )
14
+
15
+ inputs = {
16
+ "builder": {
17
+ "type": "string",
18
+ "description": "The AI builder name to get statistics for."
19
+ }
20
+ }
21
+
22
+ output_type = "string"
23
+
24
+
25
+ def forward(self, builder: str):
26
+
27
+ # Dummy Hugging Face statistics
28
+ builders = {
29
+ "meta": {
30
+ "models": 120,
31
+ "followers": 50000
32
+ },
33
+ "mistral": {
34
+ "models": 80,
35
+ "followers": 30000
36
+ },
37
+ "openai": {
38
+ "models": 150,
39
+ "followers": 100000
40
+ }
41
+ }
42
+
43
+
44
+ if builder.lower() in builders:
45
+
46
+ data = builders[builder.lower()]
47
+
48
+ return (
49
+ f"Builder: {builder}\n"
50
+ f"Models: {data['models']}\n"
51
+ f"Followers: {data['followers']}"
52
+ )
53
+
54
+ else:
55
+ return (
56
+ f"No statistics found for {builder}. "
57
+ "Try another AI builder."
58
+ )
59
+
60
+
61
+ hub_stats_tool = HubStatsTool()