From 03333e212c22802aa682a9452d1050776d90c80f Mon Sep 17 00:00:00 2001 From: Alex-Gilbert Date: Fri, 20 Feb 2026 12:38:31 -0600 Subject: [PATCH] feat: wire analyze endpoint to use cached OCR data Co-Authored-By: Claude Opus 4.6 --- unredact/app.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/unredact/app.py b/unredact/app.py index 1ca77cf..739c406 100644 --- a/unredact/app.py +++ b/unredact/app.py @@ -178,8 +178,9 @@ async def analyze_doc(doc_id: str): async def event_generator(): for page_num, pd in doc["pages"].items(): page_img = pd["original"] + ocr_lines = pd.get("ocr_lines") try: - analysis = await analyze_page(page_img) + analysis = await analyze_page(page_img, ocr_lines=ocr_lines) except Exception as exc: yield json.dumps({ "event": "error", @@ -190,6 +191,10 @@ async def analyze_doc(doc_id: str): pd["analysis"] = analysis + # Cache OCR lines if not already cached + if pd.get("ocr_lines") is None: + pd["ocr_lines"] = analysis.lines + redactions_json = [] for r in analysis.redactions: font_id = _make_font_id(r.font.font_name)