@crowandraven/evalkeeper 0.10.0 → 0.11.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 +1 -2
- package/dist/ai-sdk/decide.d.ts +35 -0
- package/dist/ai-sdk/decide.js +36 -0
- package/dist/ai-sdk/decide.js.map +1 -0
- package/dist/ai-sdk/hash.d.ts +50 -0
- package/dist/ai-sdk/hash.js +59 -0
- package/dist/ai-sdk/hash.js.map +1 -0
- package/dist/ai-sdk/index.d.ts +15 -0
- package/dist/ai-sdk/index.js +16 -0
- package/dist/ai-sdk/index.js.map +1 -0
- package/dist/ai-sdk/judge.d.ts +69 -0
- package/dist/ai-sdk/judge.js +105 -0
- package/dist/ai-sdk/judge.js.map +1 -0
- package/dist/ai-sdk/usage.d.ts +18 -0
- package/dist/ai-sdk/usage.js +19 -0
- package/dist/ai-sdk/usage.js.map +1 -0
- package/dist/board.d.ts +5 -0
- package/dist/cli/addPages.d.ts +6 -1
- package/dist/cli/addPages.js +14 -8
- package/dist/cli/addPages.js.map +1 -1
- package/dist/cli/main.d.ts +19 -5
- package/dist/cli/main.js +100 -4
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/migration.d.ts +95 -0
- package/dist/cli/migration.js +247 -0
- package/dist/cli/migration.js.map +1 -0
- package/dist/feedback.d.ts +1 -1
- package/dist/glossary.d.ts +8 -1
- package/dist/glossary.js +8 -1
- package/dist/glossary.js.map +1 -1
- package/dist/inInstructions.d.ts +1 -1
- package/dist/inInstructions.js +1 -1
- package/dist/next/RefreshWhile.d.ts +11 -0
- package/dist/next/RefreshWhile.js +28 -0
- package/dist/next/RefreshWhile.js.map +1 -0
- package/dist/next/actions.d.ts +14 -0
- package/dist/next/actions.js +332 -0
- package/dist/next/actions.js.map +1 -0
- package/dist/next/components.d.ts +9 -0
- package/dist/next/components.js +27 -0
- package/dist/next/components.js.map +1 -0
- package/dist/next/cron.d.ts +9 -0
- package/dist/next/cron.js +17 -0
- package/dist/next/cron.js.map +1 -0
- package/dist/next/index.d.ts +15 -0
- package/dist/next/index.js +16 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/pages.d.ts +70 -0
- package/dist/next/pages.js +77 -0
- package/dist/next/pages.js.map +1 -0
- package/dist/next/route.d.ts +19 -0
- package/dist/next/route.js +31 -0
- package/dist/next/route.js.map +1 -0
- package/dist/next/weekly.d.ts +20 -0
- package/dist/next/weekly.js +55 -0
- package/dist/next/weekly.js.map +1 -0
- package/dist/next/wiring.d.ts +19 -0
- package/dist/next/wiring.js +2 -0
- package/dist/next/wiring.js.map +1 -0
- package/dist/prisma/contracts.d.ts +74 -0
- package/dist/prisma/contracts.js +178 -0
- package/dist/prisma/contracts.js.map +1 -0
- package/dist/prisma/index.d.ts +423 -0
- package/dist/prisma/index.js +622 -0
- package/dist/prisma/index.js.map +1 -0
- package/dist/prisma/mapping.d.ts +63 -0
- package/dist/prisma/mapping.js +111 -0
- package/dist/prisma/mapping.js.map +1 -0
- package/dist/prisma/moveIn.d.ts +106 -0
- package/dist/prisma/moveIn.js +299 -0
- package/dist/prisma/moveIn.js.map +1 -0
- package/dist/prune.d.ts +45 -0
- package/dist/prune.js +32 -0
- package/dist/prune.js.map +1 -1
- package/dist/react/AddCase.d.ts +10 -0
- package/dist/react/AddCase.js +19 -0
- package/dist/react/AddCase.js.map +1 -0
- package/dist/react/AnswerKey.d.ts +22 -0
- package/dist/react/AnswerKey.js +83 -0
- package/dist/react/AnswerKey.js.map +1 -0
- package/dist/react/CaseMenu.d.ts +17 -0
- package/dist/react/CaseMenu.js +41 -0
- package/dist/react/CaseMenu.js.map +1 -0
- package/dist/react/CompareView.d.ts +14 -0
- package/dist/react/CompareView.js +51 -0
- package/dist/react/CompareView.js.map +1 -0
- package/dist/react/ConfirmAnswer.d.ts +13 -0
- package/dist/react/ConfirmAnswer.js +27 -0
- package/dist/react/ConfirmAnswer.js.map +1 -0
- package/dist/react/DisagreementChip.d.ts +10 -0
- package/dist/react/DisagreementChip.js +21 -0
- package/dist/react/DisagreementChip.js.map +1 -0
- package/dist/react/FeedbackView.d.ts +10 -0
- package/dist/react/FeedbackView.js +26 -0
- package/dist/react/FeedbackView.js.map +1 -0
- package/dist/react/Fields.d.ts +32 -0
- package/dist/react/Fields.js +33 -0
- package/dist/react/Fields.js.map +1 -0
- package/dist/react/HubSections.d.ts +78 -0
- package/dist/react/HubSections.js +124 -0
- package/dist/react/HubSections.js.map +1 -0
- package/dist/react/ModelMenu.d.ts +16 -0
- package/dist/react/ModelMenu.js +38 -0
- package/dist/react/ModelMenu.js.map +1 -0
- package/dist/react/RateView.d.ts +18 -0
- package/dist/react/RateView.js +30 -0
- package/dist/react/RateView.js.map +1 -0
- package/dist/react/ReadableOutput.d.ts +3 -0
- package/dist/react/ReadableOutput.js +50 -0
- package/dist/react/ReadableOutput.js.map +1 -0
- package/dist/react/RollBack.d.ts +17 -0
- package/dist/react/RollBack.js +26 -0
- package/dist/react/RollBack.js.map +1 -0
- package/dist/react/RunView.d.ts +9 -0
- package/dist/react/RunView.js +41 -0
- package/dist/react/RunView.js.map +1 -0
- package/dist/react/SettingsHistory.d.ts +33 -0
- package/dist/react/SettingsHistory.js +79 -0
- package/dist/react/SettingsHistory.js.map +1 -0
- package/dist/react/SideBySideView.d.ts +14 -0
- package/dist/react/SideBySideView.js +67 -0
- package/dist/react/SideBySideView.js.map +1 -0
- package/dist/react/SuiteSections.d.ts +111 -0
- package/dist/react/SuiteSections.js +224 -0
- package/dist/react/SuiteSections.js.map +1 -0
- package/dist/react/Tabs.d.ts +15 -0
- package/dist/react/Tabs.js +18 -0
- package/dist/react/Tabs.js.map +1 -0
- package/dist/react/Thumbs.d.ts +13 -0
- package/dist/react/Thumbs.js +54 -0
- package/dist/react/Thumbs.js.map +1 -0
- package/dist/react/WeeklyCheck.d.ts +11 -0
- package/dist/react/WeeklyCheck.js +19 -0
- package/dist/react/WeeklyCheck.js.map +1 -0
- package/dist/react/app.d.ts +118 -0
- package/dist/react/app.js +87 -0
- package/dist/react/app.js.map +1 -0
- package/dist/react/format.d.ts +27 -0
- package/dist/react/format.js +38 -0
- package/dist/react/format.js.map +1 -0
- package/dist/react/index.d.ts +31 -0
- package/dist/react/index.js +32 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/pieces.d.ts +191 -0
- package/dist/react/pieces.js +191 -0
- package/dist/react/pieces.js.map +1 -0
- package/dist/readCheck.d.ts +1 -1
- package/dist/runner.d.ts +62 -2
- package/dist/runner.js +123 -3
- package/dist/runner.js.map +1 -1
- package/dist/settings.d.ts +1 -1
- package/dist/store.d.ts +1 -1
- package/dist/suggest.d.ts +1 -1
- package/dist/suggest.js +7 -7
- package/dist/suggest.js.map +1 -1
- package/dist/suiteContract.d.ts +3 -3
- package/dist/suiteContract.js +20 -16
- package/dist/suiteContract.js.map +1 -1
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +56 -6
- package/schema/evalkeeper.prisma +196 -0
- package/src/ai-sdk/decide.ts +57 -0
- package/src/ai-sdk/hash.ts +74 -0
- package/src/ai-sdk/index.ts +15 -0
- package/src/ai-sdk/judge.ts +163 -0
- package/src/ai-sdk/usage.ts +31 -0
- package/src/board.ts +5 -0
- package/src/cli/addPages.ts +15 -7
- package/src/cli/main.ts +135 -9
- package/src/cli/migration.ts +349 -0
- package/src/feedback.ts +1 -1
- package/src/glossary.ts +16 -2
- package/src/inInstructions.ts +1 -1
- package/{templates/components/evalkeeper → src/next}/RefreshWhile.tsx +2 -2
- package/src/next/actions.ts +389 -0
- package/src/next/components.ts +31 -0
- package/{templates/lib/evalkeeper/cronAuth.ts → src/next/cron.ts} +3 -0
- package/src/next/index.ts +15 -0
- package/src/next/pages.tsx +106 -0
- package/src/next/route.ts +35 -0
- package/src/next/weekly.ts +70 -0
- package/src/next/wiring.ts +18 -0
- package/src/prisma/contracts.ts +249 -0
- package/src/prisma/index.ts +1169 -0
- package/src/prisma/mapping.ts +147 -0
- package/src/prisma/moveIn.ts +502 -0
- package/src/prune.ts +77 -0
- package/{templates/components/evalkeeper → src/react}/AddCase.tsx +6 -6
- package/{templates/components/evalkeeper → src/react}/AnswerKey.tsx +92 -61
- package/{templates/components/evalkeeper → src/react}/CaseMenu.tsx +9 -8
- package/src/react/CompareView.tsx +270 -0
- package/{templates/components/evalkeeper → src/react}/ConfirmAnswer.tsx +6 -3
- package/{templates/components/evalkeeper → src/react}/DisagreementChip.tsx +2 -3
- package/src/react/FeedbackView.tsx +230 -0
- package/{templates/components/evalkeeper → src/react}/Fields.tsx +6 -6
- package/src/react/HubSections.tsx +446 -0
- package/src/react/ModelMenu.tsx +89 -0
- package/src/react/RateView.tsx +143 -0
- package/{templates/components/evalkeeper → src/react}/ReadableOutput.tsx +1 -1
- package/{templates/components/evalkeeper → src/react}/RollBack.tsx +9 -10
- package/src/react/RunView.tsx +151 -0
- package/{templates/components/evalkeeper → src/react}/SettingsHistory.tsx +16 -9
- package/src/react/SideBySideView.tsx +307 -0
- package/src/react/SuiteSections.tsx +925 -0
- package/src/react/Tabs.tsx +61 -0
- package/{templates/components/evalkeeper → src/react}/Thumbs.tsx +7 -6
- package/{templates/components/evalkeeper → src/react}/WeeklyCheck.tsx +31 -20
- package/src/react/app.ts +173 -0
- package/src/react/format.ts +45 -0
- package/src/react/index.ts +31 -0
- package/src/react/pieces.tsx +412 -0
- package/src/readCheck.ts +1 -1
- package/src/runner.ts +167 -3
- package/src/settings.ts +1 -1
- package/src/store.ts +1 -1
- package/src/suggest.ts +7 -7
- package/src/suiteContract.ts +35 -28
- package/src/testing.ts +2 -2
- package/src/types.ts +2 -2
- package/starter/index.ts +22 -8
- package/templates/app/api/cron/evals-weekly/route.ts +5 -15
- package/templates/app/evals/[suite]/compare/page.tsx +6 -383
- package/templates/app/evals/[suite]/page.tsx +7 -685
- package/templates/app/evals/[suite]/rate/page.tsx +6 -151
- package/templates/app/evals/[suite]/runs/[runId]/page.tsx +6 -174
- package/templates/app/evals/[suite]/side-by-side/page.tsx +6 -318
- package/templates/app/evals/feedback/page.tsx +6 -227
- package/templates/app/evals/layout.tsx +10 -0
- package/templates/app/evals/page.tsx +7 -397
- package/templates/lib/evalkeeper/actions.ts +34 -317
- package/templates/lib/evalkeeper/appComponents.tsx +21 -0
- package/templates/lib/evalkeeper/evals.ts +14 -0
- package/templates/lib/evalkeeper/paths.ts +2 -7
- package/templates/components/evalkeeper/Submit.tsx +0 -67
- package/templates/components/evalkeeper/Tip.tsx +0 -98
- package/templates/components/evalkeeper/ui.tsx +0 -105
- package/templates/lib/evalkeeper/time.ts +0 -4
- package/templates/lib/evalkeeper/weekly.ts +0 -74
|
@@ -1,365 +1,82 @@
|
|
|
1
1
|
"use server";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
blindRating,
|
|
10
|
-
caseFromFeedback,
|
|
11
|
-
formText,
|
|
12
|
-
isInjectionSuite,
|
|
13
|
-
leakNote,
|
|
14
|
-
raterStatus,
|
|
15
|
-
skipMark,
|
|
16
|
-
suggest,
|
|
17
|
-
withoutLeaks,
|
|
18
|
-
} from "@crowandraven/evalkeeper";
|
|
19
|
-
import {
|
|
20
|
-
MODELS,
|
|
21
|
-
SUITES,
|
|
22
|
-
modelsFor,
|
|
23
|
-
feedbackStore,
|
|
24
|
-
requireAdmin,
|
|
25
|
-
runner,
|
|
26
|
-
settings,
|
|
27
|
-
store,
|
|
28
|
-
} from ".";
|
|
29
|
-
import { EVALS_BASE, evalsPath } from "./paths";
|
|
30
|
-
import { runWeeklyCheck, startWeeklyCheck } from "./weekly";
|
|
3
|
+
// Written by `npx @crowandraven/evalkeeper add pages`: don't edit it.
|
|
4
|
+
// Next.js takes server actions only from a "use server" module of your
|
|
5
|
+
// app, so each action here calls Evalkeeper's.
|
|
6
|
+
import { evalActions } from "@crowandraven/evalkeeper/next";
|
|
7
|
+
import { wiring } from ".";
|
|
8
|
+
import { EVALS_BASE } from "./paths";
|
|
31
9
|
|
|
32
|
-
|
|
33
|
-
* Every action on the eval pages. Each one checks requireAdmin() first,
|
|
34
|
-
* and records the admin as who made a change.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
const suiteFrom = (form: FormData) =>
|
|
38
|
-
runner.suiteOrThrow(formText(form, "suite"));
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The suite whose page chooses models: never an injection suite, whose
|
|
42
|
-
* results show on its base suite's page and count in its suggestion.
|
|
43
|
-
*/
|
|
44
|
-
function choosingSuite(form: FormData) {
|
|
45
|
-
const suite = suiteFrom(form);
|
|
46
|
-
if (isInjectionSuite(suite))
|
|
47
|
-
throw new Error(`Choose models on ${suite.base.label}`);
|
|
48
|
-
return suite;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** A suite's injection suites, as its suggestion reads them. */
|
|
52
|
-
const attacksOn = async (suiteKey: string) =>
|
|
53
|
-
attacksFrom(await runner.attackBoards(suiteKey));
|
|
10
|
+
const actions = evalActions({ ...wiring, basePath: EVALS_BASE });
|
|
54
11
|
|
|
55
12
|
export async function testModel(form: FormData) {
|
|
56
|
-
|
|
57
|
-
const suite = suiteFrom(form);
|
|
58
|
-
const model = formText(form, "model");
|
|
59
|
-
if (!modelsFor(suite.operation).includes(model))
|
|
60
|
-
throw new Error("Unknown model");
|
|
61
|
-
const { run } = await runner.createRun({ suite: suite.key, model });
|
|
62
|
-
// Answers come back after the response; the page refreshes until done.
|
|
63
|
-
after(() => runner.runEval(run.id));
|
|
64
|
-
revalidatePath(evalsPath(suite.key));
|
|
13
|
+
return actions.testModel(form);
|
|
65
14
|
}
|
|
66
15
|
|
|
67
16
|
export async function testAll(form: FormData) {
|
|
68
|
-
|
|
69
|
-
const suite = suiteFrom(form);
|
|
70
|
-
for (const model of modelsFor(suite.operation)) {
|
|
71
|
-
const { run } = await runner.createRun({ suite: suite.key, model });
|
|
72
|
-
after(() => runner.runEval(run.id));
|
|
73
|
-
}
|
|
74
|
-
revalidatePath(evalsPath(suite.key));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* The evidence for a promotion: the model's current test, the live
|
|
79
|
-
* model's, and how they compared, so the history can show why.
|
|
80
|
-
*/
|
|
81
|
-
async function evidenceFor(suiteKey: string, model: string) {
|
|
82
|
-
const board = await runner.board(suiteKey);
|
|
83
|
-
const row = board.rows.find((r) => r.model === model && !r.variant);
|
|
84
|
-
if (!row?.test || row.test.stale)
|
|
85
|
-
throw new Error("Test this model on the current cases first");
|
|
86
|
-
return {
|
|
87
|
-
row,
|
|
88
|
-
evidence: {
|
|
89
|
-
runId: row.test.runId,
|
|
90
|
-
liveRunId: board.liveRunId,
|
|
91
|
-
vsLive: row.vsLive,
|
|
92
|
-
score: { right: row.test.right, total: row.test.total },
|
|
93
|
-
},
|
|
94
|
-
};
|
|
17
|
+
return actions.testAll(form);
|
|
95
18
|
}
|
|
96
19
|
|
|
97
|
-
/** What a fallback choice records: its current test, if it has one. */
|
|
98
|
-
async function fallbackEvidence(suiteKey: string, model: string) {
|
|
99
|
-
const board = await runner.board(suiteKey);
|
|
100
|
-
const row = board.rows.find((r) => r.model === model && !r.variant);
|
|
101
|
-
if (!row?.canMakeFallback)
|
|
102
|
-
throw new Error("This model can't be the fallback");
|
|
103
|
-
const test = row.test && !row.test.stale ? row.test : null;
|
|
104
|
-
const failed = test?.failedAnswers ? `, ${test.failedAnswers} failed` : "";
|
|
105
|
-
return {
|
|
106
|
-
reason: `Made ${row.label} the fallback: ${test ? `${Math.round(test.right)}/${Math.round(test.total)}${failed}` : "not tested"}`,
|
|
107
|
-
evidence: {
|
|
108
|
-
runId: test?.runId ?? null,
|
|
109
|
-
liveRunId: board.liveRunId,
|
|
110
|
-
score: test ? { right: test.right, total: test.total } : null,
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const VS: Record<string, string> = {
|
|
116
|
-
BETTER: "more accurate than live",
|
|
117
|
-
SAME: "about as accurate as live",
|
|
118
|
-
WORSE: "less accurate than live",
|
|
119
|
-
TOO_FEW: "too few cases to compare",
|
|
120
|
-
};
|
|
121
|
-
|
|
122
20
|
export async function makeLive(form: FormData) {
|
|
123
|
-
|
|
124
|
-
const suite = choosingSuite(form);
|
|
125
|
-
const model = formText(form, "model");
|
|
126
|
-
const { row, evidence } = await evidenceFor(suite.key, model);
|
|
127
|
-
const attacked = attackMistakes(row.key, await attacksOn(suite.key));
|
|
128
|
-
await settings.update(
|
|
129
|
-
suite.operation,
|
|
130
|
-
{ model },
|
|
131
|
-
{
|
|
132
|
-
by: admin.name,
|
|
133
|
-
reason: `Made ${row.label} live: ${evidence.score.right}/${evidence.score.total}, ${VS[row.vsLive ?? ""] ?? "no comparison"}${attacked === null ? "" : `; ${attacked} serious ${attacked === 1 ? "mistake" : "mistakes"} under attack`}`,
|
|
134
|
-
evidence,
|
|
135
|
-
},
|
|
136
|
-
);
|
|
137
|
-
revalidatePath(EVALS_BASE, "layout");
|
|
21
|
+
return actions.makeLive(form);
|
|
138
22
|
}
|
|
139
23
|
|
|
140
24
|
export async function makeFallback(form: FormData) {
|
|
141
|
-
|
|
142
|
-
const suite = choosingSuite(form);
|
|
143
|
-
const model = formText(form, "model");
|
|
144
|
-
const { reason, evidence } = await fallbackEvidence(suite.key, model);
|
|
145
|
-
await settings.update(
|
|
146
|
-
suite.operation,
|
|
147
|
-
{ fallbackModel: model },
|
|
148
|
-
{ by: admin.name, reason, evidence },
|
|
149
|
-
);
|
|
150
|
-
revalidatePath(EVALS_BASE, "layout");
|
|
25
|
+
return actions.makeFallback(form);
|
|
151
26
|
}
|
|
152
27
|
|
|
153
|
-
/** Applies the suggestion: its live and fallback models, in one change. */
|
|
154
28
|
export async function useSuggestion(form: FormData) {
|
|
155
|
-
|
|
156
|
-
const suite = choosingSuite(form);
|
|
157
|
-
const [board, attacks] = await Promise.all([
|
|
158
|
-
runner.board(suite.key),
|
|
159
|
-
attacksOn(suite.key),
|
|
160
|
-
]);
|
|
161
|
-
const s = suggest(board.rows, suite.checks, suite.priority, MODELS, {
|
|
162
|
-
attacks,
|
|
163
|
-
});
|
|
164
|
-
if (!s || s.same) return;
|
|
165
|
-
await settings.update(
|
|
166
|
-
suite.operation,
|
|
167
|
-
{
|
|
168
|
-
model: s.live.model,
|
|
169
|
-
fallbackModel: s.fallback?.model ?? null,
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
by: admin.name,
|
|
173
|
-
reason: s.reasons.join(" "),
|
|
174
|
-
evidence: {
|
|
175
|
-
suggestion: s.reasons,
|
|
176
|
-
live: s.live.test?.runId ?? null,
|
|
177
|
-
fallback: s.fallback?.test?.runId ?? null,
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
);
|
|
181
|
-
revalidatePath(EVALS_BASE, "layout");
|
|
29
|
+
return actions.useSuggestion(form);
|
|
182
30
|
}
|
|
183
31
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const admin = await requireAdmin();
|
|
187
|
-
const suite = choosingSuite(form);
|
|
188
|
-
const reason = formText(form, "reason");
|
|
189
|
-
if (!reason) throw new Error("Say why you're rolling back");
|
|
190
|
-
await settings.rollBack(suite.operation, formText(form, "version"), {
|
|
191
|
-
by: admin.name,
|
|
192
|
-
reason,
|
|
193
|
-
});
|
|
194
|
-
revalidatePath(EVALS_BASE, "layout");
|
|
32
|
+
export async function rescore(form: FormData) {
|
|
33
|
+
return actions.rescore(form);
|
|
195
34
|
}
|
|
196
35
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
await requireAdmin();
|
|
200
|
-
const suite = suiteFrom(form);
|
|
201
|
-
await store.setLabelStatus(formText(form, "label"), "CONFIRMED");
|
|
202
|
-
after(() => runner.rescoreRecent(suite.key));
|
|
203
|
-
revalidatePath(evalsPath(suite.key));
|
|
36
|
+
export async function rollBackSettings(form: FormData) {
|
|
37
|
+
return actions.rollBackSettings(form);
|
|
204
38
|
}
|
|
205
39
|
|
|
206
|
-
export async function
|
|
207
|
-
|
|
208
|
-
const suite = suiteFrom(form);
|
|
209
|
-
await runner.rescoreRecent(suite.key);
|
|
210
|
-
revalidatePath(evalsPath(suite.key));
|
|
40
|
+
export async function confirmAnswer(form: FormData) {
|
|
41
|
+
return actions.confirmAnswer(form);
|
|
211
42
|
}
|
|
212
43
|
|
|
213
|
-
/**
|
|
214
|
-
* A person adds a case. They wrote its answer, so it's confirmed. The
|
|
215
|
-
* suite's leak check runs first, and the case's note says what it removed.
|
|
216
|
-
*/
|
|
217
44
|
export async function addCase(form: FormData) {
|
|
218
|
-
|
|
219
|
-
const suite = suiteFrom(form);
|
|
220
|
-
const { input, removed } = withoutLeaks(
|
|
221
|
-
suite,
|
|
222
|
-
suite.inputFromForm(form),
|
|
223
|
-
null,
|
|
224
|
-
);
|
|
225
|
-
await store.createCase({
|
|
226
|
-
suite: suite.key,
|
|
227
|
-
input,
|
|
228
|
-
tags: formText(form, "tags")
|
|
229
|
-
.split(",")
|
|
230
|
-
.map((t) => t.trim())
|
|
231
|
-
.filter(Boolean),
|
|
232
|
-
split: formText(form, "split") === "TEST" ? "TEST" : "DEV",
|
|
233
|
-
status: "ACTIVE",
|
|
234
|
-
source: "OWNER",
|
|
235
|
-
sourceRef: null,
|
|
236
|
-
note: leakNote(removed),
|
|
237
|
-
labels: [
|
|
238
|
-
{
|
|
239
|
-
kind: "EXPECTED",
|
|
240
|
-
status: "CONFIRMED",
|
|
241
|
-
value: answerFromForm(suite, form),
|
|
242
|
-
raterRole: "OWNER",
|
|
243
|
-
raterId: null,
|
|
244
|
-
note: null,
|
|
245
|
-
},
|
|
246
|
-
],
|
|
247
|
-
});
|
|
248
|
-
revalidatePath(evalsPath(suite.key));
|
|
45
|
+
return actions.addCase(form);
|
|
249
46
|
}
|
|
250
47
|
|
|
251
|
-
/**
|
|
252
|
-
* A person changes a case's answer: a new confirmed answer, with the old
|
|
253
|
-
* ones kept as history. Stored answers are rescored for free.
|
|
254
|
-
*/
|
|
255
48
|
export async function editAnswer(form: FormData) {
|
|
256
|
-
|
|
257
|
-
const suite = suiteFrom(form);
|
|
258
|
-
const caseId = formText(form, "case");
|
|
259
|
-
const known = (await store.listCases(suite.key)).some((c) => c.id === caseId);
|
|
260
|
-
if (!known) throw new Error("Unknown case");
|
|
261
|
-
await store.addLabel(caseId, {
|
|
262
|
-
kind: "EXPECTED",
|
|
263
|
-
status: "CONFIRMED",
|
|
264
|
-
value: answerFromForm(suite, form),
|
|
265
|
-
raterRole: "OWNER",
|
|
266
|
-
raterId: null,
|
|
267
|
-
note: null,
|
|
268
|
-
});
|
|
269
|
-
// A draft (from feedback) is in use once it has an answer.
|
|
270
|
-
await store.setCaseStatus(caseId, "ACTIVE");
|
|
271
|
-
after(() => runner.rescoreRecent(suite.key));
|
|
272
|
-
revalidatePath(evalsPath(suite.key));
|
|
49
|
+
return actions.editAnswer(form);
|
|
273
50
|
}
|
|
274
51
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
* retired, and not yet rated or skipped by this person, so nobody answers
|
|
278
|
-
* twice and nothing lands over another person's answer.
|
|
279
|
-
*/
|
|
280
|
-
async function caseToRate(form: FormData, raterId: string) {
|
|
281
|
-
const suite = suiteFrom(form);
|
|
282
|
-
if (suite.caseKind !== "imported")
|
|
283
|
-
throw new Error("This suite isn't rated blind");
|
|
284
|
-
const caseId = formText(form, "case");
|
|
285
|
-
const c = (await store.listCases(suite.key)).find((x) => x.id === caseId);
|
|
286
|
-
if (!c) throw new Error("Unknown case");
|
|
287
|
-
if (raterStatus(c, raterId))
|
|
288
|
-
throw new Error("You've already rated or skipped this case");
|
|
289
|
-
return { suite, c };
|
|
52
|
+
export async function retireCase(form: FormData) {
|
|
53
|
+
return actions.retireCase(form);
|
|
290
54
|
}
|
|
291
55
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
* their reason, added beside anyone else's. Tests are rescored for free.
|
|
295
|
-
*/
|
|
296
|
-
export async function rateBlind(form: FormData) {
|
|
297
|
-
const admin = await requireAdmin();
|
|
298
|
-
const { suite, c } = await caseToRate(form, admin.id);
|
|
299
|
-
await store.addLabel(
|
|
300
|
-
c.id,
|
|
301
|
-
blindRating({
|
|
302
|
-
raterId: admin.id,
|
|
303
|
-
value: answerFromForm(suite, form),
|
|
304
|
-
reason: formText(form, "reason"),
|
|
305
|
-
}),
|
|
306
|
-
);
|
|
307
|
-
// A draft is in use once it has an answer.
|
|
308
|
-
if (c.status === "DRAFT") await store.setCaseStatus(c.id, "ACTIVE");
|
|
309
|
-
after(() => runner.rescoreRecent(suite.key));
|
|
310
|
-
revalidatePath(evalsPath(suite.key), "layout");
|
|
56
|
+
export async function retireEasy(form: FormData) {
|
|
57
|
+
return actions.retireEasy(form);
|
|
311
58
|
}
|
|
312
59
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const admin = await requireAdmin();
|
|
316
|
-
const { suite, c } = await caseToRate(form, admin.id);
|
|
317
|
-
await store.addLabel(c.id, skipMark(admin.id));
|
|
318
|
-
revalidatePath(evalsPath(suite.key, "rate"));
|
|
60
|
+
export async function retireStaleDrafts(form: FormData) {
|
|
61
|
+
return actions.retireStaleDrafts(form);
|
|
319
62
|
}
|
|
320
63
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
await requireAdmin();
|
|
324
|
-
const suite = suiteFrom(form);
|
|
325
|
-
const caseId = formText(form, "case");
|
|
326
|
-
const known = (await store.listCases(suite.key)).some((c) => c.id === caseId);
|
|
327
|
-
if (!known) throw new Error("Unknown case");
|
|
328
|
-
await store.setCaseStatus(caseId, "RETIRED");
|
|
329
|
-
revalidatePath(evalsPath(suite.key));
|
|
64
|
+
export async function rateBlind(form: FormData) {
|
|
65
|
+
return actions.rateBlind(form);
|
|
330
66
|
}
|
|
331
67
|
|
|
332
|
-
async function
|
|
333
|
-
|
|
334
|
-
if (!f) throw new Error("Unknown rating");
|
|
335
|
-
return f;
|
|
68
|
+
export async function skipCase(form: FormData) {
|
|
69
|
+
return actions.skipCase(form);
|
|
336
70
|
}
|
|
337
71
|
|
|
338
|
-
/** Makes a draft case from a rating; a person finishes its answer. */
|
|
339
72
|
export async function makeCase(form: FormData) {
|
|
340
|
-
|
|
341
|
-
const f = await find(formText(form, "feedback"));
|
|
342
|
-
const suite = SUITES.find(
|
|
343
|
-
(s) => s.operation === f.operation && !isInjectionSuite(s),
|
|
344
|
-
);
|
|
345
|
-
const draft = suite ? caseFromFeedback(f, suite) : null;
|
|
346
|
-
if (!draft || !suite) throw new Error("This rating can't become a case");
|
|
347
|
-
const c = await store.createCase(draft);
|
|
348
|
-
await feedbackStore.setFeedbackStatus(f.id, "CASED", c.id);
|
|
349
|
-
revalidatePath(EVALS_BASE, "layout");
|
|
73
|
+
return actions.makeCase(form);
|
|
350
74
|
}
|
|
351
75
|
|
|
352
76
|
export async function dismissFeedback(form: FormData) {
|
|
353
|
-
|
|
354
|
-
const f = await find(formText(form, "feedback"));
|
|
355
|
-
await feedbackStore.setFeedbackStatus(f.id, "DISMISSED");
|
|
356
|
-
revalidatePath(evalsPath("feedback"));
|
|
77
|
+
return actions.dismissFeedback(form);
|
|
357
78
|
}
|
|
358
79
|
|
|
359
|
-
export async function runWeeklyNow()
|
|
360
|
-
|
|
361
|
-
// Recorded before the page re-renders, so it shows them running.
|
|
362
|
-
const ids = await startWeeklyCheck();
|
|
363
|
-
after(() => runWeeklyCheck(ids));
|
|
364
|
-
revalidatePath(EVALS_BASE);
|
|
80
|
+
export async function runWeeklyNow() {
|
|
81
|
+
return actions.runWeeklyNow();
|
|
365
82
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { EvalComponentsProvider } from "@crowandraven/evalkeeper/react";
|
|
4
|
+
import { nextComponents } from "@crowandraven/evalkeeper/next/components";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Your app's own components for Evalkeeper's screens, so they look like
|
|
8
|
+
* the rest of your app. Next.js's link and refresh come first; name a
|
|
9
|
+
* piece after them to use yours, and leave it out to keep Evalkeeper's
|
|
10
|
+
* (`EvalComponents` lists them all). Each gets the props Evalkeeper's own
|
|
11
|
+
* would, `className` included, which yours can use or ignore. Your
|
|
12
|
+
* components must be client components. This file is yours: `add pages`
|
|
13
|
+
* never overwrites it.
|
|
14
|
+
*/
|
|
15
|
+
export function AppComponents({ children }: { children: React.ReactNode }) {
|
|
16
|
+
return (
|
|
17
|
+
<EvalComponentsProvider components={{ ...nextComponents }}>
|
|
18
|
+
{children}
|
|
19
|
+
</EvalComponentsProvider>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { defineEvals } from "@crowandraven/evalkeeper/react";
|
|
3
|
+
import { evalPages } from "@crowandraven/evalkeeper/next";
|
|
4
|
+
import * as actions from "./actions";
|
|
5
|
+
import { wiring } from ".";
|
|
6
|
+
import { EVALS_BASE } from "./paths";
|
|
7
|
+
|
|
8
|
+
// Written by `npx @crowandraven/evalkeeper add pages`: don't edit it.
|
|
9
|
+
|
|
10
|
+
/** Everything Evalkeeper's screens read: your wiring, and the actions. */
|
|
11
|
+
export const evals = defineEvals({ ...wiring, actions, basePath: EVALS_BASE });
|
|
12
|
+
|
|
13
|
+
/** Evalkeeper's pages, which the route files under app/evals export. */
|
|
14
|
+
export const pages = evalPages(evals, wiring.requireAdmin);
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Where the eval pages live in your app. The CLI sets this to the base you
|
|
3
|
-
* choose (`npx @crowandraven/evalkeeper add pages --base admin/evals`);
|
|
4
|
-
* refresh on the pages is built from it.
|
|
3
|
+
* choose (`npx @crowandraven/evalkeeper add pages --base admin/evals`);
|
|
4
|
+
* every link and refresh on the pages is built from it.
|
|
5
5
|
*/
|
|
6
6
|
export const EVALS_BASE = "/evals";
|
|
7
|
-
|
|
8
|
-
/** A path under the eval pages: evalsPath("ticket_triage", "runs", id). */
|
|
9
|
-
export function evalsPath(...parts: string[]): string {
|
|
10
|
-
return [EVALS_BASE, ...parts.map(encodeURIComponent)].join("/");
|
|
11
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { LoaderCircle } from "lucide-react";
|
|
4
|
-
import { useFormStatus } from "react-dom";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A button that isn't the page's main action: the app's accent as an
|
|
8
|
-
* outline, so it still reads as a button in the app's colors (set
|
|
9
|
-
* `--accent` in evalkeeper.css).
|
|
10
|
-
*/
|
|
11
|
-
export const QUIET_BUTTON =
|
|
12
|
-
"border border-accent/40 bg-card text-accent hover:bg-accent/10";
|
|
13
|
-
|
|
14
|
-
/** A submit button that spins while its form's action runs. */
|
|
15
|
-
export function Submit({
|
|
16
|
-
children,
|
|
17
|
-
variant = "primary",
|
|
18
|
-
disabled = false,
|
|
19
|
-
}: {
|
|
20
|
-
children: React.ReactNode;
|
|
21
|
-
variant?: "primary" | "quiet";
|
|
22
|
-
/** Off until the form is ready; wrap it in a `<Tip>` saying why. */
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
}) {
|
|
25
|
-
const { pending } = useFormStatus();
|
|
26
|
-
return (
|
|
27
|
-
<button
|
|
28
|
-
type="submit"
|
|
29
|
-
disabled={pending || disabled}
|
|
30
|
-
className={`inline-flex items-center gap-2 whitespace-nowrap rounded-md px-3 py-1.5 text-sm disabled:opacity-60 ${
|
|
31
|
-
variant === "primary" ? "bg-accent text-white" : QUIET_BUTTON
|
|
32
|
-
}`}
|
|
33
|
-
>
|
|
34
|
-
{pending && <Spinner />}
|
|
35
|
-
{children}
|
|
36
|
-
</button>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* An icon-only submit button. `label` is its accessible name; wrap it in a
|
|
42
|
-
* `<Tip control>` for the tooltip. The icon turns into the loader while the
|
|
43
|
-
* action runs.
|
|
44
|
-
*/
|
|
45
|
-
export function IconSubmit({
|
|
46
|
-
label,
|
|
47
|
-
icon,
|
|
48
|
-
}: {
|
|
49
|
-
label: string;
|
|
50
|
-
icon: React.ReactNode;
|
|
51
|
-
}) {
|
|
52
|
-
const { pending } = useFormStatus();
|
|
53
|
-
return (
|
|
54
|
-
<button
|
|
55
|
-
type="submit"
|
|
56
|
-
aria-label={label}
|
|
57
|
-
disabled={pending}
|
|
58
|
-
className="inline-flex h-8 w-8 items-center justify-center rounded-md border border-line bg-card text-ink hover:bg-tint disabled:opacity-60"
|
|
59
|
-
>
|
|
60
|
-
{pending ? <Spinner /> : icon}
|
|
61
|
-
</button>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function Spinner() {
|
|
66
|
-
return <LoaderCircle aria-hidden className="h-3.5 w-3.5 animate-spin" />;
|
|
67
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Info } from "lucide-react";
|
|
2
|
-
import { GLOSSARY, type GlossaryTerm } from "@crowandraven/evalkeeper";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Tooltips that explain how things work. They open on hover and on
|
|
6
|
-
* keyboard focus, and screen readers read the text as the element's
|
|
7
|
-
* description. No JavaScript: CSS shows them. The named group (group/tip)
|
|
8
|
-
* keeps a tooltip from opening when an outer "group" (an open case) is
|
|
9
|
-
* hovered.
|
|
10
|
-
*
|
|
11
|
-
* <InfoTip term="score" /> an (i) after a label
|
|
12
|
-
* <Tip term="live"><Chip …/></Tip> explains the thing it wraps
|
|
13
|
-
* <Tip text="…" control><button …/></Tip> a button's tooltip
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
type Props = {
|
|
17
|
-
/** A glossary entry, or your own text with `text`. */
|
|
18
|
-
term?: GlossaryTerm;
|
|
19
|
-
text?: string;
|
|
20
|
-
/** Unique per page when the same term shows more than once. */
|
|
21
|
-
id?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Where it opens. "bottom" inside a scrolling container (a table), whose
|
|
24
|
-
* top edge would cut it off.
|
|
25
|
-
*/
|
|
26
|
-
side?: "top" | "bottom";
|
|
27
|
-
/** "end" near a container's right edge, so it opens leftward. */
|
|
28
|
-
align?: "center" | "end";
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
function body(props: Props) {
|
|
32
|
-
return props.text ?? (props.term ? GLOSSARY[props.term] : "");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function Bubble({
|
|
36
|
-
id,
|
|
37
|
-
text,
|
|
38
|
-
side = "top",
|
|
39
|
-
align = "center",
|
|
40
|
-
}: {
|
|
41
|
-
id: string;
|
|
42
|
-
text: string;
|
|
43
|
-
side?: "top" | "bottom" | undefined;
|
|
44
|
-
align?: "center" | "end" | undefined;
|
|
45
|
-
}) {
|
|
46
|
-
return (
|
|
47
|
-
<span
|
|
48
|
-
role="tooltip"
|
|
49
|
-
id={id}
|
|
50
|
-
className={`pointer-events-none invisible absolute ${side === "top" ? "bottom-full mb-2" : "top-full mt-2"} ${align === "end" ? "right-0" : "left-1/2 -translate-x-1/2"} z-20 w-64 rounded-md border border-line bg-card px-3 py-2 text-left text-xs font-normal normal-case leading-snug tracking-normal text-ink opacity-0 shadow-lg transition-opacity group-focus-within/tip:visible group-focus-within/tip:opacity-100 group-hover/tip:visible group-hover/tip:opacity-100`}
|
|
51
|
-
>
|
|
52
|
-
{text}
|
|
53
|
-
</span>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** A small (i) button that explains the label before it. */
|
|
58
|
-
export function InfoTip(props: Props) {
|
|
59
|
-
const text = body(props);
|
|
60
|
-
const id = `tip-${props.id ?? props.term ?? "info"}`;
|
|
61
|
-
return (
|
|
62
|
-
<span className="group/tip relative ml-1 inline-flex align-middle">
|
|
63
|
-
<button
|
|
64
|
-
type="button"
|
|
65
|
-
aria-describedby={id}
|
|
66
|
-
aria-label="What's this?"
|
|
67
|
-
className="inline-flex h-4 w-4 items-center justify-center rounded-full text-muted hover:text-ink"
|
|
68
|
-
>
|
|
69
|
-
<Info aria-hidden className="h-3.5 w-3.5" />
|
|
70
|
-
</button>
|
|
71
|
-
<Bubble id={id} text={text} side={props.side} align={props.align} />
|
|
72
|
-
</span>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** Explains whatever it wraps (a chip, a number) on hover and focus. */
|
|
77
|
-
export function Tip(
|
|
78
|
-
props: Props & {
|
|
79
|
-
children: React.ReactNode;
|
|
80
|
-
/**
|
|
81
|
-
* The child is a control that takes focus itself (a button), so the
|
|
82
|
-
* wrapper isn't a second tab stop.
|
|
83
|
-
*/
|
|
84
|
-
control?: boolean;
|
|
85
|
-
},
|
|
86
|
-
) {
|
|
87
|
-
const text = body(props);
|
|
88
|
-
const id = `tip-${props.id ?? props.term ?? "info"}`;
|
|
89
|
-
return (
|
|
90
|
-
<span
|
|
91
|
-
className="group/tip relative inline-flex"
|
|
92
|
-
{...(props.control ? {} : { tabIndex: 0, "aria-describedby": id })}
|
|
93
|
-
>
|
|
94
|
-
{props.children}
|
|
95
|
-
<Bubble id={id} text={text} side={props.side} align={props.align} />
|
|
96
|
-
</span>
|
|
97
|
-
);
|
|
98
|
-
}
|