@oh-my-pi/omp-stats 18.4.1 → 18.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/client/index.js +48 -48
- package/dist/types/client/charts/BarList.d.ts +1 -1
- package/package.json +4 -4
- package/src/client/charts/BarList.tsx +3 -2
- package/src/client/data/formatters.ts +10 -3
- package/src/client/traces/TimelineCanvas.tsx +2 -2
- package/src/client/ui/Table.tsx +2 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/omp-stats",
|
|
4
|
-
"version": "18.4.
|
|
4
|
+
"version": "18.4.3",
|
|
5
5
|
"description": "Local observability dashboard for omp AI usage statistics",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": {
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@oh-my-pi/pi-ai": "18.4.
|
|
46
|
-
"@oh-my-pi/pi-catalog": "18.4.
|
|
47
|
-
"@oh-my-pi/pi-utils": "18.4.
|
|
45
|
+
"@oh-my-pi/pi-ai": "18.4.3",
|
|
46
|
+
"@oh-my-pi/pi-catalog": "18.4.3",
|
|
47
|
+
"@oh-my-pi/pi-utils": "18.4.3",
|
|
48
48
|
"lucide-react": "^1.24.0",
|
|
49
49
|
"react": "19.2.7",
|
|
50
50
|
"react-dom": "19.2.7"
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import { formatInteger } from "../data/formatters";
|
|
2
3
|
|
|
3
4
|
export interface BarListItem {
|
|
4
5
|
key: string;
|
|
5
6
|
label: ReactNode;
|
|
6
7
|
value: number;
|
|
7
|
-
/** Formatted figure; defaults to `value
|
|
8
|
+
/** Formatted figure; defaults to `formatInteger(value)`. */
|
|
8
9
|
display?: string;
|
|
9
10
|
color?: string;
|
|
10
11
|
}
|
|
@@ -30,7 +31,7 @@ export function BarList({ items, max, onSelect }: BarListProps) {
|
|
|
30
31
|
style={{ width: `${pct}%`, background: item.color ?? "var(--chart-primary)" }}
|
|
31
32
|
/>
|
|
32
33
|
<span className="bar-list-label">{item.label}</span>
|
|
33
|
-
<span className="bar-list-value">{item.display ?? item.value
|
|
34
|
+
<span className="bar-list-value">{item.display ?? formatInteger(item.value)}</span>
|
|
34
35
|
</>
|
|
35
36
|
);
|
|
36
37
|
return onSelect ? (
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { format, formatDistanceToNow } from "@oh-my-pi/pi-utils/dates";
|
|
2
2
|
import type { MessageStats } from "../types";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Every number on the dashboard uses one fixed locale. Labels, percents
|
|
6
|
+
* (`toFixed`), durations and dates are English, so following the browser
|
|
7
|
+
* locale mixed conventions (e.g. `1,4 Mr` beside `97.0%` on a tr-TR browser).
|
|
8
|
+
*/
|
|
9
|
+
const NUMBER_LOCALE = "en-US";
|
|
10
|
+
|
|
4
11
|
export function formatInteger(value: number): string {
|
|
5
|
-
return value.toLocaleString();
|
|
12
|
+
return value.toLocaleString(NUMBER_LOCALE);
|
|
6
13
|
}
|
|
7
14
|
|
|
8
15
|
export function formatCompact(value: number): string {
|
|
9
|
-
return value.toLocaleString(
|
|
16
|
+
return value.toLocaleString(NUMBER_LOCALE, { notation: "compact" });
|
|
10
17
|
}
|
|
11
18
|
|
|
12
19
|
export function formatCost(value: number, digits?: number): string {
|
|
13
20
|
if (value === 0) return "$0";
|
|
14
21
|
const fractionDigits = digits !== undefined ? digits : value > 0 && value < 0.01 ? 4 : 2;
|
|
15
|
-
return `$${value.toLocaleString(
|
|
22
|
+
return `$${value.toLocaleString(NUMBER_LOCALE, {
|
|
16
23
|
minimumFractionDigits: fractionDigits,
|
|
17
24
|
maximumFractionDigits: fractionDigits,
|
|
18
25
|
})}`;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { ChevronDown, ChevronRight } from "lucide-react";
|
|
9
9
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
10
10
|
import { createPortal } from "react-dom";
|
|
11
|
-
import { formatDurationMs } from "../data/formatters";
|
|
11
|
+
import { formatDurationMs, formatInteger } from "../data/formatters";
|
|
12
12
|
import type { TraceMarker, TraceSpan, TraceSpanKind, TraceTrack } from "../types";
|
|
13
13
|
import { buildTicks, formatOffset, type TraceScale } from "./time-scale";
|
|
14
14
|
import { type TraceTheme, useTraceTheme } from "./trace-colors";
|
|
@@ -738,7 +738,7 @@ function renderTooltip(hover: HoverState, traceStart: number) {
|
|
|
738
738
|
</div>
|
|
739
739
|
{span.kind === "model" && (
|
|
740
740
|
<div className="muted num">
|
|
741
|
-
{span.tokens !== undefined && <>{span.tokens
|
|
741
|
+
{span.tokens !== undefined && <>{formatInteger(span.tokens)} tok</>}
|
|
742
742
|
{span.cost !== undefined && <> · ${span.cost.toFixed(4)}</>}
|
|
743
743
|
{span.ttft !== undefined && <> · TTFT {formatDurationMs(span.ttft)}</>}
|
|
744
744
|
{span.isError && <> · error</>}
|
package/src/client/ui/Table.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ArrowDown, ArrowUp } from "lucide-react";
|
|
2
2
|
import { Fragment, type ReactNode, useMemo, useState } from "react";
|
|
3
|
+
import { formatInteger } from "../data/formatters";
|
|
3
4
|
import { EmptyState } from "./States";
|
|
4
5
|
|
|
5
6
|
export interface Column<T> {
|
|
@@ -154,7 +155,7 @@ export function Table<T>({
|
|
|
154
155
|
{limit !== undefined && sorted.length > limit && (
|
|
155
156
|
<div className="table-more">
|
|
156
157
|
<span className="micro">
|
|
157
|
-
{visible.length
|
|
158
|
+
{formatInteger(visible.length)} of {formatInteger(sorted.length)}
|
|
158
159
|
</span>
|
|
159
160
|
{sorted.length > shown && (
|
|
160
161
|
<button
|