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)