12 lines
2.6 KiB
JavaScript
12 lines
2.6 KiB
JavaScript
const StrataUI=(()=>{
|
|
const esc=v=>String(v??'').replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
|
function render(){document.querySelector('#view').innerHTML='<h1>Strata</h1><p>Flash-Next als native Chat-Laufzeit hinter dem bestehenden Athena-Endpunkt. Zwei GPUs, Experten in RAM/SSD, MTP auf der zweiten GPU. Kein zusätzlicher öffentlicher API-Port.</p><section class="card" id="strata-state"></section><p id="strata-message" role="status"></p><a href="#chat" class="link">Chat-Profile öffnen →</a>';refresh();}
|
|
async function api(path='',body){const r=await fetch('/api/v1/strata-runtime'+path,body!==undefined?{method:'POST',headers:{'Content-Type':'application/json','X-Athena-Deck':'1'},body:JSON.stringify(body)}:{});const d=await r.json();if(!r.ok)throw Error(d.error);return d;}
|
|
async function refresh(){const root=document.querySelector('#strata-state');if(!root)return;try{
|
|
const [d,c]=await Promise.all([api(),fetch('/api/v1/catalog').then(r=>r.json())]);if(!root.isConnected)return;
|
|
root.innerHTML=`<h2>Strata ${esc(d.version)}</h2><p>${d.installed?'Installiert':'Einrichtung erforderlich'} · ${esc(d.revision?.slice(0,12))}</p><p>${esc(d.job?.phase||'Kein Einrichtungsauftrag aktiv.')}</p><p>Vision ist in diesem Rezept noch nicht verfügbar. Ein Chat-Slot, Kontext bis 262144. Große Kontexte benötigen zusätzlichen RAM.</p><p>${Object.entries(d.models).map(([q,ready])=>`${esc(q)}: ${ready?'vorbereitet':'Paket fehlt'}`).join(' · ')}</p><button id="strata-install" ${d.installed||d.job?.state==='running'?'disabled':''}>Native Laufzeit installieren</button><label>Modellpaket<select id="strata-model">${(c.entries||[]).filter(m=>m.file.includes('Flash-Next-GSQ-RCO')&&m.file.includes('-00001-of-')&&/IQ[23]_/.test(m.file)).map(m=>`<option value="${esc(m.id)}">${esc(m.file)}</option>`).join('')}</select></label><button id="strata-prepare" ${!d.installed||d.job?.state==='running'?'disabled':''}>Expertenpaket vorbereiten</button>${d.job?.state==='running'?'<button class="secondary" id="strata-cancel">Einrichtung abbrechen</button>':''}`;
|
|
for(const [id,path,body] of [['strata-install','/install',()=>({})],['strata-prepare','/prepare',()=>({model_id:document.querySelector('#strata-model').value})],['strata-cancel','/cancel',()=>({})]])document.querySelector('#'+id)?.addEventListener('click',async event=>{event.target.disabled=true;try{await api(path,body());refresh();}catch(e){document.querySelector('#strata-message').textContent=e.message;event.target.disabled=false;}});
|
|
}catch(e){if(root.isConnected)root.textContent=e.message;}finally{setTimeout(()=>{if(root.isConnected)refresh();},4000);}}
|
|
return {render};
|
|
})();
|