Add FastAPI endpoint and catalog loader

This commit is contained in:
Fiden committed 2026-08-07 13:04:18 +00:00
1 parent 033036db76
commit daf107feed
10 files changed
+694

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
from __future__ import annotations
import os
from pathlib import Path
from fastapi import FastAPI
from app.catalog import load_raw_catalog
from app.models import MatchRequest, MatchResponse, MatchResult
BASE_DIR = Path(__file__).resolve().parent.parent
CATALOG_PATH = Path(os.environ.get("CATALOG_PATH", BASE_DIR / "catalog_excel.csv"))
RAW_CATALOG = load_raw_catalog(CATALOG_PATH)
app = FastAPI(title="Offline catalog matcher", version="0.1.0")
@app.get("/health")
def health() -> dict[str, object]:
return {"status": "ok", "catalog_items": len(RAW_CATALOG)}
@app.post("/match", response_model=MatchResponse)
def match(request: MatchRequest) -> MatchResponse:
return MatchResponse(
results=[
MatchResult(message=message, status="not_found", candidates=[])
for message in request.messages
]
)