File size: 6,540 Bytes
3bbabdf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>RightNow Mini, side by side</title>
<style>
  :root { --ink: #1b1a17; --paper: #f6f1e7; --line: #cfc6b4; --soft: #6b655a; --go: #1b1a17; }
  * { box-sizing: border-box; }
  body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 ui-sans-serif, system-ui, "Segoe UI", sans-serif; }
  main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
  h1 { font-size: 28px; margin: 0 0 4px; letter-spacing: -0.01em; }
  p.sub { margin: 0 0 20px; color: var(--soft); }
  textarea { width: 100%; min-height: 96px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fffdf8; color: var(--ink); font: inherit; resize: vertical; }
  .row { display: flex; gap: 10px; align-items: center; margin: 10px 0 20px; flex-wrap: wrap; }
  button { padding: 10px 18px; border: 1px solid var(--go); border-radius: 8px; background: var(--go); color: var(--paper); font: inherit; cursor: pointer; }
  button[disabled] { opacity: .5; cursor: default; }
  button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
  .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  @media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }
  .pane { border: 1px solid var(--line); border-radius: 10px; background: #fffdf8; display: flex; flex-direction: column; min-height: 420px; }
  .head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
  .name { font-weight: 600; }
  .nums { font-variant-numeric: tabular-nums; color: var(--soft); white-space: nowrap; }
  .nums b { color: var(--ink); font-size: 20px; }
  pre { margin: 0; padding: 14px; white-space: pre-wrap; word-break: break-word; font: 13.5px/1.5 ui-monospace, Consolas, monospace; flex: 1; overflow: auto; max-height: 560px; }
  pre .think { color: var(--soft); }
  .note { color: var(--soft); font-size: 13.5px; margin-top: 16px; }
</style>
</head>
<body>
<main>
  <h1>RightNow Mini, side by side</h1>
  <p class="sub">The same coding task goes to both models at the same moment. The numbers are measured in your browser from what arrives.</p>
  <textarea id="task">Write a Python function that merges overlapping intervals, with type hints and five unit tests.</textarea>
  <div class="row">
    <button id="go">Run both</button>
    <button class="ghost" data-t="Write a thread-safe LRU cache in Python with O(1) get and put, and explain the locking.">LRU cache</button>
    <button class="ghost" data-t="Find and fix the bug: def median(xs): xs.sort(); n = len(xs); return xs[n // 2] if n % 2 else (xs[n // 2] + xs[n // 2 + 1]) / 2">Fix a bug</button>
    <button class="ghost" data-t="Write a SQL query and a short explanation: the three customers with the highest total order value in each country, from tables customers(id, country) and orders(customer_id, value).">SQL</button>
  </div>
  <div class="grid">
    <section class="pane"><div class="head"><span class="name" id="n-mini">RightNow Mini</span><span class="nums"><b id="tps-mini">0</b> tok/s 路 <span id="s-mini">0.0</span> s 路 <span id="tok-mini">0</span> tokens</span></div><pre id="out-mini"></pre></section>
    <section class="pane"><div class="head"><span class="name" id="n-other">Other model</span><span class="nums"><b id="tps-other">0</b> tok/s 路 <span id="s-other">0.0</span> s 路 <span id="tok-other">0</span> tokens</span></div><pre id="out-other"></pre></section>
  </div>
  <p class="note">Seconds run from the click to the last token. Tokens per second is the model's own count of output tokens when the stream reports it, otherwise the number of stream pieces, divided by the seconds since the first one. Grey text is the model's reasoning.</p>
</main>
<script>
const $ = id => document.getElementById(id);
fetch('/info').then(r => r.json()).then(i => { $('n-mini').textContent = 'RightNow Mini (' + i.mini + ')'; $('n-other').textContent = i.other; });
document.querySelectorAll('button[data-t]').forEach(b => b.onclick = () => { $('task').value = b.dataset.t; });

async function run(side, task) {
  const out = $('out-' + side); out.textContent = '';
  const t0 = performance.now(); let first = 0, pieces = 0, usage = 0, done = false;
  const tick = setInterval(() => {
    const now = performance.now();
    $('s-' + side).textContent = ((now - t0) / 1000).toFixed(1);
    const n = usage || pieces;
    $('tok-' + side).textContent = n;
    if (first && now > first) $('tps-' + side).textContent = Math.round(n / ((now - first) / 1000));
    if (done) clearInterval(tick);
  }, 100);
  try {
    const r = await fetch('/stream/' + side, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ task }) });
    if (!r.ok) { out.textContent = await r.text(); return; }
    const reader = r.body.getReader(); const dec = new TextDecoder(); let buf = '';
    for (;;) {
      const { value, done: end } = await reader.read(); if (end) break;
      buf += dec.decode(value, { stream: true });
      let i; while ((i = buf.indexOf('\n')) >= 0) {
        const line = buf.slice(0, i).trim(); buf = buf.slice(i + 1);
        if (!line.startsWith('data:')) continue;
        const data = line.slice(5).trim(); if (data === '[DONE]') continue;
        let d; try { d = JSON.parse(data); } catch (e) { continue; }
        if (d.error) { out.append(document.createTextNode('\n[' + (d.error.message || d.error) + ']')); continue; }
        if (d.usage && d.usage.completion_tokens) usage = d.usage.completion_tokens;
        for (const c of d.choices || []) {
          const dl = c.delta || {}; const think = dl.reasoning_content || dl.reasoning || ''; const text = dl.content || '';
          if (think || text) { if (!first) first = performance.now(); pieces++; }
          if (think) { const s = document.createElement('span'); s.className = 'think'; s.textContent = think; out.append(s); }
          if (text) out.append(document.createTextNode(text));
        }
        out.scrollTop = out.scrollHeight;
      }
    }
  } catch (e) { out.append(document.createTextNode('\n[' + e + ']')); }
  finally { done = true; }
}
$('go').onclick = async () => {
  const task = $('task').value.trim(); if (!task) return;
  $('go').disabled = true;
  await Promise.all([run('mini', task), run('other', task)]);
  $('go').disabled = false;
};
</script>
</body>
</html>