@crowandraven/evalkeeper 0.4.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/activity.d.ts +58 -0
- package/dist/activity.js +125 -0
- package/dist/activity.js.map +1 -0
- package/dist/assertExpect.d.ts +52 -0
- package/dist/assertExpect.js +104 -0
- package/dist/assertExpect.js.map +1 -0
- package/dist/blind.d.ts +79 -0
- package/dist/blind.js +113 -0
- package/dist/blind.js.map +1 -0
- package/dist/cli/addPages.d.ts +34 -0
- package/dist/cli/addPages.js +91 -11
- package/dist/cli/addPages.js.map +1 -1
- package/dist/cli/main.d.ts +1 -1
- package/dist/cli/main.js +9 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/compare.d.ts +38 -0
- package/dist/compare.js +62 -0
- package/dist/compare.js.map +1 -1
- package/dist/glossary.d.ts +20 -0
- package/dist/glossary.js +20 -0
- package/dist/glossary.js.map +1 -1
- package/dist/health.js +5 -3
- package/dist/health.js.map +1 -1
- package/dist/importCases.d.ts +76 -5
- package/dist/importCases.js +114 -14
- package/dist/importCases.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/memoryStore.js +3 -1
- package/dist/memoryStore.js.map +1 -1
- package/dist/readCheck.d.ts +116 -0
- package/dist/readCheck.js +321 -0
- package/dist/readCheck.js.map +1 -0
- package/dist/runner.d.ts +7 -0
- package/dist/runner.js +25 -3
- package/dist/runner.js.map +1 -1
- package/dist/settings.d.ts +81 -3
- package/dist/settings.js +160 -23
- package/dist/settings.js.map +1 -1
- package/dist/store.d.ts +10 -3
- package/dist/suggest.d.ts +10 -1
- package/dist/suggest.js +22 -4
- package/dist/suggest.js.map +1 -1
- package/dist/suiteContract.d.ts +17 -0
- package/dist/suiteContract.js +69 -0
- package/dist/suiteContract.js.map +1 -0
- package/dist/suites/crisisRisk.d.ts +83 -0
- package/dist/suites/crisisRisk.js +176 -0
- package/dist/suites/crisisRisk.js.map +1 -0
- package/dist/suites/crisisRiskCases.d.ts +40 -0
- package/dist/suites/crisisRiskCases.js +179 -0
- package/dist/suites/crisisRiskCases.js.map +1 -0
- package/dist/suites/index.d.ts +9 -0
- package/dist/suites/index.js +10 -0
- package/dist/suites/index.js.map +1 -0
- package/dist/testing.d.ts +140 -8
- package/dist/testing.js +420 -125
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +92 -0
- package/dist/types.js +68 -0
- package/dist/types.js.map +1 -1
- package/dist/weekly.d.ts +21 -3
- package/dist/weekly.js +18 -1
- package/dist/weekly.js.map +1 -1
- package/package.json +5 -1
- package/src/activity.ts +154 -0
- package/src/assertExpect.ts +168 -0
- package/src/blind.ts +138 -0
- package/src/cli/addPages.ts +119 -17
- package/src/cli/main.ts +11 -0
- package/src/compare.ts +85 -0
- package/src/glossary.ts +36 -0
- package/src/health.ts +5 -3
- package/src/importCases.ts +172 -33
- package/src/index.ts +4 -0
- package/src/memoryStore.ts +2 -1
- package/src/readCheck.ts +458 -0
- package/src/runner.ts +33 -4
- package/src/settings.ts +192 -26
- package/src/store.ts +11 -3
- package/src/suggest.ts +33 -4
- package/src/suiteContract.ts +101 -0
- package/src/suites/crisisRisk.ts +250 -0
- package/src/suites/crisisRiskCases.ts +205 -0
- package/src/suites/index.ts +9 -0
- package/src/testing.ts +564 -127
- package/src/types.ts +141 -0
- package/src/weekly.ts +39 -3
- package/templates/app/evals/[suite]/compare/page.tsx +375 -0
- package/templates/app/evals/[suite]/page.tsx +55 -19
- package/templates/app/evals/[suite]/rate/page.tsx +133 -0
- package/templates/app/evals/[suite]/runs/[runId]/page.tsx +12 -0
- package/templates/app/evals/[suite]/side-by-side/page.tsx +300 -0
- package/templates/components/evalkeeper/DisagreementChip.tsx +35 -0
- package/templates/components/evalkeeper/RollBack.tsx +21 -1
- package/templates/components/evalkeeper/SettingsHistory.tsx +20 -2
- package/templates/components/evalkeeper/WeeklyCheck.tsx +34 -2
- package/templates/lib/evalkeeper/actions.ts +68 -4
- package/templates/lib/evalkeeper/weekly.ts +27 -4
package/dist/testing.d.ts
CHANGED
|
@@ -1,26 +1,158 @@
|
|
|
1
|
+
import type { ContractExpect } from "./assertExpect.js";
|
|
1
2
|
import type { FeedbackStore } from "./feedback.js";
|
|
2
3
|
import { type SettingsStore } from "./settings.js";
|
|
3
4
|
import type { EvalStore } from "./store.js";
|
|
5
|
+
import type { AnySuite } from "./types.js";
|
|
6
|
+
import { type ReadCheckReport } from "./readCheck.js";
|
|
7
|
+
export { assertExpect, type ContractExpect, type ContractMatchers, } from "./assertExpect.js";
|
|
4
8
|
/**
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
9
|
+
* The test functions a contract registers its tests with. Vitest's
|
|
10
|
+
* `describe`, `it`, `expect`, and `afterAll` fit, and so do `node:test`'s
|
|
11
|
+
* `describe`, `it`, and `after` with `assertExpect`.
|
|
12
|
+
*/
|
|
13
|
+
export type ContractTest = {
|
|
14
|
+
/** Groups tests, like Vitest's or node:test's `describe`. */
|
|
15
|
+
describe: (name: string, fn: () => void) => unknown;
|
|
16
|
+
/** Adds a test, like Vitest's or node:test's `it`. */
|
|
17
|
+
it: (name: string, fn: () => Promise<void> | void) => unknown;
|
|
18
|
+
/** Checks values: Vitest's `expect`, or `assertExpect` on node:assert. */
|
|
19
|
+
expect: ContractExpect;
|
|
20
|
+
/**
|
|
21
|
+
* Runs once after a group's tests, like Vitest's `afterAll` or
|
|
22
|
+
* node:test's `after`. Needed only with `cleanup`.
|
|
23
|
+
*/
|
|
24
|
+
afterAll?: (fn: () => Promise<void> | void) => unknown;
|
|
25
|
+
};
|
|
26
|
+
/** Options every contract takes. */
|
|
27
|
+
export type ContractOptions = {
|
|
28
|
+
/** The test functions to use. Vitest's by default. */
|
|
29
|
+
test?: ContractTest;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Options for running a store contract on a database that holds other
|
|
33
|
+
* rows too, such as a shared development database.
|
|
34
|
+
*/
|
|
35
|
+
export type ScopedContractOptions = ContractOptions & {
|
|
36
|
+
/**
|
|
37
|
+
* A prefix for every suite and feature the contract writes (each test
|
|
38
|
+
* adds its own after it), so its rows never mix with others and `make`
|
|
39
|
+
* needn't return an empty store. Without it, `make` must return an
|
|
40
|
+
* empty store every time.
|
|
41
|
+
*/
|
|
42
|
+
scope?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Deletes the rows whose suite or feature starts with the scope, once
|
|
45
|
+
* after the contract's tests (and so also any left by an earlier run
|
|
46
|
+
* that stopped early). Needs `scope`, and `afterAll` among the test
|
|
47
|
+
* functions. For Prisma, `deleteScopedRows` from
|
|
48
|
+
* `@crowandraven/evalkeeper-prisma`.
|
|
49
|
+
*/
|
|
50
|
+
cleanup?: (scope: string) => Promise<unknown>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Options for a store contract, for a store on tables that lack an
|
|
54
|
+
* optional column.
|
|
55
|
+
*/
|
|
56
|
+
export type StoreContractOptions = ScopedContractOptions & {
|
|
57
|
+
/**
|
|
58
|
+
* Settings the store has no column for. The contract then checks the
|
|
59
|
+
* store refuses a value for them (rather than losing it) and reads
|
|
60
|
+
* them as null.
|
|
61
|
+
*/
|
|
62
|
+
without?: ("temperature" | "maxOutputTokens")[];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The contract every EvalStore must meet. Run it against your store to
|
|
66
|
+
* know the runner will work on it. `make` must return an empty store each
|
|
67
|
+
* time it's called, unless `opts.scope` is set: then every suite the
|
|
68
|
+
* contract writes (and every request hash it picks) starts with the
|
|
69
|
+
* scope, the tests never look past their own rows, and `opts.cleanup`
|
|
70
|
+
* deletes those suites' cases, answers, tests, and outputs afterward, so
|
|
71
|
+
* it can run on a database that holds other rows. `opts.without` names
|
|
72
|
+
* run settings its tables have no column for; `opts.test` passes test
|
|
73
|
+
* functions other than Vitest's.
|
|
8
74
|
*
|
|
9
75
|
* @example
|
|
10
76
|
* ```ts
|
|
11
77
|
* import { describeStoreContract } from "@crowandraven/evalkeeper/testing";
|
|
12
78
|
*
|
|
13
79
|
* describeStoreContract("my store", () => myStore(freshDatabase()));
|
|
80
|
+
*
|
|
81
|
+
* // On a database with other rows: only rows starting "contract-" are
|
|
82
|
+
* // written, and cleanup deletes only those.
|
|
83
|
+
* describeStoreContract("our tables", () => prismaStore(prisma, map), {
|
|
84
|
+
* scope: "contract-",
|
|
85
|
+
* cleanup: (scope) => deleteScopedRows(prisma, scope, { map }),
|
|
86
|
+
* });
|
|
14
87
|
* ```
|
|
15
88
|
*/
|
|
16
|
-
export declare function describeStoreContract(name: string, make: () => EvalStore | Promise<EvalStore
|
|
89
|
+
export declare function describeStoreContract(name: string, make: () => EvalStore | Promise<EvalStore>, opts?: StoreContractOptions): void;
|
|
17
90
|
/**
|
|
18
91
|
* The contract every FeedbackStore must meet. `make` must return an empty
|
|
19
|
-
* store each time it's called.
|
|
92
|
+
* store each time it's called, unless `opts.scope` is set (see
|
|
93
|
+
* `describeStoreContract`): then every feature the contract rates starts
|
|
94
|
+
* with the scope, and its lists ask for those features only.
|
|
20
95
|
*/
|
|
21
|
-
export declare function describeFeedbackStoreContract(name: string, make: () => FeedbackStore | Promise<FeedbackStore
|
|
96
|
+
export declare function describeFeedbackStoreContract(name: string, make: () => FeedbackStore | Promise<FeedbackStore>, opts?: ScopedContractOptions): void;
|
|
97
|
+
/** Options for the settings store contract. */
|
|
98
|
+
export type SettingsStoreContractOptions = ScopedContractOptions & {
|
|
99
|
+
/** Settings the store has no column for (see `StoreContractOptions`). */
|
|
100
|
+
without?: "temperature"[];
|
|
101
|
+
};
|
|
22
102
|
/**
|
|
23
103
|
* The contract every SettingsStore must meet. `make` must return an empty
|
|
24
|
-
* store each time it's called.
|
|
104
|
+
* store each time it's called, unless `opts.scope` is set (see
|
|
105
|
+
* `describeStoreContract`): then every feature the contract versions
|
|
106
|
+
* starts with the scope. `opts.without` names settings its tables have no
|
|
107
|
+
* column for (see `StoreContractOptions`).
|
|
108
|
+
*/
|
|
109
|
+
export declare function describeSettingsStoreContract(name: string, make: () => SettingsStore | Promise<SettingsStore>, opts?: SettingsStoreContractOptions): void;
|
|
110
|
+
/**
|
|
111
|
+
* The contract every set of suites should meet, so people confirming
|
|
112
|
+
* answers weeks later (and the pages) can read them: unique keys, a label
|
|
113
|
+
* and help for every top-level field of each suite's input and answer,
|
|
114
|
+
* a description for every check, and starter cases that fit the suite's
|
|
115
|
+
* own schemas. One test per suite, listing what's missing in plain words
|
|
116
|
+
* (`suiteContractProblems`).
|
|
117
|
+
*
|
|
118
|
+
* @param name - What the tests are called, e.g. "our suites".
|
|
119
|
+
* @param suites - Every suite the app registers.
|
|
120
|
+
* @param opts - Test functions other than Vitest's.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* import { describeSuiteContract } from "@crowandraven/evalkeeper/testing";
|
|
125
|
+
* import { SUITES } from "../lib/suites";
|
|
126
|
+
*
|
|
127
|
+
* describeSuiteContract("our suites", SUITES);
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare function describeSuiteContract(name: string, suites: readonly AnySuite[], opts?: ContractOptions): void;
|
|
131
|
+
/**
|
|
132
|
+
* A read-only check, as a test, that a store mapped onto your own tables
|
|
133
|
+
* reads what's already there: one test per suite that fails listing every
|
|
134
|
+
* case, answer, test, and output that doesn't parse, with counts. It only
|
|
135
|
+
* reads, so it's the check to run first, on a copy of real data. Pass the
|
|
136
|
+
* report from `checkStoreReads` (any store) or `prismaReadCheck` (sees a
|
|
137
|
+
* Prisma table's values before the store fills in defaults).
|
|
138
|
+
*
|
|
139
|
+
* @param name - What the tests are called, e.g. "our answer key".
|
|
140
|
+
* @param check - Makes the report; called once, when the tests run.
|
|
141
|
+
* @param opts - The suite keys to name a test for, and test functions
|
|
142
|
+
* other than Vitest's.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* import { describeMappedReadCheck } from "@crowandraven/evalkeeper/testing";
|
|
147
|
+
* import { prismaReadCheck } from "@crowandraven/evalkeeper-prisma";
|
|
148
|
+
*
|
|
149
|
+
* describeMappedReadCheck(
|
|
150
|
+
* "our answer key",
|
|
151
|
+
* () => prismaReadCheck(prisma, map, { suites: SUITES }),
|
|
152
|
+
* { suites: SUITES.map((s) => s.key) },
|
|
153
|
+
* );
|
|
154
|
+
* ```
|
|
25
155
|
*/
|
|
26
|
-
export declare function
|
|
156
|
+
export declare function describeMappedReadCheck(name: string, check: () => Promise<ReadCheckReport>, opts: ContractOptions & {
|
|
157
|
+
suites: readonly string[];
|
|
158
|
+
}): void;
|