@crowandraven/evalkeeper 0.4.1 → 0.7.0
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/README.md +7 -0
- package/dist/activity.d.ts +58 -0
- package/dist/activity.js +125 -0
- package/dist/activity.js.map +1 -0
- package/dist/assertExpect.d.ts +52 -0
- package/dist/assertExpect.js +104 -0
- package/dist/assertExpect.js.map +1 -0
- package/dist/blind.d.ts +79 -0
- package/dist/blind.js +113 -0
- package/dist/blind.js.map +1 -0
- package/dist/cli/addPages.d.ts +34 -0
- package/dist/cli/addPages.js +91 -11
- package/dist/cli/addPages.js.map +1 -1
- package/dist/cli/main.d.ts +1 -1
- package/dist/cli/main.js +9 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/compare.d.ts +38 -0
- package/dist/compare.js +62 -0
- package/dist/compare.js.map +1 -1
- package/dist/glossary.d.ts +20 -0
- package/dist/glossary.js +20 -0
- package/dist/glossary.js.map +1 -1
- package/dist/health.js +5 -3
- package/dist/health.js.map +1 -1
- package/dist/importCases.d.ts +76 -5
- package/dist/importCases.js +114 -14
- package/dist/importCases.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/memoryStore.js +3 -1
- package/dist/memoryStore.js.map +1 -1
- package/dist/readCheck.d.ts +116 -0
- package/dist/readCheck.js +321 -0
- package/dist/readCheck.js.map +1 -0
- package/dist/runner.d.ts +7 -0
- package/dist/runner.js +25 -3
- package/dist/runner.js.map +1 -1
- package/dist/settings.d.ts +81 -3
- package/dist/settings.js +160 -23
- package/dist/settings.js.map +1 -1
- package/dist/store.d.ts +10 -3
- package/dist/suggest.d.ts +10 -1
- package/dist/suggest.js +22 -4
- package/dist/suggest.js.map +1 -1
- package/dist/suiteContract.d.ts +17 -0
- package/dist/suiteContract.js +69 -0
- package/dist/suiteContract.js.map +1 -0
- package/dist/suites/crisisRisk.d.ts +83 -0
- package/dist/suites/crisisRisk.js +176 -0
- package/dist/suites/crisisRisk.js.map +1 -0
- package/dist/suites/crisisRiskCases.d.ts +40 -0
- package/dist/suites/crisisRiskCases.js +179 -0
- package/dist/suites/crisisRiskCases.js.map +1 -0
- package/dist/suites/index.d.ts +9 -0
- package/dist/suites/index.js +10 -0
- package/dist/suites/index.js.map +1 -0
- package/dist/testing.d.ts +140 -8
- package/dist/testing.js +420 -125
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +92 -0
- package/dist/types.js +68 -0
- package/dist/types.js.map +1 -1
- package/dist/weekly.d.ts +21 -3
- package/dist/weekly.js +18 -1
- package/dist/weekly.js.map +1 -1
- package/package.json +5 -1
- package/src/activity.ts +154 -0
- package/src/assertExpect.ts +168 -0
- package/src/blind.ts +138 -0
- package/src/cli/addPages.ts +119 -17
- package/src/cli/main.ts +11 -0
- package/src/compare.ts +85 -0
- package/src/glossary.ts +36 -0
- package/src/health.ts +5 -3
- package/src/importCases.ts +172 -33
- package/src/index.ts +4 -0
- package/src/memoryStore.ts +2 -1
- package/src/readCheck.ts +458 -0
- package/src/runner.ts +33 -4
- package/src/settings.ts +192 -26
- package/src/store.ts +11 -3
- package/src/suggest.ts +33 -4
- package/src/suiteContract.ts +101 -0
- package/src/suites/crisisRisk.ts +250 -0
- package/src/suites/crisisRiskCases.ts +205 -0
- package/src/suites/index.ts +9 -0
- package/src/testing.ts +564 -127
- package/src/types.ts +141 -0
- package/src/weekly.ts +39 -3
- package/templates/app/evals/[suite]/compare/page.tsx +375 -0
- package/templates/app/evals/[suite]/page.tsx +55 -19
- package/templates/app/evals/[suite]/rate/page.tsx +133 -0
- package/templates/app/evals/[suite]/runs/[runId]/page.tsx +12 -0
- package/templates/app/evals/[suite]/side-by-side/page.tsx +300 -0
- package/templates/components/evalkeeper/DisagreementChip.tsx +35 -0
- package/templates/components/evalkeeper/RollBack.tsx +21 -1
- package/templates/components/evalkeeper/SettingsHistory.tsx +20 -2
- package/templates/components/evalkeeper/WeeklyCheck.tsx +34 -2
- package/templates/lib/evalkeeper/actions.ts +68 -4
- package/templates/lib/evalkeeper/weekly.ts +27 -4
package/src/types.ts
CHANGED
|
@@ -174,6 +174,24 @@ export type Suite<Input, Output, Label> = {
|
|
|
174
174
|
count: number;
|
|
175
175
|
focus: string | null;
|
|
176
176
|
}): Promise<{ input: Input; label: Label; tags: string[]; note: string }[]>;
|
|
177
|
+
/**
|
|
178
|
+
* Drafts cases from what the feature saw in your app since a date (inputs
|
|
179
|
+
* people rated or admins flagged), so the answer key keeps up with real
|
|
180
|
+
* use. The weekly check calls it through `draftFromActivity`; drafts
|
|
181
|
+
* arrive with a PENDING answer or none, never confirmed. Strip names,
|
|
182
|
+
* contact details, and anything identifying from each input. Return at
|
|
183
|
+
* most `limit`, and skip anything whose `sourceRef` is in `known`.
|
|
184
|
+
*/
|
|
185
|
+
draftFromActivity?(args: {
|
|
186
|
+
/** Look at activity from this date on. */
|
|
187
|
+
since: Date;
|
|
188
|
+
/** The suite's cases, retired ones too, to avoid near-repeats. */
|
|
189
|
+
existing: { input: Input; tags: string[] }[];
|
|
190
|
+
/** The most drafts to return: what's left of this week's allowance. */
|
|
191
|
+
limit: number;
|
|
192
|
+
/** The `sourceRef` of every draft made before: skip these. */
|
|
193
|
+
known: ReadonlySet<string>;
|
|
194
|
+
}): Promise<ActivityDraft<Input, Label>[]>;
|
|
177
195
|
/**
|
|
178
196
|
* How long one answer may take before it counts as failed. Default 60s;
|
|
179
197
|
* multi-step agent turns need more. Keep it under the run budget.
|
|
@@ -201,6 +219,25 @@ export type Suite<Input, Output, Label> = {
|
|
|
201
219
|
* edited as JSON.
|
|
202
220
|
*/
|
|
203
221
|
caseKind?: "typed" | "imported" | "fixture";
|
|
222
|
+
/**
|
|
223
|
+
* Removes anything the input learned from its own case before it's
|
|
224
|
+
* frozen, so a case can't carry its answer: facts the app learned from
|
|
225
|
+
* the person's reaction to that same item, for example. `importCases`,
|
|
226
|
+
* `importStarters`, and adding a case on the pages run it, and report
|
|
227
|
+
* what it removed per case so a person can check it. Match on something
|
|
228
|
+
* specific to the case (the company's name), not something general (a
|
|
229
|
+
* job title), or it removes what other cases rightly share.
|
|
230
|
+
*
|
|
231
|
+
* @param input - The case's input, already checked against `input`.
|
|
232
|
+
* @param source - Where the case came from: its `sourceRef`, or null
|
|
233
|
+
* for a case added by hand.
|
|
234
|
+
* @returns The input without what leaked, and a plain line for each
|
|
235
|
+
* item removed (empty when nothing was).
|
|
236
|
+
*/
|
|
237
|
+
withoutLeaks?(
|
|
238
|
+
input: Input,
|
|
239
|
+
source: { sourceRef: string | null },
|
|
240
|
+
): { input: Input; removed: string[] };
|
|
204
241
|
/** A short line naming the case in lists. */
|
|
205
242
|
title(input: Input): string;
|
|
206
243
|
/** Fixture suites: the whole input, readable, for reviewing a case. */
|
|
@@ -209,6 +246,25 @@ export type Suite<Input, Output, Label> = {
|
|
|
209
246
|
labelHelp?: string;
|
|
210
247
|
};
|
|
211
248
|
|
|
249
|
+
/**
|
|
250
|
+
* A case a suite drafted from your app's activity, for a person to review.
|
|
251
|
+
* Return these from `Suite.draftFromActivity`.
|
|
252
|
+
*/
|
|
253
|
+
export type ActivityDraft<Input, Label> = {
|
|
254
|
+
/** The input the feature saw, with names and contact details removed. */
|
|
255
|
+
input: Input;
|
|
256
|
+
/** A proposed answer, stored PENDING; null: the reviewer writes one. */
|
|
257
|
+
label: Label | null;
|
|
258
|
+
tags: string[];
|
|
259
|
+
/** Why it was drafted, shown to the reviewer ("Rated thumbs down."). */
|
|
260
|
+
note: string;
|
|
261
|
+
/**
|
|
262
|
+
* What it was drafted from (an id in your app), so it's never drafted
|
|
263
|
+
* twice, even weeks later or after someone retires it.
|
|
264
|
+
*/
|
|
265
|
+
sourceRef: string;
|
|
266
|
+
};
|
|
267
|
+
|
|
212
268
|
/**
|
|
213
269
|
* One field of a suite's add/edit form. `name` is the form key (and the
|
|
214
270
|
* input or answer property it fills). "lines": one item per line, read as
|
|
@@ -261,3 +317,88 @@ export function linesOf(form: FormData, name: string): string[] {
|
|
|
261
317
|
* `unknown`; a suite's own code keeps its precise types.
|
|
262
318
|
*/
|
|
263
319
|
export type AnySuite = Suite<unknown, unknown, unknown>;
|
|
320
|
+
|
|
321
|
+
/** Where a zod issue sits, in plain words: "facts, item 2, name". */
|
|
322
|
+
function issuePath(path: readonly (string | number)[]): string {
|
|
323
|
+
return path
|
|
324
|
+
.map((p) => (typeof p === "number" ? `item ${p + 1}` : p))
|
|
325
|
+
.join(", ");
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Reads one form field as JSON and checks it with a schema; throws a
|
|
330
|
+
* plain error when the field is empty, isn't JSON, or doesn't fit (naming
|
|
331
|
+
* the first part that doesn't).
|
|
332
|
+
*/
|
|
333
|
+
function readJson<T>(
|
|
334
|
+
form: FormData,
|
|
335
|
+
field: string,
|
|
336
|
+
what: string,
|
|
337
|
+
schema: z.ZodType<T>,
|
|
338
|
+
): T {
|
|
339
|
+
const text = formText(form, field);
|
|
340
|
+
if (!text) throw new Error(`${what} is empty: fill in the "${field}" field`);
|
|
341
|
+
let value: unknown;
|
|
342
|
+
try {
|
|
343
|
+
value = JSON.parse(text);
|
|
344
|
+
} catch (e) {
|
|
345
|
+
throw new Error(
|
|
346
|
+
`${what} isn't valid JSON: ${e instanceof Error ? e.message : String(e)}`,
|
|
347
|
+
{ cause: e },
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
const parsed = schema.safeParse(value);
|
|
351
|
+
if (parsed.success) return parsed.data;
|
|
352
|
+
const issue = parsed.error.issues[0];
|
|
353
|
+
const where = issue ? issuePath(issue.path) : "";
|
|
354
|
+
const message = issue?.message ?? "invalid";
|
|
355
|
+
throw new Error(
|
|
356
|
+
where
|
|
357
|
+
? `${what} doesn't fit at ${where}: ${message}`
|
|
358
|
+
: `${what} doesn't fit: ${message}`,
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* A suite's `inputFromForm` for fixture suites (`caseKind: "fixture"`),
|
|
364
|
+
* whose cases are edited as JSON in one textarea. Reads the field, parses
|
|
365
|
+
* it, and checks it with the schema; throws a plain error when it's empty,
|
|
366
|
+
* isn't valid JSON ("Input isn't valid JSON: …"), or doesn't fit, naming
|
|
367
|
+
* the first part that doesn't ("Input doesn't fit at facts, item 2, name:
|
|
368
|
+
* Required").
|
|
369
|
+
*
|
|
370
|
+
* @param schema - The suite's input schema.
|
|
371
|
+
* @param field - The form field holding the JSON; default "input".
|
|
372
|
+
* @returns A form reader to use as the suite's `inputFromForm`.
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```ts
|
|
376
|
+
* const profileFit: Suite<Profile, Fit, FitLabel> = {
|
|
377
|
+
* // …
|
|
378
|
+
* caseKind: "fixture",
|
|
379
|
+
* inputFromForm: inputFromJson(profileSchema),
|
|
380
|
+
* labelFromForm: labelFromJson(fitLabelSchema),
|
|
381
|
+
* };
|
|
382
|
+
* ```
|
|
383
|
+
*/
|
|
384
|
+
export function inputFromJson<T>(
|
|
385
|
+
schema: z.ZodType<T>,
|
|
386
|
+
field = "input",
|
|
387
|
+
): (form: FormData) => T {
|
|
388
|
+
return (form) => readJson(form, field, "Input", schema);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* A suite's `labelFromForm` for fixture suites: like `inputFromJson`, for
|
|
393
|
+
* the expected answer ("Answer isn't valid JSON: …").
|
|
394
|
+
*
|
|
395
|
+
* @param schema - The suite's answer schema (`labelValue`).
|
|
396
|
+
* @param field - The form field holding the JSON; default "label".
|
|
397
|
+
* @returns A form reader to use as the suite's `labelFromForm`.
|
|
398
|
+
*/
|
|
399
|
+
export function labelFromJson<T>(
|
|
400
|
+
schema: z.ZodType<T>,
|
|
401
|
+
field = "label",
|
|
402
|
+
): (form: FormData) => T {
|
|
403
|
+
return (form) => readJson(form, field, "Answer", schema);
|
|
404
|
+
}
|
package/src/weekly.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { ACTIVITY_SOURCE } from "./activity.js";
|
|
1
2
|
import type { ThumbsSummary } from "./feedback.js";
|
|
2
3
|
import { retiresLabel, type ModelCatalog } from "./models.js";
|
|
3
|
-
import type { RunMetrics, RunRecord } from "./store.js";
|
|
4
|
+
import type { CaseRecord, RunMetrics, RunRecord } from "./store.js";
|
|
4
5
|
import { daysUntil, drifted, retiresSoon } from "./upkeepRules.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* The weekly check: each suite's quick set on its live model, with fresh
|
|
8
9
|
* answers, so a provider quietly changing a model under the same name shows
|
|
9
10
|
* up as drift. The summary also flags models retiring soon and features
|
|
10
|
-
* people rate poorly
|
|
11
|
+
* people rate poorly, and counts the cases suites drafted from the app's
|
|
12
|
+
* activity. It only reports; a person decides what to change.
|
|
11
13
|
* Pure.
|
|
12
14
|
*/
|
|
13
15
|
|
|
@@ -18,7 +20,8 @@ const DAY = 86_400_000;
|
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* What the last weekly check found: drift, unfinished checks, retiring models, and
|
|
21
|
-
* thumbs-down, plus when it ran
|
|
23
|
+
* thumbs-down, plus when it ran, what it cost, and the cases drafted from
|
|
24
|
+
* activity.
|
|
22
25
|
*/
|
|
23
26
|
export type WeeklySummary = {
|
|
24
27
|
/** When the last weekly check started; null before the first. */
|
|
@@ -47,6 +50,12 @@ export type WeeklySummary = {
|
|
|
47
50
|
}[];
|
|
48
51
|
/** Features with a high thumbs-down share this week. */
|
|
49
52
|
thumbs: ThumbsSummary[];
|
|
53
|
+
/**
|
|
54
|
+
* Cases each suite drafted from the app's activity in the last 7 days,
|
|
55
|
+
* and how many of them still wait for a person (no confirmed answer, not
|
|
56
|
+
* retired). Drafts are news, not trouble: they don't affect `clear`.
|
|
57
|
+
*/
|
|
58
|
+
drafted: { suite: string; label: string; count: number; waiting: number }[];
|
|
50
59
|
/** Ran, and nothing needs a look. */
|
|
51
60
|
clear: boolean;
|
|
52
61
|
};
|
|
@@ -78,6 +87,11 @@ export function weeklySummary(args: {
|
|
|
78
87
|
models: ModelCatalog;
|
|
79
88
|
/** From thumbsSummary over the last week; only flagged ones are shown. */
|
|
80
89
|
thumbs?: ThumbsSummary[];
|
|
90
|
+
/**
|
|
91
|
+
* Every suite's cases (`store.listCases`), to count the drafts from
|
|
92
|
+
* activity. Leave out to skip the count.
|
|
93
|
+
*/
|
|
94
|
+
cases?: CaseRecord[];
|
|
81
95
|
today?: Date;
|
|
82
96
|
}): WeeklySummary {
|
|
83
97
|
const today = args.today ?? new Date();
|
|
@@ -152,6 +166,27 @@ export function weeklySummary(args: {
|
|
|
152
166
|
}
|
|
153
167
|
|
|
154
168
|
const thumbs = (args.thumbs ?? []).filter((t) => t.alert);
|
|
169
|
+
|
|
170
|
+
const drafted: WeeklySummary["drafted"] = [];
|
|
171
|
+
for (const s of args.suites) {
|
|
172
|
+
const recent = (args.cases ?? []).filter(
|
|
173
|
+
(c) =>
|
|
174
|
+
c.suite === s.key &&
|
|
175
|
+
c.source === ACTIVITY_SOURCE &&
|
|
176
|
+
+today - +c.createdAt < 7 * DAY,
|
|
177
|
+
);
|
|
178
|
+
if (recent.length)
|
|
179
|
+
drafted.push({
|
|
180
|
+
suite: s.key,
|
|
181
|
+
label: s.label,
|
|
182
|
+
count: recent.length,
|
|
183
|
+
waiting: recent.filter(
|
|
184
|
+
(c) =>
|
|
185
|
+
c.status !== "RETIRED" &&
|
|
186
|
+
!c.labels.some((l) => l.status === "CONFIRMED"),
|
|
187
|
+
).length,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
155
190
|
return {
|
|
156
191
|
lastAt,
|
|
157
192
|
costUsd: batch.reduce((t, r) => t + (r.metrics?.costUsd ?? 0), 0),
|
|
@@ -160,6 +195,7 @@ export function weeklySummary(args: {
|
|
|
160
195
|
failed,
|
|
161
196
|
retiring,
|
|
162
197
|
thumbs,
|
|
198
|
+
drafted,
|
|
163
199
|
clear:
|
|
164
200
|
lastAt !== null &&
|
|
165
201
|
!drift.length &&
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
import { notFound } from "next/navigation";
|
|
3
|
+
import {
|
|
4
|
+
checkBar,
|
|
5
|
+
perAnswer,
|
|
6
|
+
seconds,
|
|
7
|
+
verdictSentence,
|
|
8
|
+
type Rate,
|
|
9
|
+
type RunRecord,
|
|
10
|
+
} from "@crowandraven/evalkeeper";
|
|
11
|
+
import { DisagreementChip } from "@/components/evalkeeper/DisagreementChip";
|
|
12
|
+
import { Submit } from "@/components/evalkeeper/Submit";
|
|
13
|
+
import { InfoTip, Tip } from "@/components/evalkeeper/Tip";
|
|
14
|
+
import { BackLink, Card, Chip, pct } from "@/components/evalkeeper/ui";
|
|
15
|
+
import {
|
|
16
|
+
MODELS,
|
|
17
|
+
SUITE_BY_KEY,
|
|
18
|
+
requireAdmin,
|
|
19
|
+
routeFor,
|
|
20
|
+
runner,
|
|
21
|
+
store,
|
|
22
|
+
} from "@/lib/evalkeeper";
|
|
23
|
+
import { evalsPath } from "@/lib/evalkeeper/paths";
|
|
24
|
+
|
|
25
|
+
export const dynamic = "force-dynamic";
|
|
26
|
+
|
|
27
|
+
/** A search parameter as one string, or null when it's missing or repeated. */
|
|
28
|
+
const one = (v: string | string[] | undefined) =>
|
|
29
|
+
typeof v === "string" && v ? v : null;
|
|
30
|
+
|
|
31
|
+
/** A test's name: its model, reasoning setting, set, and when it ran. */
|
|
32
|
+
function testName(r: RunRecord): string {
|
|
33
|
+
const model = MODELS[r.model]?.label ?? r.model;
|
|
34
|
+
const effort = r.reasoningEffort ? `, ${r.reasoningEffort} reasoning` : "";
|
|
35
|
+
const set = r.set === "ALL" ? "" : `, ${r.set.toLowerCase()} set`;
|
|
36
|
+
return `${model}${effort}${set} · ${r.startedAt.toLocaleString()}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A pass rate as "80% (8/10)", or a dash when the check never applied. */
|
|
40
|
+
function rateText(r: Rate | undefined): string {
|
|
41
|
+
return r && r.n > 0 ? `${pct(r.passed / r.n)} (${r.passed}/${r.n})` : "—";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Two finished tests of a suite compared: the verdict in plain words, each
|
|
46
|
+
* check's pass rate side by side, and the cases they graded differently,
|
|
47
|
+
* each linked to its answers side by side. `a` is the test in place (the
|
|
48
|
+
* live model's latest when left out), `b` the challenger.
|
|
49
|
+
*/
|
|
50
|
+
export default async function ComparePage({
|
|
51
|
+
params,
|
|
52
|
+
searchParams,
|
|
53
|
+
}: {
|
|
54
|
+
params: Promise<{ suite: string }>;
|
|
55
|
+
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
|
56
|
+
}) {
|
|
57
|
+
await requireAdmin();
|
|
58
|
+
const { suite: key } = await params;
|
|
59
|
+
const sp = await searchParams;
|
|
60
|
+
const suiteDef = SUITE_BY_KEY[key];
|
|
61
|
+
if (!suiteDef) notFound();
|
|
62
|
+
const runs = await store.listRuns(key, { status: "SUCCEEDED" });
|
|
63
|
+
const b = one(sp.b);
|
|
64
|
+
// Without a test in place, the live model's latest finished test.
|
|
65
|
+
let a = one(sp.a);
|
|
66
|
+
if (!a) {
|
|
67
|
+
// A feature with no settings yet has no live model to start from.
|
|
68
|
+
const live = await routeFor(suiteDef.operation).then(
|
|
69
|
+
(r) => r.model,
|
|
70
|
+
() => null,
|
|
71
|
+
);
|
|
72
|
+
a = runs.find((r) => r.model === live && r.id !== b)?.id ?? null;
|
|
73
|
+
}
|
|
74
|
+
const result = a && b ? await runner.compare(key, a, b) : null;
|
|
75
|
+
const titles = new Map(
|
|
76
|
+
(await store.listCases(key, { includeRetired: true })).map((c) => [
|
|
77
|
+
c.id,
|
|
78
|
+
suiteDef.title(suiteDef.input.parse(c.input)),
|
|
79
|
+
]),
|
|
80
|
+
);
|
|
81
|
+
const sideBySide = (caseId: string) =>
|
|
82
|
+
result
|
|
83
|
+
? `${evalsPath(key, "side-by-side")}?${new URLSearchParams({ a: result.a.id, b: result.b.id, case: caseId })}`
|
|
84
|
+
: "";
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div className="space-y-8">
|
|
88
|
+
<div className="space-y-2">
|
|
89
|
+
<BackLink href={evalsPath(key)}>{suiteDef.label}</BackLink>
|
|
90
|
+
<h1 className="text-2xl font-semibold">
|
|
91
|
+
Compare two tests
|
|
92
|
+
<InfoTip term="comparison" />
|
|
93
|
+
</h1>
|
|
94
|
+
<p className="readable text-muted">
|
|
95
|
+
Pick the test in place and a challenger. Only finished tests of{" "}
|
|
96
|
+
{suiteDef.label} can be compared.
|
|
97
|
+
</p>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<Card>
|
|
101
|
+
{/* Keyed by the tests, so the pickers show them after a swap. */}
|
|
102
|
+
<form
|
|
103
|
+
key={`${a ?? ""}-${b ?? ""}`}
|
|
104
|
+
action={evalsPath(key, "compare")}
|
|
105
|
+
className="grid items-end gap-4 md:grid-cols-[1fr_1fr_auto]"
|
|
106
|
+
>
|
|
107
|
+
<TestPicker
|
|
108
|
+
name="a"
|
|
109
|
+
label="In place"
|
|
110
|
+
term="inPlace"
|
|
111
|
+
runs={runs}
|
|
112
|
+
value={a}
|
|
113
|
+
/>
|
|
114
|
+
<TestPicker
|
|
115
|
+
name="b"
|
|
116
|
+
label="Challenger"
|
|
117
|
+
term="challenger"
|
|
118
|
+
runs={runs}
|
|
119
|
+
value={b}
|
|
120
|
+
/>
|
|
121
|
+
<div className="pb-1">
|
|
122
|
+
<Submit>Compare</Submit>
|
|
123
|
+
</div>
|
|
124
|
+
</form>
|
|
125
|
+
</Card>
|
|
126
|
+
|
|
127
|
+
{a && b && !result && (
|
|
128
|
+
<p className="readable text-warn">
|
|
129
|
+
These can't be compared: pick two different finished tests of
|
|
130
|
+
this suite.
|
|
131
|
+
</p>
|
|
132
|
+
)}
|
|
133
|
+
{runs.length < 2 && (
|
|
134
|
+
<p className="readable text-muted">
|
|
135
|
+
This suite needs two finished tests to compare. Test another model on
|
|
136
|
+
the suite page first.
|
|
137
|
+
</p>
|
|
138
|
+
)}
|
|
139
|
+
|
|
140
|
+
{result && (
|
|
141
|
+
<>
|
|
142
|
+
<Card className="space-y-3">
|
|
143
|
+
<div className="flex flex-wrap items-start justify-between gap-3">
|
|
144
|
+
<h2 className="font-semibold">
|
|
145
|
+
Verdict
|
|
146
|
+
<InfoTip term="verdict" />
|
|
147
|
+
</h2>
|
|
148
|
+
<Link
|
|
149
|
+
href={`${evalsPath(key, "compare")}?${new URLSearchParams({ a: result.b.id, b: result.a.id })}`}
|
|
150
|
+
className="text-sm text-muted hover:text-ink"
|
|
151
|
+
>
|
|
152
|
+
Swap them
|
|
153
|
+
</Link>
|
|
154
|
+
</div>
|
|
155
|
+
<p className="readable text-lg">
|
|
156
|
+
{verdictSentence(
|
|
157
|
+
result.comparison,
|
|
158
|
+
MODELS[result.b.model]?.label ?? result.b.model,
|
|
159
|
+
)}
|
|
160
|
+
</p>
|
|
161
|
+
<p className="readable text-sm text-muted">
|
|
162
|
+
<Link href={evalsPath(key, "runs", result.a.id)}>
|
|
163
|
+
{testName(result.a)}
|
|
164
|
+
</Link>{" "}
|
|
165
|
+
(in place) against{" "}
|
|
166
|
+
<Link href={evalsPath(key, "runs", result.b.id)}>
|
|
167
|
+
{testName(result.b)}
|
|
168
|
+
</Link>{" "}
|
|
169
|
+
(challenger), on{" "}
|
|
170
|
+
<Tip term="sharedCases">
|
|
171
|
+
<span>{result.comparison.n} shared cases</span>
|
|
172
|
+
</Tip>
|
|
173
|
+
.
|
|
174
|
+
</p>
|
|
175
|
+
<p className="text-sm text-muted">
|
|
176
|
+
<Tip term="cost" id="cost-compare">
|
|
177
|
+
<span>
|
|
178
|
+
Cost per answer: {perAnswer(result.comparison.cost.champion)}{" "}
|
|
179
|
+
in place, {perAnswer(result.comparison.cost.challenger)}{" "}
|
|
180
|
+
challenger
|
|
181
|
+
</span>
|
|
182
|
+
</Tip>
|
|
183
|
+
{" · "}
|
|
184
|
+
<Tip term="time" id="time-compare" align="end">
|
|
185
|
+
<span>
|
|
186
|
+
Time: {seconds(result.comparison.avgMs.champion)} in place,{" "}
|
|
187
|
+
{seconds(result.comparison.avgMs.challenger)} challenger
|
|
188
|
+
</span>
|
|
189
|
+
</Tip>
|
|
190
|
+
</p>
|
|
191
|
+
{result.caveats.length > 0 && (
|
|
192
|
+
<div className="readable rounded-md bg-tint p-3 text-sm">
|
|
193
|
+
<p className="font-medium">
|
|
194
|
+
Measured differently
|
|
195
|
+
<InfoTip term="measuredDifferently" />
|
|
196
|
+
</p>
|
|
197
|
+
<ul className="list-disc pl-5 text-muted">
|
|
198
|
+
{result.caveats.map((c) => (
|
|
199
|
+
<li key={c}>{c}</li>
|
|
200
|
+
))}
|
|
201
|
+
</ul>
|
|
202
|
+
</div>
|
|
203
|
+
)}
|
|
204
|
+
</Card>
|
|
205
|
+
|
|
206
|
+
<section className="space-y-3">
|
|
207
|
+
<h2 className="text-lg font-semibold">
|
|
208
|
+
Checks
|
|
209
|
+
<InfoTip term="checks" />
|
|
210
|
+
</h2>
|
|
211
|
+
<Card className="overflow-x-auto p-0">
|
|
212
|
+
<table className="w-full text-sm">
|
|
213
|
+
<thead className="text-left text-muted">
|
|
214
|
+
<tr className="border-b border-line">
|
|
215
|
+
<th className="p-3 font-normal">Check</th>
|
|
216
|
+
<th className="p-3 font-normal">
|
|
217
|
+
<Tip term="inPlace" side="bottom" id="inPlace-col">
|
|
218
|
+
In place
|
|
219
|
+
</Tip>
|
|
220
|
+
</th>
|
|
221
|
+
<th className="p-3 font-normal">
|
|
222
|
+
<Tip term="challenger" side="bottom" id="challenger-col">
|
|
223
|
+
Challenger
|
|
224
|
+
</Tip>
|
|
225
|
+
</th>
|
|
226
|
+
<th className="p-3 font-normal">
|
|
227
|
+
<Tip term="bar" side="bottom" align="end">
|
|
228
|
+
Bar
|
|
229
|
+
</Tip>
|
|
230
|
+
</th>
|
|
231
|
+
</tr>
|
|
232
|
+
</thead>
|
|
233
|
+
<tbody>
|
|
234
|
+
{result.suite.checks.map((c) => {
|
|
235
|
+
const r = result.comparison.byCheck[c.key];
|
|
236
|
+
return (
|
|
237
|
+
<tr
|
|
238
|
+
key={c.key}
|
|
239
|
+
className="border-b border-line last:border-0"
|
|
240
|
+
>
|
|
241
|
+
<td className="p-3">
|
|
242
|
+
<span className="flex flex-wrap items-center gap-2">
|
|
243
|
+
{c.label}
|
|
244
|
+
<Tip
|
|
245
|
+
term={c.severity}
|
|
246
|
+
id={`severity-${c.key}`}
|
|
247
|
+
side="bottom"
|
|
248
|
+
>
|
|
249
|
+
<Chip
|
|
250
|
+
tone={
|
|
251
|
+
c.severity === "serious"
|
|
252
|
+
? "serious"
|
|
253
|
+
: "neutral"
|
|
254
|
+
}
|
|
255
|
+
>
|
|
256
|
+
{c.severity}
|
|
257
|
+
</Chip>
|
|
258
|
+
</Tip>
|
|
259
|
+
</span>
|
|
260
|
+
</td>
|
|
261
|
+
<td className="p-3 tabular-nums">
|
|
262
|
+
<Tip term="passRate" id={`a-${c.key}`} side="bottom">
|
|
263
|
+
<span>{rateText(r?.champion)}</span>
|
|
264
|
+
</Tip>
|
|
265
|
+
</td>
|
|
266
|
+
<td className="p-3 tabular-nums">
|
|
267
|
+
<Tip term="passRate" id={`b-${c.key}`} side="bottom">
|
|
268
|
+
<span>{rateText(r?.challenger)}</span>
|
|
269
|
+
</Tip>
|
|
270
|
+
</td>
|
|
271
|
+
<td className="p-3 tabular-nums text-muted">
|
|
272
|
+
{pct(checkBar(c))}
|
|
273
|
+
</td>
|
|
274
|
+
</tr>
|
|
275
|
+
);
|
|
276
|
+
})}
|
|
277
|
+
</tbody>
|
|
278
|
+
</table>
|
|
279
|
+
</Card>
|
|
280
|
+
</section>
|
|
281
|
+
|
|
282
|
+
<section className="space-y-3">
|
|
283
|
+
<div className="flex flex-wrap items-center justify-between gap-3">
|
|
284
|
+
<h2 className="text-lg font-semibold">
|
|
285
|
+
Where they differ ({result.disagreements.length})
|
|
286
|
+
<InfoTip term="disagreements" />
|
|
287
|
+
</h2>
|
|
288
|
+
{result.disagreements[0] && (
|
|
289
|
+
<Link
|
|
290
|
+
href={sideBySide(result.disagreements[0].caseId)}
|
|
291
|
+
className="text-sm text-accent"
|
|
292
|
+
>
|
|
293
|
+
Read them side by side
|
|
294
|
+
</Link>
|
|
295
|
+
)}
|
|
296
|
+
</div>
|
|
297
|
+
{result.disagreements.length === 0 ? (
|
|
298
|
+
<p className="readable text-muted">
|
|
299
|
+
The two tests graded every shared case alike.
|
|
300
|
+
</p>
|
|
301
|
+
) : (
|
|
302
|
+
<Card className="space-y-2">
|
|
303
|
+
{result.disagreements.map((d) => (
|
|
304
|
+
<div
|
|
305
|
+
key={d.caseId}
|
|
306
|
+
className="flex flex-wrap items-center justify-between gap-3 rounded-md bg-tint p-3 text-sm"
|
|
307
|
+
>
|
|
308
|
+
<Link
|
|
309
|
+
href={sideBySide(d.caseId)}
|
|
310
|
+
className="font-medium hover:underline"
|
|
311
|
+
>
|
|
312
|
+
{titles.get(d.caseId) ?? "A retired case"}
|
|
313
|
+
</Link>
|
|
314
|
+
<span className="flex items-center gap-3">
|
|
315
|
+
<Tip term="caseScore" id={`score-${d.caseId}`}>
|
|
316
|
+
<span className="text-xs text-muted tabular-nums">
|
|
317
|
+
{pct(d.champion)} → {pct(d.challenger)}
|
|
318
|
+
</span>
|
|
319
|
+
</Tip>
|
|
320
|
+
<DisagreementChip
|
|
321
|
+
kind={d.kind}
|
|
322
|
+
id={`kind-${d.caseId}`}
|
|
323
|
+
align="end"
|
|
324
|
+
/>
|
|
325
|
+
</span>
|
|
326
|
+
</div>
|
|
327
|
+
))}
|
|
328
|
+
</Card>
|
|
329
|
+
)}
|
|
330
|
+
</section>
|
|
331
|
+
</>
|
|
332
|
+
)}
|
|
333
|
+
</div>
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** One of the two tests to compare, chosen from the suite's finished tests. */
|
|
338
|
+
function TestPicker({
|
|
339
|
+
name,
|
|
340
|
+
label,
|
|
341
|
+
term,
|
|
342
|
+
runs,
|
|
343
|
+
value,
|
|
344
|
+
}: {
|
|
345
|
+
name: string;
|
|
346
|
+
label: string;
|
|
347
|
+
term: "inPlace" | "challenger";
|
|
348
|
+
runs: RunRecord[];
|
|
349
|
+
value: string | null;
|
|
350
|
+
}) {
|
|
351
|
+
return (
|
|
352
|
+
<div className="space-y-1">
|
|
353
|
+
<label htmlFor={`pick-${name}`} className="block text-sm font-medium">
|
|
354
|
+
{label}
|
|
355
|
+
<InfoTip term={term} id={`${term}-pick`} />
|
|
356
|
+
</label>
|
|
357
|
+
<select
|
|
358
|
+
id={`pick-${name}`}
|
|
359
|
+
name={name}
|
|
360
|
+
defaultValue={value ?? ""}
|
|
361
|
+
required
|
|
362
|
+
className="w-full rounded-md border border-line bg-card px-3 py-2 text-sm focus:border-accent focus:outline-none"
|
|
363
|
+
>
|
|
364
|
+
<option value="" disabled>
|
|
365
|
+
Pick a test
|
|
366
|
+
</option>
|
|
367
|
+
{runs.map((r) => (
|
|
368
|
+
<option key={r.id} value={r.id}>
|
|
369
|
+
{testName(r)}
|
|
370
|
+
</option>
|
|
371
|
+
))}
|
|
372
|
+
</select>
|
|
373
|
+
</div>
|
|
374
|
+
);
|
|
375
|
+
}
|