diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-09 19:02:04 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-09 19:02:04 +0100 |
| commit | c906d90dcf0abdfb347bd67d6f33a2c45ae32e66 (patch) | |
| tree | 8d2bf424aff57e76a3adcbf79e797cacd248da7a /static | |
| parent | 84ac47a8ab196ee20ad778219bfa13df48f87241 (diff) | |
| download | deck-it-c906d90dcf0abdfb347bd67d6f33a2c45ae32e66.tar.gz deck-it-c906d90dcf0abdfb347bd67d6f33a2c45ae32e66.zip | |
fix: aggregate opencode rows from /api/summary
Diffstat (limited to 'static')
| -rw-r--r-- | static/modules/llm.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/static/modules/llm.js b/static/modules/llm.js index 093c27c..a1b775b 100644 --- a/static/modules/llm.js +++ b/static/modules/llm.js @@ -1,6 +1,13 @@ const num = (v) => (v == null ? null : Number(v)); const pct = (v) => (num(v) == null ? "—" : `${Math.round(num(v))}%`); const money = (v, cur) => (num(v) == null ? "—" : `${num(v).toFixed(2)}${cur ? " " + cur : ""}`); +const tokens = (n) => { + if (n == null) return "—"; + if (n >= 1e9) return `${(n / 1e9).toFixed(1)}B`; + if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`; + if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`; + return String(n); +}; const clock = (sec) => (sec ? new Date(sec * 1000).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : ""); function line(label, value, percent) { @@ -49,7 +56,11 @@ export default { line(`5h window ${clock(c.five_hour_resets_at)}`, pct(c.five_hour_pct), c.five_hour_pct), line(`7d window ${clock(c.seven_day_resets_at)}`, pct(c.seven_day_pct), c.seven_day_pct), line("Month", money(c.extra_used, c.extra_currency)), - line("opencode spend", money(o.total_cost)), + line("opencode spend", money(o.cost)), + line("opencode tokens", `${tokens(o.tokens)} · ${o.calls ?? 0} calls`), ); + for (const m of (o.models ?? []).slice(0, 4)) { + box.append(line(m.model || m.provider, money(m.cost))); + } }, }; |
