Spaces:
Running
Running
File size: 1,077 Bytes
65d450b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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) |