Validate product attributes and decide match status

This commit is contained in:
Fiden committed 2026-08-07 13:13:11 +00:00
1 parent da8ad74498
commit a67826daa4
4 files changed
+927 -15

No files matched your search

+13 -15
View File
@@ -5,26 +5,24 @@ from pathlib import Path
from fastapi import FastAPI
from app.catalog import load_raw_catalog
from app.models import MatchRequest, MatchResponse, MatchResult
from app.matcher import CatalogMatcher
from app.models import MatchRequest, MatchResponse
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)
MATCHER = CatalogMatcher(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)}
# The task asks for one application endpoint. OpenAPI/Swagger routes are disabled
# so the running service exposes only POST /match.
app = FastAPI(
title="Offline catalog matcher",
version="0.2.0",
docs_url=None,
redoc_url=None,
openapi_url=None,
)
@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
]
)
return MatchResponse(results=[MATCHER.match(message) for message in request.messages])