From 4af20f72e0293cdb36a2c74b673608c56942ed95 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 28 Apr 2026 17:09:07 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20OCR=20backend=20=ED=8C=8C=EB=9D=BC?= =?UTF-8?q?=EB=AF=B8=ED=84=B0=20=EB=88=84=EB=9D=BD=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(Ollama/OpenRouter=20=EB=AF=B8=EB=8F=99?= =?UTF-8?q?=EC=9E=91)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/index.html | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/static/index.html b/app/static/index.html index e6d41cb..baa750c 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -870,11 +870,23 @@ document.getElementById('cprompt-toggle-or').addEventListener('click',()=>{const document.querySelectorAll('.mode-btn').forEach(btn=>{btn.addEventListener('click',()=>{document.querySelectorAll('.mode-btn').forEach(b=>b.classList.remove('active'));btn.classList.add('active');ocrMode=btn.dataset.mode;document.getElementById('mode-desc').textContent=ocrMode==='structure'?'표 구조를 감지하고 Excel로 저장합니다':'일반 텍스트와 글자를 인식합니다'})}); document.getElementById('ocr-btn').addEventListener('click',async()=>{ if(!ocrFile)return;document.getElementById('ocr-err').style.display='none';setOcrLoading(true); - const fd=new FormData();fd.append('file',ocrFile);fd.append('mode',ocrMode);fd.append('ollama_model',document.getElementById('ocr-ollama-model').value||'');fd.append('custom_prompt',document.getElementById('custom-prompt').value||''); + const fd=new FormData(); + fd.append('file',ocrFile); + fd.append('mode',ocrMode); + fd.append('backend',ocrEngine); + // Ollama 모델 + fd.append('ollama_model', ocrEngine==='ollama' ? (document.getElementById('ocr-ollama-model').value||'') : ''); + // OpenRouter 모델 + fd.append('openrouter_model', ocrEngine==='openrouter' ? (document.getElementById('ocr-or-model').value||'') : ''); + // 커스텀 프롬프트 (엔진별) + const cp = ocrEngine==='openrouter' + ? (document.getElementById('custom-prompt-or').value||'') + : (document.getElementById('custom-prompt').value||''); + fd.append('custom_prompt', cp); try{const r=await api('POST','/api/ocr',fd);const d=await r.json();if(!r.ok)throw new Error(d.detail||'업로드 실패');pollTask(d.task_id,dt=>setProg('ocr',dt.progress||0,dt.message||'처리 중...'),showOcrResult,e=>{showErr('ocr-err',e);setOcrLoading(false)})} catch(e){showErr('ocr-err',e.message);setOcrLoading(false)} }); -function setOcrLoading(on){const io=ocrEngine==='ollama',c=io?'var(--purple)':'var(--accent)';document.getElementById('ocr-btn').disabled=on;document.getElementById('ocr-prog').style.display=on?'block':'none';document.getElementById('ocr-wave').style.display=on?'flex':'none';document.getElementById('ocr-pfill').style.background=c;document.getElementById('ocr-ppct').style.color=c;document.querySelectorAll('#ocr-wave .wave-bar').forEach(b=>b.style.background=c);if(on)setProg('ocr',0,'준비 중...')} +function setOcrLoading(on){const io=(ocrEngine==='ollama'||ocrEngine==='openrouter'),c=io?'var(--purple)':'var(--accent)';document.getElementById('ocr-btn').disabled=on;document.getElementById('ocr-prog').style.display=on?'block':'none';document.getElementById('ocr-wave').style.display=on?'flex':'none';document.getElementById('ocr-pfill').style.background=c;document.getElementById('ocr-ppct').style.color=c;document.querySelectorAll('#ocr-wave .wave-bar').forEach(b=>b.style.background=c);if(on)setProg('ocr',0,'준비 중...')} function showOcrResult(d){ ocrOutputTxt=d.txt_file||null;ocrOutputXlsx=d.xlsx_file||null;const io=d.backend==='ollama'; document.getElementById('ocr-mlines').textContent=(d.line_count||0)+'줄';document.getElementById('ocr-mmode').textContent=d.mode==='structure'?'구조분석':'텍스트';document.getElementById('ocr-mbackend').textContent=io?`Ollama`:'Paddle';document.getElementById('ocr-mtables').textContent=(d.tables||[]).length+'개';