aditya0103's picture
Tasks 5-7: eval harness, FastAPI backend, Paper & Ink UI- src/eval/ β€” precision/recall/F1 harness with type-aware comparators,micro/macro F1, CSV + markdown reports, --model benchmark flag- src/api/ β€” FastAPI backend with /extract, /schemas, /health,request-ID middleware, typed error envelope, injectable extractor- ui/ β€” Vite + React + TS + Tailwind + Motion + React Three FiberPaper & Ink editorial UI with 3D paper hero, dark/light mode,confidence inkwell, wax-stamp metrics, kinetic typography- 95 passing tests (up from 54); UI is a separate npm workspace
557ab38
Raw
History Blame Contribute Delete
971 Bytes
"""Schema discovery routes.
GET /schemas -> list of registered document types
GET /schemas/{doc_type} -> full JSON Schema for that type
The JSON Schema is what OpenAI's structured outputs uses internally β€” exposing
it lets clients validate uploads client-side, or auto-generate forms.
"""
from __future__ import annotations
from fastapi import APIRouter
from src.api.errors import UnsupportedDocType
from src.schemas.registry import get_json_schema, list_doc_types
router = APIRouter(prefix="/schemas", tags=["schemas"])
@router.get("")
def list_schemas() -> dict:
"""Return all registered document type keys."""
return {"doc_types": list_doc_types()}
@router.get("/{doc_type}")
def get_schema_json(doc_type: str) -> dict:
"""Return the JSON Schema for one document type."""
try:
return get_json_schema(doc_type)
except KeyError as e:
raise UnsupportedDocType(str(e), details={"doc_type": doc_type}) from e