aboutsummaryrefslogtreecommitdiffstats
path: root/static/modules/llm.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/modules/llm.js')
-rw-r--r--static/modules/llm.js13
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)));
+ }
},
};