m-ric HF staff commited on
Commit
a0a4d30
1 Parent(s): c29718b

Upload tool

Browse files
Files changed (4) hide show
  1. app.py +1 -1
  2. requirements.txt +1 -1
  3. tool.py +15 -0
  4. tool_config.json +8 -3
app.py CHANGED
@@ -1,4 +1,4 @@
1
  from transformers import launch_gradio_demo
2
- from model_downloads import HFModelDownloadsTool
3
 
4
  launch_gradio_demo(HFModelDownloadsTool)
 
1
  from transformers import launch_gradio_demo
2
+ from tool import HFModelDownloadsTool
3
 
4
  launch_gradio_demo(HFModelDownloadsTool)
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- transformers[agents]
2
  huggingface_hub
 
1
+ agents_package
2
  huggingface_hub
tool.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from agents import Tool
2
+
3
+ class HFModelDownloadsTool(Tool):
4
+ name = "model_download_counter"
5
+ description = "
6
+ This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub.
7
+ It returns the name of the checkpoint."
8
+ inputs = {"task":{"type":"string","description":"the task category (such as text-classification, depth-estimation, etc)"}}
9
+ output_type = "string"
10
+
11
+ def forward(self, task: str):
12
+ from huggingface_hub import list_models
13
+
14
+ model = next(iter(list_models(filter=task, sort="downloads", direction=-1)))
15
+ return model.id
tool_config.json CHANGED
@@ -1,7 +1,12 @@
1
  {
2
- "description": "This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub. It returns the name of the checkpoint.",
3
- "inputs": "{'task': {'type': 'string', 'description': 'the task category (such as text-classification, depth-estimation, etc)'}}",
 
 
 
 
 
4
  "name": "model_download_counter",
5
  "output_type": "string",
6
- "tool_class": "model_downloads.HFModelDownloadsTool"
7
  }
 
1
  {
2
+ "description": "\n This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub.\n It returns the name of the checkpoint.",
3
+ "inputs": {
4
+ "task": {
5
+ "description": "the task category (such as text-classification, depth-estimation, etc)",
6
+ "type": "string"
7
+ }
8
+ },
9
  "name": "model_download_counter",
10
  "output_type": "string",
11
+ "tool_class": "HFModelDownloadsTool"
12
  }