Spaces:
Running
Running
Download tools/fetch_huggingface_models_tool.py from maubilli/BestLocalModelAgent: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/maubilli/BestLocalModelAgent/resolve/main/tools/fetch_huggingface_models_tool.py
- Command line
-
hf download hf://spaces/maubilli/BestLocalModelAgent/tools/fetch_huggingface_models_tool.py
-
curl -L -o fetch_huggingface_models_tool.py https://huggingface.co/spaces/maubilli/BestLocalModelAgent/resolve/main/tools/fetch_huggingface_models_tool.py
1.08 kB
| from smolagents import Tool | |
| from typing import Any, Optional | |
| class SimpleTool(Tool): | |
| name = "fetch_huggingface_models_tool" | |
| description = "Fetches the latest open-weight models from Hugging Face models API (https://huggingface.co/models)." | |
| inputs = {'force_refresh': {'type': 'boolean', 'nullable': True, 'description': 'If True, bypasses local cache and fetches fresh data from Hugging Face.'}} | |
| output_type = "string" | |
| def forward(self, force_refresh: 'bool' = False) -> 'str': | |
| """Fetches the latest open-weight models from Hugging Face models API (https://huggingface.co/models). | |
| Args: | |
| force_refresh: If True, bypasses local cache and fetches fresh data from Hugging Face. | |
| Returns: | |
| A JSON string containing the latest models, parameter sizes, download counts, and links. | |
| """ | |
| import json | |
| from agents.bestLocalModel import fetch_latest_huggingface_models | |
| models = fetch_latest_huggingface_models(force_refresh=force_refresh) | |
| return json.dumps(models[:20], indent=2) |