Spaces:
Running
Running
Download app.py from Equinai/Chronos-2-API: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/Equinai/Chronos-2-API/resolve/main/app.py
- Command line
-
hf download hf://spaces/Equinai/Chronos-2-API/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Equinai/Chronos-2-API/resolve/main/app.py
1.01 kB
| from __future__ import annotations | |
| from fastapi import FastAPI, HTTPException | |
| from schemas import HealthResponse, PredictRequest, PredictResponse | |
| from service import ChronosService | |
| app = FastAPI(title="Chronos Space", version="0.1.0") | |
| service = ChronosService() | |
| def health() -> HealthResponse: | |
| return service.health() | |
| def root() -> dict[str, str]: | |
| return {"service": "chronos", "status": "ok"} | |
| def predict(payload: PredictRequest) -> PredictResponse: | |
| try: | |
| return service.predict(payload) | |
| except ValueError as exc: | |
| raise HTTPException(status_code=400, detail=str(exc)) from exc | |
| except RuntimeError as exc: | |
| raise HTTPException(status_code=503, detail=str(exc)) from exc | |
| except Exception as exc: # pragma: no cover | |
| raise HTTPException(status_code=500, detail=f"prediction_failed: {exc}") from exc | |