Spaces:
Sleeping
Sleeping
Download api/routes/models.py from david-baxter/Assistant2Api: direct link, hf CLI and curl.
- Browser
- Download file 544 Bytes
-
https://huggingface.co/spaces/david-baxter/Assistant2Api/resolve/main/api/routes/models.py
- Command line
-
hf download hf://spaces/david-baxter/Assistant2Api/api/routes/models.py
-
curl -L -o models.py https://huggingface.co/spaces/david-baxter/Assistant2Api/resolve/main/api/routes/models.py
544 Bytes
| """GET /v1/models — list available models.""" | |
| from __future__ import annotations | |
| import time | |
| from fastapi import APIRouter | |
| from config import MODEL_MAP | |
| router = APIRouter() | |
| async def list_models() -> dict: | |
| now = int(time.time()) | |
| data = [ | |
| { | |
| "id": short_name, | |
| "object": "model", | |
| "created": now, | |
| "owned_by": full_name.split("/")[0], | |
| } | |
| for short_name, full_name in MODEL_MAP.items() | |
| ] | |
| return {"object": "list", "data": data} | |