File size: 629 Bytes
7e327f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from smolagents import Tool
from huggingface_hub import HfApi


class HFAPITool(Tool):
    name = "hf_api"
    description = "Use the HuggingFace API to search for models"
    inputs = {
        "prompt": {
            "type": "string",
            "description": "The prompt to search for models",
        },
    }
    output_type = "object"

    def __init__(self):
        super().__init__()
        self.api = HfApi()

    def forward(self, prompt: str):
        models = self.api.list_models(
            library=["transformers"], pipeline_tag="object-detection", fetch_config=True
        )
        print(models)