Files
Athena-Deck/strata-ui.js

12 lines
2.9 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const StrataUI=(()=>{
const esc=v=>String(v??'').replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[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>CPU-Vision: ${d.vision?'bereit':'Encoder unter CPU-Vision vorbereiten installieren'}. Ein Slot bis 524288 (oberhalb 262144 mit YaRN ×2) oder zwei Slots mit je maximal 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><button id="strata-vision" ${!d.installed||d.vision||d.job?.state==='running'?'disabled':''}>CPU-Vision vorbereiten</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-vision','/vision',()=>({})],['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};
})();