Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do advanced tools support multiple operations? #748

Open
phpmac opened this issue Feb 22, 2025 · 0 comments
Open

Do advanced tools support multiple operations? #748

phpmac opened this issue Feb 22, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@phpmac
Copy link

phpmac commented Feb 22, 2025

For example:

from smolagents import Tool


class FileTool(Tool):
    name = "file_tool"
    description = """
    i can upload,download,delete file from hf"""
    inputs = {
        "task": {
            "type": "string",
            "description": "the task category (such as text-classification, depth-estimation, etc)",
        }
    }
    output_type = "string"

    def upload_file(self, file_path: str, repo_id: str, commit_message: str):
        from huggingface_hub import upload_file

        upload_file(file_path, repo_id, commit_message)

    def download_file(self, repo_id: str, file_path: str):
        from huggingface_hub import download_file

    def delete_file(self, repo_id: str, file_path: str):
        from huggingface_hub import delete_file

        delete_file(repo_id, file_path)


file_tool = FileTool()


it's old:

from smolagents import Tool


class HFModelDownloadsTool(Tool):
    name = "model_download_counter"
    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."""
    inputs = {
        "task": {
            "type": "string",
            "description": "the task category (such as text-classification, depth-estimation, etc)",
        }
    }
    output_type = "string"

    def forward(self, task: str):
        from huggingface_hub import list_models

        model = next(iter(list_models(filter=task, sort="downloads", direction=-1)))
        return model.id


model_downloads_tool = HFModelDownloadsTool()

what should i do

@phpmac phpmac added the enhancement New feature or request label Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant