Update index.html
Browse files- index.html +176 -400
index.html
CHANGED
|
@@ -19,187 +19,116 @@
|
|
| 19 |
}
|
| 20 |
html,body{height:100%;background:var(--bg);color:var(--t0);font-family:var(--mono);font-size:13px;overflow:hidden}
|
| 21 |
.app{display:flex;height:100vh}
|
| 22 |
-
|
| 23 |
-
/* ── Noise overlay for depth ── */
|
| 24 |
.app::before{content:'';position:fixed;inset:0;
|
| 25 |
background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
|
| 26 |
pointer-events:none;z-index:0;opacity:.4}
|
| 27 |
.app>*{position:relative;z-index:1}
|
| 28 |
-
|
| 29 |
-
/* ══ SIDEBAR ═════════════════════════════════════════════════ */
|
| 30 |
-
.sb{width:var(--sb);min-width:var(--sb);background:var(--bg1);
|
| 31 |
-
border-right:1px solid var(--bg3);display:flex;flex-direction:column;overflow:hidden}
|
| 32 |
-
|
| 33 |
.sb-logo{padding:16px;background:var(--bg);border-bottom:1px solid var(--bg3);flex-shrink:0}
|
| 34 |
.logo-row{display:flex;align-items:center;gap:10px}
|
| 35 |
-
.logo-icon{width:34px;height:34px;border-radius:9px;
|
| 36 |
-
background:linear-gradient(135deg,var(--acc3),var(--acc2));
|
| 37 |
-
display:flex;align-items:center;justify-content:center;flex-shrink:0;
|
| 38 |
-
box-shadow:0 0 20px rgba(124,107,255,.35)}
|
| 39 |
.logo-icon svg{fill:#fff}
|
| 40 |
-
.logo-text h2{font-family:var(--sans);font-size:18px;font-weight:900;
|
| 41 |
-
letter-spacing:-.04em;color:var(--t0)}
|
| 42 |
.logo-text h2 em{color:var(--acc2);font-style:normal}
|
| 43 |
-
.logo-text p{font-size:9px;color:var(--t2);margin-top:2px;
|
| 44 |
-
letter-spacing:.1em;text-transform:uppercase}
|
| 45 |
-
|
| 46 |
-
/* Tabs */
|
| 47 |
.sb-tabs{display:flex;border-bottom:1px solid var(--bg3);flex-shrink:0;background:var(--bg1)}
|
| 48 |
-
.sb-tab{flex:1;padding:8px 4px;text-align:center;font-size:9px;font-weight:700;
|
| 49 |
-
color:var(--t2);text-transform:uppercase;letter-spacing:.08em;cursor:pointer;
|
| 50 |
-
border:none;background:none;font-family:var(--mono);
|
| 51 |
-
border-bottom:2px solid transparent;transition:.15s}
|
| 52 |
.sb-tab.on{color:var(--acc2);border-bottom-color:var(--acc);background:var(--dim)}
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
.
|
| 56 |
-
scrollbar-width:thin;scrollbar-color:var(--bg4) transparent}
|
| 57 |
-
|
| 58 |
-
/* Cards */
|
| 59 |
-
.card{background:var(--bg2);border:1px solid var(--bg3);border-radius:var(--r);
|
| 60 |
-
padding:11px 13px;margin-bottom:8px}
|
| 61 |
-
.ct{font-size:9px;font-weight:700;color:var(--t2);text-transform:uppercase;
|
| 62 |
-
letter-spacing:.1em;margin-bottom:8px;display:flex;align-items:center;gap:6px}
|
| 63 |
-
|
| 64 |
-
/* Stat rows */
|
| 65 |
.sr{display:flex;justify-content:space-between;align-items:center;padding:3px 0}
|
| 66 |
.sl{color:var(--t1);font-size:11px}
|
| 67 |
.sv{font-size:12px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--t0)}
|
| 68 |
.g{color:var(--green)}.c{color:var(--cyan)}.y{color:var(--warn)}.r{color:var(--red)}.p{color:var(--acc2)}
|
| 69 |
-
|
| 70 |
-
/* Live dot */
|
| 71 |
.dot{display:inline-block;width:6px;height:6px;border-radius:50%;flex-shrink:0}
|
| 72 |
.dot.off{background:var(--t3)}.dot.on{background:var(--green);animation:pulse 1.4s infinite}
|
| 73 |
@keyframes pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.3;transform:scale(.7)}}
|
| 74 |
-
|
| 75 |
canvas#spark{width:100%;height:44px;display:block;border-radius:var(--r);background:var(--bg)}
|
| 76 |
-
|
| 77 |
-
.ta{width:100%;background:var(--bg);border:1px solid var(--bg3);border-radius:var(--r);
|
| 78 |
-
color:var(--t0);font-size:11px;padding:8px 10px;resize:vertical;
|
| 79 |
-
min-height:56px;font-family:var(--mono);line-height:1.6}
|
| 80 |
.ta:focus{outline:none;border-color:var(--acc)}
|
| 81 |
-
|
| 82 |
.pg{display:flex;flex-direction:column;gap:4px}
|
| 83 |
-
.pg label{font-size:9px;color:var(--t2);text-transform:uppercase;
|
| 84 |
-
letter-spacing:.08em;display:flex;justify-content:space-between}
|
| 85 |
.pg label span{color:var(--acc2);font-weight:700}
|
| 86 |
-
.pg input[type=range]{width:100%;-webkit-appearance:none;height:2px;
|
| 87 |
-
|
| 88 |
-
.
|
| 89 |
-
border-radius:50%;background:var(--acc);cursor:pointer;border:2px solid var(--bg1)}
|
| 90 |
-
|
| 91 |
-
.btn{display:inline-flex;align-items:center;gap:5px;padding:6px 12px;
|
| 92 |
-
border-radius:var(--r);border:1px solid var(--bg4);cursor:pointer;
|
| 93 |
-
font-size:10px;font-weight:700;font-family:var(--mono);
|
| 94 |
-
text-transform:uppercase;letter-spacing:.05em;transition:.13s}
|
| 95 |
.bp{background:var(--acc);color:#fff;border-color:var(--acc)}
|
| 96 |
.bp:hover{background:var(--acc2)}.bs{background:var(--bg3);color:var(--t1)}
|
| 97 |
.bs:hover{background:var(--bg4);color:var(--t0)}
|
| 98 |
.btn.full{width:100%;justify-content:center}.btn:disabled{opacity:.3;cursor:not-allowed}
|
| 99 |
|
| 100 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
#bench-panel{display:none;flex-direction:column;height:100%;overflow:hidden}
|
| 102 |
#bench-panel.visible{display:flex}
|
| 103 |
#stats-panel,#params-panel{display:flex;flex-direction:column;flex:1;overflow:hidden}
|
| 104 |
-
|
| 105 |
.bench-actions{padding:10px;flex-shrink:0;display:flex;flex-direction:column;gap:6px}
|
| 106 |
-
.bench-scroll{flex:1;overflow-y:auto;padding:0 10px 10px;
|
| 107 |
-
scrollbar-width:thin;scrollbar-color:var(--bg4) transparent}
|
| 108 |
-
|
| 109 |
-
/* Benchmark summary grid */
|
| 110 |
.b-grid{display:grid;grid-template-columns:1fr 1fr;gap:5px;margin-bottom:10px}
|
| 111 |
-
.b-stat{background:var(--bg2);border:1px solid var(--bg3);border-radius:var(--r);
|
| 112 |
-
|
| 113 |
-
.b-stat .
|
| 114 |
-
|
| 115 |
-
.
|
| 116 |
-
letter-spacing:.1em;margin-top:2px}
|
| 117 |
-
|
| 118 |
-
/* Phase cards */
|
| 119 |
-
.ph-card{background:var(--bg2);border:1px solid var(--bg3);border-radius:var(--r);
|
| 120 |
-
padding:9px 11px;margin-bottom:6px;animation:fadeup .2s ease}
|
| 121 |
-
.ph-title{font-size:9px;font-weight:700;color:var(--acc2);
|
| 122 |
-
text-transform:uppercase;letter-spacing:.08em;margin-bottom:6px}
|
| 123 |
.ph-label{font-size:11px;color:var(--t2);margin-bottom:4px}
|
| 124 |
.ph-stats{display:flex;gap:8px;flex-wrap:wrap;margin-top:5px}
|
| 125 |
.ph-stat{display:flex;flex-direction:column;gap:1px;min-width:50px}
|
| 126 |
.ph-stat .pv{font-size:13px;font-weight:700;color:var(--green);font-variant-numeric:tabular-nums}
|
| 127 |
.ph-stat .pk{font-size:9px;color:var(--t2);text-transform:uppercase;letter-spacing:.06em}
|
| 128 |
.ph-bar{height:2px;background:var(--bg4);border-radius:1px;margin-top:5px;overflow:hidden}
|
| 129 |
-
.ph-fill{height:100%;background:linear-gradient(90deg,var(--acc3),var(--acc2));
|
| 130 |
-
border-radius:1px;transition:width .5s ease;width:0%}
|
| 131 |
.ph-running{display:flex;align-items:center;gap:5px;font-size:10px;color:var(--warn)}
|
| 132 |
-
.spin{width:8px;height:8px;border:1.5px solid var(--warn);border-top-color:transparent;
|
| 133 |
-
border-radius:50%;animation:spin .7s linear infinite;flex-shrink:0}
|
| 134 |
@keyframes spin{to{transform:rotate(360deg)}}
|
| 135 |
.bench-empty{text-align:center;padding:30px 16px;color:var(--t2);font-size:12px;line-height:1.9}
|
| 136 |
-
.verdict{padding:10px 12px;border-radius:var(--r);font-size:11px;margin-bottom:8px;
|
| 137 |
-
border:1px solid var(--bg3)}
|
| 138 |
.verdict.good{border-color:rgba(61,255,180,.3);background:rgba(61,255,180,.06);color:var(--green)}
|
| 139 |
.verdict.mid{border-color:rgba(255,194,96,.3);background:rgba(255,194,96,.06);color:var(--warn)}
|
| 140 |
-
|
| 141 |
-
/* ══ CHAT ════════════════════════════════════════════════════ */
|
| 142 |
.chat{flex:1;display:flex;flex-direction:column;overflow:hidden}
|
| 143 |
-
|
| 144 |
-
.
|
| 145 |
-
border-bottom:1px solid var(--bg3);background:var(--bg1);gap:8px;flex-shrink:0}
|
| 146 |
-
.badge{background:var(--dim);border:1px solid rgba(124,107,255,.3);border-radius:20px;
|
| 147 |
-
padding:3px 10px;font-size:10px;font-weight:700;color:var(--acc2);font-family:var(--sans)}
|
| 148 |
.hdr-title{font-family:var(--sans);font-size:13px;font-weight:600;color:var(--t1)}
|
| 149 |
.spc{flex:1}
|
| 150 |
-
.hpill{display:flex;align-items:center;gap:6px;
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
.
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
/* Welcome */
|
| 157 |
-
.welcome{flex:1;display:flex;flex-direction:column;align-items:center;
|
| 158 |
-
justify-content:center;gap:14px;text-align:center;padding:40px;animation:fadeup .4s ease}
|
| 159 |
-
.wlogo{font-family:var(--sans);font-size:72px;font-weight:900;
|
| 160 |
-
background:linear-gradient(135deg,var(--acc),var(--cyan));
|
| 161 |
-
-webkit-background-clip:text;-webkit-text-fill-color:transparent;
|
| 162 |
-
background-clip:text;letter-spacing:-.05em;line-height:1}
|
| 163 |
-
.welcome h2{font-family:var(--sans);font-size:22px;font-weight:700;
|
| 164 |
-
color:var(--t0);letter-spacing:-.02em}
|
| 165 |
.welcome p{max-width:400px;line-height:1.8;font-size:12px;color:var(--t1)}
|
| 166 |
.chips{display:flex;gap:6px;flex-wrap:wrap;justify-content:center;margin-top:2px}
|
| 167 |
-
.chip{font-size:9px;padding:4px 10px;border:1px solid var(--bg4);border-radius:20px;
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
/* Messages */
|
| 171 |
-
.mg{display:flex;gap:0;padding:14px 20px;border-bottom:1px solid var(--bg3);
|
| 172 |
-
animation:fadeup .18s ease}
|
| 173 |
.mg:last-child{border-bottom:none}
|
| 174 |
@keyframes fadeup{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
|
| 175 |
.mg-role{width:60px;flex-shrink:0;padding-top:2px}
|
| 176 |
.mlabel{font-size:9px;font-weight:700;letter-spacing:.1em;text-transform:uppercase}
|
| 177 |
.mg.user .mlabel{color:var(--acc2)}.mg.asst .mlabel{color:var(--cyan)}
|
| 178 |
.mg-body{flex:1;min-width:0}
|
| 179 |
-
.bubble{font-size:13px;line-height:1.75;color:var(--t1);
|
| 180 |
-
white-space:pre-wrap;word-break:break-word;max-width:660px}
|
| 181 |
.mg.user .bubble{color:var(--t2)}
|
| 182 |
-
.cur{display:inline-block;width:7px;height:2px;background:var(--acc2);
|
| 183 |
-
margin-left:3px;vertical-align:middle;animation:blink .6s infinite}
|
| 184 |
@keyframes blink{0%,49%{opacity:1}50%,100%{opacity:0}}
|
| 185 |
.bmeta{font-size:10px;color:var(--t3);margin-top:5px;display:flex;flex-wrap:wrap;gap:8px}
|
| 186 |
.bmeta b{color:var(--acc2)}
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
.inputbar{padding:12px 16px;border-top:1px solid var(--bg3);
|
| 190 |
-
background:var(--bg1);flex-shrink:0}
|
| 191 |
-
.inputwrap{background:var(--bg2);border:1px solid var(--bg3);border-radius:var(--r);
|
| 192 |
-
display:flex;align-items:flex-end;padding:3px 3px 3px 12px;gap:4px;transition:.13s}
|
| 193 |
.inputwrap:focus-within{border-color:var(--acc)}
|
| 194 |
-
#inp{flex:1;background:none;border:none;outline:none;color:var(--t0);
|
| 195 |
-
font-size:13px;font-family:var(--mono);resize:none;line-height:1.6;
|
| 196 |
-
max-height:110px;padding:7px 0}
|
| 197 |
#inp::placeholder{color:var(--t3)}
|
| 198 |
-
.sbtn{background:linear-gradient(135deg,var(--acc3),var(--acc2));border:none;cursor:pointer;
|
| 199 |
-
width:32px;height:32px;border-radius:6px;display:flex;align-items:center;
|
| 200 |
-
justify-content:center;flex-shrink:0;transition:.13s;
|
| 201 |
-
align-self:flex-end;margin-bottom:3px;
|
| 202 |
-
box-shadow:0 0 12px rgba(124,107,255,.4)}
|
| 203 |
.sbtn:hover{filter:brightness(1.15)}.sbtn:disabled{opacity:.3;cursor:not-allowed}
|
| 204 |
.sbtn svg{fill:#fff}
|
| 205 |
.hint{margin-top:5px;font-size:10px;color:var(--t3);text-align:right;letter-spacing:.04em}
|
|
@@ -208,7 +137,6 @@ canvas#spark{width:100%;height:44px;display:block;border-radius:var(--r);backgro
|
|
| 208 |
<body>
|
| 209 |
<div class="app">
|
| 210 |
|
| 211 |
-
<!-- ══ SIDEBAR ════════════════════════════════════════════════ -->
|
| 212 |
<aside class="sb">
|
| 213 |
<div class="sb-logo">
|
| 214 |
<div class="logo-row">
|
|
@@ -230,30 +158,30 @@ canvas#spark{width:100%;height:44px;display:block;border-radius:var(--r);backgro
|
|
| 230 |
<button class="sb-tab" id="tab-params" onclick="switchTab('params')">Params</button>
|
| 231 |
</div>
|
| 232 |
|
| 233 |
-
<!--
|
| 234 |
<div id="stats-panel">
|
| 235 |
<div class="sb-body">
|
| 236 |
<div class="card">
|
| 237 |
<div class="ct"><span class="dot off" id="dot-s"></span>Live</div>
|
| 238 |
-
<div class="sr"><span class="sl">Throughput</span><span class="sv g"
|
| 239 |
-
<div class="sr"><span class="sl">TTFT</span>
|
| 240 |
-
<div class="sr"><span class="sl">Tokens out</span><span class="sv"
|
| 241 |
-
<div class="sr"><span class="sl">Latency</span>
|
| 242 |
</div>
|
| 243 |
<div class="card">
|
| 244 |
<div class="ct">Throughput History</div>
|
| 245 |
<canvas id="spark"></canvas>
|
| 246 |
<div style="margin-top:6px">
|
| 247 |
<div class="sr"><span class="sl">Session avg</span><span class="sv g" id="s-avg">—</span></div>
|
| 248 |
-
<div class="sr"><span class="sl">Peak</span>
|
| 249 |
</div>
|
| 250 |
</div>
|
| 251 |
<div class="card">
|
| 252 |
<div class="ct">Session</div>
|
| 253 |
-
<div class="sr"><span class="sl">Turns</span>
|
| 254 |
-
<div class="sr"><span class="sl">Total tokens</span>
|
| 255 |
-
<div class="sr"><span class="sl">KV cache</span>
|
| 256 |
-
<div class="sr"><span class="sl">Server RAM</span>
|
| 257 |
<div style="display:flex;gap:6px;margin-top:8px">
|
| 258 |
<button class="btn bs full" onclick="clearChat()">↺ Reset</button>
|
| 259 |
</div>
|
|
@@ -264,10 +192,23 @@ canvas#spark{width:100%;height:44px;display:block;border-radius:var(--r);backgro
|
|
| 264 |
<div class="sr"><span class="sl">Sessions</span><span class="sv" id="s-sess">—</span></div>
|
| 265 |
<div class="sr"><span class="sl">Uptime</span> <span class="sv" id="s-up">—</span></div>
|
| 266 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
</div>
|
| 268 |
</div>
|
| 269 |
|
| 270 |
-
<!--
|
| 271 |
<div id="bench-panel">
|
| 272 |
<div class="bench-actions">
|
| 273 |
<button class="btn bp full" id="btnbench" onclick="runBench()">▶ Run Benchmark</button>
|
|
@@ -282,13 +223,12 @@ canvas#spark{width:100%;height:44px;display:block;border-radius:var(--r);backgro
|
|
| 282 |
</div>
|
| 283 |
</div>
|
| 284 |
|
| 285 |
-
<!--
|
| 286 |
<div id="params-panel" style="display:none">
|
| 287 |
<div class="sb-body">
|
| 288 |
<div class="card">
|
| 289 |
<div class="ct">System Prompt</div>
|
| 290 |
-
<textarea class="ta" id="sysprompt" rows="4"
|
| 291 |
-
>You are a helpful, thoughtful, and articulate AI assistant.</textarea>
|
| 292 |
</div>
|
| 293 |
<div class="card">
|
| 294 |
<div class="ct">Generation</div>
|
|
@@ -314,7 +254,7 @@ canvas#spark{width:100%;height:44px;display:block;border-radius:var(--r);backgro
|
|
| 314 |
</div>
|
| 315 |
</aside>
|
| 316 |
|
| 317 |
-
<!--
|
| 318 |
<main class="chat">
|
| 319 |
<header class="chat-hdr">
|
| 320 |
<div class="badge">NanoMind · 152M</div>
|
|
@@ -346,12 +286,9 @@ canvas#spark{width:100%;height:44px;display:block;border-radius:var(--r);backgro
|
|
| 346 |
|
| 347 |
<div class="inputbar">
|
| 348 |
<div class="inputwrap">
|
| 349 |
-
<textarea id="inp" rows="1" placeholder="Send a message…"
|
| 350 |
-
onkeydown="handleKey(event)"></textarea>
|
| 351 |
<button class="sbtn" id="sbtn" onclick="send()">
|
| 352 |
-
<svg width="14" height="14" viewBox="0 0 24 24">
|
| 353 |
-
<path d="M2 21l21-9L2 3v7l15 2-15 2v7z"/>
|
| 354 |
-
</svg>
|
| 355 |
</button>
|
| 356 |
</div>
|
| 357 |
<div class="hint">Enter ↵ to send · Shift+Enter for newline</div>
|
|
@@ -360,29 +297,38 @@ canvas#spark{width:100%;height:44px;display:block;border-radius:var(--r);backgro
|
|
| 360 |
</div>
|
| 361 |
|
| 362 |
<script>
|
| 363 |
-
// ══ State ════════════════════════════════════════════════════
|
| 364 |
const API = '';
|
| 365 |
let sessId = crypto.randomUUID();
|
| 366 |
let busy = false, turns = 0, totalToks = 0;
|
| 367 |
let tpsHist = [], peakTps = 0;
|
| 368 |
|
| 369 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
function switchTab(name) {
|
| 371 |
['stats','bench','params'].forEach(t => {
|
| 372 |
const panelId = t === 'stats' ? 'stats-panel' : t + '-panel';
|
| 373 |
const panel = document.getElementById(panelId);
|
| 374 |
const tab = document.getElementById('tab-' + t);
|
| 375 |
const show = t === name;
|
| 376 |
-
|
| 377 |
-
panel.style.display = show ? 'flex' : 'none';
|
| 378 |
-
} else {
|
| 379 |
-
panel.style.display = show ? 'flex' : 'none';
|
| 380 |
-
}
|
| 381 |
tab.classList.toggle('on', show);
|
| 382 |
});
|
| 383 |
}
|
| 384 |
|
| 385 |
-
//
|
| 386 |
const inp = document.getElementById('inp');
|
| 387 |
inp.addEventListener('input', () => {
|
| 388 |
inp.style.height = 'auto';
|
|
@@ -392,7 +338,7 @@ function handleKey(e) {
|
|
| 392 |
if (e.key==='Enter' && !e.shiftKey) { e.preventDefault(); send(); }
|
| 393 |
}
|
| 394 |
|
| 395 |
-
//
|
| 396 |
function setBusy(v) {
|
| 397 |
busy = v;
|
| 398 |
document.getElementById('sbtn').disabled = v;
|
|
@@ -403,10 +349,9 @@ function setBusy(v) {
|
|
| 403 |
}
|
| 404 |
function scrollBot() { const el=document.getElementById('msgs'); el.scrollTop=el.scrollHeight; }
|
| 405 |
function hideWelcome() { const w=document.getElementById('welcome'); if(w) w.remove(); }
|
| 406 |
-
/* FIX #21: Add quote escaping to prevent XSS via innerHTML injection */
|
| 407 |
function esc(s) { return s.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,'''); }
|
| 408 |
|
| 409 |
-
//
|
| 410 |
function addUserMsg(text) {
|
| 411 |
hideWelcome();
|
| 412 |
const g = document.createElement('div'); g.className='mg user';
|
|
@@ -414,7 +359,6 @@ function addUserMsg(text) {
|
|
| 414 |
<div class="mg-body"><div class="bubble">${esc(text)}</div></div>`;
|
| 415 |
document.getElementById('msgs').appendChild(g); scrollBot();
|
| 416 |
}
|
| 417 |
-
|
| 418 |
function createAsstSlot() {
|
| 419 |
const g = document.createElement('div'); g.className='mg asst';
|
| 420 |
const bid='b'+Date.now(), mid='m'+Date.now();
|
|
@@ -427,7 +371,7 @@ function createAsstSlot() {
|
|
| 427 |
return { bubble:document.getElementById(bid), meta:document.getElementById(mid) };
|
| 428 |
}
|
| 429 |
|
| 430 |
-
//
|
| 431 |
async function send() {
|
| 432 |
if (busy) return;
|
| 433 |
const text = inp.value.trim(); if(!text) return;
|
|
@@ -435,7 +379,6 @@ async function send() {
|
|
| 435 |
addUserMsg(text); setBusy(true);
|
| 436 |
const {bubble,meta} = createAsstSlot();
|
| 437 |
let content='', t0=Date.now(), firstTok=null, tokCount=0;
|
| 438 |
-
|
| 439 |
const payload = {
|
| 440 |
message: text,
|
| 441 |
session_id: sessId,
|
|
@@ -444,10 +387,8 @@ async function send() {
|
|
| 444 |
temperature: parseFloat(document.getElementById('p-temp').value),
|
| 445 |
top_k: parseInt(document.getElementById('p-topk').value),
|
| 446 |
};
|
| 447 |
-
|
| 448 |
try {
|
| 449 |
-
const resp = await fetch(`${API}/chat`,{method:'POST',
|
| 450 |
-
headers:{'Content-Type':'application/json'},body:JSON.stringify(payload)});
|
| 451 |
if(!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
| 452 |
const reader=resp.body.getReader(), decoder=new TextDecoder();
|
| 453 |
let buf='';
|
|
@@ -460,7 +401,6 @@ async function send() {
|
|
| 460 |
if(!line.startsWith('data:')) continue;
|
| 461 |
const raw=line.slice(5).trim(); if(raw==='[DONE]') break;
|
| 462 |
let chunk; try{chunk=JSON.parse(raw);}catch{continue;}
|
| 463 |
-
|
| 464 |
if(chunk.type==='token'){
|
| 465 |
if(firstTok===null) firstTok=Date.now();
|
| 466 |
content+=chunk.text; tokCount++; totalToks++;
|
|
@@ -502,7 +442,7 @@ async function send() {
|
|
| 502 |
}
|
| 503 |
}
|
| 504 |
|
| 505 |
-
//
|
| 506 |
function drawSpark() {
|
| 507 |
const el=document.getElementById('spark'), ctx=el.getContext('2d');
|
| 508 |
const dpr=window.devicePixelRatio||1;
|
|
@@ -521,12 +461,10 @@ function drawSpark() {
|
|
| 521 |
ctx.fillStyle=grad; ctx.fill();
|
| 522 |
}
|
| 523 |
|
| 524 |
-
//
|
| 525 |
async function clearChat() {
|
| 526 |
if(busy) return;
|
| 527 |
-
await fetch(`${API}/chat/reset`,{method:'POST',
|
| 528 |
-
headers:{'Content-Type':'application/json'},
|
| 529 |
-
body:JSON.stringify({session_id:sessId})}).catch(()=>{});
|
| 530 |
sessId=crypto.randomUUID();
|
| 531 |
turns=0; totalToks=0; tpsHist=[]; peakTps=0;
|
| 532 |
document.getElementById('msgs').innerHTML=`
|
|
@@ -540,20 +478,17 @@ async function clearChat() {
|
|
| 540 |
</div>
|
| 541 |
</div>`;
|
| 542 |
['s-turns','s-totok'].forEach(id=>document.getElementById(id).textContent='0');
|
| 543 |
-
['s-tps','s-ttft','s-lat','s-avg','s-peak','s-toks','s-kv'].forEach(
|
| 544 |
-
id=>document.getElementById(id).textContent='—');
|
| 545 |
drawSpark();
|
| 546 |
}
|
| 547 |
|
| 548 |
-
//
|
| 549 |
async function pollMetrics() {
|
| 550 |
try {
|
| 551 |
const r=await fetch(`${API}/metrics`); if(!r.ok) return;
|
| 552 |
const d=await r.json();
|
| 553 |
-
document.getElementById('s-ram').textContent=
|
| 554 |
-
|
| 555 |
-
document.getElementById('s-eng').textContent=
|
| 556 |
-
(d.engines_ready||0)+' / '+(d.n_engines||'?')+' ready';
|
| 557 |
document.getElementById('s-sess').textContent=d.active_sessions||0;
|
| 558 |
document.getElementById('s-up').textContent=fmtUptime(d.uptime_s||0);
|
| 559 |
} catch {}
|
|
@@ -565,246 +500,87 @@ function fmtUptime(s){
|
|
| 565 |
}
|
| 566 |
pollMetrics(); setInterval(pollMetrics, 4000);
|
| 567 |
|
| 568 |
-
//
|
| 569 |
-
// 5 Phases — each tests something specific
|
| 570 |
const PHASES = [
|
| 571 |
-
{
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
maxNew: 60, temp: 0.1,
|
| 577 |
-
metric: 'ttft',
|
| 578 |
-
},
|
| 579 |
-
{
|
| 580 |
-
id: 'warm_ttft',
|
| 581 |
-
title: 'Phase 2 — Warm TTFT (KV Cache)',
|
| 582 |
-
desc: 'TTFT on same session — measures KV-cache speedup',
|
| 583 |
-
prompts: ["Now tell me about Tokyo's population."],
|
| 584 |
-
maxNew: 60, temp: 0.1,
|
| 585 |
-
reuseSession: true, // same session as phase 1
|
| 586 |
-
metric: 'ttft',
|
| 587 |
-
},
|
| 588 |
-
{
|
| 589 |
-
id: 'throughput',
|
| 590 |
-
title: 'Phase 3 — Throughput (tok/s)',
|
| 591 |
-
desc: '5 prompts, 80 tokens each — avg TPS',
|
| 592 |
-
prompts: [
|
| 593 |
-
"Explain machine learning in simple terms.",
|
| 594 |
-
"Write a Python function to reverse a string.",
|
| 595 |
-
"What are 3 benefits of regular exercise?",
|
| 596 |
-
"How does a neural network learn from data?",
|
| 597 |
-
"Describe the water cycle briefly.",
|
| 598 |
-
],
|
| 599 |
-
maxNew: 80, temp: 0.7,
|
| 600 |
-
metric: 'tps',
|
| 601 |
-
},
|
| 602 |
-
{
|
| 603 |
-
id: 'long_context',
|
| 604 |
-
title: 'Phase 4 — Long Context',
|
| 605 |
-
desc: 'Longer prompt input — tests attention scaling',
|
| 606 |
-
prompts: [
|
| 607 |
-
"Please provide a detailed explanation of how transformers work in natural language processing, covering the key components including attention mechanisms, positional encoding, and the encoder-decoder architecture used in models like BERT and GPT.",
|
| 608 |
-
],
|
| 609 |
-
maxNew: 100, temp: 0.5,
|
| 610 |
-
metric: 'tps',
|
| 611 |
-
},
|
| 612 |
-
{
|
| 613 |
-
id: 'consistency',
|
| 614 |
-
title: 'Phase 5 — Consistency',
|
| 615 |
-
desc: '3 identical prompts — checks TPS variance',
|
| 616 |
-
prompts: [
|
| 617 |
-
"What is machine learning?",
|
| 618 |
-
"What is machine learning?",
|
| 619 |
-
"What is machine learning?",
|
| 620 |
-
],
|
| 621 |
-
maxNew: 60, temp: 0.1,
|
| 622 |
-
metric: 'variance',
|
| 623 |
-
},
|
| 624 |
];
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
const
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
temperature: temp,
|
| 642 |
-
top_k: 40,
|
| 643 |
-
}),
|
| 644 |
-
});
|
| 645 |
-
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
| 646 |
-
|
| 647 |
-
const reader = resp.body.getReader(), decoder = new TextDecoder();
|
| 648 |
-
let buf = '';
|
| 649 |
-
while (true) {
|
| 650 |
-
const {done, value} = await reader.read(); if (done) break;
|
| 651 |
-
buf += decoder.decode(value, {stream: true});
|
| 652 |
-
let nl;
|
| 653 |
-
while ((nl = buf.indexOf('\n')) !== -1) {
|
| 654 |
-
const line = buf.slice(0, nl).trim(); buf = buf.slice(nl+1);
|
| 655 |
-
if (!line.startsWith('data:')) continue;
|
| 656 |
-
const raw = line.slice(5).trim(); if (raw === '[DONE]') break;
|
| 657 |
-
let chunk; try { chunk = JSON.parse(raw); } catch { continue; }
|
| 658 |
-
if (chunk.type === 'token') {
|
| 659 |
-
if (firstTok === null) firstTok = Date.now();
|
| 660 |
-
tokCount++;
|
| 661 |
-
} else if (chunk.type === 'done') {
|
| 662 |
-
finalTps = chunk.tps; finalMs = chunk.total_ms;
|
| 663 |
-
}
|
| 664 |
}
|
| 665 |
}
|
| 666 |
-
return
|
| 667 |
-
ttft: firstTok ? (firstTok - t0) : 0,
|
| 668 |
-
tps: finalTps,
|
| 669 |
-
totalMs: finalMs,
|
| 670 |
-
tokens: tokCount,
|
| 671 |
-
};
|
| 672 |
}
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
div.className = 'ph-card';
|
| 677 |
-
div.id = 'ph-' + phase.id;
|
| 678 |
-
div.innerHTML = `
|
| 679 |
-
<div class="ph-title">${phase.title}</div>
|
| 680 |
-
<div class="ph-label">${phase.desc}</div>
|
| 681 |
-
<div class="ph-running" id="ph-st-${phase.id}">
|
| 682 |
-
<span class="spin"></span> Running…
|
| 683 |
-
</div>
|
| 684 |
-
<div class="ph-bar"><div class="ph-fill" id="ph-bar-${phase.id}"></div></div>`;
|
| 685 |
return div;
|
| 686 |
}
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
const
|
| 696 |
-
st.innerHTML = `<div class="ph-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
</div>`;
|
| 701 |
-
return
|
| 702 |
-
|
| 703 |
-
} else if (phase.metric === 'tps') {
|
| 704 |
-
const avgTps = results.reduce((s,r)=>s+r.tps, 0) / results.length;
|
| 705 |
-
const avgTtft = results.reduce((s,r)=>s+r.ttft, 0) / results.length;
|
| 706 |
-
const cls = avgTps > 35 ? 'g' : avgTps > 20 ? 'y' : 'r';
|
| 707 |
-
st.innerHTML = `<div class="ph-stats">
|
| 708 |
-
${results.map((r,i)=>`
|
| 709 |
-
<div class="ph-stat">
|
| 710 |
-
<div class="pv" style="color:var(--${cls})">${r.tps}</div>
|
| 711 |
-
<div class="pk">P${i+1} tok/s</div>
|
| 712 |
-
</div>`).join('')}
|
| 713 |
-
<div class="ph-stat">
|
| 714 |
-
<div class="pv" style="color:var(--c)">${avgTtft.toFixed(0)}ms</div>
|
| 715 |
-
<div class="pk">avg TTFT</div>
|
| 716 |
-
</div>
|
| 717 |
-
</div>`;
|
| 718 |
-
return { label: 'Avg TPS', value: avgTps, unit: 'tok/s' };
|
| 719 |
-
|
| 720 |
-
} else if (phase.metric === 'variance') {
|
| 721 |
-
const tpsList = results.map(r=>r.tps);
|
| 722 |
-
const avg = tpsList.reduce((a,b)=>a+b,0)/tpsList.length;
|
| 723 |
-
const variance= tpsList.reduce((s,v)=>s+Math.pow(v-avg,2),0)/tpsList.length;
|
| 724 |
-
const stddev = Math.sqrt(variance).toFixed(1);
|
| 725 |
-
st.innerHTML = `<div class="ph-stats">
|
| 726 |
-
${tpsList.map((t,i)=>`<div class="ph-stat">
|
| 727 |
-
<div class="pv">${t}</div><div class="pk">run ${i+1}</div>
|
| 728 |
-
</div>`).join('')}
|
| 729 |
-
<div class="ph-stat">
|
| 730 |
-
<div class="pv" style="color:var(--c)">±${stddev}</div>
|
| 731 |
-
<div class="pk">std dev</div>
|
| 732 |
-
</div>
|
| 733 |
-
</div>`;
|
| 734 |
-
return { label: 'Std Dev', value: parseFloat(stddev), unit: '±' };
|
| 735 |
}
|
| 736 |
}
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
const
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
let summaryData = {};
|
| 753 |
-
|
| 754 |
-
for (const phase of PHASES) {
|
| 755 |
-
const card = mkPhaseCard(phase);
|
| 756 |
-
scroll.appendChild(card);
|
| 757 |
-
scroll.scrollTop = scroll.scrollHeight;
|
| 758 |
-
|
| 759 |
-
const bar = document.getElementById('ph-bar-' + phase.id);
|
| 760 |
-
const results = [];
|
| 761 |
-
|
| 762 |
-
try {
|
| 763 |
-
for (let i=0; i < phase.prompts.length; i++) {
|
| 764 |
-
const sid = phase.reuseSession ? coldSessId : crypto.randomUUID();
|
| 765 |
-
if (phase.id === 'cold_ttft') coldSessId = sid;
|
| 766 |
-
|
| 767 |
-
bar.style.width = ((i / phase.prompts.length) * 80) + '%';
|
| 768 |
-
const r = await runSinglePrompt(phase.prompts[i], phase.maxNew, phase.temp, sid);
|
| 769 |
results.push(r);
|
| 770 |
}
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
`<span style="color:var(--red)">✗ ${e.message}</span>`;
|
| 776 |
-
bar.style.background = 'var(--red)'; bar.style.width = '100%';
|
| 777 |
}
|
| 778 |
}
|
| 779 |
-
|
| 780 |
-
|
| 781 |
-
const p3 =
|
| 782 |
-
const
|
| 783 |
-
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
const coldTtft = p1 ? p1.value.toFixed(0) : '—';
|
| 787 |
-
const warmTtft = p2 ? p2.value.toFixed(0) : '—';
|
| 788 |
-
const cacheGain = (p1 && p2) ? ((p1.value - p2.value) / p1.value * 100).toFixed(0) : '—';
|
| 789 |
-
|
| 790 |
-
const verdict = p3 && p3.value > 35
|
| 791 |
-
? `<div class="verdict good">✓ Throughput target met — ${avgTps} tok/s exceeds 35 tok/s baseline</div>`
|
| 792 |
-
: `<div class="verdict mid">△ Throughput at ${avgTps} tok/s — within expected range</div>`;
|
| 793 |
-
|
| 794 |
-
const summary = document.createElement('div');
|
| 795 |
-
summary.innerHTML = `
|
| 796 |
-
${verdict}
|
| 797 |
-
<div class="b-grid">
|
| 798 |
-
<div class="b-stat"><div class="bv">${avgTps}</div><div class="bk">Avg tok/s</div></div>
|
| 799 |
-
<div class="b-stat"><div class="bv">${coldTtft}ms</div><div class="bk">Cold TTFT</div></div>
|
| 800 |
-
<div class="b-stat"><div class="bv">${warmTtft}ms</div><div class="bk">Warm TTFT</div></div>
|
| 801 |
-
<div class="b-stat"><div class="bv">${cacheGain}%</div><div class="bk">Cache Speedup</div></div>
|
| 802 |
-
</div>`;
|
| 803 |
-
scroll.insertBefore(summary, scroll.firstChild);
|
| 804 |
-
|
| 805 |
-
btn.textContent = '↺ Run Again'; btn.disabled = false;
|
| 806 |
-
benchRunning = false;
|
| 807 |
}
|
| 808 |
</script>
|
| 809 |
</body>
|
| 810 |
-
</html>
|
|
|
|
| 19 |
}
|
| 20 |
html,body{height:100%;background:var(--bg);color:var(--t0);font-family:var(--mono);font-size:13px;overflow:hidden}
|
| 21 |
.app{display:flex;height:100vh}
|
|
|
|
|
|
|
| 22 |
.app::before{content:'';position:fixed;inset:0;
|
| 23 |
background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
|
| 24 |
pointer-events:none;z-index:0;opacity:.4}
|
| 25 |
.app>*{position:relative;z-index:1}
|
| 26 |
+
.sb{width:var(--sb);min-width:var(--sb);background:var(--bg1);border-right:1px solid var(--bg3);display:flex;flex-direction:column;overflow:hidden}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
.sb-logo{padding:16px;background:var(--bg);border-bottom:1px solid var(--bg3);flex-shrink:0}
|
| 28 |
.logo-row{display:flex;align-items:center;gap:10px}
|
| 29 |
+
.logo-icon{width:34px;height:34px;border-radius:9px;background:linear-gradient(135deg,var(--acc3),var(--acc2));display:flex;align-items:center;justify-content:center;flex-shrink:0;box-shadow:0 0 20px rgba(124,107,255,.35)}
|
|
|
|
|
|
|
|
|
|
| 30 |
.logo-icon svg{fill:#fff}
|
| 31 |
+
.logo-text h2{font-family:var(--sans);font-size:18px;font-weight:900;letter-spacing:-.04em;color:var(--t0)}
|
|
|
|
| 32 |
.logo-text h2 em{color:var(--acc2);font-style:normal}
|
| 33 |
+
.logo-text p{font-size:9px;color:var(--t2);margin-top:2px;letter-spacing:.1em;text-transform:uppercase}
|
|
|
|
|
|
|
|
|
|
| 34 |
.sb-tabs{display:flex;border-bottom:1px solid var(--bg3);flex-shrink:0;background:var(--bg1)}
|
| 35 |
+
.sb-tab{flex:1;padding:8px 4px;text-align:center;font-size:9px;font-weight:700;color:var(--t2);text-transform:uppercase;letter-spacing:.08em;cursor:pointer;border:none;background:none;font-family:var(--mono);border-bottom:2px solid transparent;transition:.15s}
|
|
|
|
|
|
|
|
|
|
| 36 |
.sb-tab.on{color:var(--acc2);border-bottom-color:var(--acc);background:var(--dim)}
|
| 37 |
+
.sb-body{flex:1;overflow-y:auto;padding:10px;scrollbar-width:thin;scrollbar-color:var(--bg4) transparent}
|
| 38 |
+
.card{background:var(--bg2);border:1px solid var(--bg3);border-radius:var(--r);padding:11px 13px;margin-bottom:8px}
|
| 39 |
+
.ct{font-size:9px;font-weight:700;color:var(--t2);text-transform:uppercase;letter-spacing:.1em;margin-bottom:8px;display:flex;align-items:center;gap:6px}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
.sr{display:flex;justify-content:space-between;align-items:center;padding:3px 0}
|
| 41 |
.sl{color:var(--t1);font-size:11px}
|
| 42 |
.sv{font-size:12px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--t0)}
|
| 43 |
.g{color:var(--green)}.c{color:var(--cyan)}.y{color:var(--warn)}.r{color:var(--red)}.p{color:var(--acc2)}
|
|
|
|
|
|
|
| 44 |
.dot{display:inline-block;width:6px;height:6px;border-radius:50%;flex-shrink:0}
|
| 45 |
.dot.off{background:var(--t3)}.dot.on{background:var(--green);animation:pulse 1.4s infinite}
|
| 46 |
@keyframes pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.3;transform:scale(.7)}}
|
|
|
|
| 47 |
canvas#spark{width:100%;height:44px;display:block;border-radius:var(--r);background:var(--bg)}
|
| 48 |
+
.ta{width:100%;background:var(--bg);border:1px solid var(--bg3);border-radius:var(--r);color:var(--t0);font-size:11px;padding:8px 10px;resize:vertical;min-height:56px;font-family:var(--mono);line-height:1.6}
|
|
|
|
|
|
|
|
|
|
| 49 |
.ta:focus{outline:none;border-color:var(--acc)}
|
|
|
|
| 50 |
.pg{display:flex;flex-direction:column;gap:4px}
|
| 51 |
+
.pg label{font-size:9px;color:var(--t2);text-transform:uppercase;letter-spacing:.08em;display:flex;justify-content:space-between}
|
|
|
|
| 52 |
.pg label span{color:var(--acc2);font-weight:700}
|
| 53 |
+
.pg input[type=range]{width:100%;-webkit-appearance:none;height:2px;background:var(--bg4);border-radius:1px;outline:none}
|
| 54 |
+
.pg input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:11px;height:11px;border-radius:50%;background:var(--acc);cursor:pointer;border:2px solid var(--bg1)}
|
| 55 |
+
.btn{display:inline-flex;align-items:center;gap:5px;padding:6px 12px;border-radius:var(--r);border:1px solid var(--bg4);cursor:pointer;font-size:10px;font-weight:700;font-family:var(--mono);text-transform:uppercase;letter-spacing:.05em;transition:.13s}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
.bp{background:var(--acc);color:#fff;border-color:var(--acc)}
|
| 57 |
.bp:hover{background:var(--acc2)}.bs{background:var(--bg3);color:var(--t1)}
|
| 58 |
.bs:hover{background:var(--bg4);color:var(--t0)}
|
| 59 |
.btn.full{width:100%;justify-content:center}.btn:disabled{opacity:.3;cursor:not-allowed}
|
| 60 |
|
| 61 |
+
/* ── Filter items ── */
|
| 62 |
+
.fi{display:flex;align-items:center;gap:8px;padding:5px 7px;border-radius:6px;cursor:pointer;border:1px solid transparent;transition:.12s;margin-bottom:3px;user-select:none}
|
| 63 |
+
.fi:hover{background:var(--bg3)}
|
| 64 |
+
.fi.on{background:rgba(124,107,255,.1);border-color:rgba(124,107,255,.25)}
|
| 65 |
+
.fi.stories-on{background:rgba(61,220,255,.08);border-color:rgba(61,220,255,.25)}
|
| 66 |
+
.fcb{width:13px;height:13px;border-radius:3px;border:1px solid var(--bg4);background:var(--bg);display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:.12s}
|
| 67 |
+
.fi.on .fcb{background:var(--acc);border-color:var(--acc)}
|
| 68 |
+
.fi.stories-on .fcb{background:var(--cyan);border-color:var(--cyan)}
|
| 69 |
+
.fcb svg{opacity:0;transition:.1s}
|
| 70 |
+
.fi.on .fcb svg,.fi.stories-on .fcb svg{opacity:1}
|
| 71 |
+
.fdot{width:6px;height:6px;border-radius:50%;flex-shrink:0}
|
| 72 |
+
.flabel{font-size:11px;color:var(--t1)}
|
| 73 |
+
.fi.on .flabel,.fi.stories-on .flabel{color:var(--t0)}
|
| 74 |
+
|
| 75 |
#bench-panel{display:none;flex-direction:column;height:100%;overflow:hidden}
|
| 76 |
#bench-panel.visible{display:flex}
|
| 77 |
#stats-panel,#params-panel{display:flex;flex-direction:column;flex:1;overflow:hidden}
|
|
|
|
| 78 |
.bench-actions{padding:10px;flex-shrink:0;display:flex;flex-direction:column;gap:6px}
|
| 79 |
+
.bench-scroll{flex:1;overflow-y:auto;padding:0 10px 10px;scrollbar-width:thin;scrollbar-color:var(--bg4) transparent}
|
|
|
|
|
|
|
|
|
|
| 80 |
.b-grid{display:grid;grid-template-columns:1fr 1fr;gap:5px;margin-bottom:10px}
|
| 81 |
+
.b-stat{background:var(--bg2);border:1px solid var(--bg3);border-radius:var(--r);padding:10px;text-align:center}
|
| 82 |
+
.b-stat .bv{font-family:var(--sans);font-size:22px;font-weight:900;color:var(--acc2);letter-spacing:-.04em}
|
| 83 |
+
.b-stat .bk{font-size:9px;color:var(--t2);text-transform:uppercase;letter-spacing:.1em;margin-top:2px}
|
| 84 |
+
.ph-card{background:var(--bg2);border:1px solid var(--bg3);border-radius:var(--r);padding:9px 11px;margin-bottom:6px;animation:fadeup .2s ease}
|
| 85 |
+
.ph-title{font-size:9px;font-weight:700;color:var(--acc2);text-transform:uppercase;letter-spacing:.08em;margin-bottom:6px}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
.ph-label{font-size:11px;color:var(--t2);margin-bottom:4px}
|
| 87 |
.ph-stats{display:flex;gap:8px;flex-wrap:wrap;margin-top:5px}
|
| 88 |
.ph-stat{display:flex;flex-direction:column;gap:1px;min-width:50px}
|
| 89 |
.ph-stat .pv{font-size:13px;font-weight:700;color:var(--green);font-variant-numeric:tabular-nums}
|
| 90 |
.ph-stat .pk{font-size:9px;color:var(--t2);text-transform:uppercase;letter-spacing:.06em}
|
| 91 |
.ph-bar{height:2px;background:var(--bg4);border-radius:1px;margin-top:5px;overflow:hidden}
|
| 92 |
+
.ph-fill{height:100%;background:linear-gradient(90deg,var(--acc3),var(--acc2));border-radius:1px;transition:width .5s ease;width:0%}
|
|
|
|
| 93 |
.ph-running{display:flex;align-items:center;gap:5px;font-size:10px;color:var(--warn)}
|
| 94 |
+
.spin{width:8px;height:8px;border:1.5px solid var(--warn);border-top-color:transparent;border-radius:50%;animation:spin .7s linear infinite;flex-shrink:0}
|
|
|
|
| 95 |
@keyframes spin{to{transform:rotate(360deg)}}
|
| 96 |
.bench-empty{text-align:center;padding:30px 16px;color:var(--t2);font-size:12px;line-height:1.9}
|
| 97 |
+
.verdict{padding:10px 12px;border-radius:var(--r);font-size:11px;margin-bottom:8px;border:1px solid var(--bg3)}
|
|
|
|
| 98 |
.verdict.good{border-color:rgba(61,255,180,.3);background:rgba(61,255,180,.06);color:var(--green)}
|
| 99 |
.verdict.mid{border-color:rgba(255,194,96,.3);background:rgba(255,194,96,.06);color:var(--warn)}
|
|
|
|
|
|
|
| 100 |
.chat{flex:1;display:flex;flex-direction:column;overflow:hidden}
|
| 101 |
+
.chat-hdr{height:50px;display:flex;align-items:center;padding:0 20px;border-bottom:1px solid var(--bg3);background:var(--bg1);gap:8px;flex-shrink:0}
|
| 102 |
+
.badge{background:var(--dim);border:1px solid rgba(124,107,255,.3);border-radius:20px;padding:3px 10px;font-size:10px;font-weight:700;color:var(--acc2);font-family:var(--sans)}
|
|
|
|
|
|
|
|
|
|
| 103 |
.hdr-title{font-family:var(--sans);font-size:13px;font-weight:600;color:var(--t1)}
|
| 104 |
.spc{flex:1}
|
| 105 |
+
.hpill{display:flex;align-items:center;gap:6px;font-size:10px;color:var(--t2);text-transform:uppercase;letter-spacing:.06em}
|
| 106 |
+
.msgs{flex:1;overflow-y:auto;display:flex;flex-direction:column;scrollbar-width:thin;scrollbar-color:var(--bg4) transparent}
|
| 107 |
+
.welcome{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;text-align:center;padding:40px;animation:fadeup .4s ease}
|
| 108 |
+
.wlogo{font-family:var(--sans);font-size:72px;font-weight:900;background:linear-gradient(135deg,var(--acc),var(--cyan));-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;letter-spacing:-.05em;line-height:1}
|
| 109 |
+
.welcome h2{font-family:var(--sans);font-size:22px;font-weight:700;color:var(--t0);letter-spacing:-.02em}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
.welcome p{max-width:400px;line-height:1.8;font-size:12px;color:var(--t1)}
|
| 111 |
.chips{display:flex;gap:6px;flex-wrap:wrap;justify-content:center;margin-top:2px}
|
| 112 |
+
.chip{font-size:9px;padding:4px 10px;border:1px solid var(--bg4);border-radius:20px;color:var(--t2);letter-spacing:.07em;text-transform:uppercase;background:var(--bg2)}
|
| 113 |
+
.mg{display:flex;gap:0;padding:14px 20px;border-bottom:1px solid var(--bg3);animation:fadeup .18s ease}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
.mg:last-child{border-bottom:none}
|
| 115 |
@keyframes fadeup{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
|
| 116 |
.mg-role{width:60px;flex-shrink:0;padding-top:2px}
|
| 117 |
.mlabel{font-size:9px;font-weight:700;letter-spacing:.1em;text-transform:uppercase}
|
| 118 |
.mg.user .mlabel{color:var(--acc2)}.mg.asst .mlabel{color:var(--cyan)}
|
| 119 |
.mg-body{flex:1;min-width:0}
|
| 120 |
+
.bubble{font-size:13px;line-height:1.75;color:var(--t1);white-space:pre-wrap;word-break:break-word;max-width:660px}
|
|
|
|
| 121 |
.mg.user .bubble{color:var(--t2)}
|
| 122 |
+
.cur{display:inline-block;width:7px;height:2px;background:var(--acc2);margin-left:3px;vertical-align:middle;animation:blink .6s infinite}
|
|
|
|
| 123 |
@keyframes blink{0%,49%{opacity:1}50%,100%{opacity:0}}
|
| 124 |
.bmeta{font-size:10px;color:var(--t3);margin-top:5px;display:flex;flex-wrap:wrap;gap:8px}
|
| 125 |
.bmeta b{color:var(--acc2)}
|
| 126 |
+
.inputbar{padding:12px 16px;border-top:1px solid var(--bg3);background:var(--bg1);flex-shrink:0}
|
| 127 |
+
.inputwrap{background:var(--bg2);border:1px solid var(--bg3);border-radius:var(--r);display:flex;align-items:flex-end;padding:3px 3px 3px 12px;gap:4px;transition:.13s}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
.inputwrap:focus-within{border-color:var(--acc)}
|
| 129 |
+
#inp{flex:1;background:none;border:none;outline:none;color:var(--t0);font-size:13px;font-family:var(--mono);resize:none;line-height:1.6;max-height:110px;padding:7px 0}
|
|
|
|
|
|
|
| 130 |
#inp::placeholder{color:var(--t3)}
|
| 131 |
+
.sbtn{background:linear-gradient(135deg,var(--acc3),var(--acc2));border:none;cursor:pointer;width:32px;height:32px;border-radius:6px;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:.13s;align-self:flex-end;margin-bottom:3px;box-shadow:0 0 12px rgba(124,107,255,.4)}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
.sbtn:hover{filter:brightness(1.15)}.sbtn:disabled{opacity:.3;cursor:not-allowed}
|
| 133 |
.sbtn svg{fill:#fff}
|
| 134 |
.hint{margin-top:5px;font-size:10px;color:var(--t3);text-align:right;letter-spacing:.04em}
|
|
|
|
| 137 |
<body>
|
| 138 |
<div class="app">
|
| 139 |
|
|
|
|
| 140 |
<aside class="sb">
|
| 141 |
<div class="sb-logo">
|
| 142 |
<div class="logo-row">
|
|
|
|
| 158 |
<button class="sb-tab" id="tab-params" onclick="switchTab('params')">Params</button>
|
| 159 |
</div>
|
| 160 |
|
| 161 |
+
<!-- Stats Tab -->
|
| 162 |
<div id="stats-panel">
|
| 163 |
<div class="sb-body">
|
| 164 |
<div class="card">
|
| 165 |
<div class="ct"><span class="dot off" id="dot-s"></span>Live</div>
|
| 166 |
+
<div class="sr"><span class="sl">Throughput</span><span class="sv g" id="s-tps">—</span></div>
|
| 167 |
+
<div class="sr"><span class="sl">TTFT</span> <span class="sv c" id="s-ttft">—</span></div>
|
| 168 |
+
<div class="sr"><span class="sl">Tokens out</span><span class="sv" id="s-toks">—</span></div>
|
| 169 |
+
<div class="sr"><span class="sl">Latency</span> <span class="sv y" id="s-lat">—</span></div>
|
| 170 |
</div>
|
| 171 |
<div class="card">
|
| 172 |
<div class="ct">Throughput History</div>
|
| 173 |
<canvas id="spark"></canvas>
|
| 174 |
<div style="margin-top:6px">
|
| 175 |
<div class="sr"><span class="sl">Session avg</span><span class="sv g" id="s-avg">—</span></div>
|
| 176 |
+
<div class="sr"><span class="sl">Peak</span> <span class="sv g" id="s-peak">—</span></div>
|
| 177 |
</div>
|
| 178 |
</div>
|
| 179 |
<div class="card">
|
| 180 |
<div class="ct">Session</div>
|
| 181 |
+
<div class="sr"><span class="sl">Turns</span> <span class="sv" id="s-turns">0</span></div>
|
| 182 |
+
<div class="sr"><span class="sl">Total tokens</span><span class="sv" id="s-totok">0</span></div>
|
| 183 |
+
<div class="sr"><span class="sl">KV cache</span> <span class="sv c" id="s-kv">—</span></div>
|
| 184 |
+
<div class="sr"><span class="sl">Server RAM</span> <span class="sv" id="s-ram">—</span></div>
|
| 185 |
<div style="display:flex;gap:6px;margin-top:8px">
|
| 186 |
<button class="btn bs full" onclick="clearChat()">↺ Reset</button>
|
| 187 |
</div>
|
|
|
|
| 192 |
<div class="sr"><span class="sl">Sessions</span><span class="sv" id="s-sess">—</span></div>
|
| 193 |
<div class="sr"><span class="sl">Uptime</span> <span class="sv" id="s-up">—</span></div>
|
| 194 |
</div>
|
| 195 |
+
|
| 196 |
+
<!-- ══ FILTERS CARD ══ -->
|
| 197 |
+
<div class="card">
|
| 198 |
+
<div class="ct">Filters</div>
|
| 199 |
+
<!-- Stories — redirects to inference space -->
|
| 200 |
+
<div class="fi" id="fi-stories" onclick="goStories()">
|
| 201 |
+
<div class="fcb"><svg width="8" height="6" viewBox="0 0 8 6" fill="none"><path d="M1 3l2 2 4-4" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg></div>
|
| 202 |
+
<div class="fdot" style="background:var(--cyan)"></div>
|
| 203 |
+
<span class="flabel">Stories ↗</span>
|
| 204 |
+
</div>
|
| 205 |
+
</div>
|
| 206 |
+
<!-- ══ END FILTERS CARD ══ -->
|
| 207 |
+
|
| 208 |
</div>
|
| 209 |
</div>
|
| 210 |
|
| 211 |
+
<!-- Benchmark Tab -->
|
| 212 |
<div id="bench-panel">
|
| 213 |
<div class="bench-actions">
|
| 214 |
<button class="btn bp full" id="btnbench" onclick="runBench()">▶ Run Benchmark</button>
|
|
|
|
| 223 |
</div>
|
| 224 |
</div>
|
| 225 |
|
| 226 |
+
<!-- Params Tab -->
|
| 227 |
<div id="params-panel" style="display:none">
|
| 228 |
<div class="sb-body">
|
| 229 |
<div class="card">
|
| 230 |
<div class="ct">System Prompt</div>
|
| 231 |
+
<textarea class="ta" id="sysprompt" rows="4">You are a helpful, thoughtful, and articulate AI assistant.</textarea>
|
|
|
|
| 232 |
</div>
|
| 233 |
<div class="card">
|
| 234 |
<div class="ct">Generation</div>
|
|
|
|
| 254 |
</div>
|
| 255 |
</aside>
|
| 256 |
|
| 257 |
+
<!-- CHAT -->
|
| 258 |
<main class="chat">
|
| 259 |
<header class="chat-hdr">
|
| 260 |
<div class="badge">NanoMind · 152M</div>
|
|
|
|
| 286 |
|
| 287 |
<div class="inputbar">
|
| 288 |
<div class="inputwrap">
|
| 289 |
+
<textarea id="inp" rows="1" placeholder="Send a message…" onkeydown="handleKey(event)"></textarea>
|
|
|
|
| 290 |
<button class="sbtn" id="sbtn" onclick="send()">
|
| 291 |
+
<svg width="14" height="14" viewBox="0 0 24 24"><path d="M2 21l21-9L2 3v7l15 2-15 2v7z"/></svg>
|
|
|
|
|
|
|
| 292 |
</button>
|
| 293 |
</div>
|
| 294 |
<div class="hint">Enter ↵ to send · Shift+Enter for newline</div>
|
|
|
|
| 297 |
</div>
|
| 298 |
|
| 299 |
<script>
|
|
|
|
| 300 |
const API = '';
|
| 301 |
let sessId = crypto.randomUUID();
|
| 302 |
let busy = false, turns = 0, totalToks = 0;
|
| 303 |
let tpsHist = [], peakTps = 0;
|
| 304 |
|
| 305 |
+
// ── Filter logic ─────────────────────────────────────────────
|
| 306 |
+
function toggleFilter(el, key) {
|
| 307 |
+
el.classList.toggle('on');
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
function goStories() {
|
| 311 |
+
const el = document.getElementById('fi-stories');
|
| 312 |
+
el.classList.add('stories-on');
|
| 313 |
+
setTimeout(() => {
|
| 314 |
+
window.open('https://not-omega-inference.hf.space/', '_blank');
|
| 315 |
+
setTimeout(() => el.classList.remove('stories-on'), 400);
|
| 316 |
+
}, 160);
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
// ── Tab Switch ───────────────────────────────────────────────
|
| 320 |
function switchTab(name) {
|
| 321 |
['stats','bench','params'].forEach(t => {
|
| 322 |
const panelId = t === 'stats' ? 'stats-panel' : t + '-panel';
|
| 323 |
const panel = document.getElementById(panelId);
|
| 324 |
const tab = document.getElementById('tab-' + t);
|
| 325 |
const show = t === name;
|
| 326 |
+
panel.style.display = show ? 'flex' : 'none';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
tab.classList.toggle('on', show);
|
| 328 |
});
|
| 329 |
}
|
| 330 |
|
| 331 |
+
// ── Input ────────────────────────────────────────────────────
|
| 332 |
const inp = document.getElementById('inp');
|
| 333 |
inp.addEventListener('input', () => {
|
| 334 |
inp.style.height = 'auto';
|
|
|
|
| 338 |
if (e.key==='Enter' && !e.shiftKey) { e.preventDefault(); send(); }
|
| 339 |
}
|
| 340 |
|
| 341 |
+
// ── UI Helpers ───────────────────────────────────────────────
|
| 342 |
function setBusy(v) {
|
| 343 |
busy = v;
|
| 344 |
document.getElementById('sbtn').disabled = v;
|
|
|
|
| 349 |
}
|
| 350 |
function scrollBot() { const el=document.getElementById('msgs'); el.scrollTop=el.scrollHeight; }
|
| 351 |
function hideWelcome() { const w=document.getElementById('welcome'); if(w) w.remove(); }
|
|
|
|
| 352 |
function esc(s) { return s.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,'''); }
|
| 353 |
|
| 354 |
+
// ── Messages ─────────────────────────────────────────────────
|
| 355 |
function addUserMsg(text) {
|
| 356 |
hideWelcome();
|
| 357 |
const g = document.createElement('div'); g.className='mg user';
|
|
|
|
| 359 |
<div class="mg-body"><div class="bubble">${esc(text)}</div></div>`;
|
| 360 |
document.getElementById('msgs').appendChild(g); scrollBot();
|
| 361 |
}
|
|
|
|
| 362 |
function createAsstSlot() {
|
| 363 |
const g = document.createElement('div'); g.className='mg asst';
|
| 364 |
const bid='b'+Date.now(), mid='m'+Date.now();
|
|
|
|
| 371 |
return { bubble:document.getElementById(bid), meta:document.getElementById(mid) };
|
| 372 |
}
|
| 373 |
|
| 374 |
+
// ── Send ─────────────────────────────────────────────────────
|
| 375 |
async function send() {
|
| 376 |
if (busy) return;
|
| 377 |
const text = inp.value.trim(); if(!text) return;
|
|
|
|
| 379 |
addUserMsg(text); setBusy(true);
|
| 380 |
const {bubble,meta} = createAsstSlot();
|
| 381 |
let content='', t0=Date.now(), firstTok=null, tokCount=0;
|
|
|
|
| 382 |
const payload = {
|
| 383 |
message: text,
|
| 384 |
session_id: sessId,
|
|
|
|
| 387 |
temperature: parseFloat(document.getElementById('p-temp').value),
|
| 388 |
top_k: parseInt(document.getElementById('p-topk').value),
|
| 389 |
};
|
|
|
|
| 390 |
try {
|
| 391 |
+
const resp = await fetch(`${API}/chat`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(payload)});
|
|
|
|
| 392 |
if(!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
| 393 |
const reader=resp.body.getReader(), decoder=new TextDecoder();
|
| 394 |
let buf='';
|
|
|
|
| 401 |
if(!line.startsWith('data:')) continue;
|
| 402 |
const raw=line.slice(5).trim(); if(raw==='[DONE]') break;
|
| 403 |
let chunk; try{chunk=JSON.parse(raw);}catch{continue;}
|
|
|
|
| 404 |
if(chunk.type==='token'){
|
| 405 |
if(firstTok===null) firstTok=Date.now();
|
| 406 |
content+=chunk.text; tokCount++; totalToks++;
|
|
|
|
| 442 |
}
|
| 443 |
}
|
| 444 |
|
| 445 |
+
// ── Sparkline ────────────────────────────────────────────────
|
| 446 |
function drawSpark() {
|
| 447 |
const el=document.getElementById('spark'), ctx=el.getContext('2d');
|
| 448 |
const dpr=window.devicePixelRatio||1;
|
|
|
|
| 461 |
ctx.fillStyle=grad; ctx.fill();
|
| 462 |
}
|
| 463 |
|
| 464 |
+
// ── Clear ────────────────────────────────────────────────────
|
| 465 |
async function clearChat() {
|
| 466 |
if(busy) return;
|
| 467 |
+
await fetch(`${API}/chat/reset`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({session_id:sessId})}).catch(()=>{});
|
|
|
|
|
|
|
| 468 |
sessId=crypto.randomUUID();
|
| 469 |
turns=0; totalToks=0; tpsHist=[]; peakTps=0;
|
| 470 |
document.getElementById('msgs').innerHTML=`
|
|
|
|
| 478 |
</div>
|
| 479 |
</div>`;
|
| 480 |
['s-turns','s-totok'].forEach(id=>document.getElementById(id).textContent='0');
|
| 481 |
+
['s-tps','s-ttft','s-lat','s-avg','s-peak','s-toks','s-kv'].forEach(id=>document.getElementById(id).textContent='—');
|
|
|
|
| 482 |
drawSpark();
|
| 483 |
}
|
| 484 |
|
| 485 |
+
// ── Metrics Poll ─────────────────────────────────────────────
|
| 486 |
async function pollMetrics() {
|
| 487 |
try {
|
| 488 |
const r=await fetch(`${API}/metrics`); if(!r.ok) return;
|
| 489 |
const d=await r.json();
|
| 490 |
+
document.getElementById('s-ram').textContent=d.system_ram_used_pct.toFixed(0)+'% ('+d.process_ram_mb+'MB)';
|
| 491 |
+
document.getElementById('s-eng').textContent=(d.engines_ready||0)+' / '+(d.n_engines||'?')+' ready';
|
|
|
|
|
|
|
| 492 |
document.getElementById('s-sess').textContent=d.active_sessions||0;
|
| 493 |
document.getElementById('s-up').textContent=fmtUptime(d.uptime_s||0);
|
| 494 |
} catch {}
|
|
|
|
| 500 |
}
|
| 501 |
pollMetrics(); setInterval(pollMetrics, 4000);
|
| 502 |
|
| 503 |
+
// ── Benchmark ────────────────────────────────────────────────
|
|
|
|
| 504 |
const PHASES = [
|
| 505 |
+
{id:'cold_ttft',title:'Phase 1 — Cold TTFT',desc:'First token latency on a fresh session',prompts:["What is the capital of Japan?"],maxNew:60,temp:0.1,metric:'ttft'},
|
| 506 |
+
{id:'warm_ttft',title:'Phase 2 — Warm TTFT (KV Cache)',desc:'TTFT on same session — measures KV-cache speedup',prompts:["Now tell me about Tokyo's population."],maxNew:60,temp:0.1,reuseSession:true,metric:'ttft'},
|
| 507 |
+
{id:'throughput',title:'Phase 3 — Throughput (tok/s)',desc:'5 prompts, 80 tokens each — avg TPS',prompts:["Explain machine learning in simple terms.","Write a Python function to reverse a string.","What are 3 benefits of regular exercise?","How does a neural network learn from data?","Describe the water cycle briefly."],maxNew:80,temp:0.7,metric:'tps'},
|
| 508 |
+
{id:'long_context',title:'Phase 4 — Long Context',desc:'Longer prompt input — tests attention scaling',prompts:["Please provide a detailed explanation of how transformers work in natural language processing, covering the key components including attention mechanisms, positional encoding, and the encoder-decoder architecture used in models like BERT and GPT."],maxNew:100,temp:0.5,metric:'tps'},
|
| 509 |
+
{id:'consistency',title:'Phase 5 — Consistency',desc:'3 identical prompts — checks TPS variance',prompts:["What is machine learning?","What is machine learning?","What is machine learning?"],maxNew:60,temp:0.1,metric:'variance'},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
];
|
| 511 |
+
let benchRunning=false, coldSessId=null;
|
| 512 |
+
async function runSinglePrompt(prompt,maxNew,temp,sessionId){
|
| 513 |
+
const t0=Date.now(); let firstTok=null,tokCount=0,finalTps=0,finalMs=0;
|
| 514 |
+
const resp=await fetch(`${API}/chat`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({message:prompt,session_id:sessionId,system_prompt:'You are a helpful assistant.',max_new_tokens:maxNew,temperature:temp,top_k:40})});
|
| 515 |
+
if(!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
| 516 |
+
const reader=resp.body.getReader(), decoder=new TextDecoder(); let buf='';
|
| 517 |
+
while(true){
|
| 518 |
+
const {done,value}=await reader.read(); if(done) break;
|
| 519 |
+
buf+=decoder.decode(value,{stream:true}); let nl;
|
| 520 |
+
while((nl=buf.indexOf('\n'))!==-1){
|
| 521 |
+
const line=buf.slice(0,nl).trim(); buf=buf.slice(nl+1);
|
| 522 |
+
if(!line.startsWith('data:')) continue;
|
| 523 |
+
const raw=line.slice(5).trim(); if(raw==='[DONE]') break;
|
| 524 |
+
let chunk; try{chunk=JSON.parse(raw);}catch{continue;}
|
| 525 |
+
if(chunk.type==='token'){if(firstTok===null)firstTok=Date.now();tokCount++;}
|
| 526 |
+
else if(chunk.type==='done'){finalTps=chunk.tps;finalMs=chunk.total_ms;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 527 |
}
|
| 528 |
}
|
| 529 |
+
return{ttft:firstTok?(firstTok-t0):0,tps:finalTps,totalMs:finalMs,tokens:tokCount};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 530 |
}
|
| 531 |
+
function mkPhaseCard(phase){
|
| 532 |
+
const div=document.createElement('div'); div.className='ph-card'; div.id='ph-'+phase.id;
|
| 533 |
+
div.innerHTML=`<div class="ph-title">${phase.title}</div><div class="ph-label">${phase.desc}</div><div class="ph-running" id="ph-st-${phase.id}"><span class="spin"></span> Running…</div><div class="ph-bar"><div class="ph-fill" id="ph-bar-${phase.id}"></div></div>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 534 |
return div;
|
| 535 |
}
|
| 536 |
+
function setPhaseResult(phase,results){
|
| 537 |
+
const st=document.getElementById('ph-st-'+phase.id), bar=document.getElementById('ph-bar-'+phase.id);
|
| 538 |
+
bar.style.width='100%';
|
| 539 |
+
if(phase.metric==='ttft'){
|
| 540 |
+
const avg=results.reduce((s,r)=>s+r.ttft,0)/results.length, cls=avg<1000?'g':avg<2000?'y':'r';
|
| 541 |
+
st.innerHTML=`<div class="ph-stats"><div class="ph-stat"><div class="pv" style="color:var(--${cls})">${avg.toFixed(0)}ms</div><div class="pk">TTFT</div></div><div class="ph-stat"><div class="pv">${results[0].tokens}</div><div class="pk">tokens</div></div><div class="ph-stat"><div class="pv">${results[0].tps}</div><div class="pk">tok/s</div></div></div>`;
|
| 542 |
+
return{label:'TTFT',value:avg,unit:'ms'};
|
| 543 |
+
} else if(phase.metric==='tps'){
|
| 544 |
+
const avgTps=results.reduce((s,r)=>s+r.tps,0)/results.length, avgTtft=results.reduce((s,r)=>s+r.ttft,0)/results.length, cls=avgTps>35?'g':avgTps>20?'y':'r';
|
| 545 |
+
st.innerHTML=`<div class="ph-stats">${results.map((r,i)=>`<div class="ph-stat"><div class="pv" style="color:var(--${cls})">${r.tps}</div><div class="pk">P${i+1} tok/s</div></div>`).join('')}<div class="ph-stat"><div class="pv" style="color:var(--c)">${avgTtft.toFixed(0)}ms</div><div class="pk">avg TTFT</div></div></div>`;
|
| 546 |
+
return{label:'Avg TPS',value:avgTps,unit:'tok/s'};
|
| 547 |
+
} else {
|
| 548 |
+
const tpsList=results.map(r=>r.tps), avg=tpsList.reduce((a,b)=>a+b,0)/tpsList.length, stddev=Math.sqrt(tpsList.reduce((s,v)=>s+Math.pow(v-avg,2),0)/tpsList.length).toFixed(1);
|
| 549 |
+
st.innerHTML=`<div class="ph-stats">${tpsList.map((t,i)=>`<div class="ph-stat"><div class="pv">${t}</div><div class="pk">run ${i+1}</div></div>`).join('')}<div class="ph-stat"><div class="pv" style="color:var(--c)">±${stddev}</div><div class="pk">std dev</div></div></div>`;
|
| 550 |
+
return{label:'Std Dev',value:parseFloat(stddev),unit:'±'};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 551 |
}
|
| 552 |
}
|
| 553 |
+
async function runBench(){
|
| 554 |
+
if(benchRunning||busy) return; benchRunning=true; switchTab('bench');
|
| 555 |
+
const btn=document.getElementById('btnbench'), scroll=document.getElementById('bench-scroll');
|
| 556 |
+
btn.disabled=true; btn.textContent='Running…';
|
| 557 |
+
const empty=document.getElementById('bench-empty'); if(empty) empty.remove();
|
| 558 |
+
scroll.innerHTML=''; coldSessId=crypto.randomUUID(); let summaryData={};
|
| 559 |
+
for(const phase of PHASES){
|
| 560 |
+
const card=mkPhaseCard(phase); scroll.appendChild(card); scroll.scrollTop=scroll.scrollHeight;
|
| 561 |
+
const bar=document.getElementById('ph-bar-'+phase.id), results=[];
|
| 562 |
+
try{
|
| 563 |
+
for(let i=0;i<phase.prompts.length;i++){
|
| 564 |
+
const sid=phase.reuseSession?coldSessId:crypto.randomUUID();
|
| 565 |
+
if(phase.id==='cold_ttft') coldSessId=sid;
|
| 566 |
+
bar.style.width=((i/phase.prompts.length)*80)+'%';
|
| 567 |
+
const r=await runSinglePrompt(phase.prompts[i],phase.maxNew,phase.temp,sid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 568 |
results.push(r);
|
| 569 |
}
|
| 570 |
+
summaryData[phase.id]=setPhaseResult(phase,results);
|
| 571 |
+
}catch(e){
|
| 572 |
+
document.getElementById('ph-st-'+phase.id).innerHTML=`<span style="color:var(--red)">✗ ${e.message}</span>`;
|
| 573 |
+
bar.style.background='var(--red)'; bar.style.width='100%';
|
|
|
|
|
|
|
| 574 |
}
|
| 575 |
}
|
| 576 |
+
const p3=summaryData['throughput'], p1=summaryData['cold_ttft'], p2=summaryData['warm_ttft'];
|
| 577 |
+
const avgTps=p3?p3.value.toFixed(1):'—', coldTtft=p1?p1.value.toFixed(0):'—', warmTtft=p2?p2.value.toFixed(0):'—', cacheGain=(p1&&p2)?((p1.value-p2.value)/p1.value*100).toFixed(0):'—';
|
| 578 |
+
const verdict=p3&&p3.value>35?`<div class="verdict good">✓ Throughput target met — ${avgTps} tok/s exceeds 35 tok/s baseline</div>`:`<div class="verdict mid">△ Throughput at ${avgTps} tok/s — within expected range</div>`;
|
| 579 |
+
const summary=document.createElement('div');
|
| 580 |
+
summary.innerHTML=`${verdict}<div class="b-grid"><div class="b-stat"><div class="bv">${avgTps}</div><div class="bk">Avg tok/s</div></div><div class="b-stat"><div class="bv">${coldTtft}ms</div><div class="bk">Cold TTFT</div></div><div class="b-stat"><div class="bv">${warmTtft}ms</div><div class="bk">Warm TTFT</div></div><div class="b-stat"><div class="bv">${cacheGain}%</div><div class="bk">Cache Speedup</div></div></div>`;
|
| 581 |
+
scroll.insertBefore(summary,scroll.firstChild);
|
| 582 |
+
btn.textContent='↺ Run Again'; btn.disabled=false; benchRunning=false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 583 |
}
|
| 584 |
</script>
|
| 585 |
</body>
|
| 586 |
+
</html>
|