@crowandraven/evalkeeper 0.11.1 → 0.13.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 +49 -0
- package/dist/drafts.js +105 -0
- package/dist/drafts.js.map +1 -0
- package/dist/glossary.d.ts +6 -2
- package/dist/glossary.js +6 -2
- package/dist/glossary.js.map +1 -1
- package/dist/health.d.ts +35 -2
- package/dist/health.js +29 -5
- 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/next/actions.js +128 -15
- package/dist/next/actions.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/react/HubSections.d.ts +7 -0
- package/dist/react/HubSections.js +22 -8
- package/dist/react/HubSections.js.map +1 -1
- package/dist/react/ModelMenu.d.ts +18 -4
- package/dist/react/ModelMenu.js +12 -7
- package/dist/react/ModelMenu.js.map +1 -1
- package/dist/react/RateView.js +1 -0
- package/dist/react/RateView.js.map +1 -1
- package/dist/react/SuiteSections.d.ts +31 -0
- package/dist/react/SuiteSections.js +148 -32
- 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/pieces.d.ts +10 -1
- package/dist/react/pieces.js +50 -0
- package/dist/react/pieces.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/testing.d.ts +1 -1
- package/dist/testing.js +32 -0
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +33 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/schema/evalkeeper.prisma +3 -0
- package/src/drafts.ts +123 -0
- package/src/glossary.ts +10 -2
- package/src/health.ts +53 -6
- package/src/index.ts +2 -0
- package/src/next/actions.ts +162 -16
- package/src/next/wiring.ts +6 -0
- package/src/order.ts +64 -0
- package/src/prisma/index.ts +5 -0
- package/src/react/HubSections.tsx +31 -7
- package/src/react/ModelMenu.tsx +33 -7
- package/src/react/RateView.tsx +1 -0
- package/src/react/SuiteSections.tsx +640 -170
- package/src/react/app.ts +15 -0
- package/src/react/pieces.tsx +62 -1
- package/src/settings.ts +37 -2
- package/src/testing.ts +35 -1
- package/src/types.ts +37 -0
- package/templates/lib/evalkeeper/actions.ts +20 -0
package/src/react/app.ts
CHANGED
|
@@ -33,6 +33,16 @@ export type EvalActions = {
|
|
|
33
33
|
retireEasy?: FormAction;
|
|
34
34
|
/** Retiring drafts nobody reviewed; the health panel's button. */
|
|
35
35
|
retireStaleDrafts?: FormAction;
|
|
36
|
+
/** Adding a suite's starter cases not in its answer key yet. */
|
|
37
|
+
addStarters?: FormAction;
|
|
38
|
+
/** Making or updating an injection suite's attack cases. */
|
|
39
|
+
makeAttackCases?: FormAction;
|
|
40
|
+
/** Having the suite's `draftMore` draft cases, with an optional focus. */
|
|
41
|
+
draftMore?: FormAction;
|
|
42
|
+
/** Putting draft answers to use before review, as provisional. */
|
|
43
|
+
useDraftsProvisionally?: FormAction;
|
|
44
|
+
/** Changing what a feature's suggestion favors, as a settings version. */
|
|
45
|
+
setPriority?: FormAction;
|
|
36
46
|
runWeeklyNow: () => Promise<void>;
|
|
37
47
|
/** Blind rating; only for an app with the rate page. */
|
|
38
48
|
rateBlind?: FormAction;
|
|
@@ -66,6 +76,11 @@ export type EvalApp = {
|
|
|
66
76
|
actions: EvalActions;
|
|
67
77
|
/** Where the eval pages live, as a URL path: "/evals", "/admin/evals". */
|
|
68
78
|
basePath: string;
|
|
79
|
+
/**
|
|
80
|
+
* Every AI feature your app has, by the operation its suites name. The
|
|
81
|
+
* hub lists the ones no suite tests yet. Leave it out to skip that list.
|
|
82
|
+
*/
|
|
83
|
+
features?: { operation: string; label: string }[];
|
|
69
84
|
};
|
|
70
85
|
|
|
71
86
|
/** An `EvalApp` with its suites by key, as the screens read it. */
|
package/src/react/pieces.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { useFormStatus } from "react-dom";
|
|
11
11
|
import { ArrowLeft, Info, LoaderCircle } from "lucide-react";
|
|
12
12
|
import { GLOSSARY, type GlossaryTerm } from "../glossary.js";
|
|
13
|
-
import type { HealthStatus } from "../health.js";
|
|
13
|
+
import type { HealthFlag, HealthStatus } from "../health.js";
|
|
14
14
|
import { pct, QUIET_BUTTON } from "./format.js";
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -24,6 +24,7 @@ import { pct, QUIET_BUTTON } from "./format.js";
|
|
|
24
24
|
const CHIP = {
|
|
25
25
|
live: "bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300",
|
|
26
26
|
fallback: "bg-sky-100 text-sky-800 dark:bg-sky-500/15 dark:text-sky-200",
|
|
27
|
+
suggested: "bg-accent/10 text-accent",
|
|
27
28
|
warn: "bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-200",
|
|
28
29
|
serious: "bg-red-50 text-red-800 dark:bg-red-500/10 dark:text-red-200",
|
|
29
30
|
neutral: "bg-tint text-muted",
|
|
@@ -187,6 +188,7 @@ const STATUS: Record<HealthStatus, { label: string; tone: ChipTone }> = {
|
|
|
187
188
|
good: { label: "Good", tone: "live" },
|
|
188
189
|
fair: { label: "Fair", tone: "warn" },
|
|
189
190
|
improve: { label: "Needs work", tone: "serious" },
|
|
191
|
+
change: { label: "Change suggested", tone: "fallback" },
|
|
190
192
|
few: { label: "Few cases", tone: "warn" },
|
|
191
193
|
stale: { label: "Retest", tone: "warn" },
|
|
192
194
|
untested: { label: "Untested", tone: "neutral" },
|
|
@@ -198,6 +200,65 @@ export function StatusBadge({ status }: { status: HealthStatus }) {
|
|
|
198
200
|
return <Chip tone={s.tone}>{s.label}</Chip>;
|
|
199
201
|
}
|
|
200
202
|
|
|
203
|
+
const many = (n: number, word: string) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
204
|
+
|
|
205
|
+
/** One chip per reason a suite stands where it does. */
|
|
206
|
+
function flagChips(f: HealthFlag): { text: string; tone: ChipTone }[] {
|
|
207
|
+
switch (f.kind) {
|
|
208
|
+
case "untested":
|
|
209
|
+
return [{ text: "Untested", tone: "neutral" }];
|
|
210
|
+
case "stale":
|
|
211
|
+
return [{ text: "Retest", tone: "warn" }];
|
|
212
|
+
case "below":
|
|
213
|
+
return [
|
|
214
|
+
...(f.serious
|
|
215
|
+
? [
|
|
216
|
+
{
|
|
217
|
+
text: `${f.serious} serious under bar`,
|
|
218
|
+
tone: "serious" as const,
|
|
219
|
+
},
|
|
220
|
+
]
|
|
221
|
+
: []),
|
|
222
|
+
...(f.minor
|
|
223
|
+
? [{ text: `${f.minor} minor under bar`, tone: "warn" as const }]
|
|
224
|
+
: []),
|
|
225
|
+
];
|
|
226
|
+
case "suggestLive":
|
|
227
|
+
return [{ text: "New live model suggested", tone: "suggested" }];
|
|
228
|
+
case "suggestFallback":
|
|
229
|
+
return [{ text: "New fallback suggested", tone: "suggested" }];
|
|
230
|
+
case "retestLive":
|
|
231
|
+
return [{ text: "Retest live", tone: "warn" }];
|
|
232
|
+
case "provisional":
|
|
233
|
+
return [{ text: many(f.answers, "provisional answer"), tone: "warn" }];
|
|
234
|
+
case "fewCases":
|
|
235
|
+
return [{ text: "Too few cases", tone: "warn" }];
|
|
236
|
+
case "addCases":
|
|
237
|
+
return [
|
|
238
|
+
{ text: `Add cases (${f.cases} of ${f.target})`, tone: "neutral" },
|
|
239
|
+
];
|
|
240
|
+
case "good":
|
|
241
|
+
return [{ text: "Good", tone: "live" }];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* A suite's health as chips naming each reason ("2 serious under bar",
|
|
247
|
+
* "New fallback suggested", "Add cases (33 of 50)"), so a card says why at
|
|
248
|
+
* a glance; its details say more.
|
|
249
|
+
*/
|
|
250
|
+
export function HealthChips({ flags }: { flags: readonly HealthFlag[] }) {
|
|
251
|
+
return (
|
|
252
|
+
<span className="inline-flex flex-wrap gap-1.5">
|
|
253
|
+
{flags.flatMap(flagChips).map((c) => (
|
|
254
|
+
<Chip key={c.text} tone={c.tone}>
|
|
255
|
+
{c.text}
|
|
256
|
+
</Chip>
|
|
257
|
+
))}
|
|
258
|
+
</span>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
201
262
|
/**
|
|
202
263
|
* A link to another page. A plain `<a>` by default; pass your router's
|
|
203
264
|
* link (Next.js's `Link`, say) to move between pages without a reload.
|
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/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,31 @@ 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;
|
|
281
|
+
/**
|
|
282
|
+
* How a person should judge an answer, where it takes more than each
|
|
283
|
+
* field's help: shown above the answer key as "How to judge an answer".
|
|
284
|
+
* Without it, `labelHelp` shows there. For people only: it never reaches
|
|
285
|
+
* the model, so it doesn't change the instructions hash.
|
|
286
|
+
*/
|
|
287
|
+
answerGuide?: AnswerGuide;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
/** How to judge a suite's answers: a lead-in, the points, and a note. */
|
|
291
|
+
export type AnswerGuide = {
|
|
292
|
+
/** A short lead-in: "When you confirm a case, check:". */
|
|
293
|
+
lead?: string;
|
|
294
|
+
/** One point each; `term`, when given, comes first in bold. */
|
|
295
|
+
points: { term?: string; text: string }[];
|
|
296
|
+
/** Steps to follow in order (numbered), or points in any order. */
|
|
297
|
+
ordered?: boolean;
|
|
298
|
+
/** A closing note, shown quieter. */
|
|
299
|
+
note?: string;
|
|
263
300
|
};
|
|
264
301
|
|
|
265
302
|
/**
|
|
@@ -77,6 +77,26 @@ export async function dismissFeedback(form: FormData) {
|
|
|
77
77
|
return actions.dismissFeedback(form);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
export async function addStarters(form: FormData) {
|
|
81
|
+
return actions.addStarters(form);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export async function makeAttackCases(form: FormData) {
|
|
85
|
+
return actions.makeAttackCases(form);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function draftMore(form: FormData) {
|
|
89
|
+
return actions.draftMore(form);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export async function useDraftsProvisionally(form: FormData) {
|
|
93
|
+
return actions.useDraftsProvisionally(form);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function setPriority(form: FormData) {
|
|
97
|
+
return actions.setPriority(form);
|
|
98
|
+
}
|
|
99
|
+
|
|
80
100
|
export async function runWeeklyNow() {
|
|
81
101
|
return actions.runWeeklyNow();
|
|
82
102
|
}
|