fix: PaddleOCR engine forces words_first in frontend to match backend
Some checks failed
CI / go-lint (push) Has been cancelled
CI / python-lint (push) Has been cancelled
CI / nodejs-lint (push) Has been cancelled
CI / test-go-school (push) Has been cancelled
CI / test-go-edu-search (push) Has been cancelled
CI / test-python-klausur (push) Has been cancelled
CI / test-python-agent-core (push) Has been cancelled
CI / test-nodejs-website (push) Has been cancelled

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 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-12 14:52:18 +01:00
parent 685d135be5
commit bb90d1ba94

View File

@@ -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