@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
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import {
|
|
2
|
+
attacksFrom,
|
|
3
|
+
attention,
|
|
4
|
+
isInjectionSuite,
|
|
5
|
+
perAnswer,
|
|
6
|
+
seconds,
|
|
7
|
+
suiteHealth,
|
|
8
|
+
thumbsSummary,
|
|
9
|
+
type GlossaryTerm,
|
|
10
|
+
type HistoryEntry,
|
|
11
|
+
type Settings,
|
|
12
|
+
type SettingsVersion,
|
|
13
|
+
} from "../index.js";
|
|
14
|
+
import { Link, Card, InfoTip, StatusBadge } from "./pieces.js";
|
|
15
|
+
import { pct, dayOf } from "./format.js";
|
|
16
|
+
import { HistoryEntries } from "./SettingsHistory.js";
|
|
17
|
+
import {
|
|
18
|
+
daysAgo,
|
|
19
|
+
evalsPath,
|
|
20
|
+
loadWeekly,
|
|
21
|
+
type EvalAppConfig,
|
|
22
|
+
attacksResisted,
|
|
23
|
+
} from "./app.js";
|
|
24
|
+
import type { Runner } from "../runner.js";
|
|
25
|
+
import { ChevronDown } from "lucide-react";
|
|
26
|
+
import { WeeklyCheck } from "./WeeklyCheck.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Everything the evals hub shows, loaded together. Sections read from
|
|
30
|
+
* this, so a hub of your own loads the same data once.
|
|
31
|
+
*/
|
|
32
|
+
export async function loadHub(app: EvalAppConfig) {
|
|
33
|
+
const [boards, weekly] = await Promise.all([
|
|
34
|
+
Promise.all(app.suites.map((s) => app.runner.board(s.key))),
|
|
35
|
+
loadWeekly(app),
|
|
36
|
+
]);
|
|
37
|
+
const histories = await Promise.all(
|
|
38
|
+
app.suites.map((s) =>
|
|
39
|
+
Promise.all([
|
|
40
|
+
app.settings.history(s.operation),
|
|
41
|
+
app.settings.current(s.operation),
|
|
42
|
+
]),
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
const thumbs = thumbsSummary(
|
|
46
|
+
await app.feedbackStore.listFeedback(),
|
|
47
|
+
daysAgo(7),
|
|
48
|
+
);
|
|
49
|
+
const down = thumbs.reduce((t, s) => t + s.down, 0);
|
|
50
|
+
const waiting = thumbs.reduce((t, s) => t + s.open, 0);
|
|
51
|
+
const flagged = thumbs.filter((s) => s.alert).length;
|
|
52
|
+
// An injection suite shows on its base suite's card, not its own.
|
|
53
|
+
const attacksOn = (key: string) =>
|
|
54
|
+
boards.filter((x) => isInjectionSuite(x.suite) && x.suite.base.key === key);
|
|
55
|
+
const cards = boards
|
|
56
|
+
.map((b, i) => ({ b, i }))
|
|
57
|
+
.filter(({ b }) => !isInjectionSuite(b.suite));
|
|
58
|
+
const needs = attention(
|
|
59
|
+
cards.map(({ b }) => ({
|
|
60
|
+
key: b.suite.key,
|
|
61
|
+
label: b.suite.label,
|
|
62
|
+
rows: b.rows,
|
|
63
|
+
toReview: b.provisional,
|
|
64
|
+
})),
|
|
65
|
+
);
|
|
66
|
+
return {
|
|
67
|
+
app,
|
|
68
|
+
boards,
|
|
69
|
+
weekly,
|
|
70
|
+
histories,
|
|
71
|
+
thumbs,
|
|
72
|
+
down,
|
|
73
|
+
waiting,
|
|
74
|
+
flagged,
|
|
75
|
+
attacksOn,
|
|
76
|
+
cards,
|
|
77
|
+
needs,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** What `loadHub` returns, for sections and custom pages. */
|
|
82
|
+
export type HubData = Awaited<ReturnType<typeof loadHub>>;
|
|
83
|
+
|
|
84
|
+
/** What the evals hub is for. */
|
|
85
|
+
export function HubIntro() {
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
<div className="readable space-y-2">
|
|
89
|
+
<h1 className="text-2xl font-semibold">Evals</h1>
|
|
90
|
+
<p className="text-muted">
|
|
91
|
+
Each suite tests one AI feature against answers people confirmed. Test
|
|
92
|
+
models on it, then pick the live one on evidence.
|
|
93
|
+
</p>
|
|
94
|
+
</div>
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Where the features stand: most room to improve, the slowest and costliest live models, and thumbs down this week. */
|
|
100
|
+
export function HubStats({ data }: { data: HubData }) {
|
|
101
|
+
const { app, down, waiting, flagged, needs } = data;
|
|
102
|
+
return (
|
|
103
|
+
<>
|
|
104
|
+
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
|
105
|
+
<Stat
|
|
106
|
+
title="Most room to improve"
|
|
107
|
+
term="improve"
|
|
108
|
+
value={needs.improve ? pct(needs.improve.best) : "—"}
|
|
109
|
+
detail={
|
|
110
|
+
!needs.improve
|
|
111
|
+
? "Test a suite to see"
|
|
112
|
+
: needs.improve.best >= 1
|
|
113
|
+
? "Every suite has a model scoring 100%"
|
|
114
|
+
: `${needs.improve.label}, best on ${needs.improve.model}`
|
|
115
|
+
}
|
|
116
|
+
/>
|
|
117
|
+
<Stat
|
|
118
|
+
title="Slowest live model"
|
|
119
|
+
term="slowest"
|
|
120
|
+
value={needs.slowest ? seconds(needs.slowest.ms) : "—"}
|
|
121
|
+
detail={
|
|
122
|
+
needs.slowest
|
|
123
|
+
? `${needs.slowest.label} on ${needs.slowest.model}`
|
|
124
|
+
: "—"
|
|
125
|
+
}
|
|
126
|
+
/>
|
|
127
|
+
<Stat
|
|
128
|
+
title="Costliest live model"
|
|
129
|
+
term="costliest"
|
|
130
|
+
value={needs.costliest ? perAnswer(needs.costliest.usd) : "—"}
|
|
131
|
+
detail={
|
|
132
|
+
needs.costliest
|
|
133
|
+
? `${needs.costliest.label} on ${needs.costliest.model}`
|
|
134
|
+
: "—"
|
|
135
|
+
}
|
|
136
|
+
/>
|
|
137
|
+
<Link href={evalsPath(app, "feedback")}>
|
|
138
|
+
<Stat
|
|
139
|
+
title="Thumbs down this week"
|
|
140
|
+
term="thumbs"
|
|
141
|
+
value={String(down)}
|
|
142
|
+
detail={
|
|
143
|
+
flagged
|
|
144
|
+
? `${flagged} feature${flagged === 1 ? "" : "s"} need a look · ${waiting} waiting`
|
|
145
|
+
: `${waiting} waiting for a look`
|
|
146
|
+
}
|
|
147
|
+
/>
|
|
148
|
+
</Link>
|
|
149
|
+
</div>
|
|
150
|
+
</>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** One card per feature, with an injection suite's results on its base feature's card. */
|
|
155
|
+
export function SuiteList({ data }: { data: HubData }) {
|
|
156
|
+
const { app, histories, attacksOn, cards } = data;
|
|
157
|
+
return (
|
|
158
|
+
<>
|
|
159
|
+
<section aria-labelledby="suites" className="space-y-3">
|
|
160
|
+
<h2 id="suites" className="text-lg font-semibold">
|
|
161
|
+
Suites
|
|
162
|
+
<InfoTip term="suites" />
|
|
163
|
+
</h2>
|
|
164
|
+
{cards.length === 0 && <NoSuites />}
|
|
165
|
+
<div className="space-y-4">
|
|
166
|
+
{cards.map(({ b, i }) => {
|
|
167
|
+
const attacked = attacksOn(b.suite.key);
|
|
168
|
+
const h = suiteHealth(
|
|
169
|
+
b.rows,
|
|
170
|
+
b.suite.checks,
|
|
171
|
+
b.suite.priority,
|
|
172
|
+
b.cases,
|
|
173
|
+
b.provisional,
|
|
174
|
+
app.models,
|
|
175
|
+
{ attacks: attacksFrom(attacked) },
|
|
176
|
+
);
|
|
177
|
+
const [history, current] = histories[i] ?? [[], null];
|
|
178
|
+
return (
|
|
179
|
+
<SuiteCard
|
|
180
|
+
app={app}
|
|
181
|
+
key={b.suite.key}
|
|
182
|
+
board={b}
|
|
183
|
+
attacked={attacked}
|
|
184
|
+
health={h}
|
|
185
|
+
history={history}
|
|
186
|
+
current={current}
|
|
187
|
+
/>
|
|
188
|
+
);
|
|
189
|
+
})}
|
|
190
|
+
</div>
|
|
191
|
+
</section>
|
|
192
|
+
</>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Before the first suite: what a suite is, and how to add one. */
|
|
197
|
+
function NoSuites() {
|
|
198
|
+
return (
|
|
199
|
+
<Card className="readable space-y-3 text-sm">
|
|
200
|
+
<p className="font-semibold">No suites yet</p>
|
|
201
|
+
<p className="text-muted">
|
|
202
|
+
A suite tests one AI feature: its cases, the answers a person confirms,
|
|
203
|
+
and the checks that grade any model against them. To add one:
|
|
204
|
+
</p>
|
|
205
|
+
<ol className="list-decimal space-y-2 pl-4">
|
|
206
|
+
<li>
|
|
207
|
+
Write it: the input and answer shapes with zod, two or three checks,{" "}
|
|
208
|
+
<code>run</code>, and <code>grade</code>.
|
|
209
|
+
</li>
|
|
210
|
+
<li>
|
|
211
|
+
Add it to <code>app.suites</code> in{" "}
|
|
212
|
+
<code>lib/evalkeeper/index.ts</code>, with its instructions hash.
|
|
213
|
+
</li>
|
|
214
|
+
<li>
|
|
215
|
+
Add cases (here, or with <code>importCases</code> from files you
|
|
216
|
+
have), confirm their answers, and test models.
|
|
217
|
+
</li>
|
|
218
|
+
</ol>
|
|
219
|
+
<p className="text-muted">
|
|
220
|
+
Step by step:{" "}
|
|
221
|
+
<a
|
|
222
|
+
href="https://seanhudson.github.io/evalkeeper/start/adding-to-your-app/#5-write-your-first-suite"
|
|
223
|
+
target="_blank"
|
|
224
|
+
rel="noreferrer"
|
|
225
|
+
className="underline"
|
|
226
|
+
>
|
|
227
|
+
Write your first suite
|
|
228
|
+
</a>
|
|
229
|
+
.
|
|
230
|
+
</p>
|
|
231
|
+
</Card>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function Stat({
|
|
236
|
+
title,
|
|
237
|
+
term,
|
|
238
|
+
value,
|
|
239
|
+
detail,
|
|
240
|
+
}: {
|
|
241
|
+
title: string;
|
|
242
|
+
term: GlossaryTerm;
|
|
243
|
+
value: string;
|
|
244
|
+
detail: string;
|
|
245
|
+
}) {
|
|
246
|
+
return (
|
|
247
|
+
<Card className="space-y-1">
|
|
248
|
+
<p className="text-sm text-muted">
|
|
249
|
+
{title}
|
|
250
|
+
<InfoTip term={term} />
|
|
251
|
+
</p>
|
|
252
|
+
<p className="text-2xl font-semibold tabular-nums">{value}</p>
|
|
253
|
+
<p className="text-sm text-muted">{detail}</p>
|
|
254
|
+
</Card>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
type Board = Awaited<ReturnType<Runner["board"]>>;
|
|
259
|
+
|
|
260
|
+
const day = dayOf;
|
|
261
|
+
/** Green at 95% and up, amber from 80%, red below. */
|
|
262
|
+
const scoreTone = (rate: number) =>
|
|
263
|
+
rate >= 0.95 ? "text-good" : rate >= 0.8 ? "text-warn" : "text-bad";
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* One feature on the hub: its live version and models, what the live
|
|
267
|
+
* model costs and how fast it is, its latest test, how it does under
|
|
268
|
+
* attack, what needs a look, and its settings history.
|
|
269
|
+
*/
|
|
270
|
+
function SuiteCard({
|
|
271
|
+
app,
|
|
272
|
+
board: b,
|
|
273
|
+
attacked,
|
|
274
|
+
health: h,
|
|
275
|
+
history,
|
|
276
|
+
current,
|
|
277
|
+
}: {
|
|
278
|
+
app: EvalAppConfig;
|
|
279
|
+
board: Board;
|
|
280
|
+
/** The injection suites that attack this feature. */
|
|
281
|
+
attacked: Board[];
|
|
282
|
+
health: ReturnType<typeof suiteHealth>;
|
|
283
|
+
history: HistoryEntry[];
|
|
284
|
+
current: { settings: Settings; version: SettingsVersion | null } | null;
|
|
285
|
+
}) {
|
|
286
|
+
const label = (model: string) => app.models[model]?.label ?? model;
|
|
287
|
+
const live = b.rows.find((r) => r.live && !r.variant);
|
|
288
|
+
const t = live?.test;
|
|
289
|
+
const version = current?.version ?? null;
|
|
290
|
+
const since = version
|
|
291
|
+
? (history.find((e) => e.to.id === version.id)?.createdAt ??
|
|
292
|
+
version.createdAt)
|
|
293
|
+
: null;
|
|
294
|
+
const s = current?.settings;
|
|
295
|
+
const price = s ? app.models[s.model] : undefined;
|
|
296
|
+
const versions = Math.max(1, ...history.map((e) => e.to.number));
|
|
297
|
+
return (
|
|
298
|
+
<Card className="relative space-y-4 transition-colors hover:border-muted">
|
|
299
|
+
<div className="flex flex-wrap items-start justify-between gap-4">
|
|
300
|
+
<div className="min-w-0 space-y-2">
|
|
301
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
302
|
+
<h2 className="font-semibold">
|
|
303
|
+
{/* Covers the whole card; the versions toggle sits above it. */}
|
|
304
|
+
<Link
|
|
305
|
+
href={evalsPath(app, b.suite.key)}
|
|
306
|
+
className="after:absolute after:inset-0 after:rounded-lg"
|
|
307
|
+
>
|
|
308
|
+
{b.suite.label}
|
|
309
|
+
</Link>
|
|
310
|
+
</h2>
|
|
311
|
+
<StatusBadge status={h.status} />
|
|
312
|
+
</div>
|
|
313
|
+
<p className="readable text-sm text-muted">{b.suite.description}</p>
|
|
314
|
+
</div>
|
|
315
|
+
{t && (
|
|
316
|
+
<div className="shrink-0 space-y-0.5 text-right text-sm">
|
|
317
|
+
<p className="font-semibold tabular-nums">
|
|
318
|
+
{perAnswer(t.costPerAnswer)} / answer
|
|
319
|
+
</p>
|
|
320
|
+
<p className="text-xs text-muted">{seconds(t.avgMs)} avg</p>
|
|
321
|
+
{price?.inputPer1M !== undefined &&
|
|
322
|
+
price.outputPer1M !== undefined && (
|
|
323
|
+
<p className="text-xs text-muted">
|
|
324
|
+
${price.inputPer1M} / ${price.outputPer1M} per 1M
|
|
325
|
+
</p>
|
|
326
|
+
)}
|
|
327
|
+
</div>
|
|
328
|
+
)}
|
|
329
|
+
</div>
|
|
330
|
+
|
|
331
|
+
{/* The models and how live does, read together. */}
|
|
332
|
+
<div className="space-y-1">
|
|
333
|
+
{s && (
|
|
334
|
+
<p className="text-sm text-muted">
|
|
335
|
+
<span className="font-semibold text-ink">{label(s.model)}</span>
|
|
336
|
+
{s.fallbackModel ? (
|
|
337
|
+
<>
|
|
338
|
+
{" "}
|
|
339
|
+
· fallback{" "}
|
|
340
|
+
<span className="font-semibold text-ink">
|
|
341
|
+
{label(s.fallbackModel)}
|
|
342
|
+
</span>
|
|
343
|
+
</>
|
|
344
|
+
) : (
|
|
345
|
+
" · no fallback"
|
|
346
|
+
)}
|
|
347
|
+
{s.reasoningEffort ? ` · reasoning ${s.reasoningEffort}` : ""}
|
|
348
|
+
</p>
|
|
349
|
+
)}
|
|
350
|
+
|
|
351
|
+
<p className="text-sm">
|
|
352
|
+
{t ? (
|
|
353
|
+
<>
|
|
354
|
+
Score{" "}
|
|
355
|
+
<span className={`font-semibold ${scoreTone(t.right / t.total)}`}>
|
|
356
|
+
{pct(t.right / t.total)}
|
|
357
|
+
</span>
|
|
358
|
+
</>
|
|
359
|
+
) : (
|
|
360
|
+
"Live model not tested yet"
|
|
361
|
+
)}{" "}
|
|
362
|
+
· {b.cases} cases · {h.testedModels} models tested
|
|
363
|
+
</p>
|
|
364
|
+
</div>
|
|
365
|
+
|
|
366
|
+
{h.details.length > 0 && (
|
|
367
|
+
<ul className="readable list-disc space-y-1 pl-5 text-sm text-muted">
|
|
368
|
+
{h.details.slice(0, 3).map((d) => (
|
|
369
|
+
<li key={d}>{d}</li>
|
|
370
|
+
))}
|
|
371
|
+
</ul>
|
|
372
|
+
)}
|
|
373
|
+
|
|
374
|
+
{/* Once the feature has attack cases (a test makes them). */}
|
|
375
|
+
{attacked
|
|
376
|
+
.filter((a) => a.cases > 0)
|
|
377
|
+
.map((a) => {
|
|
378
|
+
const r = live ? attacksResisted(live.key, [a]) : null;
|
|
379
|
+
return (
|
|
380
|
+
<p key={a.suite.key} className="relative text-sm">
|
|
381
|
+
Attacks resisted
|
|
382
|
+
<InfoTip term="attacksResisted" />:{" "}
|
|
383
|
+
{r === null ? (
|
|
384
|
+
<span className="text-muted">not tested yet</span>
|
|
385
|
+
) : (
|
|
386
|
+
<Link
|
|
387
|
+
href={evalsPath(app, a.suite.key)}
|
|
388
|
+
className={`font-semibold hover:underline ${scoreTone(r.resisted / r.of)}`}
|
|
389
|
+
>
|
|
390
|
+
{pct(r.resisted / r.of)}
|
|
391
|
+
</Link>
|
|
392
|
+
)}{" "}
|
|
393
|
+
of {a.cases} {a.cases === 1 ? "attack" : "attacks"}
|
|
394
|
+
</p>
|
|
395
|
+
);
|
|
396
|
+
})}
|
|
397
|
+
|
|
398
|
+
{s && (
|
|
399
|
+
<details className="group/history relative rounded-md bg-tint">
|
|
400
|
+
<summary className="flex list-none items-center justify-between gap-2 p-3 text-sm font-medium">
|
|
401
|
+
Versions
|
|
402
|
+
<span className="flex items-center gap-1 text-xs font-normal text-muted">
|
|
403
|
+
<span className="font-medium text-ink">
|
|
404
|
+
v{version?.number ?? 1}
|
|
405
|
+
</span>{" "}
|
|
406
|
+
{since ? `live since ${day(since)}` : "defaults from code"} ·{" "}
|
|
407
|
+
{versions} version{versions === 1 ? "" : "s"}
|
|
408
|
+
<ChevronDown
|
|
409
|
+
aria-hidden
|
|
410
|
+
className="h-4 w-4 transition-transform group-open/history:rotate-180"
|
|
411
|
+
/>
|
|
412
|
+
</span>
|
|
413
|
+
</summary>
|
|
414
|
+
<div className="px-3 pb-3">
|
|
415
|
+
<HistoryEntries
|
|
416
|
+
app={app}
|
|
417
|
+
suite={b.suite.key}
|
|
418
|
+
entries={history}
|
|
419
|
+
liveId={version?.id ?? null}
|
|
420
|
+
label={label}
|
|
421
|
+
defaults={s}
|
|
422
|
+
plain
|
|
423
|
+
/>
|
|
424
|
+
</div>
|
|
425
|
+
</details>
|
|
426
|
+
)}
|
|
427
|
+
</Card>
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* The hub as Evalkeeper arranges it: where each suite stands and what
|
|
433
|
+
* needs attention. A hub of your own loads the same data (`loadHub`) and
|
|
434
|
+
* arranges these sections another way.
|
|
435
|
+
*/
|
|
436
|
+
export async function HubPage({ app }: { app: EvalAppConfig }) {
|
|
437
|
+
const data = await loadHub(app);
|
|
438
|
+
return (
|
|
439
|
+
<div className="space-y-8">
|
|
440
|
+
<HubIntro />
|
|
441
|
+
<HubStats data={data} />
|
|
442
|
+
<WeeklyCheck app={app} weekly={data.weekly} />
|
|
443
|
+
<SuiteList data={data} />
|
|
444
|
+
</div>
|
|
445
|
+
);
|
|
446
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { EllipsisVertical } from "lucide-react";
|
|
5
|
+
import { Button } from "./pieces.js";
|
|
6
|
+
import type { FormAction } from "./app.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A model row's menu: make it live, or make it the fallback, where the
|
|
10
|
+
* row allows either. Keeps the model table narrow. Closes on a click
|
|
11
|
+
* outside or Escape.
|
|
12
|
+
*/
|
|
13
|
+
export function ModelMenu({
|
|
14
|
+
suite,
|
|
15
|
+
model,
|
|
16
|
+
label,
|
|
17
|
+
makeLive,
|
|
18
|
+
makeFallback,
|
|
19
|
+
}: {
|
|
20
|
+
suite: string;
|
|
21
|
+
model: string;
|
|
22
|
+
/** The model's name, for the button's accessible name. */
|
|
23
|
+
label: string;
|
|
24
|
+
/** Your makeLive action, when the model can be made live. */
|
|
25
|
+
makeLive: FormAction | null;
|
|
26
|
+
/** Your makeFallback action, when it can be the fallback. */
|
|
27
|
+
makeFallback: FormAction | null;
|
|
28
|
+
}) {
|
|
29
|
+
const [open, setOpen] = useState(false);
|
|
30
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!open) return;
|
|
34
|
+
const close = (e: MouseEvent | KeyboardEvent) => {
|
|
35
|
+
if (
|
|
36
|
+
e instanceof KeyboardEvent
|
|
37
|
+
? e.key === "Escape"
|
|
38
|
+
: !ref.current?.contains(e.target as Node)
|
|
39
|
+
)
|
|
40
|
+
setOpen(false);
|
|
41
|
+
};
|
|
42
|
+
document.addEventListener("mousedown", close);
|
|
43
|
+
document.addEventListener("keydown", close);
|
|
44
|
+
return () => {
|
|
45
|
+
document.removeEventListener("mousedown", close);
|
|
46
|
+
document.removeEventListener("keydown", close);
|
|
47
|
+
};
|
|
48
|
+
}, [open]);
|
|
49
|
+
|
|
50
|
+
if (!makeLive && !makeFallback) return null;
|
|
51
|
+
const item =
|
|
52
|
+
"block w-full rounded px-3 py-1.5 text-left text-sm hover:bg-tint";
|
|
53
|
+
const choice = (action: FormAction, text: string) => (
|
|
54
|
+
<form action={action}>
|
|
55
|
+
<input type="hidden" name="suite" value={suite} />
|
|
56
|
+
<input type="hidden" name="model" value={model} />
|
|
57
|
+
<Button type="submit" role="menuitem" className={item}>
|
|
58
|
+
{text}
|
|
59
|
+
</Button>
|
|
60
|
+
</form>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div ref={ref} className="relative">
|
|
65
|
+
<Button
|
|
66
|
+
type="button"
|
|
67
|
+
aria-label={`Choose ${label}`}
|
|
68
|
+
title={`Choose ${label}`}
|
|
69
|
+
aria-haspopup="menu"
|
|
70
|
+
aria-expanded={open}
|
|
71
|
+
onClick={() => {
|
|
72
|
+
setOpen(!open);
|
|
73
|
+
}}
|
|
74
|
+
className="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted hover:bg-tint hover:text-ink"
|
|
75
|
+
>
|
|
76
|
+
<EllipsisVertical aria-hidden className="h-4 w-4" />
|
|
77
|
+
</Button>
|
|
78
|
+
{open && (
|
|
79
|
+
<div
|
|
80
|
+
role="menu"
|
|
81
|
+
className="absolute right-0 z-20 mt-1 w-40 rounded-md border border-line bg-card p-1 shadow-lg"
|
|
82
|
+
>
|
|
83
|
+
{makeLive && choice(makeLive, "Make live")}
|
|
84
|
+
{makeFallback && choice(makeFallback, "Make fallback")}
|
|
85
|
+
</div>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { LINK } from "./format.js";
|
|
2
|
+
import { evalsPath, type EvalAppConfig } from "./app.js";
|
|
3
|
+
import { Link } from "./pieces.js";
|
|
4
|
+
import { BackLink, Card, InfoTip, Submit, TextArea, Tip } from "./pieces.js";
|
|
5
|
+
import { rateQueue } from "../index.js";
|
|
6
|
+
import { AnswerInput, FieldValues } from "./Fields.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Rating an imported suite's cases blind: one case at a time, the oldest
|
|
10
|
+
* this person hasn't rated or skipped, shown by its input alone. The app's
|
|
11
|
+
* output, what anyone did with the item, other answers, tags, and notes
|
|
12
|
+
* stay hidden, because any of them anchors the rating.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Blind rating: one case at a time, by its input only. Null when it doesn't exist. */
|
|
16
|
+
export async function RateView({
|
|
17
|
+
app,
|
|
18
|
+
suite: key,
|
|
19
|
+
rater,
|
|
20
|
+
}: {
|
|
21
|
+
/** Your screens' configuration. */
|
|
22
|
+
app: EvalAppConfig;
|
|
23
|
+
suite: string;
|
|
24
|
+
/** Who is rating: their own answers are kept apart. */
|
|
25
|
+
rater: { id: string; name: string };
|
|
26
|
+
}) {
|
|
27
|
+
const admin = rater;
|
|
28
|
+
const suite = app.suiteByKey[key];
|
|
29
|
+
const fields = suite?.fields;
|
|
30
|
+
if (
|
|
31
|
+
!suite ||
|
|
32
|
+
suite.caseKind !== "imported" ||
|
|
33
|
+
!fields ||
|
|
34
|
+
!(suite.labelFromForm || app.answerEditors[key])
|
|
35
|
+
)
|
|
36
|
+
return null;
|
|
37
|
+
const queue = rateQueue(await app.store.listCases(key), admin.id);
|
|
38
|
+
const next = queue.next;
|
|
39
|
+
const input = next ? suite.input.parse(next.input) : null;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div className="space-y-8">
|
|
43
|
+
<div className="space-y-2">
|
|
44
|
+
<BackLink href={evalsPath(app, key)}>{suite.label}</BackLink>
|
|
45
|
+
<h1 className="text-2xl font-semibold">
|
|
46
|
+
Rate blind
|
|
47
|
+
<InfoTip term="rateBlind" />
|
|
48
|
+
</h1>
|
|
49
|
+
<p className="readable text-muted">
|
|
50
|
+
One case at a time, from its input alone. You won't see what the
|
|
51
|
+
app decided or what anyone did with it, so nothing anchors your
|
|
52
|
+
answer. Give the answer and why, or skip it.
|
|
53
|
+
</p>
|
|
54
|
+
<p className="text-sm text-muted">
|
|
55
|
+
<Tip term="rateQueue" id="rate-queue">
|
|
56
|
+
<span>
|
|
57
|
+
{queue.rated} rated · {queue.skipped} skipped · {queue.left} left
|
|
58
|
+
</span>
|
|
59
|
+
</Tip>
|
|
60
|
+
</p>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
{next && input !== null ? (
|
|
64
|
+
<Card className="space-y-6">
|
|
65
|
+
<section className="space-y-3">
|
|
66
|
+
<h2 className="font-semibold">{suite.title(input)}</h2>
|
|
67
|
+
{fields.input.length ? (
|
|
68
|
+
<FieldValues
|
|
69
|
+
fields={fields.input}
|
|
70
|
+
values={next.input}
|
|
71
|
+
prefix="rate-in-"
|
|
72
|
+
/>
|
|
73
|
+
) : (
|
|
74
|
+
<pre className="readable whitespace-pre-wrap text-sm">
|
|
75
|
+
{suite.describe?.(input) ?? JSON.stringify(next.input, null, 2)}
|
|
76
|
+
</pre>
|
|
77
|
+
)}
|
|
78
|
+
</section>
|
|
79
|
+
|
|
80
|
+
{/* Keyed by case, so the next case starts with an empty form. */}
|
|
81
|
+
<form
|
|
82
|
+
key={next.id}
|
|
83
|
+
action={app.actions.rateBlind}
|
|
84
|
+
className="space-y-4"
|
|
85
|
+
>
|
|
86
|
+
<input type="hidden" name="suite" value={key} />
|
|
87
|
+
<input type="hidden" name="case" value={next.id} />
|
|
88
|
+
<AnswerInput
|
|
89
|
+
fields={fields.label}
|
|
90
|
+
editor={app.answerEditors[key]}
|
|
91
|
+
input={next.input}
|
|
92
|
+
prefix="rate-"
|
|
93
|
+
/>
|
|
94
|
+
<div className="space-y-1">
|
|
95
|
+
<label
|
|
96
|
+
htmlFor="rate-reason"
|
|
97
|
+
className="block text-sm font-medium"
|
|
98
|
+
>
|
|
99
|
+
Why
|
|
100
|
+
</label>
|
|
101
|
+
<TextArea
|
|
102
|
+
id="rate-reason"
|
|
103
|
+
name="reason"
|
|
104
|
+
required
|
|
105
|
+
rows={3}
|
|
106
|
+
className="w-full rounded-md border border-line bg-card px-3 py-2 text-sm focus:border-accent focus:outline-none"
|
|
107
|
+
/>
|
|
108
|
+
<p className="readable text-xs text-muted">
|
|
109
|
+
What in the input decided it, in a sentence. Kept with your
|
|
110
|
+
answer, so anyone checking it later sees your reasoning.
|
|
111
|
+
</p>
|
|
112
|
+
</div>
|
|
113
|
+
<p className="readable text-xs text-muted">
|
|
114
|
+
Saves your own confirmed answer beside anyone else's, and
|
|
115
|
+
rescores tests for free.
|
|
116
|
+
</p>
|
|
117
|
+
<Submit>Save rating</Submit>
|
|
118
|
+
</form>
|
|
119
|
+
|
|
120
|
+
<form action={app.actions.skipCase}>
|
|
121
|
+
<input type="hidden" name="suite" value={key} />
|
|
122
|
+
<input type="hidden" name="case" value={next.id} />
|
|
123
|
+
<Tip control term="skip" id="rate-skip">
|
|
124
|
+
<Submit variant="quiet">Skip</Submit>
|
|
125
|
+
</Tip>
|
|
126
|
+
</form>
|
|
127
|
+
</Card>
|
|
128
|
+
) : (
|
|
129
|
+
<Card className="space-y-2">
|
|
130
|
+
<h2 className="font-semibold">Nothing left for you to rate</h2>
|
|
131
|
+
<p className="readable text-sm text-muted">
|
|
132
|
+
You've rated or skipped every case in this suite.
|
|
133
|
+
{queue.skipped > 0 &&
|
|
134
|
+
" Cases you skipped are still in the answer key, where you can write their answers."}
|
|
135
|
+
</p>
|
|
136
|
+
<Link href={evalsPath(app, key)} className={`text-sm ${LINK}`}>
|
|
137
|
+
Back to the answer key
|
|
138
|
+
</Link>
|
|
139
|
+
</Card>
|
|
140
|
+
)}
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
}
|