@crowandraven/evalkeeper 0.12.0 → 0.14.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/drafts.d.ts +2 -0
- package/dist/drafts.js +3 -1
- package/dist/drafts.js.map +1 -1
- package/dist/failures.d.ts +16 -0
- package/dist/failures.js +40 -0
- package/dist/failures.js.map +1 -0
- package/dist/glossary.d.ts +4 -2
- package/dist/glossary.js +4 -2
- package/dist/glossary.js.map +1 -1
- package/dist/health.d.ts +35 -2
- package/dist/health.js +31 -6
- package/dist/health.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/legs.d.ts +4 -1
- package/dist/legs.js +6 -2
- package/dist/legs.js.map +1 -1
- package/dist/next/actions.js +79 -15
- package/dist/next/actions.js.map +1 -1
- package/dist/next/route.js +2 -1
- package/dist/next/route.js.map +1 -1
- package/dist/next/weekly.d.ts +7 -2
- package/dist/next/weekly.js +5 -3
- package/dist/next/weekly.js.map +1 -1
- package/dist/next/wiring.d.ts +6 -0
- package/dist/order.d.ts +18 -0
- package/dist/order.js +53 -0
- package/dist/order.js.map +1 -0
- package/dist/prisma/index.d.ts +1 -0
- package/dist/prisma/index.js +3 -0
- package/dist/prisma/index.js.map +1 -1
- package/dist/prune.d.ts +4 -1
- package/dist/prune.js +11 -2
- package/dist/prune.js.map +1 -1
- package/dist/react/AddCase.d.ts +12 -2
- package/dist/react/AddCase.js +70 -8
- package/dist/react/AddCase.js.map +1 -1
- package/dist/react/AnswerKey.js +11 -5
- package/dist/react/AnswerKey.js.map +1 -1
- package/dist/react/CaseMenu.d.ts +6 -1
- package/dist/react/CaseMenu.js +5 -2
- package/dist/react/CaseMenu.js.map +1 -1
- package/dist/react/CompareView.js +4 -4
- package/dist/react/CompareView.js.map +1 -1
- package/dist/react/FeedbackView.js +3 -3
- package/dist/react/FeedbackView.js.map +1 -1
- package/dist/react/HubSections.js +11 -10
- package/dist/react/HubSections.js.map +1 -1
- package/dist/react/ModelMenu.d.ts +13 -4
- package/dist/react/ModelMenu.js +12 -7
- package/dist/react/ModelMenu.js.map +1 -1
- package/dist/react/PriorityPicker.d.ts +21 -0
- package/dist/react/PriorityPicker.js +47 -0
- package/dist/react/PriorityPicker.js.map +1 -0
- package/dist/react/RateView.js +1 -0
- package/dist/react/RateView.js.map +1 -1
- package/dist/react/RunView.js +21 -5
- package/dist/react/RunView.js.map +1 -1
- package/dist/react/SettingsHistory.js +3 -3
- package/dist/react/SettingsHistory.js.map +1 -1
- package/dist/react/SuiteSections.d.ts +6 -0
- package/dist/react/SuiteSections.js +100 -39
- package/dist/react/SuiteSections.js.map +1 -1
- package/dist/react/WeeklyCheck.js +4 -8
- package/dist/react/WeeklyCheck.js.map +1 -1
- package/dist/react/app.d.ts +4 -0
- package/dist/react/app.js.map +1 -1
- package/dist/react/format.d.ts +2 -2
- package/dist/react/format.js +4 -2
- package/dist/react/format.js.map +1 -1
- package/dist/react/pieces.d.ts +21 -1
- package/dist/react/pieces.js +67 -2
- package/dist/react/pieces.js.map +1 -1
- package/dist/runner.d.ts +7 -2
- package/dist/runner.js +5 -2
- package/dist/runner.js.map +1 -1
- package/dist/settings.d.ts +14 -0
- package/dist/settings.js +24 -2
- package/dist/settings.js.map +1 -1
- package/dist/suggest.js +25 -7
- package/dist/suggest.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +32 -0
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -1
- package/package.json +10 -10
- package/schema/evalkeeper.prisma +3 -0
- package/src/drafts.ts +6 -1
- package/src/failures.ts +50 -0
- package/src/glossary.ts +6 -2
- package/src/health.ts +55 -7
- package/src/index.ts +2 -0
- package/src/legs.ts +8 -2
- package/src/next/actions.ts +96 -17
- package/src/next/route.ts +2 -1
- package/src/next/weekly.ts +15 -4
- package/src/next/wiring.ts +6 -0
- package/src/order.ts +64 -0
- package/src/prisma/index.ts +5 -0
- package/src/prune.ts +15 -1
- package/src/react/AddCase.tsx +98 -11
- package/src/react/AnswerKey.tsx +74 -14
- package/src/react/CaseMenu.tsx +24 -0
- package/src/react/CompareView.tsx +19 -4
- package/src/react/FeedbackView.tsx +13 -3
- package/src/react/HubSections.tsx +18 -11
- package/src/react/ModelMenu.tsx +24 -7
- package/src/react/PriorityPicker.tsx +143 -0
- package/src/react/RateView.tsx +1 -0
- package/src/react/RunView.tsx +41 -6
- package/src/react/SettingsHistory.tsx +3 -3
- package/src/react/SuiteSections.tsx +418 -251
- package/src/react/WeeklyCheck.tsx +12 -6
- package/src/react/app.ts +4 -0
- package/src/react/format.ts +4 -2
- package/src/react/pieces.tsx +96 -2
- package/src/runner.ts +11 -4
- package/src/settings.ts +37 -2
- package/src/suggest.ts +26 -7
- package/src/testing.ts +35 -1
- package/src/types.ts +18 -0
- package/templates/lib/evalkeeper/actions.ts +8 -0
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
RefreshWhile,
|
|
8
8
|
Submit,
|
|
9
9
|
Tip,
|
|
10
|
+
LocalDate,
|
|
10
11
|
} from "./pieces.js";
|
|
11
|
-
import { pct,
|
|
12
|
+
import { pct, LINK } from "./format.js";
|
|
12
13
|
import { evalsPath, type EvalAppConfig } from "./app.js";
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -37,11 +38,16 @@ export function WeeklyCheck({
|
|
|
37
38
|
</div>
|
|
38
39
|
<Card className="space-y-4">
|
|
39
40
|
<p className="readable text-sm text-muted">
|
|
40
|
-
{weekly.running > 0
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
{weekly.running > 0 ? (
|
|
42
|
+
`Running now: ${weekly.running} quick set${weekly.running === 1 ? "" : "s"} left. `
|
|
43
|
+
) : weekly.lastAt ? (
|
|
44
|
+
<>
|
|
45
|
+
Last run <LocalDate date={weekly.lastAt} />,{" "}
|
|
46
|
+
{money(weekly.costUsd)}.{" "}
|
|
47
|
+
</>
|
|
48
|
+
) : (
|
|
49
|
+
"Not run yet. "
|
|
50
|
+
)}
|
|
45
51
|
Every Monday, each live model answers its suite's quick set
|
|
46
52
|
again, so a quiet change by its provider shows up here. It also flags
|
|
47
53
|
models retiring soon and features people rate poorly. Suites that can
|
package/src/react/app.ts
CHANGED
|
@@ -41,6 +41,10 @@ export type EvalActions = {
|
|
|
41
41
|
draftMore?: FormAction;
|
|
42
42
|
/** Putting draft answers to use before review, as provisional. */
|
|
43
43
|
useDraftsProvisionally?: FormAction;
|
|
44
|
+
/** Changing what a feature's suggestion favors, as a settings version. */
|
|
45
|
+
setPriority?: FormAction;
|
|
46
|
+
/** Keeping a split case's answer as right, after checking it. */
|
|
47
|
+
keepAnswer?: FormAction;
|
|
44
48
|
runWeeklyNow: () => Promise<void>;
|
|
45
49
|
/** Blind rating; only for an app with the rate page. */
|
|
46
50
|
rateBlind?: FormAction;
|
package/src/react/format.ts
CHANGED
|
@@ -20,21 +20,23 @@ export const QUIET_BUTTON =
|
|
|
20
20
|
* A day, with the month as a word so no reader mistakes it:
|
|
21
21
|
* "Oct 28, 2026" (10/28 is the 10th of the 28th month in most of the world).
|
|
22
22
|
*/
|
|
23
|
-
export const dayOf = (d: Date): string =>
|
|
23
|
+
export const dayOf = (d: Date, timeZone?: string): string =>
|
|
24
24
|
d.toLocaleDateString("en-US", {
|
|
25
25
|
month: "short",
|
|
26
26
|
day: "numeric",
|
|
27
27
|
year: "numeric",
|
|
28
|
+
...(timeZone ? { timeZone } : {}),
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
/** A day and time, the same way: "Oct 28, 2026, 3:04 PM". */
|
|
31
|
-
export const momentOf = (d: Date): string =>
|
|
32
|
+
export const momentOf = (d: Date, timeZone?: string): string =>
|
|
32
33
|
d.toLocaleString("en-US", {
|
|
33
34
|
month: "short",
|
|
34
35
|
day: "numeric",
|
|
35
36
|
year: "numeric",
|
|
36
37
|
hour: "numeric",
|
|
37
38
|
minute: "2-digit",
|
|
39
|
+
...(timeZone ? { timeZone } : {}),
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
/**
|
package/src/react/pieces.tsx
CHANGED
|
@@ -4,14 +4,15 @@ import {
|
|
|
4
4
|
createContext,
|
|
5
5
|
createElement,
|
|
6
6
|
useContext,
|
|
7
|
+
useSyncExternalStore,
|
|
7
8
|
type ComponentType,
|
|
8
9
|
type ReactNode,
|
|
9
10
|
} from "react";
|
|
10
11
|
import { useFormStatus } from "react-dom";
|
|
11
12
|
import { ArrowLeft, Info, LoaderCircle } from "lucide-react";
|
|
12
13
|
import { GLOSSARY, type GlossaryTerm } from "../glossary.js";
|
|
13
|
-
import type { HealthStatus } from "../health.js";
|
|
14
|
-
import { pct, QUIET_BUTTON } from "./format.js";
|
|
14
|
+
import type { HealthFlag, HealthStatus } from "../health.js";
|
|
15
|
+
import { dayOf, momentOf, pct, QUIET_BUTTON } from "./format.js";
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* The pieces Evalkeeper's screens are built from. Each draws Evalkeeper's
|
|
@@ -24,6 +25,7 @@ import { pct, QUIET_BUTTON } from "./format.js";
|
|
|
24
25
|
const CHIP = {
|
|
25
26
|
live: "bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300",
|
|
26
27
|
fallback: "bg-sky-100 text-sky-800 dark:bg-sky-500/15 dark:text-sky-200",
|
|
28
|
+
suggested: "bg-accent/10 text-accent",
|
|
27
29
|
warn: "bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-200",
|
|
28
30
|
serious: "bg-red-50 text-red-800 dark:bg-red-500/10 dark:text-red-200",
|
|
29
31
|
neutral: "bg-tint text-muted",
|
|
@@ -187,6 +189,7 @@ const STATUS: Record<HealthStatus, { label: string; tone: ChipTone }> = {
|
|
|
187
189
|
good: { label: "Good", tone: "live" },
|
|
188
190
|
fair: { label: "Fair", tone: "warn" },
|
|
189
191
|
improve: { label: "Needs work", tone: "serious" },
|
|
192
|
+
change: { label: "Change suggested", tone: "fallback" },
|
|
190
193
|
few: { label: "Few cases", tone: "warn" },
|
|
191
194
|
stale: { label: "Retest", tone: "warn" },
|
|
192
195
|
untested: { label: "Untested", tone: "neutral" },
|
|
@@ -198,6 +201,65 @@ export function StatusBadge({ status }: { status: HealthStatus }) {
|
|
|
198
201
|
return <Chip tone={s.tone}>{s.label}</Chip>;
|
|
199
202
|
}
|
|
200
203
|
|
|
204
|
+
const many = (n: number, word: string) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
205
|
+
|
|
206
|
+
/** One chip per reason a suite stands where it does. */
|
|
207
|
+
function flagChips(f: HealthFlag): { text: string; tone: ChipTone }[] {
|
|
208
|
+
switch (f.kind) {
|
|
209
|
+
case "untested":
|
|
210
|
+
return [{ text: "Untested", tone: "neutral" }];
|
|
211
|
+
case "stale":
|
|
212
|
+
return [{ text: "Retest", tone: "warn" }];
|
|
213
|
+
case "below":
|
|
214
|
+
return [
|
|
215
|
+
...(f.serious
|
|
216
|
+
? [
|
|
217
|
+
{
|
|
218
|
+
text: `${f.serious} serious under bar`,
|
|
219
|
+
tone: "serious" as const,
|
|
220
|
+
},
|
|
221
|
+
]
|
|
222
|
+
: []),
|
|
223
|
+
...(f.minor
|
|
224
|
+
? [{ text: `${f.minor} minor under bar`, tone: "warn" as const }]
|
|
225
|
+
: []),
|
|
226
|
+
];
|
|
227
|
+
case "suggestLive":
|
|
228
|
+
return [{ text: "New live model suggested", tone: "suggested" }];
|
|
229
|
+
case "suggestFallback":
|
|
230
|
+
return [{ text: "New fallback suggested", tone: "suggested" }];
|
|
231
|
+
case "retestLive":
|
|
232
|
+
return [{ text: "Retest live", tone: "warn" }];
|
|
233
|
+
case "provisional":
|
|
234
|
+
return [{ text: many(f.answers, "provisional answer"), tone: "warn" }];
|
|
235
|
+
case "fewCases":
|
|
236
|
+
return [{ text: "Too few cases", tone: "warn" }];
|
|
237
|
+
case "addCases":
|
|
238
|
+
return [
|
|
239
|
+
{ text: `Add cases (${f.cases} of ${f.target})`, tone: "neutral" },
|
|
240
|
+
];
|
|
241
|
+
case "good":
|
|
242
|
+
return [{ text: "Good", tone: "live" }];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* A suite's health as chips naming each reason ("2 serious under bar",
|
|
248
|
+
* "New fallback suggested", "Add cases (33 of 50)"), so a card says why at
|
|
249
|
+
* a glance; its details say more.
|
|
250
|
+
*/
|
|
251
|
+
export function HealthChips({ flags }: { flags: readonly HealthFlag[] }) {
|
|
252
|
+
return (
|
|
253
|
+
<span className="inline-flex flex-wrap gap-1.5">
|
|
254
|
+
{flags.flatMap(flagChips).map((c) => (
|
|
255
|
+
<Chip key={c.text} tone={c.tone}>
|
|
256
|
+
{c.text}
|
|
257
|
+
</Chip>
|
|
258
|
+
))}
|
|
259
|
+
</span>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
201
263
|
/**
|
|
202
264
|
* A link to another page. A plain `<a>` by default; pass your router's
|
|
203
265
|
* link (Next.js's `Link`, say) to move between pages without a reload.
|
|
@@ -410,3 +472,35 @@ export function RefreshWhile(props: RefreshWhileProps) {
|
|
|
410
472
|
const C = useSwapped("RefreshWhile");
|
|
411
473
|
return C ? createElement(C, props) : null;
|
|
412
474
|
}
|
|
475
|
+
|
|
476
|
+
/** A store that never changes, for useSyncExternalStore. */
|
|
477
|
+
const noChange = () => () => {};
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* A date in the viewer's own time zone: "Oct 29, 2026", or with the time.
|
|
481
|
+
* A server formats in its own zone (UTC on most hosts), which can show
|
|
482
|
+
* tomorrow's date in someone's evening, so this renders UTC first and the
|
|
483
|
+
* viewer's zone once the page loads, inside a <time> with the instant.
|
|
484
|
+
*/
|
|
485
|
+
export function LocalDate({
|
|
486
|
+
date,
|
|
487
|
+
time = false,
|
|
488
|
+
}: {
|
|
489
|
+
date: Date | string;
|
|
490
|
+
/** Include the time of day. */
|
|
491
|
+
time?: boolean;
|
|
492
|
+
}) {
|
|
493
|
+
const d = new Date(date);
|
|
494
|
+
// False on the server and while hydrating, true once in the browser.
|
|
495
|
+
const here = useSyncExternalStore(
|
|
496
|
+
noChange,
|
|
497
|
+
() => true,
|
|
498
|
+
() => false,
|
|
499
|
+
);
|
|
500
|
+
const zone = here ? undefined : "UTC";
|
|
501
|
+
return (
|
|
502
|
+
<time dateTime={d.toISOString()}>
|
|
503
|
+
{time ? momentOf(d, zone) : dayOf(d, zone)}
|
|
504
|
+
</time>
|
|
505
|
+
);
|
|
506
|
+
}
|
package/src/runner.ts
CHANGED
|
@@ -60,8 +60,8 @@ export const STUCK_MS = 6 * 60_000;
|
|
|
60
60
|
export const REUSE_DAYS = 7;
|
|
61
61
|
|
|
62
62
|
/** A provider refusing calls for billing: every later call fails too. */
|
|
63
|
-
export
|
|
64
|
-
|
|
63
|
+
export { OUT_OF_CREDITS } from "./failures.js";
|
|
64
|
+
import { OUT_OF_CREDITS } from "./failures.js";
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* What the runner needs from your app: storage, suites, models, instruction hashes, and,
|
|
@@ -108,7 +108,7 @@ export type RunnerOptions = {
|
|
|
108
108
|
*/
|
|
109
109
|
continueRun?: (
|
|
110
110
|
runId: string,
|
|
111
|
-
opts: Required<RunEvalOptions
|
|
111
|
+
opts: Required<Omit<RunEvalOptions, "requestStartedAt">>,
|
|
112
112
|
) => Promise<boolean>;
|
|
113
113
|
/**
|
|
114
114
|
* Which model each operation runs on now, its fallback, and its
|
|
@@ -157,6 +157,11 @@ export type RunEvalOptions = {
|
|
|
157
157
|
leg?: number;
|
|
158
158
|
/** What earlier legs' judge spent. */
|
|
159
159
|
judgeCostUsd?: number;
|
|
160
|
+
/**
|
|
161
|
+
* When the request running this leg started, if earlier than this call
|
|
162
|
+
* (tests queued one after another): the time limit counts from then.
|
|
163
|
+
*/
|
|
164
|
+
requestStartedAt?: number;
|
|
160
165
|
};
|
|
161
166
|
|
|
162
167
|
const sha = (text: string, n = 8) =>
|
|
@@ -584,8 +589,9 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
584
589
|
let outOfCredits = null as string | null;
|
|
585
590
|
const timeout = suite.answerTimeoutMs ?? ANSWER_TIMEOUT_MS;
|
|
586
591
|
const deadline = opts.requestLimitMs
|
|
587
|
-
? Date.now() + opts.requestLimitMs - timeout
|
|
592
|
+
? (o.requestStartedAt ?? Date.now()) + opts.requestLimitMs - timeout
|
|
588
593
|
: Infinity;
|
|
594
|
+
const late = Date.now() > deadline;
|
|
589
595
|
let skipped = 0;
|
|
590
596
|
|
|
591
597
|
await mapLimit(todo, suite.concurrency ?? 6, async ({ c, repeat }) => {
|
|
@@ -678,6 +684,7 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
678
684
|
done: todo.length - skipped,
|
|
679
685
|
leg,
|
|
680
686
|
outOfCredits: !!outOfCredits,
|
|
687
|
+
late,
|
|
681
688
|
}) &&
|
|
682
689
|
opts.continueRun &&
|
|
683
690
|
(await opts.continueRun(runId, next).catch(() => false))
|
package/src/settings.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReasoningEffort } from "./models.js";
|
|
2
2
|
import type { Route } from "./runner.js";
|
|
3
|
+
import type { SuitePriority } from "./types.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Versioned model settings. Each AI feature's settings (its model,
|
|
@@ -28,8 +29,27 @@ export type Settings = {
|
|
|
28
29
|
* temperature than the live one is out of date.
|
|
29
30
|
*/
|
|
30
31
|
temperature?: number | null;
|
|
32
|
+
/**
|
|
33
|
+
* What the suggestion favors once accuracy holds: cost, speed, or
|
|
34
|
+
* quality (accuracy alone). Null or unset: the suite's own priority. An
|
|
35
|
+
* admin can change it on the suite's page, as a version like the rest.
|
|
36
|
+
*/
|
|
37
|
+
favor?: SuitePriority["favor"] | null;
|
|
31
38
|
};
|
|
32
39
|
|
|
40
|
+
/**
|
|
41
|
+
* A suite's priority with its live settings' `favor`, when one is set:
|
|
42
|
+
* what its page, its hub card, and **Use these** weigh. Pure.
|
|
43
|
+
*/
|
|
44
|
+
export function priorityOf(
|
|
45
|
+
suite: { priority: SuitePriority },
|
|
46
|
+
settings: Pick<Settings, "favor"> | null | undefined,
|
|
47
|
+
): SuitePriority {
|
|
48
|
+
return settings?.favor
|
|
49
|
+
? { ...suite.priority, favor: settings.favor }
|
|
50
|
+
: suite.priority;
|
|
51
|
+
}
|
|
52
|
+
|
|
33
53
|
/**
|
|
34
54
|
* One numbered version of a feature's settings, with the instructions it ran with. Never changed.
|
|
35
55
|
*/
|
|
@@ -201,7 +221,8 @@ export function sameSettings(a: Settings, b: Settings): boolean {
|
|
|
201
221
|
a.fallbackModel === b.fallbackModel &&
|
|
202
222
|
a.reasoningEffort === b.reasoningEffort &&
|
|
203
223
|
a.maxOutputTokens === b.maxOutputTokens &&
|
|
204
|
-
(a.temperature ?? null) === (b.temperature ?? null)
|
|
224
|
+
(a.temperature ?? null) === (b.temperature ?? null) &&
|
|
225
|
+
(a.favor ?? null) === (b.favor ?? null)
|
|
205
226
|
);
|
|
206
227
|
}
|
|
207
228
|
|
|
@@ -213,6 +234,8 @@ export function settingsOf(v: Settings): Settings {
|
|
|
213
234
|
reasoningEffort: v.reasoningEffort,
|
|
214
235
|
maxOutputTokens: v.maxOutputTokens,
|
|
215
236
|
temperature: v.temperature ?? null,
|
|
237
|
+
// Only when set, so a store whose tables predate it keeps working.
|
|
238
|
+
...(v.favor ? { favor: v.favor } : {}),
|
|
216
239
|
};
|
|
217
240
|
}
|
|
218
241
|
|
|
@@ -242,6 +265,11 @@ export function describeChange(
|
|
|
242
265
|
out.push(
|
|
243
266
|
`Temperature: ${from.temperature ?? "default"} → ${to.temperature ?? "default"}`,
|
|
244
267
|
);
|
|
268
|
+
if ((from.favor ?? null) !== (to.favor ?? null)) {
|
|
269
|
+
const name = (f: Settings["favor"]) =>
|
|
270
|
+
f === "quality" ? "accuracy" : (f ?? "the suite's own");
|
|
271
|
+
out.push(`Favors: ${name(from.favor)} → ${name(to.favor)}`);
|
|
272
|
+
}
|
|
245
273
|
return out;
|
|
246
274
|
}
|
|
247
275
|
|
|
@@ -436,9 +464,16 @@ export function createSettings(opts: {
|
|
|
436
464
|
expectLive: null,
|
|
437
465
|
});
|
|
438
466
|
} else if (sameSettings(settingsOf(live), next)) return null;
|
|
467
|
+
// A promotion changes what answers: the live model or its reasoning.
|
|
468
|
+
// A new fallback, even with evidence, is a change.
|
|
469
|
+
const was = settingsOf(live);
|
|
470
|
+
const promoted =
|
|
471
|
+
by.evidence !== undefined &&
|
|
472
|
+
(was.model !== next.model ||
|
|
473
|
+
(was.reasoningEffort ?? null) !== (next.reasoningEffort ?? null));
|
|
439
474
|
return store.switchTo(operation, {
|
|
440
475
|
create: { settings: settingsOf(next), promptVersion },
|
|
441
|
-
kind:
|
|
476
|
+
kind: promoted ? "PROMOTE" : "CHANGE",
|
|
442
477
|
reason: by.reason,
|
|
443
478
|
by: by.by,
|
|
444
479
|
evidence: by.evidence,
|
package/src/suggest.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Rate } from "./stats.js";
|
|
|
3
3
|
import type { CheckDef, SuitePriority } from "./types.js";
|
|
4
4
|
import type { Verdict } from "./compare.js";
|
|
5
5
|
import { at } from "./util.js";
|
|
6
|
+
import { failureHints, failureKind } from "./failures.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Which model to make live and which the fallback, from a suite's current
|
|
@@ -154,6 +155,19 @@ export function seriousMistakes(row: SuggestRow, checks: CheckDef[]): number {
|
|
|
154
155
|
|
|
155
156
|
const mistakes = (n: number) => `${n} serious mistake${n === 1 ? "" : "s"}`;
|
|
156
157
|
const rate = (r: SuggestRow) => (r.test ? r.test.right / r.test.total : 0);
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Two scores side by side, "92% against 88%", with as many decimals as it
|
|
161
|
+
* takes (up to two) when they differ but would round alike ("98.14%
|
|
162
|
+
* against 98.06%"), so a reason never compares a number with itself.
|
|
163
|
+
*/
|
|
164
|
+
function against(a: number, b: number): string {
|
|
165
|
+
const at = (x: number, d: number) => (x * 100).toFixed(d);
|
|
166
|
+
const d = [0, 1, 2].find((n) => at(a, n) !== at(b, n)) ?? 0;
|
|
167
|
+
return d === 0
|
|
168
|
+
? `${pct(a)} against ${pct(b)}`
|
|
169
|
+
: `${at(a, d)}% against ${at(b, d)}%`;
|
|
170
|
+
}
|
|
157
171
|
const pct = (x: number) => `${Math.round(x * 100)}%`;
|
|
158
172
|
const cost = (r: SuggestRow) => r.test?.costPerAnswer ?? Infinity;
|
|
159
173
|
const ms = (r: SuggestRow) => r.test?.avgMs ?? Infinity;
|
|
@@ -234,8 +248,13 @@ export function suggest<R extends SuggestRow>(
|
|
|
234
248
|
next = liveFailed;
|
|
235
249
|
const n = liveFailed.test.failedAnswers ?? 0;
|
|
236
250
|
const why = liveFailed.test.failureReason;
|
|
251
|
+
const kind = failureKind(why ?? null);
|
|
252
|
+
// Timeouts and answers cut short fail the same way again: say what
|
|
253
|
+
// to change instead of only "test again".
|
|
237
254
|
reasons.push(
|
|
238
|
-
|
|
255
|
+
kind === "timeout" || kind === "cutShort"
|
|
256
|
+
? `${n} of ${liveFailed.label}'s answers failed on its last test (${why}), so it can't be compared yet. ${failureHints([why ?? null]).join(" ")}`
|
|
257
|
+
: `Test ${liveFailed.label} again: ${n} of its answers failed on its last test${why ? ` (${why})` : ""}, so it can't be compared yet.`,
|
|
239
258
|
);
|
|
240
259
|
} else if (!live) {
|
|
241
260
|
if (!liveable.length) return null;
|
|
@@ -266,21 +285,21 @@ export function suggest<R extends SuggestRow>(
|
|
|
266
285
|
const ra = underAttack(r);
|
|
267
286
|
const la = underAttack(live);
|
|
268
287
|
return ra !== null && la !== null && ra <= la - 2 && rate(r) >= rate(live)
|
|
269
|
-
? `${r.label} makes fewer serious mistakes on the attacks than ${live.label} (${ra} against ${la}), and scores at least as well (${
|
|
288
|
+
? `${r.label} makes fewer serious mistakes on the attacks than ${live.label} (${ra} against ${la}), and scores at least as well (${against(rate(r), rate(live))}).`
|
|
270
289
|
: null;
|
|
271
290
|
};
|
|
272
291
|
const why = (r: R): string | null => {
|
|
273
292
|
if (rate(r) < rate(live)) return trade(r);
|
|
274
293
|
if (r.vsLive === "BETTER")
|
|
275
|
-
return `${r.label} is clearly more accurate than ${live.label}
|
|
294
|
+
return `${r.label} is clearly more accurate than ${live.label} on the cases both answered (overall ${against(rate(r), rate(live))}).`;
|
|
276
295
|
if (serious(r) <= serious(live) - 2)
|
|
277
|
-
return `${r.label} makes fewer serious mistakes than ${live.label} (${serious(r)} against ${serious(live)}), and scores at least as well (${
|
|
296
|
+
return `${r.label} makes fewer serious mistakes than ${live.label} (${serious(r)} against ${serious(live)}), and scores at least as well (${against(rate(r), rate(live))}).`;
|
|
278
297
|
const byAttacks = attackReason(r);
|
|
279
298
|
if (byAttacks) return byAttacks;
|
|
280
299
|
if (priority.favor === "cost" && clearlyLess(cost(r), cost(live)))
|
|
281
|
-
return `${r.label} scores at least as well as ${live.label} (${
|
|
300
|
+
return `${r.label} scores at least as well as ${live.label} (${against(rate(r), rate(live))}) at ${Math.round((1 - cost(r) / cost(live)) * 100)}% less per answer.`;
|
|
282
301
|
if (priority.favor === "speed" && clearlyLess(ms(r), ms(live)))
|
|
283
|
-
return `${r.label} scores at least as well as ${live.label} (${
|
|
302
|
+
return `${r.label} scores at least as well as ${live.label} (${against(rate(r), rate(live))}) and answers faster (${(ms(r) / 1000).toFixed(1)}s against ${(ms(live) / 1000).toFixed(1)}s).`;
|
|
284
303
|
return null;
|
|
285
304
|
};
|
|
286
305
|
// Cost and speed suites: a little less accurate, no clear difference,
|
|
@@ -293,7 +312,7 @@ export function suggest<R extends SuggestRow>(
|
|
|
293
312
|
serious(r) > serious(live)
|
|
294
313
|
)
|
|
295
314
|
return null;
|
|
296
|
-
const close = `${r.label} is about as accurate as ${live.label} (${
|
|
315
|
+
const close = `${r.label} is about as accurate as ${live.label} (${against(rate(r), rate(live))}: closer than these cases can tell apart), with no more serious mistakes`;
|
|
297
316
|
if (priority.favor === "cost" && cost(r) <= cost(live) * HALF)
|
|
298
317
|
return `${close}, at ${Math.round((1 - cost(r) / cost(live)) * 100)}% less per answer. This suite favors cost.`;
|
|
299
318
|
if (priority.favor === "speed" && ms(r) <= ms(live) * HALF)
|
package/src/testing.ts
CHANGED
|
@@ -789,7 +789,7 @@ export function describeFeedbackStoreContract(
|
|
|
789
789
|
/** Options for the settings store contract. */
|
|
790
790
|
export type SettingsStoreContractOptions = ScopedContractOptions & {
|
|
791
791
|
/** Settings the store has no column for (see `StoreContractOptions`). */
|
|
792
|
-
without?: "temperature"[];
|
|
792
|
+
without?: ("temperature" | "favor")[];
|
|
793
793
|
};
|
|
794
794
|
|
|
795
795
|
/**
|
|
@@ -940,6 +940,40 @@ export function describeSettingsStoreContract(
|
|
|
940
940
|
});
|
|
941
941
|
}
|
|
942
942
|
|
|
943
|
+
if (opts.without?.includes("favor")) {
|
|
944
|
+
it("refuses a priority it has no column for, and keeps none", async () => {
|
|
945
|
+
const store = await make();
|
|
946
|
+
const op = names()("triage");
|
|
947
|
+
await expect(
|
|
948
|
+
store.switchTo(op, {
|
|
949
|
+
...create("a", null),
|
|
950
|
+
create: {
|
|
951
|
+
settings: { ...settings("a"), favor: "speed" },
|
|
952
|
+
promptVersion: "p1",
|
|
953
|
+
},
|
|
954
|
+
}),
|
|
955
|
+
).rejects.toThrow("favor");
|
|
956
|
+
const v1 = await store.switchTo(op, create("a", null));
|
|
957
|
+
expect(v1.favor ?? null).toBeNull();
|
|
958
|
+
});
|
|
959
|
+
} else {
|
|
960
|
+
it("keeps a version's priority", async () => {
|
|
961
|
+
const store = await make();
|
|
962
|
+
const op = names()("triage");
|
|
963
|
+
const v1 = await store.switchTo(op, {
|
|
964
|
+
...create("a", null),
|
|
965
|
+
create: {
|
|
966
|
+
settings: { ...settings("a"), favor: "speed" },
|
|
967
|
+
promptVersion: "p1",
|
|
968
|
+
},
|
|
969
|
+
});
|
|
970
|
+
expect(v1.favor).toBe("speed");
|
|
971
|
+
expect((await store.liveVersion(op))?.favor).toBe("speed");
|
|
972
|
+
const v2 = await store.switchTo(op, create("b", v1.id));
|
|
973
|
+
expect(v2.favor ?? null).toBeNull();
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
|
|
943
977
|
it("keeps every kind of change, with its evidence", async () => {
|
|
944
978
|
const store = await make();
|
|
945
979
|
const op = names()("triage");
|
package/src/types.ts
CHANGED
|
@@ -62,6 +62,18 @@ export function checkBar(c: CheckDef): number {
|
|
|
62
62
|
return c.bar ?? (c.severity === "serious" ? 0.95 : 0.75);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* A rate as a whole percent, except when it's under its bar but would
|
|
67
|
+
* round up to it: then one decimal, so "94.7%, under the 95% bar" never
|
|
68
|
+
* reads as "95%, under the 95% bar". Pure.
|
|
69
|
+
*/
|
|
70
|
+
export function pctBeside(rate: number, bar: number): string {
|
|
71
|
+
const whole = Math.round(rate * 100);
|
|
72
|
+
return rate < bar && whole >= Math.round(bar * 100)
|
|
73
|
+
? `${(Math.floor(rate * 1000) / 10).toFixed(1)}%`
|
|
74
|
+
: `${whole}%`;
|
|
75
|
+
}
|
|
76
|
+
|
|
65
77
|
/** Meets the bar, is within 10 points of it, or is further below. */
|
|
66
78
|
export function barStatus(
|
|
67
79
|
rate: number,
|
|
@@ -260,6 +272,12 @@ export type Suite<Input, Output, Label> = {
|
|
|
260
272
|
describe?(input: Input): string;
|
|
261
273
|
/** Fixture suites: what the expected answer's fields mean. */
|
|
262
274
|
labelHelp?: string;
|
|
275
|
+
/**
|
|
276
|
+
* False when blind rating doesn't fit the suite's cases: each answer is
|
|
277
|
+
* one person's own (a verdict on their own data), or your app has no
|
|
278
|
+
* rate page. The answer key then offers no **Rate blind**.
|
|
279
|
+
*/
|
|
280
|
+
rateBlind?: boolean;
|
|
263
281
|
/**
|
|
264
282
|
* How a person should judge an answer, where it takes more than each
|
|
265
283
|
* field's help: shown above the answer key as "How to judge an answer".
|
|
@@ -93,6 +93,14 @@ export async function useDraftsProvisionally(form: FormData) {
|
|
|
93
93
|
return actions.useDraftsProvisionally(form);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
export async function setPriority(form: FormData) {
|
|
97
|
+
return actions.setPriority(form);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export async function keepAnswer(form: FormData) {
|
|
101
|
+
return actions.keepAnswer(form);
|
|
102
|
+
}
|
|
103
|
+
|
|
96
104
|
export async function runWeeklyNow() {
|
|
97
105
|
return actions.runWeeklyNow();
|
|
98
106
|
}
|