@crowandraven/evalkeeper 0.18.0 → 0.19.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/dist/decisions.js +1 -1
- package/dist/decisions.js.map +1 -1
- package/dist/drafts.d.ts +2 -0
- package/dist/drafts.js +1 -1
- package/dist/drafts.js.map +1 -1
- package/dist/glossary.d.ts +25 -14
- package/dist/glossary.js +25 -14
- package/dist/glossary.js.map +1 -1
- package/dist/health.js +2 -2
- package/dist/health.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/memoryStore.d.ts +2 -1
- package/dist/memoryStore.js +9 -0
- package/dist/memoryStore.js.map +1 -1
- package/dist/next/actions.js +58 -3
- package/dist/next/actions.js.map +1 -1
- package/dist/prisma/contracts.d.ts +5 -2
- package/dist/prisma/contracts.js +7 -1
- package/dist/prisma/contracts.js.map +1 -1
- package/dist/prisma/index.d.ts +40 -1
- package/dist/prisma/index.js +37 -1
- package/dist/prisma/index.js.map +1 -1
- package/dist/prune.d.ts +5 -2
- package/dist/prune.js +7 -4
- package/dist/prune.js.map +1 -1
- package/dist/react/AddCase.js +11 -5
- package/dist/react/AddCase.js.map +1 -1
- package/dist/react/AnswerKey.js +7 -4
- package/dist/react/AnswerKey.js.map +1 -1
- package/dist/react/CaseMenu.d.ts +2 -2
- package/dist/react/CaseMenu.js +10 -31
- package/dist/react/CaseMenu.js.map +1 -1
- package/dist/react/CompareView.js +3 -3
- package/dist/react/CompareView.js.map +1 -1
- package/dist/react/ConfirmAnswer.js +1 -1
- package/dist/react/ConfirmAnswer.js.map +1 -1
- package/dist/react/Drawer.d.ts +32 -0
- package/dist/react/Drawer.js +60 -0
- package/dist/react/Drawer.js.map +1 -0
- package/dist/react/HubSections.d.ts +31 -18
- package/dist/react/HubSections.js +104 -103
- package/dist/react/HubSections.js.map +1 -1
- package/dist/react/Menu.d.ts +37 -0
- package/dist/react/Menu.js +51 -0
- package/dist/react/Menu.js.map +1 -0
- package/dist/react/ModelMenu.d.ts +1 -1
- package/dist/react/ModelMenu.js +8 -32
- package/dist/react/ModelMenu.js.map +1 -1
- package/dist/react/RunView.js +24 -4
- package/dist/react/RunView.js.map +1 -1
- package/dist/react/Spending.d.ts +25 -0
- package/dist/react/Spending.js +51 -0
- package/dist/react/Spending.js.map +1 -0
- package/dist/react/SuiteSections.d.ts +25 -6
- package/dist/react/SuiteSections.js +233 -75
- package/dist/react/SuiteSections.js.map +1 -1
- package/dist/react/app.d.ts +18 -0
- package/dist/react/app.js.map +1 -1
- package/dist/react/format.d.ts +13 -0
- package/dist/react/format.js +13 -0
- package/dist/react/format.js.map +1 -1
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/pieces.d.ts +21 -8
- package/dist/react/pieces.js +44 -14
- package/dist/react/pieces.js.map +1 -1
- package/dist/runner.d.ts +15 -1
- package/dist/runner.js +89 -13
- package/dist/runner.js.map +1 -1
- package/dist/settings.d.ts +12 -0
- package/dist/settings.js +18 -0
- package/dist/settings.js.map +1 -1
- package/dist/spending.d.ts +100 -0
- package/dist/spending.js +133 -0
- package/dist/spending.js.map +1 -0
- package/dist/stats.d.ts +3 -1
- package/dist/stats.js +6 -2
- package/dist/stats.js.map +1 -1
- package/dist/store.d.ts +5 -0
- package/dist/suggest.js +17 -12
- package/dist/suggest.js.map +1 -1
- package/dist/suiteSettings.d.ts +78 -0
- package/dist/suiteSettings.js +142 -0
- package/dist/suiteSettings.js.map +1 -0
- package/dist/suites/crisisRisk.js +3 -3
- package/dist/suites/crisisRisk.js.map +1 -1
- package/dist/suites/hopelessness.js +6 -6
- package/dist/suites/hopelessness.js.map +1 -1
- package/dist/suites/injection.js +2 -2
- package/dist/suites/injection.js.map +1 -1
- package/dist/summary.d.ts +41 -4
- package/dist/summary.js +46 -8
- package/dist/summary.js.map +1 -1
- package/dist/testing.d.ts +19 -0
- package/dist/testing.js +61 -0
- package/dist/testing.js.map +1 -1
- package/dist/todo.d.ts +146 -0
- package/dist/todo.js +198 -0
- package/dist/todo.js.map +1 -0
- package/dist/types.d.ts +40 -7
- package/dist/types.js +28 -4
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/schema/evalkeeper.prisma +13 -0
- package/src/decisions.ts +1 -1
- package/src/drafts.ts +3 -1
- package/src/glossary.ts +35 -14
- package/src/health.ts +3 -2
- package/src/index.ts +3 -0
- package/src/memoryStore.ts +15 -1
- package/src/next/actions.ts +67 -2
- package/src/prisma/contracts.ts +16 -1
- package/src/prisma/index.ts +68 -1
- package/src/prune.ts +7 -2
- package/src/react/AddCase.tsx +13 -11
- package/src/react/AnswerKey.tsx +17 -5
- package/src/react/CaseMenu.tsx +23 -77
- package/src/react/CompareView.tsx +4 -10
- package/src/react/ConfirmAnswer.tsx +1 -1
- package/src/react/Drawer.tsx +130 -0
- package/src/react/HubSections.tsx +180 -414
- package/src/react/Menu.tsx +155 -0
- package/src/react/ModelMenu.tsx +23 -74
- package/src/react/RunView.tsx +46 -3
- package/src/react/Spending.tsx +200 -0
- package/src/react/SuiteSections.tsx +579 -175
- package/src/react/app.ts +18 -0
- package/src/react/format.ts +15 -0
- package/src/react/index.ts +3 -0
- package/src/react/pieces.tsx +57 -18
- package/src/runner.ts +122 -12
- package/src/settings.ts +20 -0
- package/src/spending.ts +209 -0
- package/src/stats.ts +8 -2
- package/src/store.ts +5 -0
- package/src/suggest.ts +21 -14
- package/src/suiteSettings.ts +201 -0
- package/src/suites/crisisRisk.ts +3 -3
- package/src/suites/hopelessness.ts +6 -6
- package/src/suites/injection.ts +2 -2
- package/src/summary.ts +59 -8
- package/src/testing.ts +77 -0
- package/src/todo.ts +318 -0
- package/src/types.ts +57 -9
- package/starter/index.ts +7 -0
- package/templates/lib/evalkeeper/actions.ts +20 -0
package/src/react/app.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { BoardRow } from "../board.js";
|
|
|
8
8
|
import type { VersionedSettings } from "../settings.js";
|
|
9
9
|
import type { AnswerEditorProps, AnySuite } from "../types.js";
|
|
10
10
|
import { weeklySummary, type WeeklySummary } from "../weekly.js";
|
|
11
|
+
import type { EvalSpending } from "../spending.js";
|
|
11
12
|
|
|
12
13
|
/** A form action: a server action the screens' forms submit to. */
|
|
13
14
|
export type FormAction = (form: FormData) => Promise<void>;
|
|
@@ -45,6 +46,16 @@ export type EvalActions = {
|
|
|
45
46
|
setPriority?: FormAction;
|
|
46
47
|
/** Keeping a split case's answer as right, after checking it. */
|
|
47
48
|
keepAnswer?: FormAction;
|
|
49
|
+
/** Retiring starter cases a starter update replaced. */
|
|
50
|
+
retireReplacedStarters?: FormAction;
|
|
51
|
+
/** Saving a suite's settings (its target number of cases). */
|
|
52
|
+
saveSuiteSettings?: FormAction;
|
|
53
|
+
/** Saving the daily spending limits; needs your app's `spending`. */
|
|
54
|
+
saveLimits?: FormAction;
|
|
55
|
+
/** Stopping every test now; needs your app's `spending.stopAll`. */
|
|
56
|
+
stopTests?: FormAction;
|
|
57
|
+
/** Lifting a stop early; needs your app's `spending.allow`. */
|
|
58
|
+
allowTests?: FormAction;
|
|
48
59
|
runWeeklyNow: () => Promise<void>;
|
|
49
60
|
/** Blind rating; only for an app with the rate page. */
|
|
50
61
|
rateBlind?: FormAction;
|
|
@@ -84,6 +95,13 @@ export type EvalApp = {
|
|
|
84
95
|
* description when there is one. Leave it out to skip that list.
|
|
85
96
|
*/
|
|
86
97
|
features?: { operation: string; label: string; description?: string }[];
|
|
98
|
+
/**
|
|
99
|
+
* What eval tests spent against your daily limits, and the stop. Your
|
|
100
|
+
* app keeps the numbers and enforces the limits; the pages show them
|
|
101
|
+
* (in the page menu, or in a warning when tests are over a limit,
|
|
102
|
+
* stopped, or running) and save the limits. Leave it out to show none.
|
|
103
|
+
*/
|
|
104
|
+
spending?: EvalSpending;
|
|
87
105
|
};
|
|
88
106
|
|
|
89
107
|
/** An `EvalApp` with its suites by key, as the screens read it. */
|
package/src/react/format.ts
CHANGED
|
@@ -45,3 +45,18 @@ export const momentOf = (d: Date, timeZone?: string): string =>
|
|
|
45
45
|
* styled as buttons, card titles, and the back link have their own look.
|
|
46
46
|
*/
|
|
47
47
|
export const LINK = "text-accent hover:underline";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A tinted background with readable text, from the app's color names
|
|
51
|
+
* (`--color-good`, `--color-warn`, `--color-bad`), so the app's
|
|
52
|
+
* evalkeeper.css decides both themes: no fixed palette colors and no
|
|
53
|
+
* `dark:` variants, which follow the system rather than the app.
|
|
54
|
+
*/
|
|
55
|
+
export const TINT = {
|
|
56
|
+
good: "bg-good/15 text-[color-mix(in_srgb,var(--color-good)_55%,var(--color-ink))]",
|
|
57
|
+
warn: "bg-warn/15 text-[color-mix(in_srgb,var(--color-warn)_55%,var(--color-ink))]",
|
|
58
|
+
bad: "bg-bad/10 text-[color-mix(in_srgb,var(--color-bad)_60%,var(--color-ink))]",
|
|
59
|
+
} as const;
|
|
60
|
+
|
|
61
|
+
/** A warning panel's tint: the warn color, faint, behind ink text. */
|
|
62
|
+
export const WARN_PANEL = "bg-warn/10 border border-warn/40";
|
package/src/react/index.ts
CHANGED
|
@@ -28,4 +28,7 @@ export * from "./SideBySideView.js";
|
|
|
28
28
|
export * from "./RateView.js";
|
|
29
29
|
export * from "./FeedbackView.js";
|
|
30
30
|
export * from "./ModelMenu.js";
|
|
31
|
+
export * from "./Menu.js";
|
|
32
|
+
export * from "./Drawer.js";
|
|
33
|
+
export * from "./Spending.js";
|
|
31
34
|
export * from "./Tabs.js";
|
package/src/react/pieces.tsx
CHANGED
|
@@ -17,7 +17,9 @@ import {
|
|
|
17
17
|
type HealthStanding,
|
|
18
18
|
type HealthStatus,
|
|
19
19
|
} from "../health.js";
|
|
20
|
-
import { dayOf, momentOf, pct, QUIET_BUTTON } from "./format.js";
|
|
20
|
+
import { dayOf, momentOf, pct, QUIET_BUTTON, TINT } from "./format.js";
|
|
21
|
+
import { SUITE_STATUS_LABEL, type SuiteStatus } from "../todo.js";
|
|
22
|
+
import { SEVERITY_LABEL, type CheckDef } from "../types.js";
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* The pieces Evalkeeper's screens are built from. Each draws Evalkeeper's
|
|
@@ -27,12 +29,14 @@ import { dayOf, momentOf, pct, QUIET_BUTTON } from "./format.js";
|
|
|
27
29
|
* client components).
|
|
28
30
|
*/
|
|
29
31
|
|
|
32
|
+
// Every tone from the app's color names, so its evalkeeper.css decides
|
|
33
|
+
// both themes.
|
|
30
34
|
const CHIP = {
|
|
31
|
-
live:
|
|
32
|
-
fallback: "bg-
|
|
35
|
+
live: TINT.good,
|
|
36
|
+
fallback: "bg-ink/10 text-ink",
|
|
33
37
|
suggested: "bg-accent/10 text-accent",
|
|
34
|
-
warn:
|
|
35
|
-
serious:
|
|
38
|
+
warn: TINT.warn,
|
|
39
|
+
serious: TINT.bad,
|
|
36
40
|
neutral: "bg-tint text-muted",
|
|
37
41
|
} as const;
|
|
38
42
|
|
|
@@ -191,7 +195,7 @@ export function Card(props: CardProps) {
|
|
|
191
195
|
);
|
|
192
196
|
}
|
|
193
197
|
|
|
194
|
-
/** A small rounded label: Live, Fallback, Retires …,
|
|
198
|
+
/** A small rounded label: Live, Fallback, Retires …, Must pass. */
|
|
195
199
|
export function Chip(props: ChipProps) {
|
|
196
200
|
const C = useSwapped("Chip");
|
|
197
201
|
if (C) return createElement(C, props);
|
|
@@ -234,13 +238,18 @@ function flagChips(f: HealthFlag): { text: string; tone: ChipTone }[] {
|
|
|
234
238
|
...(f.serious
|
|
235
239
|
? [
|
|
236
240
|
{
|
|
237
|
-
text: `${f.serious} serious under
|
|
241
|
+
text: `${f.serious} must-pass ${f.serious === 1 ? "check" : "checks"} under ${f.serious === 1 ? "its" : "their"} aim`,
|
|
238
242
|
tone: "serious" as const,
|
|
239
243
|
},
|
|
240
244
|
]
|
|
241
245
|
: []),
|
|
242
246
|
...(f.minor
|
|
243
|
-
? [
|
|
247
|
+
? [
|
|
248
|
+
{
|
|
249
|
+
text: `${f.minor} nice-to-have ${f.minor === 1 ? "check" : "checks"} under ${f.minor === 1 ? "its" : "their"} aim`,
|
|
250
|
+
tone: "warn" as const,
|
|
251
|
+
},
|
|
252
|
+
]
|
|
244
253
|
: []),
|
|
245
254
|
];
|
|
246
255
|
case "suggestLive":
|
|
@@ -278,9 +287,42 @@ export function StandingBadge({ standing }: { standing: HealthStanding }) {
|
|
|
278
287
|
return <Chip tone={STANDING_TONE[standing]}>{STANDING_LABEL[standing]}</Chip>;
|
|
279
288
|
}
|
|
280
289
|
|
|
290
|
+
const SUITE_STATUS_TONE: Record<SuiteStatus, ChipTone> = {
|
|
291
|
+
attention: "warn",
|
|
292
|
+
unknown: "neutral",
|
|
293
|
+
healthy: "live",
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* A suite's status on the hub and its page: Needs attention (amber), Can't
|
|
298
|
+
* tell yet (gray), or Healthy (green). Each color means only that.
|
|
299
|
+
*/
|
|
300
|
+
export function SuiteStatusBadge({ status }: { status: SuiteStatus }) {
|
|
301
|
+
return (
|
|
302
|
+
<Chip tone={SUITE_STATUS_TONE[status]}>{SUITE_STATUS_LABEL[status]}</Chip>
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** A check's severity as the pages say it: Must pass, or Nice to have. */
|
|
307
|
+
export function SeverityChip({ severity }: { severity: CheckDef["severity"] }) {
|
|
308
|
+
return (
|
|
309
|
+
<Chip
|
|
310
|
+
tone={
|
|
311
|
+
severity === "serious"
|
|
312
|
+
? "serious"
|
|
313
|
+
: severity === "moderate"
|
|
314
|
+
? "warn"
|
|
315
|
+
: "neutral"
|
|
316
|
+
}
|
|
317
|
+
>
|
|
318
|
+
{SEVERITY_LABEL[severity]}
|
|
319
|
+
</Chip>
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
281
323
|
/**
|
|
282
|
-
* The reasons behind a suite's standing as one plain line ("1
|
|
283
|
-
* under
|
|
324
|
+
* The reasons behind a suite's standing as one plain line ("1 must-pass
|
|
325
|
+
* check under its aim · New fallback suggested"), for under its name. Provisional
|
|
284
326
|
* answers are left out: a choice, not a problem, so the card says it in a
|
|
285
327
|
* footnote instead.
|
|
286
328
|
*/
|
|
@@ -289,8 +331,9 @@ export function HealthReasons({ flags }: { flags: readonly HealthFlag[] }) {
|
|
|
289
331
|
.filter((f) => f.kind !== "provisional" && f.kind !== "good")
|
|
290
332
|
.flatMap(flagChips);
|
|
291
333
|
if (!reasons.length) return null;
|
|
292
|
-
// Each in its standing's color with an icon, so it
|
|
293
|
-
// without another row of chips.
|
|
334
|
+
// Each in its standing's color, urgent ones with an alert icon, so it
|
|
335
|
+
// reads at a glance without another row of chips. The others get no
|
|
336
|
+
// icon: an (i) is only ever a tip you can open.
|
|
294
337
|
return (
|
|
295
338
|
<ul className="flex flex-wrap gap-x-4 gap-y-1 text-sm font-medium">
|
|
296
339
|
{reasons.map((r) => {
|
|
@@ -306,11 +349,7 @@ export function HealthReasons({ flags }: { flags: readonly HealthFlag[] }) {
|
|
|
306
349
|
: "text-ink"
|
|
307
350
|
}`}
|
|
308
351
|
>
|
|
309
|
-
{urgent
|
|
310
|
-
<CircleAlert aria-hidden className="h-4 w-4 shrink-0" />
|
|
311
|
-
) : (
|
|
312
|
-
<Info aria-hidden className="h-4 w-4 shrink-0 text-muted" />
|
|
313
|
-
)}
|
|
352
|
+
{urgent && <CircleAlert aria-hidden className="h-4 w-4 shrink-0" />}
|
|
314
353
|
{r.text}
|
|
315
354
|
</li>
|
|
316
355
|
);
|
|
@@ -320,7 +359,7 @@ export function HealthReasons({ flags }: { flags: readonly HealthFlag[] }) {
|
|
|
320
359
|
}
|
|
321
360
|
|
|
322
361
|
/**
|
|
323
|
-
* A suite's health as chips naming each reason ("2
|
|
362
|
+
* A suite's health as chips naming each reason ("2 must-pass checks under their aim",
|
|
324
363
|
* "New fallback suggested", "Add cases (33 of 50)"), so a card says why at
|
|
325
364
|
* a glance; its details say more.
|
|
326
365
|
*/
|
package/src/runner.ts
CHANGED
|
@@ -48,6 +48,14 @@ export { confirmedLabel, isProvisional };
|
|
|
48
48
|
import { injectionSuitesOf, type AnySuite, type CheckResult } from "./types.js";
|
|
49
49
|
import { injectionCases } from "./suites/injection.js";
|
|
50
50
|
import { at } from "./util.js";
|
|
51
|
+
import { targetCasesOf } from "./summary.js";
|
|
52
|
+
import {
|
|
53
|
+
NO_SUITE_SETTINGS,
|
|
54
|
+
effectiveChecks,
|
|
55
|
+
levelsOf,
|
|
56
|
+
type SuiteSettings,
|
|
57
|
+
type SuiteSettingsStore,
|
|
58
|
+
} from "./suiteSettings.js";
|
|
51
59
|
import { mustGet } from "./util.js";
|
|
52
60
|
|
|
53
61
|
/**
|
|
@@ -136,6 +144,13 @@ export type RunnerOptions = {
|
|
|
136
144
|
* fallback model, so nobody spends a test on a model that's going away.
|
|
137
145
|
*/
|
|
138
146
|
retiringOnBoard?: "always" | "inUse";
|
|
147
|
+
/**
|
|
148
|
+
* Where settings a person adjusts on a suite's page are kept (its target
|
|
149
|
+
* number of cases). `memoryStore` and `prismaSuiteSettingsStore` are
|
|
150
|
+
* ones. Without it, every suite uses its values in code, and the page
|
|
151
|
+
* offers no Suite settings.
|
|
152
|
+
*/
|
|
153
|
+
suiteSettings?: SuiteSettingsStore;
|
|
139
154
|
};
|
|
140
155
|
|
|
141
156
|
/**
|
|
@@ -549,8 +564,22 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
549
564
|
/** Only these cases' answers count; all when absent. */
|
|
550
565
|
caseIds?: ReadonlySet<string>,
|
|
551
566
|
): Promise<RunMetrics> {
|
|
552
|
-
const
|
|
553
|
-
|
|
567
|
+
const levels = levelsOf(suite.checks);
|
|
568
|
+
// Each result keeps the level it was graded at, so a nice-to-have miss
|
|
569
|
+
// never fails an answer wherever the answer is read.
|
|
570
|
+
const outputs = await Promise.all(
|
|
571
|
+
(await store.listOutputs(run.id))
|
|
572
|
+
.filter((o) => !caseIds || caseIds.has(o.caseId))
|
|
573
|
+
.map(async (o) => {
|
|
574
|
+
if (!o.scores) return o;
|
|
575
|
+
const stamped = o.scores.map((c) => {
|
|
576
|
+
const level = levels[c.key];
|
|
577
|
+
return level ? { ...c, level } : c;
|
|
578
|
+
});
|
|
579
|
+
if (stamped.some((c, i) => c.level !== o.scores?.[i]?.level))
|
|
580
|
+
await store.setOutputScores(o.id, stamped);
|
|
581
|
+
return { ...o, scores: stamped };
|
|
582
|
+
}),
|
|
554
583
|
);
|
|
555
584
|
const scored: ScoredOutput[] = outputs.map((o) => ({
|
|
556
585
|
caseId: o.caseId,
|
|
@@ -567,6 +596,7 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
567
596
|
),
|
|
568
597
|
judgeCostUsd,
|
|
569
598
|
failureReason: commonError(outputs.map((o) => o.error)),
|
|
599
|
+
levels,
|
|
570
600
|
};
|
|
571
601
|
}
|
|
572
602
|
|
|
@@ -581,7 +611,7 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
581
611
|
if (!run || run.status !== "RUNNING") return;
|
|
582
612
|
const leg = o.leg ?? 1;
|
|
583
613
|
try {
|
|
584
|
-
const suite =
|
|
614
|
+
const suite = await effectiveSuite(run.suite);
|
|
585
615
|
const cases = await casesFor(suite.key, run.set);
|
|
586
616
|
const since = new Date(Date.now() - REUSE_DAYS * 86_400_000);
|
|
587
617
|
const jobs = cases.flatMap((c) =>
|
|
@@ -733,7 +763,7 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
733
763
|
async function rescoreRun(runId: string) {
|
|
734
764
|
const run = await store.getRun(runId);
|
|
735
765
|
if (!run) return;
|
|
736
|
-
const suite =
|
|
766
|
+
const suite = await effectiveSuite(run.suite);
|
|
737
767
|
const cases = new Map(
|
|
738
768
|
(await store.listCases(suite.key)).map((c) => [c.id, c]),
|
|
739
769
|
);
|
|
@@ -801,30 +831,96 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
801
831
|
* the tags spread, from the board's current tests.
|
|
802
832
|
*/
|
|
803
833
|
async function answerKeyHealthOf(suiteKey: string, today = new Date()) {
|
|
804
|
-
const [b, cases] = await Promise.all([
|
|
834
|
+
const [b, cases, target] = await Promise.all([
|
|
805
835
|
board(suiteKey),
|
|
806
836
|
store.listCases(suiteKey),
|
|
837
|
+
targetCases(suiteKey),
|
|
807
838
|
]);
|
|
808
|
-
const rounds = await easyRounds(suiteKey, cases);
|
|
809
|
-
return answerKeyHealth(
|
|
839
|
+
const rounds = await easyRounds(suiteKey, cases, target);
|
|
840
|
+
return answerKeyHealth(
|
|
841
|
+
cases,
|
|
842
|
+
withRounds(b.caseResults, rounds),
|
|
843
|
+
today,
|
|
844
|
+
null,
|
|
845
|
+
target,
|
|
846
|
+
);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* A suite's saved settings (its target number of cases), or none saved
|
|
851
|
+
* when there's no `suiteSettings` store or it can't be read: a page
|
|
852
|
+
* still loads, on the suite's values in code.
|
|
853
|
+
*/
|
|
854
|
+
async function suiteSettingsOf(suiteKey: string): Promise<SuiteSettings> {
|
|
855
|
+
if (!opts.suiteSettings) return NO_SUITE_SETTINGS;
|
|
856
|
+
try {
|
|
857
|
+
return await opts.suiteSettings.getSuiteSettings(suiteKey);
|
|
858
|
+
} catch {
|
|
859
|
+
return NO_SUITE_SETTINGS;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* A suite's target number of cases: saved in its settings, else its
|
|
865
|
+
* `targetCases`, else TARGET_CASES. It sets the floor for retiring easy
|
|
866
|
+
* cases, how many drafts to ask for, and when the page asks for more.
|
|
867
|
+
*/
|
|
868
|
+
async function targetCases(suiteKey: string): Promise<number> {
|
|
869
|
+
return targetCasesOf(
|
|
870
|
+
suiteOrThrow(suiteKey),
|
|
871
|
+
await suiteSettingsOf(suiteKey),
|
|
872
|
+
);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* A suite with a person's levels and aims (Suite settings) in place of
|
|
877
|
+
* its checks' own: what grading, the board, and the pages use.
|
|
878
|
+
*/
|
|
879
|
+
async function effectiveSuite(suiteKey: string): Promise<AnySuite> {
|
|
880
|
+
const suite = suiteOrThrow(suiteKey);
|
|
881
|
+
if (!opts.suiteSettings) return suite;
|
|
882
|
+
const saved = await suiteSettingsOf(suite.key);
|
|
883
|
+
return { ...suite, checks: effectiveChecks(suite.checks, saved) };
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Saves a suite's settings, as a person changed them on its page.
|
|
888
|
+
* Throws without a `suiteSettings` store.
|
|
889
|
+
*/
|
|
890
|
+
async function saveSuiteSettings(
|
|
891
|
+
suiteKey: string,
|
|
892
|
+
settings: SuiteSettings,
|
|
893
|
+
by: string | null,
|
|
894
|
+
): Promise<void> {
|
|
895
|
+
if (!opts.suiteSettings)
|
|
896
|
+
throw new Error(
|
|
897
|
+
"Suite settings need a place to keep them: pass suiteSettings to createRunner.",
|
|
898
|
+
);
|
|
899
|
+
await opts.suiteSettings.saveSuiteSettings(
|
|
900
|
+
suiteOrThrow(suiteKey).key,
|
|
901
|
+
settings,
|
|
902
|
+
by,
|
|
903
|
+
);
|
|
810
904
|
}
|
|
811
905
|
|
|
812
906
|
/**
|
|
813
907
|
* Per case, the rounds of testing it passed (EASY_MIN_ROUNDS): days on
|
|
814
908
|
* which at least EASY_MIN_MODELS models were tested on it and every one
|
|
815
909
|
* got it fully right (all repeats), counted only after its answer last
|
|
816
|
-
* changed. Empty when the suite has
|
|
817
|
-
*
|
|
910
|
+
* changed. Empty when the suite has its floor of cases in use or fewer
|
|
911
|
+
* (its target number of cases, EASY_FLOOR_CASES by default): nothing can
|
|
912
|
+
* be retired then, so the history isn't read.
|
|
818
913
|
*/
|
|
819
914
|
async function easyRounds(
|
|
820
915
|
suiteKey: string,
|
|
821
916
|
cases?: readonly CaseRecord[],
|
|
917
|
+
floor: number = EASY_FLOOR_CASES,
|
|
822
918
|
): Promise<Record<string, number>> {
|
|
823
919
|
const all = cases ?? (await store.listCases(suiteKey));
|
|
824
920
|
const inUse = all.filter(
|
|
825
921
|
(c) => c.status !== "RETIRED" && confirmedLabel(c.labels),
|
|
826
922
|
);
|
|
827
|
-
if (inUse.length <=
|
|
923
|
+
if (inUse.length <= floor) return {};
|
|
828
924
|
const since = new Map(
|
|
829
925
|
inUse.map((c) => {
|
|
830
926
|
const l = confirmedLabel(c.labels);
|
|
@@ -992,7 +1088,7 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
992
1088
|
* the two answers side by side.
|
|
993
1089
|
*/
|
|
994
1090
|
async function compare(suiteKey: string, a: string, b: string) {
|
|
995
|
-
const suite =
|
|
1091
|
+
const suite = await effectiveSuite(suiteKey);
|
|
996
1092
|
const [ra, rb] = await Promise.all([store.getRun(a), store.getRun(b)]);
|
|
997
1093
|
if (
|
|
998
1094
|
!ra ||
|
|
@@ -1075,7 +1171,12 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
1075
1171
|
async function board(suiteKey: string) {
|
|
1076
1172
|
if (!opts.route || !opts.candidates)
|
|
1077
1173
|
throw new Error("The board needs the route and candidates options");
|
|
1078
|
-
|
|
1174
|
+
// With a person's levels and aims, so every page reads the same checks.
|
|
1175
|
+
const suite = await effectiveSuite(suiteKey);
|
|
1176
|
+
const levels = levelsOf(suite.checks);
|
|
1177
|
+
const sameLevels = (r: RunRecord) =>
|
|
1178
|
+
!r.metrics?.levels ||
|
|
1179
|
+
Object.entries(levels).every(([k, l]) => r.metrics?.levels?.[k] === l);
|
|
1079
1180
|
const [route, cases, prompt] = await Promise.all([
|
|
1080
1181
|
opts.route(suite.operation),
|
|
1081
1182
|
casesFor(suite.key, "ALL"),
|
|
@@ -1111,7 +1212,10 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
1111
1212
|
const liveCap = route.maxOutputTokens ?? null;
|
|
1112
1213
|
// A test at another temperature or output cap than the live ones
|
|
1113
1214
|
// answered differently.
|
|
1215
|
+
// Tests graded at other levels need a rescore (free); tests from
|
|
1216
|
+
// before levels were kept count as current.
|
|
1114
1217
|
const isCurrent = (r: RunRecord) =>
|
|
1218
|
+
sameLevels(r) &&
|
|
1115
1219
|
r.datasetVersion === current &&
|
|
1116
1220
|
r.promptVersion === prompt &&
|
|
1117
1221
|
(r.temperature ?? null) === liveTemperature &&
|
|
@@ -1428,6 +1532,12 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
1428
1532
|
answerKeyHealth: answerKeyHealthOf,
|
|
1429
1533
|
retireEasy,
|
|
1430
1534
|
easyRounds,
|
|
1535
|
+
targetCases,
|
|
1536
|
+
effectiveSuite,
|
|
1537
|
+
suiteSettings: suiteSettingsOf,
|
|
1538
|
+
saveSuiteSettings,
|
|
1539
|
+
/** Whether suite settings can be saved (a `suiteSettings` store). */
|
|
1540
|
+
canSaveSuiteSettings: opts.suiteSettings !== undefined,
|
|
1431
1541
|
retireStaleDrafts,
|
|
1432
1542
|
stopStuckRuns,
|
|
1433
1543
|
compare,
|
package/src/settings.ts
CHANGED
|
@@ -197,6 +197,26 @@ export class SettingsConflict extends Error {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
/**
|
|
201
|
+
* A feature's live settings, or null when it has none yet (no version,
|
|
202
|
+
* and no default in code). Use it where one feature with no settings must
|
|
203
|
+
* not break a page that shows many.
|
|
204
|
+
*
|
|
205
|
+
* @param settings - Your versioned settings (`createSettings`).
|
|
206
|
+
* @param operation - The feature.
|
|
207
|
+
*/
|
|
208
|
+
export async function currentSettings(
|
|
209
|
+
settings: Pick<VersionedSettings, "current">,
|
|
210
|
+
operation: string,
|
|
211
|
+
): Promise<{ settings: Settings; version: SettingsVersion | null } | null> {
|
|
212
|
+
try {
|
|
213
|
+
return await settings.current(operation);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
if (e instanceof NoSettingsError) return null;
|
|
216
|
+
throw e;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
200
220
|
/**
|
|
201
221
|
* A feature has no settings: no version yet, and no default in code. Apps
|
|
202
222
|
* whose models are chosen in an admin page, not in code, see this until
|
package/src/spending.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What eval tests have spent against daily limits, and the stop, as the
|
|
3
|
+
* eval pages show them. Your app keeps the numbers and enforces the limits
|
|
4
|
+
* where its AI calls are made; Evalkeeper draws the panel and the form, so
|
|
5
|
+
* no app adds its own UI to the eval pages. Pure, apart from
|
|
6
|
+
* `memorySpending`, which keeps everything in memory for demos and tests.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Spending over the last 24 hours against the daily limits. */
|
|
10
|
+
export type SpendingReading = {
|
|
11
|
+
/** USD every eval test spent in the last 24 hours, all features. */
|
|
12
|
+
spentUsd: number;
|
|
13
|
+
/** The daily limit for all tests together, in USD. */
|
|
14
|
+
limitUsd: number;
|
|
15
|
+
/** Tests are stopped until then; null: not stopped. */
|
|
16
|
+
stoppedUntil: Date | null;
|
|
17
|
+
/** Tests running now. */
|
|
18
|
+
running: number;
|
|
19
|
+
/** The feature a suite's page tests, when the reading is for one. */
|
|
20
|
+
feature?: {
|
|
21
|
+
operation: string;
|
|
22
|
+
spentUsd: number;
|
|
23
|
+
/** Its own daily limit, in USD; null: none of its own. */
|
|
24
|
+
limitUsd: number | null;
|
|
25
|
+
/** What an empty limit falls back to (null: none of its own), for the form. */
|
|
26
|
+
defaultUsd: number | null;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** The limits a person saves, from the Spending and daily limits form. */
|
|
31
|
+
export type SpendingLimits = {
|
|
32
|
+
/** The daily limit for all tests, in USD. */
|
|
33
|
+
allUsd: number;
|
|
34
|
+
/** The feature's own limit; null: its default. Only on a suite's page. */
|
|
35
|
+
feature?: { operation: string; usd: number | null };
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Your app's spending, for the eval pages: read it, save limits, and stop
|
|
40
|
+
* or allow tests. Pass it as `spending` in your wiring. Without it, the
|
|
41
|
+
* pages show no spending at all.
|
|
42
|
+
*/
|
|
43
|
+
export type EvalSpending = {
|
|
44
|
+
/** Spending and limits; with an operation, that feature's too. */
|
|
45
|
+
read(operation?: string): Promise<SpendingReading>;
|
|
46
|
+
/** Saves both limits at once (one form, one Save). */
|
|
47
|
+
saveLimits(limits: SpendingLimits, by: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Stops every test now: no eval call is allowed for a while, and tests
|
|
50
|
+
* marked running are closed. Returns how many it closed. Leave it out
|
|
51
|
+
* and the pages offer no Stop.
|
|
52
|
+
*/
|
|
53
|
+
stopAll?(by: string): Promise<number>;
|
|
54
|
+
/** Lifts a stop early; the limits still apply. */
|
|
55
|
+
allow?(): Promise<void>;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** The most a limit can be set to, so a typo can't remove it. */
|
|
59
|
+
export const MAX_LIMIT_USD = 500;
|
|
60
|
+
|
|
61
|
+
/** USD as the pages show money: "$15.00". */
|
|
62
|
+
export const usd = (n: number): string => `$${n.toFixed(2)}`;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A limit as typed, in dollars: a number from a cent to MAX_LIMIT_USD
|
|
66
|
+
* (a leading $ and commas allowed), rounded to the cent; null when empty.
|
|
67
|
+
* Throws a sentence a person can act on when it doesn't fit.
|
|
68
|
+
*
|
|
69
|
+
* @param typed - The field's text.
|
|
70
|
+
*/
|
|
71
|
+
export function parseLimit(typed: string): number | null {
|
|
72
|
+
const t = typed.trim().replace(/^\$/, "").replaceAll(",", "");
|
|
73
|
+
if (!t) return null;
|
|
74
|
+
const n = Number(t);
|
|
75
|
+
if (!Number.isFinite(n) || n < 0.01 || n > MAX_LIMIT_USD)
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Enter a limit in dollars, from $0.01 to ${usd(MAX_LIMIT_USD)}.`,
|
|
78
|
+
);
|
|
79
|
+
return Math.round(n * 100) / 100;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Reads the Spending and daily limits form: `allUsd` (required) and, on a
|
|
84
|
+
* suite's page, `operation` and `featureUsd` (empty: its default).
|
|
85
|
+
*
|
|
86
|
+
* @param form - The submitted form.
|
|
87
|
+
*/
|
|
88
|
+
export function limitsFromForm(form: FormData): SpendingLimits {
|
|
89
|
+
const text = (k: string) => {
|
|
90
|
+
const v = form.get(k);
|
|
91
|
+
return typeof v === "string" ? v : "";
|
|
92
|
+
};
|
|
93
|
+
const allUsd = parseLimit(text("allUsd"));
|
|
94
|
+
if (allUsd === null) throw new Error("Enter a daily limit for all tests.");
|
|
95
|
+
const operation = text("operation").trim();
|
|
96
|
+
return operation
|
|
97
|
+
? { allUsd, feature: { operation, usd: parseLimit(text("featureUsd")) } }
|
|
98
|
+
: { allUsd };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Why tests can't run now, in words that say what to do; null: they can. */
|
|
102
|
+
export function spendingHalt(
|
|
103
|
+
r: SpendingReading,
|
|
104
|
+
now: Date = new Date(),
|
|
105
|
+
): string | null {
|
|
106
|
+
if (r.stoppedUntil && r.stoppedUntil > now)
|
|
107
|
+
return `Tests are stopped until ${timeOf(r.stoppedUntil)}. Answers already given are kept, and reused when you test again. Allow tests to start sooner.`;
|
|
108
|
+
if (r.spentUsd >= r.limitUsd)
|
|
109
|
+
return `Tests have spent ${usd(r.spentUsd)} in the last 24 hours, over the ${usd(r.limitUsd)} daily limit for all tests. Raise the limit, or wait until earlier spending is more than 24 hours old.`;
|
|
110
|
+
const f = r.feature;
|
|
111
|
+
if (f && f.limitUsd !== null && f.spentUsd >= f.limitUsd)
|
|
112
|
+
return `This feature's tests have spent ${usd(f.spentUsd)} in the last 24 hours, over its ${usd(f.limitUsd)} daily limit. Raise its limit, or wait until earlier spending is more than 24 hours old.`;
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Whether spending earns room on the page: tests are stopped, over a
|
|
118
|
+
* limit, or running (so Stop is in reach). Otherwise it stays in the
|
|
119
|
+
* page's menu.
|
|
120
|
+
*/
|
|
121
|
+
export function spendingNeedsRoom(
|
|
122
|
+
r: SpendingReading,
|
|
123
|
+
now: Date = new Date(),
|
|
124
|
+
): boolean {
|
|
125
|
+
return r.running > 0 || spendingHalt(r, now) !== null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const timeOf = (d: Date) =>
|
|
129
|
+
d.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Spending kept in memory, for demos and tests: you add what each test
|
|
133
|
+
* spends (`spend`) and how many run (`setRunning`), and the stop lasts
|
|
134
|
+
* `stopMinutes`.
|
|
135
|
+
*
|
|
136
|
+
* @param opts - Starting limits, defaults per feature, and how long a stop lasts.
|
|
137
|
+
*/
|
|
138
|
+
export function memorySpending(
|
|
139
|
+
opts: {
|
|
140
|
+
limitUsd?: number;
|
|
141
|
+
featureDefaults?: Readonly<Record<string, number>>;
|
|
142
|
+
stopMinutes?: number;
|
|
143
|
+
} = {},
|
|
144
|
+
): EvalSpending & {
|
|
145
|
+
/** Records USD a feature's test spent, now. */
|
|
146
|
+
spend(operation: string, usd: number, at?: Date): void;
|
|
147
|
+
/** Sets how many tests are running. */
|
|
148
|
+
setRunning(n: number): void;
|
|
149
|
+
} {
|
|
150
|
+
let limitUsd = opts.limitUsd ?? 15;
|
|
151
|
+
const own = new Map<string, number>();
|
|
152
|
+
const spent: { operation: string; usd: number; at: Date }[] = [];
|
|
153
|
+
let running = 0;
|
|
154
|
+
let stoppedUntil: Date | null = null;
|
|
155
|
+
const since = () => Date.now() - 24 * 60 * 60 * 1000;
|
|
156
|
+
const sum = (op?: string) =>
|
|
157
|
+
spent
|
|
158
|
+
.filter(
|
|
159
|
+
(s) => +s.at >= since() && (op === undefined || s.operation === op),
|
|
160
|
+
)
|
|
161
|
+
.reduce((t, s) => t + s.usd, 0);
|
|
162
|
+
return {
|
|
163
|
+
async read(operation) {
|
|
164
|
+
const defaultUsd =
|
|
165
|
+
operation === undefined
|
|
166
|
+
? null
|
|
167
|
+
: (opts.featureDefaults?.[operation] ?? null);
|
|
168
|
+
return {
|
|
169
|
+
spentUsd: sum(),
|
|
170
|
+
limitUsd,
|
|
171
|
+
stoppedUntil,
|
|
172
|
+
running,
|
|
173
|
+
...(operation === undefined
|
|
174
|
+
? {}
|
|
175
|
+
: {
|
|
176
|
+
feature: {
|
|
177
|
+
operation,
|
|
178
|
+
spentUsd: sum(operation),
|
|
179
|
+
limitUsd: own.get(operation) ?? defaultUsd,
|
|
180
|
+
defaultUsd,
|
|
181
|
+
},
|
|
182
|
+
}),
|
|
183
|
+
};
|
|
184
|
+
},
|
|
185
|
+
async saveLimits(limits) {
|
|
186
|
+
limitUsd = limits.allUsd;
|
|
187
|
+
const f = limits.feature;
|
|
188
|
+
if (f) {
|
|
189
|
+
if (f.usd === null) own.delete(f.operation);
|
|
190
|
+
else own.set(f.operation, f.usd);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
async stopAll() {
|
|
194
|
+
stoppedUntil = new Date(Date.now() + (opts.stopMinutes ?? 15) * 60_000);
|
|
195
|
+
const closed = running;
|
|
196
|
+
running = 0;
|
|
197
|
+
return closed;
|
|
198
|
+
},
|
|
199
|
+
async allow() {
|
|
200
|
+
stoppedUntil = null;
|
|
201
|
+
},
|
|
202
|
+
spend(operation, amount, at = new Date()) {
|
|
203
|
+
spent.push({ operation, usd: amount, at });
|
|
204
|
+
},
|
|
205
|
+
setRunning(n) {
|
|
206
|
+
running = n;
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
}
|
package/src/stats.ts
CHANGED
|
@@ -86,10 +86,16 @@ export type SuiteMetrics = {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* Whether an answer passed every check that applied
|
|
89
|
+
* Whether an answer passed every check that applied, leaving out
|
|
90
|
+
* nice-to-have (minor) misses, which never fail an answer. A failed answer
|
|
91
|
+
* (null) didn't.
|
|
90
92
|
*/
|
|
91
93
|
export function allPassed(checks: CheckResult[] | null): boolean {
|
|
92
|
-
|
|
94
|
+
// A nice-to-have miss is a fair difference of judgment: never a failure.
|
|
95
|
+
return (
|
|
96
|
+
checks !== null &&
|
|
97
|
+
checks.every((c) => c.pass !== false || c.level === "minor")
|
|
98
|
+
);
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
/**
|