Spaces:
Sleeping
Sleeping
import aiohttp | |
from fastapi import FastAPI | |
from fastapi.responses import JSONResponse, PlainTextResponse | |
app = FastAPI() | |
async def homepage(): | |
return "Request or go to /v1/models to use the space, make sure its a GET" | |
async def main(): | |
url = 'https://huggingface.co/models-json?inference=warm&sort=trending&withCount=true' | |
async with aiohttp.ClientSession() as session: | |
async with session.get(url) as response: | |
models = await response.json() | |
output = [ | |
{ | |
"created": 0, | |
"id": key['id'], | |
"object": "model", | |
"owned_by": key['author'], | |
"pipeline": key['pipeline_tag'] | |
} | |
for key in models['models'] | |
if not key['private'] and not key['gated'] | |
] | |
return JSONResponse(content=output) | |