From bb90d1ba9486fac80cfe0639d711b684ccd1a54a Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Thu, 12 Mar 2026 14:52:18 +0100 Subject: [PATCH] fix: PaddleOCR engine forces words_first in frontend to match backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When engine=paddle is selected, the backend overrides grid_method to words_first and returns plain JSON (no SSE streaming). The frontend was not aware of this override — it sent stream=true and tried to parse SSE events from a JSON response, resulting in "Keine Daten". Co-Authored-By: Claude Opus 4.6 --- .../components/ocr-pipeline/StepWordRecognition.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/admin-lehrer/components/ocr-pipeline/StepWordRecognition.tsx b/admin-lehrer/components/ocr-pipeline/StepWordRecognition.tsx index e1d338a..f2dead0 100644 --- a/admin-lehrer/components/ocr-pipeline/StepWordRecognition.tsx +++ b/admin-lehrer/components/ocr-pipeline/StepWordRecognition.tsx @@ -108,12 +108,16 @@ export function StepWordRecognition({ sessionId, onNext, goToStep, skipHealGaps setGridResult(null) try { + // PaddleOCR forces words_first on the backend, so align frontend accordingly + const effectiveGridMethod = eng === 'paddle' ? 'words_first' : gridMethod + const useStream = effectiveGridMethod === 'v2' + // Retry once if initial request fails (e.g. after container restart, // session cache may not be warm yet when navigating via wizard) let res: Response | null = null for (let attempt = 0; attempt < 2; attempt++) { res = await fetch( - `${KLAUSUR_API}/api/v1/ocr-pipeline/sessions/${sessionId}/words?stream=${gridMethod === 'v2' ? 'true' : 'false'}&engine=${eng}&pronunciation=${pronunciation}${skipHealGaps ? '&skip_heal_gaps=true' : ''}&grid_method=${gridMethod}`, + `${KLAUSUR_API}/api/v1/ocr-pipeline/sessions/${sessionId}/words?stream=${useStream ? 'true' : 'false'}&engine=${eng}&pronunciation=${pronunciation}${skipHealGaps ? '&skip_heal_gaps=true' : ''}&grid_method=${effectiveGridMethod}`, { method: 'POST' }, ) if (res.ok) break @@ -129,8 +133,8 @@ export function StepWordRecognition({ sessionId, onNext, goToStep, skipHealGaps throw new Error(err.detail || 'Worterkennung fehlgeschlagen') } - // words_first returns plain JSON (no streaming) - if (gridMethod === 'words_first') { + // words_first / paddle returns plain JSON (no streaming) + if (!useStream) { const data = await res.json() as GridResult applyGridResult(data) return