GoshawkVortexAI commited on
Commit
0dc40db
·
verified ·
1 Parent(s): ff296bd

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +11 -19
index.html CHANGED
@@ -192,10 +192,8 @@ table{width:100%;border-collapse:collapse;font-size:13px}th,td{text-align:left;p
192
  <div><label for="th">GÜVEN EŞİĞİ: <b id="thv">50</b>%</label><input type="range" id="th" min="30" max="95" value="50"></div>
193
  <div><label for="tm">VURGU RENGİ</label><select id="tm"><option value="gold">Altın</option><option value="violet">Mor</option></select></div>
194
  <div><label class="ck"><input type="checkbox" id="qo"> Sınıflandırmadan sonra Qwen yorumu</label></div>
195
- <div><label for="qm">QWEN MODEL</label><input type="text" id="qm" placeholder="Qwen/Qwen2.5-7B-Instruct"></div>
196
- <div><label for="qe">API ADRESİ (OpenAI uyumlu)</label><input type="text" id="qe"></div>
197
- <div><label for="qt">HUGGING FACE TOKEN (hf_…)</label><input type="password" id="qt" autocomplete="off" placeholder="hf_xxxxxxxx"></div>
198
- <div style="font-size:12px;color:var(--mu);line-height:1.6">Token yalnızca bu tarayıcıda saklanır. Yorum için belgenin ilk ~3000 karakteri seçtiğiniz API'ye gönderilir.</div>
199
  <div><button class="btn o" onclick="clearH()">Geçmişi Temizle</button></div></div></div></div>
200
  </main>
201
  <div id="toast"></div>
@@ -222,7 +220,7 @@ const SAMPLES={
222
  const USERS0=[{u:"admin",p:"admin123",r:"Yönetici"}];
223
  const LS={get(k,d){try{return JSON.parse(localStorage.getItem(k))??d}catch(e){return d}},set(k,v){try{localStorage.setItem(k,JSON.stringify(v))}catch(e){}}};
224
  let H=LS.get("lx_h",[]),EXTRA=LS.get("lx_u",[]),ST=LS.get("lx_s",{th:50,tm:"gold"}),ME=null;
225
- ST=Object.assign({qo:true,qe:"https://router.huggingface.co/v1/chat/completions",qm:"Qwen/Qwen2.5-7B-Instruct",qt:""},ST);
226
  const esc=s=>String(s).replace(/[&<>"]/g,c=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[c]));
227
  const pc=v=>(v*100).toFixed(1);
228
  function toast(m){const t=$("toast");t.textContent=m;t.classList.add("on");setTimeout(()=>t.classList.remove("on"),2200)}
@@ -413,28 +411,22 @@ let LAST=null,QAC=null;
413
  function qwenAgain(){if(LAST)qwen(LAST,true);else toast("Önce bir belge analiz edin")}
414
  async function qwen(a,force){
415
  const box=$("qw");
416
- if(!ST.qt){box.className="qw er";box.textContent="Qwen için Ayarlar'dan Hugging Face token girin.";return}
417
  if(QAC)QAC.abort();QAC=new AbortController();
418
  box.className="qw load";box.textContent="";
419
  const{r,e}=a;
420
  const info=`Sınıf: ${r.label} (güven %${pc(r.conf)})\nAnahtar kelimeler: ${r.kw.join(", ")||"-"}\nTarihler: ${e.dates.join(", ")||"-"}\nTutarlar: ${e.amt.join(", ")||"-"}\nDosya no: ${e.cases.join(", ")||"-"}\nKimlik no tespit edildi: ${e.tc?"evet":"hayır"}`;
421
- const body={model:ST.qm,stream:true,max_tokens:350,temperature:.3,messages:[
422
- {role:"system",content:"Sen Türk hukuku konusunda yardımcı bir asistansın. Bir sınıflandırıcının sonucunu ve belge metnini alırsın. Türkçe, en fazla 120 kelimeyle yorumla: 1) Belge ne ve sınıflandırma makul mü, 2) Dikkat edilmesi gereken noktalar/riskler, 3) Önerilen sonraki adım. Kısa maddeler kullan. Kesin hukuki tavsiye verme."},
423
- {role:"user",content:info+"\n\nBelge metni:\n"+a.text.slice(0,3000)}]};
424
  try{
425
- const res=await fetch(ST.qe,{method:"POST",signal:QAC.signal,headers:{"Content-Type":"application/json",Authorization:"Bearer "+ST.qt},body:JSON.stringify(body)});
426
- if(!res.ok){let m="";try{m=(await res.json()).error;m=m.message||m}catch(x){}throw new Error("HTTP "+res.status+(m?" – "+m:""))}
427
- const rd=res.body.getReader(),dc=new TextDecoder();let buf="",out="";
428
- for(;;){const{done,value}=await rd.read();if(done)break;buf+=dc.decode(value,{stream:true});
429
- const ls=buf.split("\n");buf=ls.pop();
430
- for(const l of ls){if(!l.startsWith("data:"))continue;const d=l.slice(5).trim();if(d==="[DONE]")continue;
431
- try{const t=JSON.parse(d).choices[0].delta.content;if(t){out+=t;box.textContent=out}}catch(x){}}}
432
- box.className="qw";if(!out)box.textContent="Boş yanıt geldi."
433
  }catch(err){if(err.name==="AbortError")return;box.className="qw er";box.textContent="Qwen hatası: "+err.message}
434
  }
435
- $("qo").checked=!!ST.qo;$("qm").value=ST.qm;$("qe").value=ST.qe;$("qt").value=ST.qt;
436
  $("qo").onchange=e=>{ST.qo=e.target.checked;LS.set("lx_s",ST)};
437
- [["qm","qm"],["qe","qe"],["qt","qt"]].forEach(([i,k])=>$(i).onchange=e=>{ST[k]=e.target.value.trim();LS.set("lx_s",ST);toast("Kaydedildi")});
438
 
439
  function bars(el,rows,tot){el.innerHTML=rows.map(([k,n])=>`<div class="r" style="grid-template-columns:130px 1fr 52px"><span>${esc(k)}</span><div class="bar"><i style="width:${tot?n/tot*100:0}%"></i></div><span>${n}</span></div>`).join("")}
440
  function refresh(){
 
192
  <div><label for="th">GÜVEN EŞİĞİ: <b id="thv">50</b>%</label><input type="range" id="th" min="30" max="95" value="50"></div>
193
  <div><label for="tm">VURGU RENGİ</label><select id="tm"><option value="gold">Altın</option><option value="violet">Mor</option></select></div>
194
  <div><label class="ck"><input type="checkbox" id="qo"> Sınıflandırmadan sonra Qwen yorumu</label></div>
195
+ <div><label for="qe">QWEN API ADRESİ</label><input type="text" id="qe" placeholder="/comment"></div>
196
+ <div style="font-size:12px;color:var(--mu);line-height:1.6">Model Space'inizde çalışır, token gerekmez. Yorum için belgenin ilk ~3000 karakteri bu adrese gönderilir.</div>
 
 
197
  <div><button class="btn o" onclick="clearH()">Geçmişi Temizle</button></div></div></div></div>
198
  </main>
199
  <div id="toast"></div>
 
220
  const USERS0=[{u:"admin",p:"admin123",r:"Yönetici"}];
221
  const LS={get(k,d){try{return JSON.parse(localStorage.getItem(k))??d}catch(e){return d}},set(k,v){try{localStorage.setItem(k,JSON.stringify(v))}catch(e){}}};
222
  let H=LS.get("lx_h",[]),EXTRA=LS.get("lx_u",[]),ST=LS.get("lx_s",{th:50,tm:"gold"}),ME=null;
223
+ ST=Object.assign({qo:true,qe:"/comment"},ST);if(!ST.qe||/huggingface/.test(ST.qe))ST.qe="/comment";
224
  const esc=s=>String(s).replace(/[&<>"]/g,c=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[c]));
225
  const pc=v=>(v*100).toFixed(1);
226
  function toast(m){const t=$("toast");t.textContent=m;t.classList.add("on");setTimeout(()=>t.classList.remove("on"),2200)}
 
411
  function qwenAgain(){if(LAST)qwen(LAST,true);else toast("Önce bir belge analiz edin")}
412
  async function qwen(a,force){
413
  const box=$("qw");
 
414
  if(QAC)QAC.abort();QAC=new AbortController();
415
  box.className="qw load";box.textContent="";
416
  const{r,e}=a;
417
  const info=`Sınıf: ${r.label} (güven %${pc(r.conf)})\nAnahtar kelimeler: ${r.kw.join(", ")||"-"}\nTarihler: ${e.dates.join(", ")||"-"}\nTutarlar: ${e.amt.join(", ")||"-"}\nDosya no: ${e.cases.join(", ")||"-"}\nKimlik no tespit edildi: ${e.tc?"evet":"hayır"}`;
418
+ const body={info,text:a.text.slice(0,3000)};
 
 
419
  try{
420
+ const res=await fetch(ST.qe,{method:"POST",signal:QAC.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify(body)});
421
+ if(!res.ok)throw new Error("HTTP "+res.status+(res.status===404?" – /comment bulunamadı (Space'te app.py çalışıyor mu?)":""));
422
+ const rd=res.body.getReader(),dc=new TextDecoder();let out="";
423
+ for(;;){const{done,value}=await rd.read();if(done)break;out+=dc.decode(value,{stream:true});box.textContent=out}
424
+ box.className="qw";if(!out.trim())box.textContent="Boş yanıt geldi."
 
 
 
425
  }catch(err){if(err.name==="AbortError")return;box.className="qw er";box.textContent="Qwen hatası: "+err.message}
426
  }
427
+ $("qo").checked=!!ST.qo;$("qe").value=ST.qe;
428
  $("qo").onchange=e=>{ST.qo=e.target.checked;LS.set("lx_s",ST)};
429
+ $("qe").onchange=e=>{ST.qe=e.target.value.trim()||"/comment";LS.set("lx_s",ST);toast("Kaydedildi")};
430
 
431
  function bars(el,rows,tot){el.innerHTML=rows.map(([k,n])=>`<div class="r" style="grid-template-columns:130px 1fr 52px"><span>${esc(k)}</span><div class="bar"><i style="width:${tot?n/tot*100:0}%"></i></div><span>${n}</span></div>`).join("")}
432
  function refresh(){