Download api.py from maxcasado/POC2PROD: direct link, hf CLI and curl.
- Browser
- Download file 390 Bytes
-
https://huggingface.co/spaces/maxcasado/POC2PROD/resolve/main/api.py
- Command line
-
hf download hf://spaces/maxcasado/POC2PROD/api.py
-
curl -L -o api.py https://huggingface.co/spaces/maxcasado/POC2PROD/resolve/main/api.py
390 Bytes
| # api.py | |
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| from typing import List, Dict, Any | |
| from model_utils import predict_proba | |
| app = FastAPI(title="StackOverflow Tagger API") | |
| class Query(BaseModel): | |
| text: str | |
| top_k: int = 10 | |
| def predict(q: Query) -> Dict[str, Any]: | |
| tags = predict_proba(q.text, top_k=q.top_k) | |
| return {"tags": tags} | |