Spaces:
Build error
Build error
Upload tool
Browse files- app.py +1 -1
- requirements.txt +1 -1
- tool.py +15 -0
- tool_config.json +8 -3
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
from transformers import launch_gradio_demo
|
2 |
-
from
|
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 |
-
|
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
|
3 |
-
"inputs":
|
|
|
|
|
|
|
|
|
|
|
4 |
"name": "model_download_counter",
|
5 |
"output_type": "string",
|
6 |
-
"tool_class": "
|
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 |
}
|