@crowandraven/evalkeeper 0.8.0 → 0.10.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/cli/addPages.js +1 -1
- package/dist/cli/addPages.js.map +1 -1
- package/dist/feedback.d.ts +3 -1
- package/dist/feedback.js +3 -1
- package/dist/feedback.js.map +1 -1
- package/dist/glossary.d.ts +5 -0
- package/dist/glossary.js +5 -0
- package/dist/glossary.js.map +1 -1
- package/dist/health.d.ts +4 -1
- package/dist/health.js +4 -2
- package/dist/health.js.map +1 -1
- package/dist/importCases.d.ts +15 -4
- package/dist/importCases.js +20 -18
- package/dist/importCases.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/reviews.d.ts +172 -0
- package/dist/reviews.js +294 -0
- package/dist/reviews.js.map +1 -0
- package/dist/runner.d.ts +14 -1
- package/dist/runner.js +10 -0
- package/dist/runner.js.map +1 -1
- package/dist/suggest.d.ts +52 -2
- package/dist/suggest.js +101 -8
- package/dist/suggest.js.map +1 -1
- package/dist/suiteContract.d.ts +3 -2
- package/dist/suiteContract.js +5 -2
- package/dist/suiteContract.js.map +1 -1
- package/dist/suites/attackImport.d.ts +99 -0
- package/dist/suites/attackImport.js +283 -0
- package/dist/suites/attackImport.js.map +1 -0
- package/dist/suites/crisisRisk.d.ts +9 -2
- package/dist/suites/crisisRisk.js +8 -3
- package/dist/suites/crisisRisk.js.map +1 -1
- package/dist/suites/crisisRiskCases.d.ts +4 -3
- package/dist/suites/crisisRiskCases.js +4 -3
- package/dist/suites/crisisRiskCases.js.map +1 -1
- package/dist/suites/crisisRiskReviews.d.ts +15 -0
- package/dist/suites/crisisRiskReviews.js +926 -0
- package/dist/suites/crisisRiskReviews.js.map +1 -0
- package/dist/suites/hopelessness.d.ts +9 -2
- package/dist/suites/hopelessness.js +8 -5
- package/dist/suites/hopelessness.js.map +1 -1
- package/dist/suites/hopelessnessCases.d.ts +3 -2
- package/dist/suites/hopelessnessCases.js +3 -2
- package/dist/suites/hopelessnessCases.js.map +1 -1
- package/dist/suites/hopelessnessReviews.d.ts +15 -0
- package/dist/suites/hopelessnessReviews.js +1080 -0
- package/dist/suites/hopelessnessReviews.js.map +1 -0
- package/dist/suites/index.d.ts +5 -0
- package/dist/suites/index.js +5 -0
- package/dist/suites/index.js.map +1 -1
- package/dist/suites/injection.d.ts +162 -0
- package/dist/suites/injection.js +331 -0
- package/dist/suites/injection.js.map +1 -0
- package/dist/suites/injectionAttacks.d.ts +3 -0
- package/dist/suites/injectionAttacks.js +34 -0
- package/dist/suites/injectionAttacks.js.map +1 -0
- package/dist/types.d.ts +100 -2
- package/dist/types.js +106 -11
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/addPages.ts +1 -1
- package/src/feedback.ts +3 -1
- package/src/glossary.ts +10 -0
- package/src/health.ts +4 -2
- package/src/importCases.ts +21 -20
- package/src/index.ts +1 -0
- package/src/reviews.ts +428 -0
- package/src/runner.ts +15 -1
- package/src/suggest.ts +145 -13
- package/src/suiteContract.ts +5 -2
- package/src/suites/attackImport.ts +327 -0
- package/src/suites/crisisRisk.ts +15 -3
- package/src/suites/crisisRiskCases.ts +4 -3
- package/src/suites/crisisRiskReviews.ts +927 -0
- package/src/suites/hopelessness.ts +15 -5
- package/src/suites/hopelessnessCases.ts +3 -2
- package/src/suites/hopelessnessReviews.ts +1081 -0
- package/src/suites/index.ts +5 -0
- package/src/suites/injection.ts +463 -0
- package/src/suites/injectionAttacks.ts +136 -0
- package/src/types.ts +169 -17
- package/starter/index.ts +11 -0
- package/templates/app/evals/[suite]/page.tsx +185 -32
- package/templates/app/evals/[suite]/rate/page.tsx +14 -4
- package/templates/app/evals/feedback/page.tsx +3 -1
- package/templates/app/evals/page.tsx +44 -5
- package/templates/components/evalkeeper/AnswerKey.tsx +35 -6
- package/templates/components/evalkeeper/Fields.tsx +49 -5
- package/templates/lib/evalkeeper/actions.ts +39 -15
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import type { ReasoningEffort } from "./models.js";
|
|
3
|
+
import type { ShippedReview } from "./reviews.js";
|
|
3
4
|
/**
|
|
4
5
|
* An eval suite: how to run one AI operation on a frozen case and how to
|
|
5
6
|
* grade what comes back. Code says how to evaluate; the database holds the
|
|
@@ -156,6 +157,15 @@ export type Suite<Input, Output, Label> = {
|
|
|
156
157
|
smoke?: boolean;
|
|
157
158
|
note: string;
|
|
158
159
|
}[];
|
|
160
|
+
/**
|
|
161
|
+
* Reviews of `starter` cases that ship with the suite: its author or an
|
|
162
|
+
* expert confirmed a case's answer once, for every app, so
|
|
163
|
+
* `importStarters` adds it confirmed instead of pending. Each names who,
|
|
164
|
+
* what qualifies them, and when, and counts only while the case's input
|
|
165
|
+
* and answer are what they saw; the suite contract fails on one that
|
|
166
|
+
* doesn't.
|
|
167
|
+
*/
|
|
168
|
+
reviews?: readonly ShippedReview[];
|
|
159
169
|
/**
|
|
160
170
|
* Drafts new cases aimed at what the answer key is missing, for a person
|
|
161
171
|
* to review (they arrive with PENDING answers).
|
|
@@ -270,13 +280,15 @@ export type ActivityDraft<Input, Label> = {
|
|
|
270
280
|
/**
|
|
271
281
|
* One field of a suite's add/edit form. `name` is the form key (and the
|
|
272
282
|
* input or answer property it fills). "lines": one item per line, read as
|
|
273
|
-
* a list.
|
|
283
|
+
* a list. "json": a structured value (a list of objects, a nested shape)
|
|
284
|
+
* edited as JSON in a monospace box, checked against the suite's schema
|
|
285
|
+
* when saved.
|
|
274
286
|
*/
|
|
275
287
|
export type FormField = {
|
|
276
288
|
name: string;
|
|
277
289
|
label: string;
|
|
278
290
|
help: string;
|
|
279
|
-
kind: "text" | "textarea" | "select" | "lines";
|
|
291
|
+
kind: "text" | "textarea" | "select" | "lines" | "json";
|
|
280
292
|
/** For "select". */
|
|
281
293
|
options?: readonly string[];
|
|
282
294
|
required?: boolean;
|
|
@@ -294,6 +306,28 @@ export declare function linesOf(form: FormData, name: string): string[];
|
|
|
294
306
|
* `unknown`; a suite's own code keeps its precise types.
|
|
295
307
|
*/
|
|
296
308
|
export type AnySuite = Suite<unknown, unknown, unknown>;
|
|
309
|
+
/**
|
|
310
|
+
* Whether a suite is an injection suite (`injectionSuite` from
|
|
311
|
+
* `@crowandraven/evalkeeper/suites`): it runs on its base suite's
|
|
312
|
+
* operation, so code that finds a feature's suite by operation should
|
|
313
|
+
* skip it and find the base suite.
|
|
314
|
+
*
|
|
315
|
+
* @param suite - Any registered suite.
|
|
316
|
+
*/
|
|
317
|
+
export declare function isInjectionSuite(suite: AnySuite): suite is AnySuite & {
|
|
318
|
+
base: AnySuite;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* The injection suites that attack a suite: the ones whose base it is.
|
|
322
|
+
* Their results belong with the base suite's, since both test the same
|
|
323
|
+
* feature and one choice of model serves both.
|
|
324
|
+
*
|
|
325
|
+
* @param suites - Every registered suite.
|
|
326
|
+
* @param baseKey - The base suite's key.
|
|
327
|
+
*/
|
|
328
|
+
export declare function injectionSuitesOf(suites: readonly AnySuite[], baseKey: string): (AnySuite & {
|
|
329
|
+
base: AnySuite;
|
|
330
|
+
})[];
|
|
297
331
|
/**
|
|
298
332
|
* A suite's `inputFromForm` for fixture suites (`caseKind: "fixture"`),
|
|
299
333
|
* whose cases are edited as JSON in one textarea. Reads the field, parses
|
|
@@ -326,3 +360,67 @@ export declare function inputFromJson<T>(schema: z.ZodType<T>, field?: string):
|
|
|
326
360
|
* @returns A form reader to use as the suite's `labelFromForm`.
|
|
327
361
|
*/
|
|
328
362
|
export declare function labelFromJson<T>(schema: z.ZodType<T>, field?: string): (form: FormData) => T;
|
|
363
|
+
/**
|
|
364
|
+
* A form's values for a suite's fields, each read by its kind: text as it
|
|
365
|
+
* is, "lines" as a list, "json" parsed (with a plain error naming the
|
|
366
|
+
* field when it isn't valid JSON; empty reads as null). Pure.
|
|
367
|
+
*
|
|
368
|
+
* @param fields - The suite's input or answer fields.
|
|
369
|
+
* @param form - The submitted form.
|
|
370
|
+
*/
|
|
371
|
+
export declare function valuesFromFields(fields: readonly FormField[], form: FormData): Record<string, unknown>;
|
|
372
|
+
/**
|
|
373
|
+
* A suite's `inputFromForm` from its fields, any kinds: reads each field
|
|
374
|
+
* by kind (`valuesFromFields`) and checks the whole with the schema,
|
|
375
|
+
* throwing a plain error that names the first part that doesn't fit.
|
|
376
|
+
*
|
|
377
|
+
* @param schema - The suite's input schema.
|
|
378
|
+
* @param fields - The suite's input fields (`fields.input`).
|
|
379
|
+
* @returns A form reader to use as the suite's `inputFromForm`.
|
|
380
|
+
*/
|
|
381
|
+
export declare function inputFromFields<T>(schema: z.ZodType<T>, fields: readonly FormField[]): (form: FormData) => T;
|
|
382
|
+
/**
|
|
383
|
+
* A suite's `labelFromForm` from its answer fields, like `inputFromFields`.
|
|
384
|
+
*
|
|
385
|
+
* @param schema - The suite's answer schema (`labelValue`).
|
|
386
|
+
* @param fields - The suite's answer fields (`fields.label`).
|
|
387
|
+
* @returns A form reader to use as the suite's `labelFromForm`.
|
|
388
|
+
*/
|
|
389
|
+
export declare function labelFromFields<T>(schema: z.ZodType<T>, fields: readonly FormField[]): (form: FormData) => T;
|
|
390
|
+
/**
|
|
391
|
+
* The form field an answer editor submits its answer under, as JSON
|
|
392
|
+
* (see `AnswerEditorProps`).
|
|
393
|
+
*/
|
|
394
|
+
export declare const ANSWER_JSON_FIELD = "answerJson";
|
|
395
|
+
/**
|
|
396
|
+
* What an app's own answer editor gets, for answers plain fields can't
|
|
397
|
+
* edit well (a list of facts with a category each, a verdict with
|
|
398
|
+
* reasons). The editor is a client component that renders its own
|
|
399
|
+
* controls and keeps the whole answer, as JSON, in a form field named
|
|
400
|
+
* `name` (a hidden input). Register it in your wiring module's
|
|
401
|
+
* `answerEditors`, keyed by suite; the copied answer key, "Add a case",
|
|
402
|
+
* and blind rating use it in place of the suite's answer fields, and the
|
|
403
|
+
* actions check what it submits against the suite's `labelValue`.
|
|
404
|
+
*/
|
|
405
|
+
export type AnswerEditorProps = {
|
|
406
|
+
/** The form field to submit the answer under, as JSON. */
|
|
407
|
+
name: string;
|
|
408
|
+
/** Prefix for element ids, unique on the page. */
|
|
409
|
+
idPrefix: string;
|
|
410
|
+
/** The case's input, when there is one yet (null on "Add a case"). */
|
|
411
|
+
input: unknown;
|
|
412
|
+
/** The current answer, or null for a new one. */
|
|
413
|
+
value: unknown;
|
|
414
|
+
/** The suite's answer fields, for their labels and help. */
|
|
415
|
+
fields: readonly FormField[];
|
|
416
|
+
};
|
|
417
|
+
/**
|
|
418
|
+
* The answer a form submits for a suite: from an answer editor (JSON in
|
|
419
|
+
* `ANSWER_JSON_FIELD`, checked against the suite's `labelValue`) when the
|
|
420
|
+
* form has one, otherwise the suite's own `labelFromForm`. Throws a plain
|
|
421
|
+
* error when the suite has neither, or the answer doesn't fit.
|
|
422
|
+
*
|
|
423
|
+
* @param suite - The suite the answer is for.
|
|
424
|
+
* @param form - The submitted form.
|
|
425
|
+
*/
|
|
426
|
+
export declare function answerFromForm(suite: AnySuite, form: FormData): unknown;
|
package/dist/types.js
CHANGED
|
@@ -32,6 +32,8 @@ export function fieldValue(field, value) {
|
|
|
32
32
|
const v = value && typeof value === "object"
|
|
33
33
|
? value[field.name]
|
|
34
34
|
: undefined;
|
|
35
|
+
if (field.kind === "json")
|
|
36
|
+
return v === undefined || v === null ? "" : JSON.stringify(v, null, 2);
|
|
35
37
|
if (Array.isArray(v))
|
|
36
38
|
return v.map(asText).join("\n");
|
|
37
39
|
return asText(v);
|
|
@@ -43,28 +45,45 @@ export function linesOf(form, name) {
|
|
|
43
45
|
.map((l) => l.trim())
|
|
44
46
|
.filter(Boolean);
|
|
45
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether a suite is an injection suite (`injectionSuite` from
|
|
50
|
+
* `@crowandraven/evalkeeper/suites`): it runs on its base suite's
|
|
51
|
+
* operation, so code that finds a feature's suite by operation should
|
|
52
|
+
* skip it and find the base suite.
|
|
53
|
+
*
|
|
54
|
+
* @param suite - Any registered suite.
|
|
55
|
+
*/
|
|
56
|
+
export function isInjectionSuite(suite) {
|
|
57
|
+
return "base" in suite && "attackCase" in suite;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The injection suites that attack a suite: the ones whose base it is.
|
|
61
|
+
* Their results belong with the base suite's, since both test the same
|
|
62
|
+
* feature and one choice of model serves both.
|
|
63
|
+
*
|
|
64
|
+
* @param suites - Every registered suite.
|
|
65
|
+
* @param baseKey - The base suite's key.
|
|
66
|
+
*/
|
|
67
|
+
export function injectionSuitesOf(suites, baseKey) {
|
|
68
|
+
return suites.filter((s) => isInjectionSuite(s) && s.base.key === baseKey);
|
|
69
|
+
}
|
|
46
70
|
/** Where a zod issue sits, in plain words: "facts, item 2, name". */
|
|
47
71
|
function issuePath(path) {
|
|
48
72
|
return path
|
|
49
73
|
.map((p) => (typeof p === "number" ? `item ${p + 1}` : p))
|
|
50
74
|
.join(", ");
|
|
51
75
|
}
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
* plain error when the field is empty, isn't JSON, or doesn't fit (naming
|
|
55
|
-
* the first part that doesn't).
|
|
56
|
-
*/
|
|
57
|
-
function readJson(form, field, what, schema) {
|
|
58
|
-
const text = formText(form, field);
|
|
59
|
-
if (!text)
|
|
60
|
-
throw new Error(`${what} is empty: fill in the "${field}" field`);
|
|
61
|
-
let value;
|
|
76
|
+
/** Text as JSON, with a plain error naming what it was. */
|
|
77
|
+
function parseJson(text, what) {
|
|
62
78
|
try {
|
|
63
|
-
|
|
79
|
+
return JSON.parse(text);
|
|
64
80
|
}
|
|
65
81
|
catch (e) {
|
|
66
82
|
throw new Error(`${what} isn't valid JSON: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
|
|
67
83
|
}
|
|
84
|
+
}
|
|
85
|
+
/** A value checked with a schema, with a plain error naming the first misfit. */
|
|
86
|
+
function fit(value, schema, what) {
|
|
68
87
|
const parsed = schema.safeParse(value);
|
|
69
88
|
if (parsed.success)
|
|
70
89
|
return parsed.data;
|
|
@@ -75,6 +94,17 @@ function readJson(form, field, what, schema) {
|
|
|
75
94
|
? `${what} doesn't fit at ${where}: ${message}`
|
|
76
95
|
: `${what} doesn't fit: ${message}`);
|
|
77
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Reads one form field as JSON and checks it with a schema; throws a
|
|
99
|
+
* plain error when the field is empty, isn't JSON, or doesn't fit (naming
|
|
100
|
+
* the first part that doesn't).
|
|
101
|
+
*/
|
|
102
|
+
function readJson(form, field, what, schema) {
|
|
103
|
+
const text = formText(form, field);
|
|
104
|
+
if (!text)
|
|
105
|
+
throw new Error(`${what} is empty: fill in the "${field}" field`);
|
|
106
|
+
return fit(parseJson(text, what), schema, what);
|
|
107
|
+
}
|
|
78
108
|
/**
|
|
79
109
|
* A suite's `inputFromForm` for fixture suites (`caseKind: "fixture"`),
|
|
80
110
|
* whose cases are edited as JSON in one textarea. Reads the field, parses
|
|
@@ -111,4 +141,69 @@ export function inputFromJson(schema, field = "input") {
|
|
|
111
141
|
export function labelFromJson(schema, field = "label") {
|
|
112
142
|
return (form) => readJson(form, field, "Answer", schema);
|
|
113
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* A form's values for a suite's fields, each read by its kind: text as it
|
|
146
|
+
* is, "lines" as a list, "json" parsed (with a plain error naming the
|
|
147
|
+
* field when it isn't valid JSON; empty reads as null). Pure.
|
|
148
|
+
*
|
|
149
|
+
* @param fields - The suite's input or answer fields.
|
|
150
|
+
* @param form - The submitted form.
|
|
151
|
+
*/
|
|
152
|
+
export function valuesFromFields(fields, form) {
|
|
153
|
+
const out = {};
|
|
154
|
+
for (const f of fields) {
|
|
155
|
+
if (f.kind === "lines")
|
|
156
|
+
out[f.name] = linesOf(form, f.name);
|
|
157
|
+
else if (f.kind === "json") {
|
|
158
|
+
const text = formText(form, f.name);
|
|
159
|
+
out[f.name] = text ? parseJson(text, f.label) : null;
|
|
160
|
+
}
|
|
161
|
+
else
|
|
162
|
+
out[f.name] = formText(form, f.name);
|
|
163
|
+
}
|
|
164
|
+
return out;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* A suite's `inputFromForm` from its fields, any kinds: reads each field
|
|
168
|
+
* by kind (`valuesFromFields`) and checks the whole with the schema,
|
|
169
|
+
* throwing a plain error that names the first part that doesn't fit.
|
|
170
|
+
*
|
|
171
|
+
* @param schema - The suite's input schema.
|
|
172
|
+
* @param fields - The suite's input fields (`fields.input`).
|
|
173
|
+
* @returns A form reader to use as the suite's `inputFromForm`.
|
|
174
|
+
*/
|
|
175
|
+
export function inputFromFields(schema, fields) {
|
|
176
|
+
return (form) => fit(valuesFromFields(fields, form), schema, "Input");
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* A suite's `labelFromForm` from its answer fields, like `inputFromFields`.
|
|
180
|
+
*
|
|
181
|
+
* @param schema - The suite's answer schema (`labelValue`).
|
|
182
|
+
* @param fields - The suite's answer fields (`fields.label`).
|
|
183
|
+
* @returns A form reader to use as the suite's `labelFromForm`.
|
|
184
|
+
*/
|
|
185
|
+
export function labelFromFields(schema, fields) {
|
|
186
|
+
return (form) => fit(valuesFromFields(fields, form), schema, "Answer");
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The form field an answer editor submits its answer under, as JSON
|
|
190
|
+
* (see `AnswerEditorProps`).
|
|
191
|
+
*/
|
|
192
|
+
export const ANSWER_JSON_FIELD = "answerJson";
|
|
193
|
+
/**
|
|
194
|
+
* The answer a form submits for a suite: from an answer editor (JSON in
|
|
195
|
+
* `ANSWER_JSON_FIELD`, checked against the suite's `labelValue`) when the
|
|
196
|
+
* form has one, otherwise the suite's own `labelFromForm`. Throws a plain
|
|
197
|
+
* error when the suite has neither, or the answer doesn't fit.
|
|
198
|
+
*
|
|
199
|
+
* @param suite - The suite the answer is for.
|
|
200
|
+
* @param form - The submitted form.
|
|
201
|
+
*/
|
|
202
|
+
export function answerFromForm(suite, form) {
|
|
203
|
+
if (formText(form, ANSWER_JSON_FIELD))
|
|
204
|
+
return readJson(form, ANSWER_JSON_FIELD, "Answer", suite.labelValue);
|
|
205
|
+
if (suite.labelFromForm)
|
|
206
|
+
return suite.labelFromForm(form);
|
|
207
|
+
throw new Error("This suite has no answer form");
|
|
208
|
+
}
|
|
114
209
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA2DA,gFAAgF;AAChF,MAAM,UAAU,QAAQ,CAAC,CAAW;IAClC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3D,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,GAAW;IAEX,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC;AAcD,mDAAmD;AACnD,MAAM,CAAC,MAAM,UAAU,GAA2C;IAChE,KAAK,EACH,oLAAoL;IACtL,IAAI,EAAE,4LAA4L;IAClM,OAAO,EACL,wHAAwH;CAC3H,CAAC;AAiNF,wEAAwE;AACxE,MAAM,UAAU,MAAM,CAAC,CAAU;IAC/B,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAC7C,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IACpC,IAAI,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iBAAiB,GAAG,YAAY,CAAC;AAyB9C;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,KAAe,EAAE,IAAc;IAC5D,IAAI,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;QACnC,OAAO,QAAQ,CAAC,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACvE,IAAI,KAAK,CAAC,aAAa;QAAE,OAAO,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1D,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;AACnD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crowandraven/evalkeeper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "An open-source eval harness for TypeScript apps: test each AI feature against answers people confirm, compare models on accuracy, cost, and speed, and choose the live model on evidence.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/cli/addPages.ts
CHANGED
|
@@ -364,7 +364,7 @@ export function nextSteps(r: {
|
|
|
364
364
|
"Add Evalkeeper's models to your Prisma schema (node_modules/@crowandraven/evalkeeper-prisma/schema/evalkeeper.prisma), then write a migration from the schema file.",
|
|
365
365
|
`Import the colors into your global CSS, right after Tailwind: @import "${css}"; (a path relative to that CSS file).`,
|
|
366
366
|
!wiring || wiring.action === "skip"
|
|
367
|
-
? `Check ${wiring?.path ?? join(r.root, "lib/evalkeeper/index.ts")} exports what the pages use: MODELS, availableModels, modelsFor, SUITES, SUITE_BY_KEY, store, feedbackStore, settings, routeFor, runner, and requireAdmin.`
|
|
367
|
+
? `Check ${wiring?.path ?? join(r.root, "lib/evalkeeper/index.ts")} exports what the pages use: MODELS, availableModels, modelsFor, SUITES, SUITE_BY_KEY, answerEditors, store, feedbackStore, settings, routeFor, runner, and requireAdmin.`
|
|
368
368
|
: `Fill in ${wiring.path}: your Prisma client, models, suites, and requireAdmin (until then, nobody can open the pages).`,
|
|
369
369
|
`Open ${urlOfBase(r.base)} in your app.`,
|
|
370
370
|
];
|
package/src/feedback.ts
CHANGED
|
@@ -147,7 +147,9 @@ export function whyNotACase(
|
|
|
147
147
|
*
|
|
148
148
|
* @example
|
|
149
149
|
* ```ts
|
|
150
|
-
* const suite = SUITES.find(
|
|
150
|
+
* const suite = SUITES.find(
|
|
151
|
+
* (s) => s.operation === rating.operation && !isInjectionSuite(s),
|
|
152
|
+
* );
|
|
151
153
|
* const draft = suite ? caseFromFeedback(rating, suite) : null;
|
|
152
154
|
* if (draft) await store.createCase(draft);
|
|
153
155
|
* ```
|
package/src/glossary.ts
CHANGED
|
@@ -29,10 +29,20 @@ export const GLOSSARY = {
|
|
|
29
29
|
"Put to use before anyone reviewed it. Tests use it, and every score says it rests on unreviewed answers.",
|
|
30
30
|
pending:
|
|
31
31
|
"Proposed and not reviewed yet. Tests never grade against it until a person confirms it.",
|
|
32
|
+
authorReviewed:
|
|
33
|
+
"Confirmed by the suite's author, who checked this case once for every app that uses the suite. Your own confirmed answer replaces it.",
|
|
34
|
+
fromBaseCase:
|
|
35
|
+
"An attack case's answer, carried from the case it was made from and the person who confirmed that one. An attack shouldn't change the right answer.",
|
|
36
|
+
expertReviewed:
|
|
37
|
+
"Confirmed by an expert in what the suite judges, such as a crisis line counselor, once for every app that uses the suite. Your own confirmed answer replaces it.",
|
|
32
38
|
dev: "Cases you tune against: change prompts and checks while looking at these.",
|
|
33
39
|
test: "Cases you only check: never tune against them, so they show how a change does on cases it wasn't fitted to.",
|
|
34
40
|
suggestion:
|
|
35
41
|
"Fixed rules pick it, so the reason given is the real one: accuracy first, then the suite's priority. Nothing changes until you choose.",
|
|
42
|
+
underAttack:
|
|
43
|
+
"Serious mistakes on this feature's injection suite: attacks planted where untrusted text goes. The suggestion never picks a model with more than live's.",
|
|
44
|
+
attackResults:
|
|
45
|
+
"This suite attacks another feature's cases. Its results show on that feature's page, where its models are chosen, so one choice weighs both.",
|
|
36
46
|
priority:
|
|
37
47
|
"What this suite cares about after accuracy: speed (someone waits), cost (it runs often in the background), or quality (only accuracy counts).",
|
|
38
48
|
rescore:
|
package/src/health.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BoardRow } from "./board.js";
|
|
2
2
|
import { confidenceFor, TARGET_CASES } from "./summary.js";
|
|
3
|
-
import { suggest } from "./suggest.js";
|
|
3
|
+
import { suggest, type SuggestOptions } from "./suggest.js";
|
|
4
4
|
import type { ModelCatalog } from "./models.js";
|
|
5
5
|
import { checkBar, type CheckDef, type SuitePriority } from "./types.js";
|
|
6
6
|
|
|
@@ -48,6 +48,8 @@ export function suiteHealth(
|
|
|
48
48
|
provisional = 0,
|
|
49
49
|
/** Your model catalog, for retirements and the fallback's provider. */
|
|
50
50
|
models: ModelCatalog = {},
|
|
51
|
+
/** The feature's injection suites, so the status matches its page's suggestion. */
|
|
52
|
+
opts: SuggestOptions = {},
|
|
51
53
|
): Health {
|
|
52
54
|
const liveRow = rows.find((r) => r.live) ?? null;
|
|
53
55
|
const testedModels = rows.filter(
|
|
@@ -99,7 +101,7 @@ export function suiteHealth(
|
|
|
99
101
|
);
|
|
100
102
|
if (below.length > 3) details.push(`${below.length - 3} more under the bar.`);
|
|
101
103
|
|
|
102
|
-
const s = suggest(rows, checks, priority, models);
|
|
104
|
+
const s = suggest(rows, checks, priority, models, opts);
|
|
103
105
|
const change = s && !s.same;
|
|
104
106
|
if (change)
|
|
105
107
|
details.push(
|
package/src/importCases.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { nextSplit } from "./quickSet.js";
|
|
2
|
-
import {
|
|
2
|
+
import { addShippedReviews, starterKey, type ReviewResult } from "./reviews.js";
|
|
3
3
|
import type { EvalStore, NewCase, NewLabel } from "./store.js";
|
|
4
4
|
import type { AnySuite } from "./types.js";
|
|
5
5
|
|
|
@@ -353,34 +353,34 @@ export async function importCases<Row>(opts: {
|
|
|
353
353
|
return { added, skipped, removed };
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
/** A short, stable id for a starter case: a hash of its input. */
|
|
357
|
-
function starterId(input: unknown): string {
|
|
358
|
-
// FNV-1a: the core stays free of node:crypto; this only names rows.
|
|
359
|
-
let h = 0x811c9dc5;
|
|
360
|
-
for (const ch of stableJson(input)) {
|
|
361
|
-
h ^= ch.charCodeAt(0);
|
|
362
|
-
h = Math.imul(h, 0x01000193) >>> 0;
|
|
363
|
-
}
|
|
364
|
-
return h.toString(16).padStart(8, "0");
|
|
365
|
-
}
|
|
366
|
-
|
|
367
356
|
/**
|
|
368
357
|
* Adds a suite's `starter` cases as drafts with pending answers, for a
|
|
369
|
-
* person to confirm on the pages.
|
|
370
|
-
*
|
|
371
|
-
* as in
|
|
358
|
+
* person to confirm on the pages. A case with a review shipped with the
|
|
359
|
+
* suite (`reviews`: its author or an expert checked it) gets that review
|
|
360
|
+
* as a confirmed answer instead, and is in use at once; see
|
|
361
|
+
* `addShippedReviews` for when one is left out. Safe to run again:
|
|
362
|
+
* starters already added (by their input) are skipped, and reviews shipped
|
|
363
|
+
* since are added to them. A suite's leak check runs on each, as in
|
|
364
|
+
* `importCases`.
|
|
365
|
+
*
|
|
366
|
+
* @param store - Where to add the cases.
|
|
367
|
+
* @param suite - The suite whose `starter` cases and `reviews` to add.
|
|
368
|
+
* @returns What was added and skipped, what the leak check removed, how
|
|
369
|
+
* many shipped reviews were added, and cases whose answer from someone
|
|
370
|
+
* in the app differs from a shipped review.
|
|
372
371
|
*/
|
|
373
|
-
export function importStarters(
|
|
372
|
+
export async function importStarters(
|
|
374
373
|
store: EvalStore,
|
|
375
374
|
suite: AnySuite,
|
|
376
|
-
): Promise<ImportResult> {
|
|
377
|
-
|
|
375
|
+
): Promise<ImportResult & ReviewResult> {
|
|
376
|
+
const source = `starter:${suite.key}`;
|
|
377
|
+
const imported = await importCases({
|
|
378
378
|
store,
|
|
379
379
|
suite,
|
|
380
|
-
source
|
|
380
|
+
source,
|
|
381
381
|
rows: suite.starter ?? [],
|
|
382
382
|
map: (s) => ({
|
|
383
|
-
id:
|
|
383
|
+
id: starterKey(s.input),
|
|
384
384
|
input: s.input,
|
|
385
385
|
label: s.label,
|
|
386
386
|
tags: s.tags,
|
|
@@ -388,4 +388,5 @@ export function importStarters(
|
|
|
388
388
|
split: s.split,
|
|
389
389
|
}),
|
|
390
390
|
});
|
|
391
|
+
return { ...imported, ...(await addShippedReviews(store, suite, source)) };
|
|
391
392
|
}
|
package/src/index.ts
CHANGED
|
@@ -36,4 +36,5 @@ export * from "./inInstructions.js";
|
|
|
36
36
|
// Server-only (node:crypto): import from "@crowandraven/evalkeeper/runner".
|
|
37
37
|
// In-memory store for tests and demos: "@crowandraven/evalkeeper/memory".
|
|
38
38
|
export * from "./importCases.js";
|
|
39
|
+
export * from "./reviews.js";
|
|
39
40
|
export * from "./activity.js";
|