feat: wire analyze endpoint to use cached OCR data

Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
Alex-GilbertandClaude Opus 4.6 committed 2026-02-20 12:38:31 -06:00
1 parent f24a710b9e
commit 03333e212c
1 file changed
+6 -1
+6 -1
View File
@@ -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)