@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.
Files changed (241) hide show
  1. package/README.md +1 -2
  2. package/dist/ai-sdk/decide.d.ts +35 -0
  3. package/dist/ai-sdk/decide.js +36 -0
  4. package/dist/ai-sdk/decide.js.map +1 -0
  5. package/dist/ai-sdk/hash.d.ts +50 -0
  6. package/dist/ai-sdk/hash.js +59 -0
  7. package/dist/ai-sdk/hash.js.map +1 -0
  8. package/dist/ai-sdk/index.d.ts +15 -0
  9. package/dist/ai-sdk/index.js +16 -0
  10. package/dist/ai-sdk/index.js.map +1 -0
  11. package/dist/ai-sdk/judge.d.ts +69 -0
  12. package/dist/ai-sdk/judge.js +105 -0
  13. package/dist/ai-sdk/judge.js.map +1 -0
  14. package/dist/ai-sdk/usage.d.ts +18 -0
  15. package/dist/ai-sdk/usage.js +19 -0
  16. package/dist/ai-sdk/usage.js.map +1 -0
  17. package/dist/board.d.ts +5 -0
  18. package/dist/cli/addPages.d.ts +6 -1
  19. package/dist/cli/addPages.js +14 -8
  20. package/dist/cli/addPages.js.map +1 -1
  21. package/dist/cli/main.d.ts +19 -5
  22. package/dist/cli/main.js +100 -4
  23. package/dist/cli/main.js.map +1 -1
  24. package/dist/cli/migration.d.ts +95 -0
  25. package/dist/cli/migration.js +247 -0
  26. package/dist/cli/migration.js.map +1 -0
  27. package/dist/feedback.d.ts +1 -1
  28. package/dist/glossary.d.ts +8 -1
  29. package/dist/glossary.js +8 -1
  30. package/dist/glossary.js.map +1 -1
  31. package/dist/inInstructions.d.ts +1 -1
  32. package/dist/inInstructions.js +1 -1
  33. package/dist/next/RefreshWhile.d.ts +11 -0
  34. package/dist/next/RefreshWhile.js +28 -0
  35. package/dist/next/RefreshWhile.js.map +1 -0
  36. package/dist/next/actions.d.ts +14 -0
  37. package/dist/next/actions.js +332 -0
  38. package/dist/next/actions.js.map +1 -0
  39. package/dist/next/components.d.ts +9 -0
  40. package/dist/next/components.js +27 -0
  41. package/dist/next/components.js.map +1 -0
  42. package/dist/next/cron.d.ts +9 -0
  43. package/dist/next/cron.js +17 -0
  44. package/dist/next/cron.js.map +1 -0
  45. package/dist/next/index.d.ts +15 -0
  46. package/dist/next/index.js +16 -0
  47. package/dist/next/index.js.map +1 -0
  48. package/dist/next/pages.d.ts +70 -0
  49. package/dist/next/pages.js +77 -0
  50. package/dist/next/pages.js.map +1 -0
  51. package/dist/next/route.d.ts +19 -0
  52. package/dist/next/route.js +31 -0
  53. package/dist/next/route.js.map +1 -0
  54. package/dist/next/weekly.d.ts +20 -0
  55. package/dist/next/weekly.js +55 -0
  56. package/dist/next/weekly.js.map +1 -0
  57. package/dist/next/wiring.d.ts +19 -0
  58. package/dist/next/wiring.js +2 -0
  59. package/dist/next/wiring.js.map +1 -0
  60. package/dist/prisma/contracts.d.ts +74 -0
  61. package/dist/prisma/contracts.js +178 -0
  62. package/dist/prisma/contracts.js.map +1 -0
  63. package/dist/prisma/index.d.ts +423 -0
  64. package/dist/prisma/index.js +622 -0
  65. package/dist/prisma/index.js.map +1 -0
  66. package/dist/prisma/mapping.d.ts +63 -0
  67. package/dist/prisma/mapping.js +111 -0
  68. package/dist/prisma/mapping.js.map +1 -0
  69. package/dist/prisma/moveIn.d.ts +106 -0
  70. package/dist/prisma/moveIn.js +299 -0
  71. package/dist/prisma/moveIn.js.map +1 -0
  72. package/dist/prune.d.ts +45 -0
  73. package/dist/prune.js +32 -0
  74. package/dist/prune.js.map +1 -1
  75. package/dist/react/AddCase.d.ts +10 -0
  76. package/dist/react/AddCase.js +19 -0
  77. package/dist/react/AddCase.js.map +1 -0
  78. package/dist/react/AnswerKey.d.ts +22 -0
  79. package/dist/react/AnswerKey.js +83 -0
  80. package/dist/react/AnswerKey.js.map +1 -0
  81. package/dist/react/CaseMenu.d.ts +17 -0
  82. package/dist/react/CaseMenu.js +41 -0
  83. package/dist/react/CaseMenu.js.map +1 -0
  84. package/dist/react/CompareView.d.ts +14 -0
  85. package/dist/react/CompareView.js +51 -0
  86. package/dist/react/CompareView.js.map +1 -0
  87. package/dist/react/ConfirmAnswer.d.ts +13 -0
  88. package/dist/react/ConfirmAnswer.js +27 -0
  89. package/dist/react/ConfirmAnswer.js.map +1 -0
  90. package/dist/react/DisagreementChip.d.ts +10 -0
  91. package/dist/react/DisagreementChip.js +21 -0
  92. package/dist/react/DisagreementChip.js.map +1 -0
  93. package/dist/react/FeedbackView.d.ts +10 -0
  94. package/dist/react/FeedbackView.js +26 -0
  95. package/dist/react/FeedbackView.js.map +1 -0
  96. package/dist/react/Fields.d.ts +32 -0
  97. package/dist/react/Fields.js +33 -0
  98. package/dist/react/Fields.js.map +1 -0
  99. package/dist/react/HubSections.d.ts +78 -0
  100. package/dist/react/HubSections.js +124 -0
  101. package/dist/react/HubSections.js.map +1 -0
  102. package/dist/react/ModelMenu.d.ts +16 -0
  103. package/dist/react/ModelMenu.js +38 -0
  104. package/dist/react/ModelMenu.js.map +1 -0
  105. package/dist/react/RateView.d.ts +18 -0
  106. package/dist/react/RateView.js +30 -0
  107. package/dist/react/RateView.js.map +1 -0
  108. package/dist/react/ReadableOutput.d.ts +3 -0
  109. package/dist/react/ReadableOutput.js +50 -0
  110. package/dist/react/ReadableOutput.js.map +1 -0
  111. package/dist/react/RollBack.d.ts +17 -0
  112. package/dist/react/RollBack.js +26 -0
  113. package/dist/react/RollBack.js.map +1 -0
  114. package/dist/react/RunView.d.ts +9 -0
  115. package/dist/react/RunView.js +41 -0
  116. package/dist/react/RunView.js.map +1 -0
  117. package/dist/react/SettingsHistory.d.ts +33 -0
  118. package/dist/react/SettingsHistory.js +79 -0
  119. package/dist/react/SettingsHistory.js.map +1 -0
  120. package/dist/react/SideBySideView.d.ts +14 -0
  121. package/dist/react/SideBySideView.js +67 -0
  122. package/dist/react/SideBySideView.js.map +1 -0
  123. package/dist/react/SuiteSections.d.ts +111 -0
  124. package/dist/react/SuiteSections.js +224 -0
  125. package/dist/react/SuiteSections.js.map +1 -0
  126. package/dist/react/Tabs.d.ts +15 -0
  127. package/dist/react/Tabs.js +18 -0
  128. package/dist/react/Tabs.js.map +1 -0
  129. package/dist/react/Thumbs.d.ts +13 -0
  130. package/dist/react/Thumbs.js +54 -0
  131. package/dist/react/Thumbs.js.map +1 -0
  132. package/dist/react/WeeklyCheck.d.ts +11 -0
  133. package/dist/react/WeeklyCheck.js +19 -0
  134. package/dist/react/WeeklyCheck.js.map +1 -0
  135. package/dist/react/app.d.ts +118 -0
  136. package/dist/react/app.js +87 -0
  137. package/dist/react/app.js.map +1 -0
  138. package/dist/react/format.d.ts +27 -0
  139. package/dist/react/format.js +38 -0
  140. package/dist/react/format.js.map +1 -0
  141. package/dist/react/index.d.ts +31 -0
  142. package/dist/react/index.js +32 -0
  143. package/dist/react/index.js.map +1 -0
  144. package/dist/react/pieces.d.ts +191 -0
  145. package/dist/react/pieces.js +191 -0
  146. package/dist/react/pieces.js.map +1 -0
  147. package/dist/readCheck.d.ts +1 -1
  148. package/dist/runner.d.ts +62 -2
  149. package/dist/runner.js +123 -3
  150. package/dist/runner.js.map +1 -1
  151. package/dist/settings.d.ts +1 -1
  152. package/dist/store.d.ts +1 -1
  153. package/dist/suggest.d.ts +1 -1
  154. package/dist/suggest.js +7 -7
  155. package/dist/suggest.js.map +1 -1
  156. package/dist/suiteContract.d.ts +3 -3
  157. package/dist/suiteContract.js +20 -16
  158. package/dist/suiteContract.js.map +1 -1
  159. package/dist/testing.d.ts +2 -2
  160. package/dist/testing.js +1 -1
  161. package/dist/types.js +1 -1
  162. package/dist/types.js.map +1 -1
  163. package/package.json +56 -6
  164. package/schema/evalkeeper.prisma +196 -0
  165. package/src/ai-sdk/decide.ts +57 -0
  166. package/src/ai-sdk/hash.ts +74 -0
  167. package/src/ai-sdk/index.ts +15 -0
  168. package/src/ai-sdk/judge.ts +163 -0
  169. package/src/ai-sdk/usage.ts +31 -0
  170. package/src/board.ts +5 -0
  171. package/src/cli/addPages.ts +15 -7
  172. package/src/cli/main.ts +135 -9
  173. package/src/cli/migration.ts +349 -0
  174. package/src/feedback.ts +1 -1
  175. package/src/glossary.ts +16 -2
  176. package/src/inInstructions.ts +1 -1
  177. package/{templates/components/evalkeeper → src/next}/RefreshWhile.tsx +2 -2
  178. package/src/next/actions.ts +389 -0
  179. package/src/next/components.ts +31 -0
  180. package/{templates/lib/evalkeeper/cronAuth.ts → src/next/cron.ts} +3 -0
  181. package/src/next/index.ts +15 -0
  182. package/src/next/pages.tsx +106 -0
  183. package/src/next/route.ts +35 -0
  184. package/src/next/weekly.ts +70 -0
  185. package/src/next/wiring.ts +18 -0
  186. package/src/prisma/contracts.ts +249 -0
  187. package/src/prisma/index.ts +1169 -0
  188. package/src/prisma/mapping.ts +147 -0
  189. package/src/prisma/moveIn.ts +502 -0
  190. package/src/prune.ts +77 -0
  191. package/{templates/components/evalkeeper → src/react}/AddCase.tsx +6 -6
  192. package/{templates/components/evalkeeper → src/react}/AnswerKey.tsx +92 -61
  193. package/{templates/components/evalkeeper → src/react}/CaseMenu.tsx +9 -8
  194. package/src/react/CompareView.tsx +270 -0
  195. package/{templates/components/evalkeeper → src/react}/ConfirmAnswer.tsx +6 -3
  196. package/{templates/components/evalkeeper → src/react}/DisagreementChip.tsx +2 -3
  197. package/src/react/FeedbackView.tsx +230 -0
  198. package/{templates/components/evalkeeper → src/react}/Fields.tsx +6 -6
  199. package/src/react/HubSections.tsx +446 -0
  200. package/src/react/ModelMenu.tsx +89 -0
  201. package/src/react/RateView.tsx +143 -0
  202. package/{templates/components/evalkeeper → src/react}/ReadableOutput.tsx +1 -1
  203. package/{templates/components/evalkeeper → src/react}/RollBack.tsx +9 -10
  204. package/src/react/RunView.tsx +151 -0
  205. package/{templates/components/evalkeeper → src/react}/SettingsHistory.tsx +16 -9
  206. package/src/react/SideBySideView.tsx +307 -0
  207. package/src/react/SuiteSections.tsx +925 -0
  208. package/src/react/Tabs.tsx +61 -0
  209. package/{templates/components/evalkeeper → src/react}/Thumbs.tsx +7 -6
  210. package/{templates/components/evalkeeper → src/react}/WeeklyCheck.tsx +31 -20
  211. package/src/react/app.ts +173 -0
  212. package/src/react/format.ts +45 -0
  213. package/src/react/index.ts +31 -0
  214. package/src/react/pieces.tsx +412 -0
  215. package/src/readCheck.ts +1 -1
  216. package/src/runner.ts +167 -3
  217. package/src/settings.ts +1 -1
  218. package/src/store.ts +1 -1
  219. package/src/suggest.ts +7 -7
  220. package/src/suiteContract.ts +35 -28
  221. package/src/testing.ts +2 -2
  222. package/src/types.ts +2 -2
  223. package/starter/index.ts +22 -8
  224. package/templates/app/api/cron/evals-weekly/route.ts +5 -15
  225. package/templates/app/evals/[suite]/compare/page.tsx +6 -383
  226. package/templates/app/evals/[suite]/page.tsx +7 -685
  227. package/templates/app/evals/[suite]/rate/page.tsx +6 -151
  228. package/templates/app/evals/[suite]/runs/[runId]/page.tsx +6 -174
  229. package/templates/app/evals/[suite]/side-by-side/page.tsx +6 -318
  230. package/templates/app/evals/feedback/page.tsx +6 -227
  231. package/templates/app/evals/layout.tsx +10 -0
  232. package/templates/app/evals/page.tsx +7 -397
  233. package/templates/lib/evalkeeper/actions.ts +34 -317
  234. package/templates/lib/evalkeeper/appComponents.tsx +21 -0
  235. package/templates/lib/evalkeeper/evals.ts +14 -0
  236. package/templates/lib/evalkeeper/paths.ts +2 -7
  237. package/templates/components/evalkeeper/Submit.tsx +0 -67
  238. package/templates/components/evalkeeper/Tip.tsx +0 -98
  239. package/templates/components/evalkeeper/ui.tsx +0 -105
  240. package/templates/lib/evalkeeper/time.ts +0 -4
  241. package/templates/lib/evalkeeper/weekly.ts +0 -74
@@ -1,687 +1,9 @@
1
- import type { Metadata } from "next";
2
- import Link from "next/link";
3
- import { notFound } from "next/navigation";
4
- import {
5
- FAVOR_TEXT,
6
- attackMistakes,
7
- attacksFrom,
8
- checkBar,
9
- isInjectionSuite,
10
- meanCalibrationError,
11
- money,
12
- probabilityQuality,
13
- perAnswer,
14
- retiresLabel,
15
- seconds,
16
- seriousMistakes,
17
- suggest,
18
- } from "@crowandraven/evalkeeper";
19
- import { AnswerKey } from "@/components/evalkeeper/AnswerKey";
20
- import { RefreshWhile } from "@/components/evalkeeper/RefreshWhile";
21
- import { IconSubmit, Spinner, Submit } from "@/components/evalkeeper/Submit";
22
- import { RotateCw } from "lucide-react";
23
- import { BackLink, Card, Chip, Score, pct } from "@/components/evalkeeper/ui";
24
- import {
25
- answerEditors,
26
- MODELS,
27
- requireAdmin,
28
- runner,
29
- settings,
30
- SUITE_BY_KEY,
31
- } from "@/lib/evalkeeper";
32
- import { SettingsHistory } from "@/components/evalkeeper/SettingsHistory";
33
- import {
34
- makeFallback,
35
- makeLive,
36
- rescore,
37
- testAll,
38
- testModel,
39
- useSuggestion,
40
- } from "@/lib/evalkeeper/actions";
41
- import { InfoTip, Tip } from "@/components/evalkeeper/Tip";
42
- import { EVALS_BASE, evalsPath } from "@/lib/evalkeeper/paths";
1
+ import { pages } from "@/lib/evalkeeper/evals";
43
2
 
44
- export const dynamic = "force-dynamic";
45
-
46
- export async function generateMetadata({
47
- params,
48
- }: {
49
- params: Promise<{ suite: string }>;
50
- }): Promise<Metadata> {
51
- const { suite } = await params;
52
- return { title: `Evals: ${SUITE_BY_KEY[suite]?.label ?? "Evals"}` };
53
- }
54
-
55
- /** A share as a whole percent, or a dash when there's nothing to show. */
56
- const asPct = (x: number | null) => (x === null ? "—" : pct(x));
57
-
58
- const VS: Record<string, string> = {
59
- BETTER: "More accurate",
60
- SAME: "About as accurate",
61
- WORSE: "Less accurate",
62
- TOO_FEW: "Too few cases to tell",
63
- };
64
-
65
- export default async function SuitePage({
66
- params,
67
- }: {
68
- params: Promise<{ suite: string }>;
69
- }) {
70
- await requireAdmin();
71
- const { suite: key } = await params;
72
- const operation = SUITE_BY_KEY[key]?.operation;
73
- if (!operation) notFound();
74
- // The board and the settings load together: on a remote database each
75
- // waits on round trips, so one after the other doubles the wait.
76
- const [b, attackBoards, [history, liveSettings], inInstructions] =
77
- await Promise.all([
78
- runner.board(key),
79
- // Injection suites that attack this feature: their results count here.
80
- runner.attackBoards(key),
81
- // Records a deploy if the instructions changed under the live
82
- // settings, before reading them.
83
- settings
84
- .syncPrompt(operation)
85
- .then(() =>
86
- Promise.all([
87
- settings.history(operation),
88
- settings.current(operation),
89
- ]),
90
- ),
91
- runner.casesInInstructions(key),
92
- ]);
93
- const { suite, rows } = b;
94
- const attacks = attacksFrom(attackBoards);
95
- // An injection suite's models are chosen on its base suite's page.
96
- const choosesHere = !isInjectionSuite(suite);
97
- const s = choosesHere
98
- ? suggest(rows, suite.checks, suite.priority, MODELS, { attacks })
99
- : null;
100
- const testing =
101
- rows.some((r) => r.testing) ||
102
- attackBoards.some((a) => a.rows.some((r) => r.testing));
103
- // What testing each model would cost now, counting answers it would reuse.
104
- const estimates = new Map(
105
- await Promise.all(
106
- rows.map(
107
- async (r) =>
108
- [
109
- r.key,
110
- await runner.estimateRun(key, r.model, "ALL", 1, {
111
- reasoningEffort: r.effort,
112
- }),
113
- ] as const,
114
- ),
115
- ),
116
- );
117
- // What testing each untested model against the attacks would cost.
118
- const attackEstimates = new Map(
119
- await Promise.all(
120
- attackBoards.flatMap((a) =>
121
- rows
122
- .filter((r) => !r.variant)
123
- .map(
124
- async (r) =>
125
- [
126
- `${a.suite.key}|${r.key}`,
127
- await runner.estimateRun(a.suite.key, r.model, "ALL", 1),
128
- ] as const,
129
- ),
130
- ),
131
- ),
132
- );
133
- const live = rows.find((r) => r.live);
134
-
135
- return (
136
- <div className="space-y-8">
137
- <RefreshWhile active={testing} />
138
- <div className="space-y-2">
139
- <BackLink href={EVALS_BASE}>Evals</BackLink>
140
- <h1 className="text-2xl font-semibold">{suite.label}</h1>
141
- <p className="readable text-muted">{suite.description}</p>
142
- <p className="readable text-sm text-muted">
143
- Priority: {FAVOR_TEXT[suite.priority.favor]}.
144
- <InfoTip term="priority" />
145
- </p>
146
- </div>
147
-
148
- {isInjectionSuite(suite) && (
149
- <Card className="space-y-2">
150
- <h2 className="font-semibold">
151
- Models are chosen on {suite.base.label}
152
- <InfoTip term="attackResults" />
153
- </h2>
154
- <p className="readable text-sm text-muted">
155
- This suite tests the same feature as {suite.base.label}, so one
156
- choice of model serves both. Its results show there as Under attack,
157
- and the suggestion there never picks a model with more serious
158
- mistakes under attack than live.
159
- </p>
160
- <Link
161
- href={evalsPath(suite.base.key)}
162
- className="inline-block text-sm text-accent hover:underline"
163
- >
164
- Choose models on {suite.base.label}
165
- </Link>
166
- </Card>
167
- )}
168
-
169
- {/* Shown when nothing would change too, so a higher score that
170
- isn't enough to switch for comes with its reason. */}
171
- {s && (
172
- <Card className="space-y-3">
173
- <div className="flex flex-wrap items-start justify-between gap-3">
174
- <h2 className="font-semibold">
175
- {s.same ? "No change suggested" : "Suggested"}
176
- <InfoTip term="suggestion" />
177
- </h2>
178
- {/* Retesting live changes nothing until the fallback would. */}
179
- {!s.same &&
180
- !(s.retestLive && (!s.fallback || s.fallback.fallback)) && (
181
- <form action={useSuggestion}>
182
- <input type="hidden" name="suite" value={key} />
183
- <Submit>Use these</Submit>
184
- </form>
185
- )}
186
- </div>
187
- {!s.same && (
188
- <p>
189
- Live: <strong>{s.live.label}</strong>
190
- {s.fallback && (
191
- <>
192
- {" "}
193
- · Fallback: <strong>{s.fallback.label}</strong>
194
- </>
195
- )}
196
- </p>
197
- )}
198
- <ul className="readable list-disc space-y-1 pl-5 text-sm text-muted">
199
- {s.reasons.map((r) => (
200
- <li key={r}>{r}</li>
201
- ))}
202
- </ul>
203
- </Card>
204
- )}
3
+ // Written by `npx @crowandraven/evalkeeper add pages`. To arrange
4
+ // a suite's page your own way, replace this file with the sections ("Arrange
5
+ // your own page" in the guide).
205
6
 
206
- {inInstructions.length > 0 && (
207
- <Card className="space-y-2">
208
- <h2 className="font-semibold text-warn">
209
- Cases in the instructions
210
- <InfoTip term="inInstructions" />
211
- </h2>
212
- <p className="readable text-sm text-muted">
213
- These cases&apos; words appear in what the model is told, so a test
214
- grades it on answers it was handed. Take the example out of the
215
- instructions, or rewrite or retire the case.
216
- </p>
217
- <ul className="readable list-disc space-y-1 pl-5 text-sm">
218
- {inInstructions.map((c) => (
219
- <li key={c.caseId}>
220
- {c.title}: “{c.found}”
221
- </li>
222
- ))}
223
- </ul>
224
- </Card>
225
- )}
226
-
227
- <section className="space-y-3">
228
- <div className="flex items-center justify-between gap-4">
229
- <h2 className="text-lg font-semibold">Models</h2>
230
- <div className="flex items-center gap-4">
231
- <Link
232
- href={evalsPath(key, "compare")}
233
- className="text-sm text-muted hover:text-ink"
234
- >
235
- Compare two tests
236
- </Link>
237
- <form action={testAll}>
238
- <input type="hidden" name="suite" value={key} />
239
- <Submit variant="quiet">Test every model</Submit>
240
- </form>
241
- </div>
242
- </div>
243
- <Card className="overflow-x-auto p-0 lg:overflow-visible">
244
- <table className="w-full text-sm">
245
- <thead className="text-left text-muted">
246
- <tr className="border-b border-line">
247
- <th className="p-3 font-normal">Model</th>
248
- <th className="p-3 font-normal">
249
- <Tip term="score" side="bottom">
250
- Score
251
- </Tip>
252
- </th>
253
- <th className="p-3 font-normal">
254
- <Tip term="seriousMistakes" side="bottom">
255
- Serious mistakes
256
- </Tip>
257
- </th>
258
- {attackBoards.length > 0 && (
259
- <th className="p-3 font-normal">
260
- <Tip term="underAttack" side="bottom">
261
- Under attack
262
- </Tip>
263
- </th>
264
- )}
265
- <th className="p-3 font-normal">
266
- <Tip term="time" side="bottom" align="end">
267
- Time
268
- </Tip>
269
- </th>
270
- {suite.decisions && (
271
- <>
272
- <th className="p-3 font-normal">
273
- <Tip term="probabilityQuality" side="bottom">
274
- Probability quality
275
- </Tip>
276
- </th>
277
- <th className="p-3 font-normal">
278
- <Tip term="calibrationError" side="bottom" align="end">
279
- Calibration error
280
- </Tip>
281
- </th>
282
- </>
283
- )}
284
- <th className="p-3 font-normal">
285
- <Tip term="cost" side="bottom" align="end">
286
- Cost
287
- </Tip>
288
- </th>
289
- <th className="p-3 font-normal">
290
- <Tip term="againstLive" side="bottom" align="end">
291
- Against live
292
- </Tip>
293
- </th>
294
- <th className="p-3" />
295
- </tr>
296
- </thead>
297
- <tbody>
298
- {rows.map((r) => (
299
- <tr key={r.key} className="border-b border-line last:border-0">
300
- <td className="p-3">
301
- <div className="flex flex-wrap items-center gap-2">
302
- <span
303
- className={r.live ? "font-semibold" : "font-medium"}
304
- >
305
- {r.label}
306
- </span>
307
- {r.live && (
308
- <Tip term="live" side="bottom" id={`live-${r.key}`}>
309
- <Chip tone="live">Live</Chip>
310
- </Tip>
311
- )}
312
- {r.fallback && (
313
- <Tip
314
- term="fallback"
315
- side="bottom"
316
- id={`fallback-${r.key}`}
317
- >
318
- <Chip tone="fallback">Fallback</Chip>
319
- </Tip>
320
- )}
321
- {retiresLabel(MODELS, r.model) && (
322
- <Tip
323
- term="retiring"
324
- side="bottom"
325
- id={`retiring-${r.key}`}
326
- >
327
- <Chip tone="warn">
328
- Retires {retiresLabel(MODELS, r.model)}
329
- </Chip>
330
- </Tip>
331
- )}
332
- {suite.decisions && MODELS[r.model]?.decisions && (
333
- <Tip
334
- term={
335
- MODELS[r.model]?.decisions === "native"
336
- ? "nativeProbabilities"
337
- : "promptedProbabilities"
338
- }
339
- side="bottom"
340
- id={`decisions-${r.key}`}
341
- >
342
- <Chip tone="neutral">
343
- {MODELS[r.model]?.decisions === "native"
344
- ? "Native probabilities"
345
- : "Prompted"}
346
- </Chip>
347
- </Tip>
348
- )}
349
- {r.test?.stale && (
350
- <Tip
351
- term="outOfDate"
352
- side="bottom"
353
- id={`stale-${r.key}`}
354
- >
355
- <Chip tone="neutral">Out of date</Chip>
356
- </Tip>
357
- )}
358
- </div>
359
- </td>
360
- <td className="p-3">
361
- {r.testing ? (
362
- <span
363
- role="status"
364
- title="Testing"
365
- className="inline-flex text-accent"
366
- >
367
- <Spinner />
368
- </span>
369
- ) : r.test ? (
370
- <Link href={evalsPath(key, "runs", r.test.runId)}>
371
- <Score right={r.test.right} total={r.test.total} />
372
- </Link>
373
- ) : (
374
- <span className="text-muted">
375
- {r.failed ?? "Not tested"}
376
- </span>
377
- )}
378
- </td>
379
- <td className="p-3 tabular-nums">
380
- {r.test ? seriousMistakes(r, suite.checks) : "—"}
381
- </td>
382
- {attackBoards.length > 0 && (
383
- <td className="p-3">
384
- <div className="flex flex-col gap-1">
385
- {attackBoards.map((a) => (
386
- <UnderAttack
387
- key={a.suite.key}
388
- attackSuite={a.suite.key}
389
- attackLabel={a.suite.label}
390
- row={a.rows.find((x) => x.key === r.key)}
391
- mistakes={attackMistakes(r.key, attacksFrom([a]))}
392
- model={r.model}
393
- variant={r.variant}
394
- estimate={attackEstimates.get(
395
- `${a.suite.key}|${r.key}`,
396
- )}
397
- />
398
- ))}
399
- </div>
400
- </td>
401
- )}
402
- <td className="p-3 tabular-nums">
403
- {r.test ? seconds(r.test.avgMs) : "—"}
404
- </td>
405
- {suite.decisions && (
406
- <>
407
- <td className="p-3 tabular-nums">
408
- {asPct(
409
- r.test ? probabilityQuality(r.test.measures) : null,
410
- )}
411
- </td>
412
- <td className="p-3 tabular-nums">
413
- {asPct(
414
- r.test ? meanCalibrationError(r.test.measures) : null,
415
- )}
416
- </td>
417
- </>
418
- )}
419
- <td className="p-3 tabular-nums">
420
- {r.test ? perAnswer(r.test.costPerAnswer) : "—"}
421
- </td>
422
- <td className="p-3">
423
- {r.vsLive && live?.test && r.test && !r.live ? (
424
- <Link
425
- href={`${evalsPath(key, "compare")}?${new URLSearchParams({ a: live.test.runId, b: r.test.runId })}`}
426
- >
427
- {VS[r.vsLive]}
428
- </Link>
429
- ) : r.vsLive ? (
430
- VS[r.vsLive]
431
- ) : (
432
- "—"
433
- )}
434
- </td>
435
- <td className="p-3">
436
- <div className="flex flex-col items-end gap-0.5">
437
- <div className="flex justify-end gap-2">
438
- {choosesHere && r.canMakeFallback && (
439
- <form action={makeFallback}>
440
- <input type="hidden" name="suite" value={key} />
441
- <input type="hidden" name="model" value={r.model} />
442
- <Submit variant="quiet">Make fallback</Submit>
443
- </form>
444
- )}
445
- {choosesHere && !r.live && r.canMakeLive && (
446
- <form action={makeLive}>
447
- <input type="hidden" name="suite" value={key} />
448
- <input type="hidden" name="model" value={r.model} />
449
- <Submit variant="quiet">Make live</Submit>
450
- </form>
451
- )}
452
- <form action={testModel}>
453
- <input type="hidden" name="suite" value={key} />
454
- <input type="hidden" name="model" value={r.model} />
455
- <Tip
456
- control
457
- id={`test-${r.key}`}
458
- text={
459
- r.test
460
- ? "Test this model again on every case in use."
461
- : "Test this model on every case in use."
462
- }
463
- side="bottom"
464
- align="end"
465
- >
466
- <IconSubmit
467
- label="Test"
468
- icon={
469
- <RotateCw aria-hidden className="h-4 w-4" />
470
- }
471
- />
472
- </Tip>
473
- </form>
474
- </div>
475
- <EstimateNote
476
- id={r.key}
477
- estimate={estimates.get(r.key)}
478
- />
479
- {r.test && !r.test.stale && r.test.failedAnswers > 0 && (
480
- <span className="text-right text-xs text-muted">
481
- {r.test.failedAnswers}{" "}
482
- {r.test.failedAnswers === 1 ? "answer" : "answers"}{" "}
483
- failed on its last test
484
- </span>
485
- )}
486
- </div>
487
- </td>
488
- </tr>
489
- ))}
490
- </tbody>
491
- </table>
492
- </Card>
493
- </section>
494
-
495
- {choosesHere && (
496
- <SettingsHistory
497
- suite={key}
498
- entries={history}
499
- liveId={liveSettings.version?.id ?? null}
500
- label={(m) => MODELS[m]?.label ?? m}
501
- defaults={liveSettings.settings}
502
- />
503
- )}
504
-
505
- <section className="space-y-3">
506
- <h2 className="text-lg font-semibold">
507
- Checks
508
- <InfoTip term="checks" />
509
- </h2>
510
- <div className="grid gap-3 md:grid-cols-2">
511
- {suite.checks.map((c) => {
512
- const rate = live?.test?.byCheck[c.key];
513
- return (
514
- <Card key={c.key} className="space-y-1">
515
- <div className="flex justify-between gap-4">
516
- <h3 className="font-medium">{c.label}</h3>
517
- <Tip term={c.severity} id={`severity-${c.key}`}>
518
- <Chip
519
- tone={c.severity === "serious" ? "serious" : "neutral"}
520
- >
521
- {c.severity}
522
- </Chip>
523
- </Tip>
524
- </div>
525
- <p className="readable text-sm text-muted">{c.description}</p>
526
- <p className="text-sm">
527
- {rate && rate.n > 0 && (
528
- <>
529
- Live:{" "}
530
- <span
531
- className={
532
- rate.passed / rate.n >= checkBar(c)
533
- ? "text-good"
534
- : "text-warn"
535
- }
536
- >
537
- {pct(rate.passed / rate.n)}
538
- </span>{" "}
539
- ({rate.passed}/{rate.n}) ·{" "}
540
- </>
541
- )}
542
- <Tip term="bar" id={`bar-${c.key}`}>
543
- <span className="text-muted">Bar: {pct(checkBar(c))}</span>
544
- </Tip>
545
- </p>
546
- </Card>
547
- );
548
- })}
549
- </div>
550
- </section>
551
-
552
- {/* The weekly check links here to review drafts. */}
553
- <section id="answer-key" className="scroll-mt-4 space-y-3">
554
- <AnswerKey
555
- suite={suite}
556
- rows={rows}
557
- heading={
558
- <h2 className="text-lg font-semibold">
559
- Answer key ({b.cases} cases in use)
560
- <InfoTip term="answerKey" />
561
- </h2>
562
- }
563
- tools={
564
- <>
565
- {suite.caseKind === "imported" &&
566
- (suite.labelFromForm || answerEditors[key]) && (
567
- <Tip control term="rateBlind" side="bottom" align="end">
568
- <Link
569
- href={evalsPath(key, "rate")}
570
- 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"
571
- >
572
- Rate blind
573
- </Link>
574
- </Tip>
575
- )}
576
- <form action={rescore}>
577
- <input type="hidden" name="suite" value={key} />
578
- <Tip control term="rescore" side="bottom" align="end">
579
- <IconSubmit
580
- label="Rescore tests"
581
- icon={<RotateCw aria-hidden className="h-4 w-4" />}
582
- />
583
- </Tip>
584
- </form>
585
- </>
586
- }
587
- />
588
- </section>
589
- </div>
590
- );
591
- }
592
-
593
- /** "Free: all 16 reused" or "~$0.03, 4 of 16 reused", under a model's buttons. */
594
- function EstimateNote({
595
- id,
596
- estimate,
597
- }: {
598
- id: string;
599
- estimate:
600
- { answers: number; reused: number; costUsd: number | null } | undefined;
601
- }) {
602
- if (!estimate || estimate.answers === 0) return null;
603
- const { answers, reused, costUsd } = estimate;
604
- const text =
605
- reused === answers
606
- ? `Free: all ${answers} reused`
607
- : `${costUsd === null ? "Cost unknown" : `~${money(costUsd)}`}${reused ? `, ${reused} of ${answers} reused` : ""}`;
608
- return (
609
- <Tip
610
- text="What testing this model costs now. Answers an identical request gave in the last 7 days are reused for free."
611
- id={`estimate-${id}`}
612
- side="bottom"
613
- align="end"
614
- >
615
- <span className="whitespace-nowrap text-xs text-muted">{text}</span>
616
- </Tip>
617
- );
618
- }
619
-
620
- /**
621
- * A model's serious mistakes on one injection suite, linked to that test,
622
- * or a button to test it there. Out of date and failed tests say so: the
623
- * suggestion counts only current, complete ones.
624
- */
625
- function UnderAttack({
626
- attackSuite,
627
- attackLabel,
628
- row,
629
- mistakes,
630
- model,
631
- variant,
632
- estimate,
633
- }: {
634
- attackSuite: string;
635
- attackLabel: string;
636
- row:
637
- | {
638
- key: string;
639
- testing: boolean;
640
- test: { runId: string; stale: boolean; failedAnswers: number } | null;
641
- }
642
- | undefined;
643
- mistakes: number | null;
644
- model: string;
645
- variant: boolean;
646
- estimate:
647
- { answers: number; reused: number; costUsd: number | null } | undefined;
648
- }) {
649
- if (row?.testing)
650
- return (
651
- <span role="status" title="Testing" className="inline-flex text-accent">
652
- <Spinner />
653
- </span>
654
- );
655
- if (row?.test)
656
- return (
657
- <Link
658
- href={evalsPath(attackSuite, "runs", row.test.runId)}
659
- title={attackLabel}
660
- className="tabular-nums"
661
- >
662
- {mistakes ?? "—"}
663
- {row.test.stale
664
- ? " · out of date"
665
- : row.test.failedAnswers
666
- ? " · answers failed"
667
- : ""}
668
- </Link>
669
- );
670
- // Settings rows are tested on the base suite only.
671
- if (variant) return <span className="text-muted">—</span>;
672
- return (
673
- <form action={testModel} className="flex flex-col items-start gap-0.5">
674
- <input type="hidden" name="suite" value={attackSuite} />
675
- <input type="hidden" name="model" value={model} />
676
- <Tip
677
- control
678
- id={`attack-${attackSuite}-${row?.key ?? model}`}
679
- text={`Test this model on ${attackLabel}, every attack case in use.`}
680
- side="bottom"
681
- >
682
- <Submit variant="quiet">Test attacks</Submit>
683
- </Tip>
684
- <EstimateNote id={`attack-${attackSuite}-${model}`} estimate={estimate} />
685
- </form>
686
- );
687
- }
7
+ export const dynamic = "force-dynamic";
8
+ export const generateMetadata = pages.suite.generateMetadata;
9
+ export default pages.suite.Page;