@crowandraven/evalkeeper 0.10.0 → 0.11.1
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
|
@@ -0,0 +1,925 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FAVOR_TEXT,
|
|
3
|
+
answerKeyHealth,
|
|
4
|
+
attacksFrom,
|
|
5
|
+
checkBar,
|
|
6
|
+
isInjectionSuite,
|
|
7
|
+
meanCalibrationError,
|
|
8
|
+
money,
|
|
9
|
+
probabilityQuality,
|
|
10
|
+
perAnswer,
|
|
11
|
+
retiresLabel,
|
|
12
|
+
seconds,
|
|
13
|
+
seriousMistakes,
|
|
14
|
+
suggest,
|
|
15
|
+
} from "../index.js";
|
|
16
|
+
import { AnswerKey } from "./AnswerKey.js";
|
|
17
|
+
import { ModelMenu } from "./ModelMenu.js";
|
|
18
|
+
import { Tabs } from "./Tabs.js";
|
|
19
|
+
import {
|
|
20
|
+
Link,
|
|
21
|
+
BackLink,
|
|
22
|
+
Card,
|
|
23
|
+
RefreshWhile,
|
|
24
|
+
Chip,
|
|
25
|
+
IconSubmit,
|
|
26
|
+
InfoTip,
|
|
27
|
+
Score,
|
|
28
|
+
Spinner,
|
|
29
|
+
Submit,
|
|
30
|
+
Tip,
|
|
31
|
+
} from "./pieces.js";
|
|
32
|
+
import { pct, LINK } from "./format.js";
|
|
33
|
+
import { RotateCw } from "lucide-react";
|
|
34
|
+
import { evalsPath, type EvalAppConfig, attacksResisted } from "./app.js";
|
|
35
|
+
import { SettingsHistory } from "./SettingsHistory.js";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Everything a suite's page shows, loaded together: on a remote database
|
|
39
|
+
* each read waits on round trips, so one after the other multiplies the
|
|
40
|
+
* wait. Null for a suite that doesn't exist. Sections read from this, so a
|
|
41
|
+
* page that arranges them its own way loads the same data once.
|
|
42
|
+
*
|
|
43
|
+
* @param key - The suite's key.
|
|
44
|
+
*/
|
|
45
|
+
export async function loadSuitePage(app: EvalAppConfig, key: string) {
|
|
46
|
+
const operation = app.suiteByKey[key]?.operation;
|
|
47
|
+
if (!operation) return null;
|
|
48
|
+
const [b, attackBoards, [history, liveSettings], inInstructions, cases] =
|
|
49
|
+
await Promise.all([
|
|
50
|
+
app.runner.board(key),
|
|
51
|
+
// Injection suites that attack this feature: their results count here.
|
|
52
|
+
app.runner.attackBoards(key),
|
|
53
|
+
// Records a deploy if the instructions changed under the live
|
|
54
|
+
// settings, before reading them.
|
|
55
|
+
app.settings
|
|
56
|
+
.syncPrompt(operation)
|
|
57
|
+
.then(() =>
|
|
58
|
+
Promise.all([
|
|
59
|
+
app.settings.history(operation),
|
|
60
|
+
app.settings.current(operation),
|
|
61
|
+
]),
|
|
62
|
+
),
|
|
63
|
+
app.runner.casesInInstructions(key),
|
|
64
|
+
app.store.listCases(key),
|
|
65
|
+
]);
|
|
66
|
+
const { suite, rows } = b;
|
|
67
|
+
const attacks = attacksFrom(attackBoards);
|
|
68
|
+
// An injection suite's models are chosen on its base suite's page.
|
|
69
|
+
const choosesHere = !isInjectionSuite(suite);
|
|
70
|
+
const s = choosesHere
|
|
71
|
+
? suggest(rows, suite.checks, suite.priority, app.models, { attacks })
|
|
72
|
+
: null;
|
|
73
|
+
const testing =
|
|
74
|
+
rows.some((r) => r.testing) ||
|
|
75
|
+
attackBoards.some((a) => a.rows.some((r) => r.testing));
|
|
76
|
+
// What testing each model would cost now, attack cases included,
|
|
77
|
+
// counting answers it would reuse.
|
|
78
|
+
const estimates = new Map(
|
|
79
|
+
await Promise.all(
|
|
80
|
+
rows.map(
|
|
81
|
+
async (r) =>
|
|
82
|
+
[
|
|
83
|
+
r.key,
|
|
84
|
+
await app.runner.estimateTest(key, r.model, "ALL", 1, {
|
|
85
|
+
reasoningEffort: r.effort,
|
|
86
|
+
}),
|
|
87
|
+
] as const,
|
|
88
|
+
),
|
|
89
|
+
),
|
|
90
|
+
);
|
|
91
|
+
// Results under attack show once the feature has attack cases: a test
|
|
92
|
+
// makes them from its confirmed answers.
|
|
93
|
+
const showAttacks = attackBoards.some((a) => a.cases > 0);
|
|
94
|
+
const live = rows.find((r) => r.live);
|
|
95
|
+
// What would keep the answer key useful, from the same tests.
|
|
96
|
+
const health = answerKeyHealth(cases, b.caseResults);
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
app,
|
|
100
|
+
key,
|
|
101
|
+
operation,
|
|
102
|
+
b,
|
|
103
|
+
suite,
|
|
104
|
+
rows,
|
|
105
|
+
attackBoards,
|
|
106
|
+
attacks,
|
|
107
|
+
history,
|
|
108
|
+
liveSettings,
|
|
109
|
+
inInstructions,
|
|
110
|
+
s,
|
|
111
|
+
choosesHere,
|
|
112
|
+
testing,
|
|
113
|
+
estimates,
|
|
114
|
+
showAttacks,
|
|
115
|
+
live,
|
|
116
|
+
health,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** What `loadSuitePage` returns, for sections and custom pages. */
|
|
121
|
+
export type SuitePageData = NonNullable<
|
|
122
|
+
Awaited<ReturnType<typeof loadSuitePage>>
|
|
123
|
+
>;
|
|
124
|
+
|
|
125
|
+
/** A share as a whole percent, or a dash when there's nothing to show. */
|
|
126
|
+
const asPct = (x: number | null) => (x === null ? "—" : pct(x));
|
|
127
|
+
|
|
128
|
+
const VS: Record<string, string> = {
|
|
129
|
+
BETTER: "More accurate",
|
|
130
|
+
SAME: "About as accurate",
|
|
131
|
+
WORSE: "Less accurate",
|
|
132
|
+
TOO_FEW: "Too few cases to tell",
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/** The suite's name, what it tests, and its priority. */
|
|
136
|
+
export function SuiteHeader({ data }: { data: SuitePageData }) {
|
|
137
|
+
const { app, suite } = data;
|
|
138
|
+
return (
|
|
139
|
+
<>
|
|
140
|
+
<div className="space-y-2">
|
|
141
|
+
<BackLink href={app.basePath}>Evals</BackLink>
|
|
142
|
+
<h1 className="text-2xl font-semibold">{suite.label}</h1>
|
|
143
|
+
<p className="readable text-muted">{suite.description}</p>
|
|
144
|
+
<p className="readable text-sm text-muted">
|
|
145
|
+
Priority: {FAVOR_TEXT[suite.priority.favor]}.
|
|
146
|
+
<InfoTip term="priority" />
|
|
147
|
+
</p>
|
|
148
|
+
</div>
|
|
149
|
+
</>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** On an injection suite: models are chosen on its base suite, with a link there. */
|
|
154
|
+
export function ChosenOnBase({ data }: { data: SuitePageData }) {
|
|
155
|
+
const { app, suite } = data;
|
|
156
|
+
return (
|
|
157
|
+
<>
|
|
158
|
+
{isInjectionSuite(suite) && (
|
|
159
|
+
<Card className="space-y-2">
|
|
160
|
+
<h2 className="font-semibold">
|
|
161
|
+
Models are chosen on {suite.base.label}
|
|
162
|
+
<InfoTip term="attackResults" />
|
|
163
|
+
</h2>
|
|
164
|
+
<p className="readable text-sm text-muted">
|
|
165
|
+
This suite tests the same feature as {suite.base.label}, so one
|
|
166
|
+
choice of model serves both. Its results show there as Attacks
|
|
167
|
+
resisted, and the suggestion there never picks a model with more
|
|
168
|
+
serious mistakes on them than live.
|
|
169
|
+
</p>
|
|
170
|
+
<Link
|
|
171
|
+
href={evalsPath(app, suite.base.key)}
|
|
172
|
+
className={`inline-block text-sm ${LINK}`}
|
|
173
|
+
>
|
|
174
|
+
Choose models on {suite.base.label}
|
|
175
|
+
</Link>
|
|
176
|
+
</Card>
|
|
177
|
+
)}
|
|
178
|
+
</>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Which models to make live and the fallback, and why; shown when nothing would change too. */
|
|
183
|
+
export function SuggestionCard({ data }: { data: SuitePageData }) {
|
|
184
|
+
const { app, key, s } = data;
|
|
185
|
+
return (
|
|
186
|
+
<>
|
|
187
|
+
{/* Shown when nothing would change too, so a higher score that
|
|
188
|
+
isn't enough to switch for comes with its reason. */}
|
|
189
|
+
{s && (
|
|
190
|
+
<Card className="space-y-3">
|
|
191
|
+
<div className="flex flex-wrap items-start justify-between gap-3">
|
|
192
|
+
<h2 className="font-semibold">
|
|
193
|
+
{s.same ? "No change suggested" : "Suggested"}
|
|
194
|
+
<InfoTip term="suggestion" />
|
|
195
|
+
</h2>
|
|
196
|
+
{/* Retesting live changes nothing until the fallback would. */}
|
|
197
|
+
{!s.same &&
|
|
198
|
+
!(s.retestLive && (!s.fallback || s.fallback.fallback)) && (
|
|
199
|
+
<form action={app.actions.useSuggestion}>
|
|
200
|
+
<input type="hidden" name="suite" value={key} />
|
|
201
|
+
<Submit>Use these</Submit>
|
|
202
|
+
</form>
|
|
203
|
+
)}
|
|
204
|
+
</div>
|
|
205
|
+
{!s.same && (
|
|
206
|
+
<p>
|
|
207
|
+
Live: <strong>{s.live.label}</strong>
|
|
208
|
+
{s.fallback && (
|
|
209
|
+
<>
|
|
210
|
+
{" "}
|
|
211
|
+
· Fallback: <strong>{s.fallback.label}</strong>
|
|
212
|
+
</>
|
|
213
|
+
)}
|
|
214
|
+
</p>
|
|
215
|
+
)}
|
|
216
|
+
<ul className="readable list-disc space-y-1 pl-5 text-sm text-muted">
|
|
217
|
+
{s.reasons.map((r) => (
|
|
218
|
+
<li key={r}>{r}</li>
|
|
219
|
+
))}
|
|
220
|
+
</ul>
|
|
221
|
+
</Card>
|
|
222
|
+
)}
|
|
223
|
+
</>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Cases whose words appear in the feature's instructions. */
|
|
228
|
+
export function CasesInInstructions({ data }: { data: SuitePageData }) {
|
|
229
|
+
const { inInstructions } = data;
|
|
230
|
+
return (
|
|
231
|
+
<>
|
|
232
|
+
{inInstructions.length > 0 && (
|
|
233
|
+
<Card className="space-y-2">
|
|
234
|
+
<h2 className="font-semibold text-warn">
|
|
235
|
+
Cases in the instructions
|
|
236
|
+
<InfoTip term="inInstructions" />
|
|
237
|
+
</h2>
|
|
238
|
+
<p className="readable text-sm text-muted">
|
|
239
|
+
These cases' words appear in what the model is told, so a test
|
|
240
|
+
grades it on answers it was handed. Take the example out of the
|
|
241
|
+
instructions, or rewrite or retire the case.
|
|
242
|
+
</p>
|
|
243
|
+
<ul className="readable list-disc space-y-1 pl-5 text-sm">
|
|
244
|
+
{inInstructions.map((c) => (
|
|
245
|
+
<li key={c.caseId}>
|
|
246
|
+
{c.title}: “{c.found}”
|
|
247
|
+
</li>
|
|
248
|
+
))}
|
|
249
|
+
</ul>
|
|
250
|
+
</Card>
|
|
251
|
+
)}
|
|
252
|
+
</>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** Every model the feature can use: its latest test, how it compares with live, under attack, and buttons to test it or choose it. */
|
|
257
|
+
export function ModelTable({ data }: { data: SuitePageData }) {
|
|
258
|
+
const {
|
|
259
|
+
app,
|
|
260
|
+
key,
|
|
261
|
+
suite,
|
|
262
|
+
rows,
|
|
263
|
+
attackBoards,
|
|
264
|
+
choosesHere,
|
|
265
|
+
estimates,
|
|
266
|
+
showAttacks,
|
|
267
|
+
live,
|
|
268
|
+
} = data;
|
|
269
|
+
return (
|
|
270
|
+
<>
|
|
271
|
+
<section className="space-y-3">
|
|
272
|
+
<div className="flex items-center justify-between gap-4">
|
|
273
|
+
<h2 className="text-lg font-semibold">Models</h2>
|
|
274
|
+
<div className="flex items-center gap-4">
|
|
275
|
+
<form action={app.actions.testAll}>
|
|
276
|
+
<input type="hidden" name="suite" value={key} />
|
|
277
|
+
<Submit variant="quiet">Test every model</Submit>
|
|
278
|
+
</form>
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
<Card className="overflow-x-auto p-0 lg:overflow-visible">
|
|
282
|
+
<table className="w-full text-sm">
|
|
283
|
+
<thead className="text-left text-muted">
|
|
284
|
+
<tr className="border-b border-line">
|
|
285
|
+
<th className="p-3 font-normal">Model</th>
|
|
286
|
+
<th className="p-3 font-normal">
|
|
287
|
+
<Tip term="score" side="bottom">
|
|
288
|
+
Score
|
|
289
|
+
</Tip>
|
|
290
|
+
</th>
|
|
291
|
+
<th className="p-3 font-normal">
|
|
292
|
+
<Tip term="seriousMistakes" side="bottom">
|
|
293
|
+
Serious mistakes
|
|
294
|
+
</Tip>
|
|
295
|
+
</th>
|
|
296
|
+
{showAttacks && (
|
|
297
|
+
<th className="p-3 font-normal">
|
|
298
|
+
<Tip term="attacksResisted" side="bottom">
|
|
299
|
+
Attacks resisted
|
|
300
|
+
</Tip>
|
|
301
|
+
</th>
|
|
302
|
+
)}
|
|
303
|
+
<th className="p-3 font-normal">
|
|
304
|
+
<Tip term="time" side="bottom" align="end">
|
|
305
|
+
Time
|
|
306
|
+
</Tip>
|
|
307
|
+
</th>
|
|
308
|
+
{suite.decisions && (
|
|
309
|
+
<>
|
|
310
|
+
<th className="p-3 font-normal">
|
|
311
|
+
<Tip term="probabilityQuality" side="bottom">
|
|
312
|
+
Probability quality
|
|
313
|
+
</Tip>
|
|
314
|
+
</th>
|
|
315
|
+
<th className="p-3 font-normal">
|
|
316
|
+
<Tip term="calibrationError" side="bottom" align="end">
|
|
317
|
+
Calibration error
|
|
318
|
+
</Tip>
|
|
319
|
+
</th>
|
|
320
|
+
</>
|
|
321
|
+
)}
|
|
322
|
+
<th className="p-3 font-normal">
|
|
323
|
+
<Tip term="cost" side="bottom" align="end">
|
|
324
|
+
Cost
|
|
325
|
+
</Tip>
|
|
326
|
+
</th>
|
|
327
|
+
<th className="p-3 font-normal">
|
|
328
|
+
<Tip term="againstLive" side="bottom" align="end">
|
|
329
|
+
Against live
|
|
330
|
+
</Tip>
|
|
331
|
+
</th>
|
|
332
|
+
<th className="p-3" />
|
|
333
|
+
</tr>
|
|
334
|
+
</thead>
|
|
335
|
+
<tbody>
|
|
336
|
+
{rows.map((r) => (
|
|
337
|
+
<tr key={r.key} className="border-b border-line last:border-0">
|
|
338
|
+
<td className="p-3">
|
|
339
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
340
|
+
<span
|
|
341
|
+
className={r.live ? "font-semibold" : "font-medium"}
|
|
342
|
+
>
|
|
343
|
+
{r.label}
|
|
344
|
+
</span>
|
|
345
|
+
{r.live && (
|
|
346
|
+
<Tip term="live" side="bottom" id={`live-${r.key}`}>
|
|
347
|
+
<Chip tone="live">Live</Chip>
|
|
348
|
+
</Tip>
|
|
349
|
+
)}
|
|
350
|
+
{r.fallback && (
|
|
351
|
+
<Tip
|
|
352
|
+
term="fallback"
|
|
353
|
+
side="bottom"
|
|
354
|
+
id={`fallback-${r.key}`}
|
|
355
|
+
>
|
|
356
|
+
<Chip tone="fallback">Fallback</Chip>
|
|
357
|
+
</Tip>
|
|
358
|
+
)}
|
|
359
|
+
{retiresLabel(app.models, r.model) && (
|
|
360
|
+
<Tip
|
|
361
|
+
term="retiring"
|
|
362
|
+
side="bottom"
|
|
363
|
+
id={`retiring-${r.key}`}
|
|
364
|
+
>
|
|
365
|
+
<Chip tone="warn">
|
|
366
|
+
Retires {retiresLabel(app.models, r.model)}
|
|
367
|
+
</Chip>
|
|
368
|
+
</Tip>
|
|
369
|
+
)}
|
|
370
|
+
{suite.decisions && app.models[r.model]?.decisions && (
|
|
371
|
+
<Tip
|
|
372
|
+
term={
|
|
373
|
+
app.models[r.model]?.decisions === "native"
|
|
374
|
+
? "nativeProbabilities"
|
|
375
|
+
: "promptedProbabilities"
|
|
376
|
+
}
|
|
377
|
+
side="bottom"
|
|
378
|
+
id={`decisions-${r.key}`}
|
|
379
|
+
>
|
|
380
|
+
<Chip tone="neutral">
|
|
381
|
+
{app.models[r.model]?.decisions === "native"
|
|
382
|
+
? "Native probabilities"
|
|
383
|
+
: "Prompted"}
|
|
384
|
+
</Chip>
|
|
385
|
+
</Tip>
|
|
386
|
+
)}
|
|
387
|
+
{r.test?.stale && (
|
|
388
|
+
<Tip
|
|
389
|
+
term="outOfDate"
|
|
390
|
+
side="bottom"
|
|
391
|
+
id={`stale-${r.key}`}
|
|
392
|
+
>
|
|
393
|
+
<Chip tone="neutral">Out of date</Chip>
|
|
394
|
+
</Tip>
|
|
395
|
+
)}
|
|
396
|
+
</div>
|
|
397
|
+
</td>
|
|
398
|
+
<td className="p-3">
|
|
399
|
+
{r.testing ? (
|
|
400
|
+
<span
|
|
401
|
+
role="status"
|
|
402
|
+
title="Testing"
|
|
403
|
+
className="inline-flex text-accent"
|
|
404
|
+
>
|
|
405
|
+
<Spinner />
|
|
406
|
+
</span>
|
|
407
|
+
) : r.test ? (
|
|
408
|
+
<Link href={evalsPath(app, key, "runs", r.test.runId)}>
|
|
409
|
+
<Score right={r.test.right} total={r.test.total} />
|
|
410
|
+
</Link>
|
|
411
|
+
) : (
|
|
412
|
+
<span className="text-muted">
|
|
413
|
+
{r.failed ?? "Not tested"}
|
|
414
|
+
</span>
|
|
415
|
+
)}
|
|
416
|
+
</td>
|
|
417
|
+
<td className="p-3 tabular-nums">
|
|
418
|
+
{r.test ? seriousMistakes(r, suite.checks) : "—"}
|
|
419
|
+
</td>
|
|
420
|
+
{showAttacks && (
|
|
421
|
+
<td className="p-3">
|
|
422
|
+
<div className="flex flex-col gap-1">
|
|
423
|
+
{attackBoards.map((a) => (
|
|
424
|
+
<UnderAttack
|
|
425
|
+
app={app}
|
|
426
|
+
key={a.suite.key}
|
|
427
|
+
attackSuite={a.suite.key}
|
|
428
|
+
attackLabel={a.suite.label}
|
|
429
|
+
row={a.rows.find((x) => x.key === r.key)}
|
|
430
|
+
resisted={attacksResisted(r.key, [a])}
|
|
431
|
+
/>
|
|
432
|
+
))}
|
|
433
|
+
</div>
|
|
434
|
+
</td>
|
|
435
|
+
)}
|
|
436
|
+
<td className="p-3 tabular-nums">
|
|
437
|
+
{r.test ? seconds(r.test.avgMs) : "—"}
|
|
438
|
+
</td>
|
|
439
|
+
{suite.decisions && (
|
|
440
|
+
<>
|
|
441
|
+
<td className="p-3 tabular-nums">
|
|
442
|
+
{asPct(
|
|
443
|
+
r.test ? probabilityQuality(r.test.measures) : null,
|
|
444
|
+
)}
|
|
445
|
+
</td>
|
|
446
|
+
<td className="p-3 tabular-nums">
|
|
447
|
+
{asPct(
|
|
448
|
+
r.test ? meanCalibrationError(r.test.measures) : null,
|
|
449
|
+
)}
|
|
450
|
+
</td>
|
|
451
|
+
</>
|
|
452
|
+
)}
|
|
453
|
+
<td className="p-3 tabular-nums">
|
|
454
|
+
{r.test ? perAnswer(r.test.costPerAnswer) : "—"}
|
|
455
|
+
</td>
|
|
456
|
+
<td className="p-3">
|
|
457
|
+
{r.vsLive && live?.test && r.test && !r.live ? (
|
|
458
|
+
<Link
|
|
459
|
+
href={`${evalsPath(app, key, "compare")}?${new URLSearchParams({ a: live.test.runId, b: r.test.runId })}`}
|
|
460
|
+
className={LINK}
|
|
461
|
+
>
|
|
462
|
+
{VS[r.vsLive]}
|
|
463
|
+
</Link>
|
|
464
|
+
) : r.vsLive ? (
|
|
465
|
+
VS[r.vsLive]
|
|
466
|
+
) : (
|
|
467
|
+
"—"
|
|
468
|
+
)}
|
|
469
|
+
</td>
|
|
470
|
+
<td className="p-3">
|
|
471
|
+
<div className="flex flex-col items-end gap-0.5">
|
|
472
|
+
<div className="flex justify-end gap-2">
|
|
473
|
+
<form action={app.actions.testModel}>
|
|
474
|
+
<input type="hidden" name="suite" value={key} />
|
|
475
|
+
<input type="hidden" name="model" value={r.model} />
|
|
476
|
+
<Tip
|
|
477
|
+
control
|
|
478
|
+
id={`test-${r.key}`}
|
|
479
|
+
text={
|
|
480
|
+
r.test
|
|
481
|
+
? "Test this model again on every case in use."
|
|
482
|
+
: "Test this model on every case in use."
|
|
483
|
+
}
|
|
484
|
+
side="bottom"
|
|
485
|
+
align="end"
|
|
486
|
+
>
|
|
487
|
+
<IconSubmit
|
|
488
|
+
label="Test"
|
|
489
|
+
icon={
|
|
490
|
+
<RotateCw aria-hidden className="h-4 w-4" />
|
|
491
|
+
}
|
|
492
|
+
/>
|
|
493
|
+
</Tip>
|
|
494
|
+
</form>
|
|
495
|
+
{choosesHere && (
|
|
496
|
+
<ModelMenu
|
|
497
|
+
suite={key}
|
|
498
|
+
model={r.model}
|
|
499
|
+
label={r.label}
|
|
500
|
+
makeLive={
|
|
501
|
+
!r.live && r.canMakeLive
|
|
502
|
+
? app.actions.makeLive
|
|
503
|
+
: null
|
|
504
|
+
}
|
|
505
|
+
makeFallback={
|
|
506
|
+
r.canMakeFallback
|
|
507
|
+
? app.actions.makeFallback
|
|
508
|
+
: null
|
|
509
|
+
}
|
|
510
|
+
/>
|
|
511
|
+
)}
|
|
512
|
+
</div>
|
|
513
|
+
<EstimateNote
|
|
514
|
+
id={r.key}
|
|
515
|
+
estimate={estimates.get(r.key)}
|
|
516
|
+
/>
|
|
517
|
+
{r.test && !r.test.stale && r.test.failedAnswers > 0 && (
|
|
518
|
+
<span className="text-right text-xs text-muted">
|
|
519
|
+
{r.test.failedAnswers}{" "}
|
|
520
|
+
{r.test.failedAnswers === 1 ? "answer" : "answers"}{" "}
|
|
521
|
+
failed on its last test
|
|
522
|
+
</span>
|
|
523
|
+
)}
|
|
524
|
+
</div>
|
|
525
|
+
</td>
|
|
526
|
+
</tr>
|
|
527
|
+
))}
|
|
528
|
+
</tbody>
|
|
529
|
+
</table>
|
|
530
|
+
</Card>
|
|
531
|
+
</section>
|
|
532
|
+
</>
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/** The feature's settings history, with rollback; not on an injection suite. */
|
|
537
|
+
export function Versions({ data }: { data: SuitePageData }) {
|
|
538
|
+
const { app, key, history, liveSettings, choosesHere } = data;
|
|
539
|
+
return (
|
|
540
|
+
<>
|
|
541
|
+
{choosesHere && (
|
|
542
|
+
<SettingsHistory
|
|
543
|
+
app={app}
|
|
544
|
+
suite={key}
|
|
545
|
+
entries={history}
|
|
546
|
+
liveId={liveSettings.version?.id ?? null}
|
|
547
|
+
label={(m) => app.models[m]?.label ?? m}
|
|
548
|
+
defaults={liveSettings.settings}
|
|
549
|
+
/>
|
|
550
|
+
)}
|
|
551
|
+
</>
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/** Each check: what it checks, its severity and bar, and how the live model does. */
|
|
556
|
+
export function ChecksSection({ data }: { data: SuitePageData }) {
|
|
557
|
+
const { suite, live } = data;
|
|
558
|
+
return (
|
|
559
|
+
<>
|
|
560
|
+
<section className="space-y-3">
|
|
561
|
+
<h2 className="text-lg font-semibold">
|
|
562
|
+
Checks
|
|
563
|
+
<InfoTip term="checks" />
|
|
564
|
+
</h2>
|
|
565
|
+
<div className="grid gap-3 md:grid-cols-2">
|
|
566
|
+
{suite.checks.map((c) => {
|
|
567
|
+
const rate = live?.test?.byCheck[c.key];
|
|
568
|
+
return (
|
|
569
|
+
<Card key={c.key} className="space-y-1">
|
|
570
|
+
<div className="flex justify-between gap-4">
|
|
571
|
+
<h3 className="font-medium">{c.label}</h3>
|
|
572
|
+
<Tip term={c.severity} id={`severity-${c.key}`}>
|
|
573
|
+
<Chip
|
|
574
|
+
tone={c.severity === "serious" ? "serious" : "neutral"}
|
|
575
|
+
>
|
|
576
|
+
{c.severity}
|
|
577
|
+
</Chip>
|
|
578
|
+
</Tip>
|
|
579
|
+
</div>
|
|
580
|
+
<p className="readable text-sm text-muted">{c.description}</p>
|
|
581
|
+
<p className="text-sm">
|
|
582
|
+
{rate && rate.n > 0 && (
|
|
583
|
+
<>
|
|
584
|
+
Live:{" "}
|
|
585
|
+
<span
|
|
586
|
+
className={
|
|
587
|
+
rate.passed / rate.n >= checkBar(c)
|
|
588
|
+
? "text-good"
|
|
589
|
+
: "text-warn"
|
|
590
|
+
}
|
|
591
|
+
>
|
|
592
|
+
{pct(rate.passed / rate.n)}
|
|
593
|
+
</span>{" "}
|
|
594
|
+
({rate.passed}/{rate.n}) ·{" "}
|
|
595
|
+
</>
|
|
596
|
+
)}
|
|
597
|
+
<Tip term="bar" id={`bar-${c.key}`}>
|
|
598
|
+
<span className="text-muted">Bar: {pct(checkBar(c))}</span>
|
|
599
|
+
</Tip>
|
|
600
|
+
</p>
|
|
601
|
+
</Card>
|
|
602
|
+
);
|
|
603
|
+
})}
|
|
604
|
+
</div>
|
|
605
|
+
</section>
|
|
606
|
+
</>
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/** The answer key: the cases in use and their answers, with ways to add and rate them. */
|
|
611
|
+
export function AnswerKeySection({ data }: { data: SuitePageData }) {
|
|
612
|
+
const { app, key, b, suite, rows, attackBoards } = data;
|
|
613
|
+
// A feature's attack cases are a tab of its answer key.
|
|
614
|
+
const attacked = attackBoards.filter((a) => a.cases > 0);
|
|
615
|
+
const cases = (
|
|
616
|
+
<AnswerKey
|
|
617
|
+
app={app}
|
|
618
|
+
suite={suite}
|
|
619
|
+
rows={rows}
|
|
620
|
+
heading={
|
|
621
|
+
<h2 className="text-lg font-semibold">
|
|
622
|
+
Answer key ({b.cases} cases in use)
|
|
623
|
+
<InfoTip term="answerKey" />
|
|
624
|
+
</h2>
|
|
625
|
+
}
|
|
626
|
+
tools={
|
|
627
|
+
<>
|
|
628
|
+
{suite.caseKind === "imported" &&
|
|
629
|
+
(suite.labelFromForm || app.answerEditors[key]) && (
|
|
630
|
+
<Tip control term="rateBlind" side="bottom" align="end">
|
|
631
|
+
<Link
|
|
632
|
+
href={evalsPath(app, key, "rate")}
|
|
633
|
+
className="inline-flex items-center rounded-md border border-accent/40 bg-card px-3 py-1.5 text-sm text-accent hover:bg-accent/10"
|
|
634
|
+
>
|
|
635
|
+
Rate blind
|
|
636
|
+
</Link>
|
|
637
|
+
</Tip>
|
|
638
|
+
)}
|
|
639
|
+
<form action={app.actions.rescore}>
|
|
640
|
+
<input type="hidden" name="suite" value={key} />
|
|
641
|
+
<Tip control term="rescore" side="bottom" align="end">
|
|
642
|
+
<IconSubmit
|
|
643
|
+
label="Rescore tests"
|
|
644
|
+
icon={<RotateCw aria-hidden className="h-4 w-4" />}
|
|
645
|
+
/>
|
|
646
|
+
</Tip>
|
|
647
|
+
</form>
|
|
648
|
+
</>
|
|
649
|
+
}
|
|
650
|
+
/>
|
|
651
|
+
);
|
|
652
|
+
return (
|
|
653
|
+
// The weekly check links here to review drafts.
|
|
654
|
+
<section id="answer-key" className="scroll-mt-4 space-y-3">
|
|
655
|
+
{attacked.length === 0 ? (
|
|
656
|
+
cases
|
|
657
|
+
) : (
|
|
658
|
+
<Tabs
|
|
659
|
+
label="The answer key's cases"
|
|
660
|
+
tabs={[
|
|
661
|
+
{ id: "cases", title: `Cases (${b.cases})`, panel: cases },
|
|
662
|
+
...attacked.map((a) => ({
|
|
663
|
+
id: a.suite.key,
|
|
664
|
+
title: `Attacks (${a.cases})`,
|
|
665
|
+
panel: (
|
|
666
|
+
<AnswerKey
|
|
667
|
+
app={app}
|
|
668
|
+
readOnly
|
|
669
|
+
suite={a.suite}
|
|
670
|
+
rows={a.rows}
|
|
671
|
+
heading={
|
|
672
|
+
<p className="readable text-sm text-muted">
|
|
673
|
+
Each is a confirmed case with an attack planted where
|
|
674
|
+
untrusted text goes, and keeps that case's answer. A
|
|
675
|
+
model's Test runs them, and they follow the cases as
|
|
676
|
+
answers change.
|
|
677
|
+
</p>
|
|
678
|
+
}
|
|
679
|
+
/>
|
|
680
|
+
),
|
|
681
|
+
})),
|
|
682
|
+
]}
|
|
683
|
+
/>
|
|
684
|
+
)}
|
|
685
|
+
</section>
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/** "Free: all 16 reused" or "~$0.03, 4 of 16 reused", under a model's buttons. */
|
|
690
|
+
function EstimateNote({
|
|
691
|
+
id,
|
|
692
|
+
estimate,
|
|
693
|
+
}: {
|
|
694
|
+
id: string;
|
|
695
|
+
estimate:
|
|
696
|
+
{ answers: number; reused: number; costUsd: number | null } | undefined;
|
|
697
|
+
}) {
|
|
698
|
+
if (!estimate || estimate.answers === 0) return null;
|
|
699
|
+
const { answers, reused, costUsd } = estimate;
|
|
700
|
+
const text =
|
|
701
|
+
reused === answers
|
|
702
|
+
? `Free: all ${answers} reused`
|
|
703
|
+
: `${costUsd === null ? "Cost unknown" : `~${money(costUsd)}`}${reused ? `, ${reused} of ${answers} reused` : ""}`;
|
|
704
|
+
return (
|
|
705
|
+
<Tip
|
|
706
|
+
text="What testing this model costs now. Answers an identical request gave in the last 7 days are reused for free."
|
|
707
|
+
id={`estimate-${id}`}
|
|
708
|
+
side="bottom"
|
|
709
|
+
align="end"
|
|
710
|
+
>
|
|
711
|
+
<span className="whitespace-nowrap text-xs text-muted">{text}</span>
|
|
712
|
+
</Tip>
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* A model's serious mistakes on one injection suite, linked to that test,
|
|
718
|
+
* or a dash until the model's Test runs the attacks along with its cases.
|
|
719
|
+
* Out of date and failed tests say so: the suggestion counts only
|
|
720
|
+
* current, complete ones.
|
|
721
|
+
*/
|
|
722
|
+
function UnderAttack({
|
|
723
|
+
app,
|
|
724
|
+
attackSuite,
|
|
725
|
+
attackLabel,
|
|
726
|
+
row,
|
|
727
|
+
resisted,
|
|
728
|
+
}: {
|
|
729
|
+
app: EvalAppConfig;
|
|
730
|
+
attackSuite: string;
|
|
731
|
+
attackLabel: string;
|
|
732
|
+
row:
|
|
733
|
+
| {
|
|
734
|
+
key: string;
|
|
735
|
+
testing: boolean;
|
|
736
|
+
test: { runId: string; stale: boolean; failedAnswers: number } | null;
|
|
737
|
+
}
|
|
738
|
+
| undefined;
|
|
739
|
+
resisted: { resisted: number; of: number } | null;
|
|
740
|
+
}) {
|
|
741
|
+
if (row?.testing)
|
|
742
|
+
return (
|
|
743
|
+
<span role="status" title="Testing" className="inline-flex text-accent">
|
|
744
|
+
<Spinner />
|
|
745
|
+
</span>
|
|
746
|
+
);
|
|
747
|
+
if (row?.test)
|
|
748
|
+
return (
|
|
749
|
+
<Link
|
|
750
|
+
href={evalsPath(app, attackSuite, "runs", row.test.runId)}
|
|
751
|
+
title={attackLabel}
|
|
752
|
+
className="tabular-nums"
|
|
753
|
+
>
|
|
754
|
+
{resisted ? pct(resisted.resisted / resisted.of) : "—"}
|
|
755
|
+
{row.test.stale
|
|
756
|
+
? " · out of date"
|
|
757
|
+
: row.test.failedAnswers
|
|
758
|
+
? " · answers failed"
|
|
759
|
+
: ""}
|
|
760
|
+
</Link>
|
|
761
|
+
);
|
|
762
|
+
// Not tested yet: the model's Test runs the attacks with its cases.
|
|
763
|
+
return <span className="text-muted">—</span>;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Keeping the answer key useful: easy cases to retire (a floor stays),
|
|
768
|
+
* cases models split on and near-duplicates to check, old drafts, and
|
|
769
|
+
* tags with a single case. Shows only what needs a look, and nothing on
|
|
770
|
+
* an injection suite, whose cases are made from its base suite's.
|
|
771
|
+
*/
|
|
772
|
+
export function AnswerKeyHealthSection({ data }: { data: SuitePageData }) {
|
|
773
|
+
const { app, key, suite, health: h, choosesHere } = data;
|
|
774
|
+
const thin = h.tags.filter(([, n]) => n === 1).map(([t]) => t);
|
|
775
|
+
const needs =
|
|
776
|
+
h.easyToRetire.length ||
|
|
777
|
+
h.split.length ||
|
|
778
|
+
h.duplicates.length ||
|
|
779
|
+
h.staleDrafts.length ||
|
|
780
|
+
thin.length;
|
|
781
|
+
if (!choosesHere || !needs) return null;
|
|
782
|
+
const title = (c: { input: unknown }) => {
|
|
783
|
+
const p = suite.input.safeParse(c.input);
|
|
784
|
+
return p.success ? suite.title(p.data) : "(case)";
|
|
785
|
+
};
|
|
786
|
+
const caseLink = (c: { id: string; input: unknown }) => (
|
|
787
|
+
<a href={`#case-${c.id}`} className={LINK}>
|
|
788
|
+
{title(c)}
|
|
789
|
+
</a>
|
|
790
|
+
);
|
|
791
|
+
const { retireEasy, retireStaleDrafts } = app.actions;
|
|
792
|
+
const cases = (n: number) => `${n} ${n === 1 ? "case" : "cases"}`;
|
|
793
|
+
const drafts = (n: number) => `${n} ${n === 1 ? "draft" : "drafts"}`;
|
|
794
|
+
return (
|
|
795
|
+
<section className="space-y-3" aria-labelledby="answer-key-health">
|
|
796
|
+
<h2 id="answer-key-health" className="text-lg font-semibold">
|
|
797
|
+
Answer key health
|
|
798
|
+
<InfoTip term="answerKeyHealth" />
|
|
799
|
+
</h2>
|
|
800
|
+
<Card className="space-y-5 text-sm">
|
|
801
|
+
{h.easyToRetire.length > 0 && (
|
|
802
|
+
<div className="readable space-y-2">
|
|
803
|
+
<p>
|
|
804
|
+
<span className="font-medium">Easy cases</span>
|
|
805
|
+
<InfoTip term="easyCases" />: every current model gets{" "}
|
|
806
|
+
{cases(h.easy.length)} fully right, so they no longer tell models
|
|
807
|
+
apart. Retire {h.easyToRetire.length} and keep{" "}
|
|
808
|
+
{h.easy.length - h.easyToRetire.length} as a floor
|
|
809
|
+
<InfoTip term="easyFloor" />, so a test still catches a model that
|
|
810
|
+
breaks the basics. Recent tests are rescored for free.
|
|
811
|
+
</p>
|
|
812
|
+
{retireEasy && (
|
|
813
|
+
<form action={retireEasy}>
|
|
814
|
+
<input type="hidden" name="suite" value={key} />
|
|
815
|
+
<Submit variant="quiet">
|
|
816
|
+
Retire {h.easyToRetire.length} easy{" "}
|
|
817
|
+
{h.easyToRetire.length === 1 ? "case" : "cases"}
|
|
818
|
+
</Submit>
|
|
819
|
+
</form>
|
|
820
|
+
)}
|
|
821
|
+
</div>
|
|
822
|
+
)}
|
|
823
|
+
{h.split.length > 0 && (
|
|
824
|
+
<div className="readable space-y-1">
|
|
825
|
+
<p>
|
|
826
|
+
<span className="font-medium">Split cases</span>
|
|
827
|
+
<InfoTip term="splitCases" />: models divide about evenly on{" "}
|
|
828
|
+
{cases(h.split.length)}. The answer may be unclear, so check it
|
|
829
|
+
first.
|
|
830
|
+
</p>
|
|
831
|
+
<ul className="list-disc space-y-0.5 pl-5">
|
|
832
|
+
{h.split.map((c) => (
|
|
833
|
+
<li key={c.id}>{caseLink(c)}</li>
|
|
834
|
+
))}
|
|
835
|
+
</ul>
|
|
836
|
+
</div>
|
|
837
|
+
)}
|
|
838
|
+
{h.duplicates.length > 0 && (
|
|
839
|
+
<div className="readable space-y-1">
|
|
840
|
+
<p>
|
|
841
|
+
<span className="font-medium">Near-duplicates</span>
|
|
842
|
+
<InfoTip term="nearDuplicates" />: these pairs share nearly all
|
|
843
|
+
their words. Keep the clearer one.
|
|
844
|
+
</p>
|
|
845
|
+
<ul className="list-disc space-y-0.5 pl-5">
|
|
846
|
+
{h.duplicates.map(([a, b]) => (
|
|
847
|
+
<li key={`${a.id}-${b.id}`}>
|
|
848
|
+
{caseLink(a)} and {caseLink(b)}
|
|
849
|
+
</li>
|
|
850
|
+
))}
|
|
851
|
+
</ul>
|
|
852
|
+
</div>
|
|
853
|
+
)}
|
|
854
|
+
{h.staleDrafts.length > 0 && (
|
|
855
|
+
<div className="readable space-y-2">
|
|
856
|
+
<p>
|
|
857
|
+
<span className="font-medium">Old drafts</span>
|
|
858
|
+
<InfoTip term="oldDrafts" />: {drafts(h.staleDrafts.length)}{" "}
|
|
859
|
+
nobody reviewed in 30 days. The weekly check retires them on its
|
|
860
|
+
own.
|
|
861
|
+
</p>
|
|
862
|
+
{retireStaleDrafts && (
|
|
863
|
+
<form action={retireStaleDrafts}>
|
|
864
|
+
<input type="hidden" name="suite" value={key} />
|
|
865
|
+
<Submit variant="quiet">
|
|
866
|
+
Retire {h.staleDrafts.length} old{" "}
|
|
867
|
+
{h.staleDrafts.length === 1 ? "draft" : "drafts"} now
|
|
868
|
+
</Submit>
|
|
869
|
+
</form>
|
|
870
|
+
)}
|
|
871
|
+
</div>
|
|
872
|
+
)}
|
|
873
|
+
{thin.length > 0 && (
|
|
874
|
+
<div className="space-y-2">
|
|
875
|
+
<p className="readable">
|
|
876
|
+
<span className="font-medium">Coverage</span>
|
|
877
|
+
<InfoTip term="tagCoverage" />: {thin.length}{" "}
|
|
878
|
+
{thin.length === 1 ? "tag has" : "tags have"} a single case. A new
|
|
879
|
+
case there tells you the most.
|
|
880
|
+
</p>
|
|
881
|
+
<ul className="flex flex-wrap gap-1.5">
|
|
882
|
+
{h.tags.map(([t, n]) => (
|
|
883
|
+
<li key={t}>
|
|
884
|
+
<Chip tone={n === 1 ? "warn" : "neutral"}>
|
|
885
|
+
{t} · {n}
|
|
886
|
+
</Chip>
|
|
887
|
+
</li>
|
|
888
|
+
))}
|
|
889
|
+
</ul>
|
|
890
|
+
</div>
|
|
891
|
+
)}
|
|
892
|
+
</Card>
|
|
893
|
+
</section>
|
|
894
|
+
);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* A suite's page as Evalkeeper arranges it, or null for a suite you don't
|
|
899
|
+
* have. A page of your own loads the same data (`loadSuitePage`) and
|
|
900
|
+
* arranges these sections another way.
|
|
901
|
+
*/
|
|
902
|
+
export async function SuitePage({
|
|
903
|
+
app,
|
|
904
|
+
suite,
|
|
905
|
+
}: {
|
|
906
|
+
app: EvalAppConfig;
|
|
907
|
+
suite: string;
|
|
908
|
+
}) {
|
|
909
|
+
const data = await loadSuitePage(app, suite);
|
|
910
|
+
if (!data) return null;
|
|
911
|
+
return (
|
|
912
|
+
<div className="space-y-8">
|
|
913
|
+
<RefreshWhile active={data.testing} />
|
|
914
|
+
<SuiteHeader data={data} />
|
|
915
|
+
<ChosenOnBase data={data} />
|
|
916
|
+
<SuggestionCard data={data} />
|
|
917
|
+
<CasesInInstructions data={data} />
|
|
918
|
+
<ModelTable data={data} />
|
|
919
|
+
<Versions data={data} />
|
|
920
|
+
<ChecksSection data={data} />
|
|
921
|
+
<AnswerKeyHealthSection data={data} />
|
|
922
|
+
<AnswerKeySection data={data} />
|
|
923
|
+
</div>
|
|
924
|
+
);
|
|
925
|
+
}
|