This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
WARNING: This is an experimental implementation. Expect rough edges while using it. | |
------------------------------------------------- | |
Defines a FastMCP server that exposes the Hugging Face Hub API as a set of tools. | |
In practice, all public methods from `HfApi` are exposed as tools, except for the ones dealing with files: | |
- `create_commit` | |
- `hf_hub_download` | |
- `preupload_lfs_files` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import functools | |
from typing import Callable, Coroutine, Any, TypeVar, ParamSpec | |
T_Retval = TypeVar("T_Retval") | |
T_ParamSpec = ParamSpec("T_ParamSpec") | |
def syncify(async_function: Callable[T_ParamSpec, Coroutine[Any, Any, T_Retval]]) -> Callable[T_ParamSpec, T_Retval]: | |
# Taken from https://github.com/tiangolo/asyncer and simplified |