From d9bd60abfbc22ce316667d884c0466c5f04bd763 Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 19 Oct 2026 21:25:07 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B9=98=EA=B3=BC=20=EC=A0=80=EB=84=90=20?= =?UTF-8?q?=EA=B2=80=EC=83=89:=20=EA=B2=80=EC=83=89=20=EB=B2=84=ED=8A=BC?= =?UTF-8?q?=20=EC=98=86=20AI=20=EA=B2=80=EC=83=89(=EB=AA=A8=EB=8D=B8?= =?UTF-8?q?=EC=9D=B4=20=EC=98=81=EB=AC=B8=20=EA=B2=80=EC=83=89=EC=96=B4?= =?UTF-8?q?=C2=B7=EC=97=B0=EB=8F=84=C2=B7=EB=85=BC=EB=AC=B8=20=EC=A2=85?= =?UTF-8?q?=EB=A5=98=EB=A5=BC=20=EC=A0=95=ED=95=B4=20=EA=B2=80=EC=83=89)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- web-ui/html/dental-journals.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/web-ui/html/dental-journals.html b/web-ui/html/dental-journals.html index 9056d69..3ef63ab 100644 --- a/web-ui/html/dental-journals.html +++ b/web-ui/html/dental-journals.html @@ -120,6 +120,7 @@ button:disabled{opacity:.5;cursor:default} +
🔎 결과 내 검색 @@ -479,6 +480,27 @@ async function chatOnce(message,ctx){ } finally { try{ fetch('/api/chat/sessions/'+encodeURIComponent(sidTmp),{method:'DELETE',credentials:'include',headers:authH()}); }catch(e){} } return out; } +// AI 검색: 입력창의 요청을 모델이 PubMed 검색어(영문)·연도·논문 종류로 바꿔 채운 뒤 일반 검색을 실행한다. +async function aiSearch(){ + const req=$('q').value.trim(); if(!req){ $('status').textContent='AI 검색은 요청 내용을 입력창에 적어야 합니다.'; return; } + const btn=$('aibtn'); btn.disabled=true; btn.textContent='🤖 생각 중…'; $('status').textContent='모델이 검색어를 정하는 중…'; + try{ + const prompt='치과 논문을 PubMed에서 찾으려 한다. 도구는 쓰지 말고 JSON 한 줄로만 답하라.\n' + +'형식: {"query":"영문 검색어","min_year":null,"types":[]}\n' + +'규칙: query는 핵심 영문 키워드 2~4개를 공백으로 나열(AND·OR·대괄호 태그·따옴표 금지, 저널 이름은 넣지 말 것). 요청에 기간·최신 언급이 있을 때만 min_year에 연도(숫자), 없으면 null. ' + +'types는 요청이 특정 종류를 말할 때만 다음 id 중에서: '+ptypes.map(t=>t.id+'='+t.label).join(', ')+'. JSON 외 다른 글자 금지.\n\n요청: '+req; + const out=await chatOnce(prompt,''); + const m=out.match(/\{[\s\S]*\}/); if(!m) throw new Error('검색어를 받지 못했습니다'); + const plan=JSON.parse(m[0]); + const qq=String(plan.query||'').replace(/[\[\]"()]|\b(AND|OR|NOT)\b/g,' ').replace(/\s+/g,' ').trim(); + if(!qq) throw new Error('검색어가 비어 있습니다'); + $('q').value=qq; $('raw').checked=false; + const y=Number(plan.min_year); if(Number.isInteger(y)&&y>=1990&&y<=2100) $('yr').value=y; + if(Array.isArray(plan.types)){ tsel=new Set(plan.types.filter(x=>ptypes.some(t=>t.id===x))); try{ localStorage.setItem('dj-types',JSON.stringify([...tsel])); }catch(e){} renderTypes(); } + newSearch(); + }catch(e){ $('status').textContent='AI 검색 실패: '+e.message; } + finally{ btn.disabled=false; btn.textContent='🤖 AI 검색'; } +} function parseJsonLoose(t){ t=String(t||'').replace(/```(?:json)?/gi,''); const a=t.indexOf('{'), b=t.lastIndexOf('}'); if(a<0||b