@crowandraven/evalkeeper 0.9.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 (246) 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 +9 -0
  29. package/dist/glossary.js +9 -0
  30. package/dist/glossary.js.map +1 -1
  31. package/dist/health.d.ts +4 -1
  32. package/dist/health.js +4 -2
  33. package/dist/health.js.map +1 -1
  34. package/dist/inInstructions.d.ts +1 -1
  35. package/dist/inInstructions.js +1 -1
  36. package/dist/next/RefreshWhile.d.ts +11 -0
  37. package/dist/next/RefreshWhile.js +28 -0
  38. package/dist/next/RefreshWhile.js.map +1 -0
  39. package/dist/next/actions.d.ts +14 -0
  40. package/dist/next/actions.js +332 -0
  41. package/dist/next/actions.js.map +1 -0
  42. package/dist/next/components.d.ts +9 -0
  43. package/dist/next/components.js +27 -0
  44. package/dist/next/components.js.map +1 -0
  45. package/dist/next/cron.d.ts +9 -0
  46. package/dist/next/cron.js +17 -0
  47. package/dist/next/cron.js.map +1 -0
  48. package/dist/next/index.d.ts +15 -0
  49. package/dist/next/index.js +16 -0
  50. package/dist/next/index.js.map +1 -0
  51. package/dist/next/pages.d.ts +70 -0
  52. package/dist/next/pages.js +77 -0
  53. package/dist/next/pages.js.map +1 -0
  54. package/dist/next/route.d.ts +19 -0
  55. package/dist/next/route.js +31 -0
  56. package/dist/next/route.js.map +1 -0
  57. package/dist/next/weekly.d.ts +20 -0
  58. package/dist/next/weekly.js +55 -0
  59. package/dist/next/weekly.js.map +1 -0
  60. package/dist/next/wiring.d.ts +19 -0
  61. package/dist/next/wiring.js +2 -0
  62. package/dist/next/wiring.js.map +1 -0
  63. package/dist/prisma/contracts.d.ts +74 -0
  64. package/dist/prisma/contracts.js +178 -0
  65. package/dist/prisma/contracts.js.map +1 -0
  66. package/dist/prisma/index.d.ts +423 -0
  67. package/dist/prisma/index.js +622 -0
  68. package/dist/prisma/index.js.map +1 -0
  69. package/dist/prisma/mapping.d.ts +63 -0
  70. package/dist/prisma/mapping.js +111 -0
  71. package/dist/prisma/mapping.js.map +1 -0
  72. package/dist/prisma/moveIn.d.ts +106 -0
  73. package/dist/prisma/moveIn.js +299 -0
  74. package/dist/prisma/moveIn.js.map +1 -0
  75. package/dist/prune.d.ts +45 -0
  76. package/dist/prune.js +32 -0
  77. package/dist/prune.js.map +1 -1
  78. package/dist/react/AddCase.d.ts +10 -0
  79. package/dist/react/AddCase.js +19 -0
  80. package/dist/react/AddCase.js.map +1 -0
  81. package/dist/react/AnswerKey.d.ts +22 -0
  82. package/dist/react/AnswerKey.js +83 -0
  83. package/dist/react/AnswerKey.js.map +1 -0
  84. package/dist/react/CaseMenu.d.ts +17 -0
  85. package/dist/react/CaseMenu.js +41 -0
  86. package/dist/react/CaseMenu.js.map +1 -0
  87. package/dist/react/CompareView.d.ts +14 -0
  88. package/dist/react/CompareView.js +51 -0
  89. package/dist/react/CompareView.js.map +1 -0
  90. package/dist/react/ConfirmAnswer.d.ts +13 -0
  91. package/dist/react/ConfirmAnswer.js +27 -0
  92. package/dist/react/ConfirmAnswer.js.map +1 -0
  93. package/dist/react/DisagreementChip.d.ts +10 -0
  94. package/dist/react/DisagreementChip.js +21 -0
  95. package/dist/react/DisagreementChip.js.map +1 -0
  96. package/dist/react/FeedbackView.d.ts +10 -0
  97. package/dist/react/FeedbackView.js +26 -0
  98. package/dist/react/FeedbackView.js.map +1 -0
  99. package/dist/react/Fields.d.ts +32 -0
  100. package/dist/react/Fields.js +33 -0
  101. package/dist/react/Fields.js.map +1 -0
  102. package/dist/react/HubSections.d.ts +78 -0
  103. package/dist/react/HubSections.js +124 -0
  104. package/dist/react/HubSections.js.map +1 -0
  105. package/dist/react/ModelMenu.d.ts +16 -0
  106. package/dist/react/ModelMenu.js +38 -0
  107. package/dist/react/ModelMenu.js.map +1 -0
  108. package/dist/react/RateView.d.ts +18 -0
  109. package/dist/react/RateView.js +30 -0
  110. package/dist/react/RateView.js.map +1 -0
  111. package/dist/react/ReadableOutput.d.ts +3 -0
  112. package/dist/react/ReadableOutput.js +50 -0
  113. package/dist/react/ReadableOutput.js.map +1 -0
  114. package/dist/react/RollBack.d.ts +17 -0
  115. package/dist/react/RollBack.js +26 -0
  116. package/dist/react/RollBack.js.map +1 -0
  117. package/dist/react/RunView.d.ts +9 -0
  118. package/dist/react/RunView.js +41 -0
  119. package/dist/react/RunView.js.map +1 -0
  120. package/dist/react/SettingsHistory.d.ts +33 -0
  121. package/dist/react/SettingsHistory.js +79 -0
  122. package/dist/react/SettingsHistory.js.map +1 -0
  123. package/dist/react/SideBySideView.d.ts +14 -0
  124. package/dist/react/SideBySideView.js +67 -0
  125. package/dist/react/SideBySideView.js.map +1 -0
  126. package/dist/react/SuiteSections.d.ts +111 -0
  127. package/dist/react/SuiteSections.js +224 -0
  128. package/dist/react/SuiteSections.js.map +1 -0
  129. package/dist/react/Tabs.d.ts +15 -0
  130. package/dist/react/Tabs.js +18 -0
  131. package/dist/react/Tabs.js.map +1 -0
  132. package/dist/react/Thumbs.d.ts +13 -0
  133. package/dist/react/Thumbs.js +54 -0
  134. package/dist/react/Thumbs.js.map +1 -0
  135. package/dist/react/WeeklyCheck.d.ts +11 -0
  136. package/dist/react/WeeklyCheck.js +19 -0
  137. package/dist/react/WeeklyCheck.js.map +1 -0
  138. package/dist/react/app.d.ts +118 -0
  139. package/dist/react/app.js +87 -0
  140. package/dist/react/app.js.map +1 -0
  141. package/dist/react/format.d.ts +27 -0
  142. package/dist/react/format.js +38 -0
  143. package/dist/react/format.js.map +1 -0
  144. package/dist/react/index.d.ts +31 -0
  145. package/dist/react/index.js +32 -0
  146. package/dist/react/index.js.map +1 -0
  147. package/dist/react/pieces.d.ts +191 -0
  148. package/dist/react/pieces.js +191 -0
  149. package/dist/react/pieces.js.map +1 -0
  150. package/dist/readCheck.d.ts +1 -1
  151. package/dist/runner.d.ts +76 -3
  152. package/dist/runner.js +133 -3
  153. package/dist/runner.js.map +1 -1
  154. package/dist/settings.d.ts +1 -1
  155. package/dist/store.d.ts +1 -1
  156. package/dist/suggest.d.ts +52 -2
  157. package/dist/suggest.js +101 -8
  158. package/dist/suggest.js.map +1 -1
  159. package/dist/suiteContract.d.ts +3 -3
  160. package/dist/suiteContract.js +20 -16
  161. package/dist/suiteContract.js.map +1 -1
  162. package/dist/testing.d.ts +2 -2
  163. package/dist/testing.js +1 -1
  164. package/dist/types.d.ts +79 -2
  165. package/dist/types.js +96 -12
  166. package/dist/types.js.map +1 -1
  167. package/package.json +56 -6
  168. package/schema/evalkeeper.prisma +196 -0
  169. package/src/ai-sdk/decide.ts +57 -0
  170. package/src/ai-sdk/hash.ts +74 -0
  171. package/src/ai-sdk/index.ts +15 -0
  172. package/src/ai-sdk/judge.ts +163 -0
  173. package/src/ai-sdk/usage.ts +31 -0
  174. package/src/board.ts +5 -0
  175. package/src/cli/addPages.ts +15 -7
  176. package/src/cli/main.ts +135 -9
  177. package/src/cli/migration.ts +349 -0
  178. package/src/feedback.ts +1 -1
  179. package/src/glossary.ts +18 -0
  180. package/src/health.ts +4 -2
  181. package/src/inInstructions.ts +1 -1
  182. package/{templates/components/evalkeeper → src/next}/RefreshWhile.tsx +2 -2
  183. package/src/next/actions.ts +389 -0
  184. package/src/next/components.ts +31 -0
  185. package/{templates/lib/evalkeeper/cronAuth.ts → src/next/cron.ts} +3 -0
  186. package/src/next/index.ts +15 -0
  187. package/src/next/pages.tsx +106 -0
  188. package/src/next/route.ts +35 -0
  189. package/src/next/weekly.ts +70 -0
  190. package/src/next/wiring.ts +18 -0
  191. package/src/prisma/contracts.ts +249 -0
  192. package/src/prisma/index.ts +1169 -0
  193. package/src/prisma/mapping.ts +147 -0
  194. package/src/prisma/moveIn.ts +502 -0
  195. package/src/prune.ts +77 -0
  196. package/{templates/components/evalkeeper → src/react}/AddCase.tsx +6 -6
  197. package/{templates/components/evalkeeper → src/react}/AnswerKey.tsx +96 -59
  198. package/{templates/components/evalkeeper → src/react}/CaseMenu.tsx +9 -8
  199. package/src/react/CompareView.tsx +270 -0
  200. package/{templates/components/evalkeeper → src/react}/ConfirmAnswer.tsx +6 -3
  201. package/{templates/components/evalkeeper → src/react}/DisagreementChip.tsx +2 -3
  202. package/src/react/FeedbackView.tsx +230 -0
  203. package/{templates/components/evalkeeper → src/react}/Fields.tsx +54 -10
  204. package/src/react/HubSections.tsx +446 -0
  205. package/src/react/ModelMenu.tsx +89 -0
  206. package/src/react/RateView.tsx +143 -0
  207. package/{templates/components/evalkeeper → src/react}/ReadableOutput.tsx +1 -1
  208. package/{templates/components/evalkeeper → src/react}/RollBack.tsx +9 -10
  209. package/src/react/RunView.tsx +151 -0
  210. package/{templates/components/evalkeeper → src/react}/SettingsHistory.tsx +16 -9
  211. package/src/react/SideBySideView.tsx +307 -0
  212. package/src/react/SuiteSections.tsx +925 -0
  213. package/src/react/Tabs.tsx +61 -0
  214. package/{templates/components/evalkeeper → src/react}/Thumbs.tsx +7 -6
  215. package/{templates/components/evalkeeper → src/react}/WeeklyCheck.tsx +31 -20
  216. package/src/react/app.ts +173 -0
  217. package/src/react/format.ts +45 -0
  218. package/src/react/index.ts +31 -0
  219. package/src/react/pieces.tsx +412 -0
  220. package/src/readCheck.ts +1 -1
  221. package/src/runner.ts +182 -4
  222. package/src/settings.ts +1 -1
  223. package/src/store.ts +1 -1
  224. package/src/suggest.ts +145 -13
  225. package/src/suiteContract.ts +35 -28
  226. package/src/testing.ts +2 -2
  227. package/src/types.ts +147 -19
  228. package/starter/index.ts +33 -8
  229. package/templates/app/api/cron/evals-weekly/route.ts +5 -15
  230. package/templates/app/evals/[suite]/compare/page.tsx +6 -383
  231. package/templates/app/evals/[suite]/page.tsx +7 -532
  232. package/templates/app/evals/[suite]/rate/page.tsx +6 -141
  233. package/templates/app/evals/[suite]/runs/[runId]/page.tsx +6 -174
  234. package/templates/app/evals/[suite]/side-by-side/page.tsx +6 -318
  235. package/templates/app/evals/feedback/page.tsx +6 -227
  236. package/templates/app/evals/layout.tsx +10 -0
  237. package/templates/app/evals/page.tsx +7 -365
  238. package/templates/lib/evalkeeper/actions.ts +34 -296
  239. package/templates/lib/evalkeeper/appComponents.tsx +21 -0
  240. package/templates/lib/evalkeeper/evals.ts +14 -0
  241. package/templates/lib/evalkeeper/paths.ts +2 -7
  242. package/templates/components/evalkeeper/Submit.tsx +0 -67
  243. package/templates/components/evalkeeper/Tip.tsx +0 -98
  244. package/templates/components/evalkeeper/ui.tsx +0 -105
  245. package/templates/lib/evalkeeper/time.ts +0 -4
  246. package/templates/lib/evalkeeper/weekly.ts +0 -74
@@ -1,229 +1,8 @@
1
- import type { Metadata } from "next";
2
- import {
3
- asText,
4
- isInjectionSuite,
5
- thumbsSummary,
6
- whyNotACase,
7
- type AnySuite,
8
- type FeedbackRecord,
9
- } from "@crowandraven/evalkeeper";
10
- import { FieldValues } from "@/components/evalkeeper/Fields";
11
- import { Submit } from "@/components/evalkeeper/Submit";
12
- import { InfoTip, Tip } from "@/components/evalkeeper/Tip";
13
- import { BackLink, Card, Chip, pct } from "@/components/evalkeeper/ui";
14
- import { ThumbsDown, ThumbsUp } from "lucide-react";
15
- import { feedbackStore, requireAdmin, SUITES } from "@/lib/evalkeeper";
16
- import { daysAgo } from "@/lib/evalkeeper/time";
17
- import { dismissFeedback, makeCase } from "@/lib/evalkeeper/actions";
18
- import { EVALS_BASE } from "@/lib/evalkeeper/paths";
1
+ import { pages } from "@/lib/evalkeeper/evals";
19
2
 
20
- export const dynamic = "force-dynamic";
21
-
22
- export const metadata: Metadata = { title: "Feedback: Evals" };
23
-
24
- /**
25
- * What people thought of the AI's answers: thumbs per feature this week,
26
- * and each rating waiting for a look, to make into a case or dismiss.
27
- */
28
- export default async function FeedbackPage() {
29
- await requireAdmin();
30
- const all = await feedbackStore.listFeedback();
31
- const summary = thumbsSummary(all, daysAgo(7));
32
- const open = all
33
- .filter((f) => f.status === "OPEN")
34
- .sort((a, b) => Number(b.rating === "DOWN") - Number(a.rating === "DOWN"));
35
- const suiteFor = (op: string) =>
36
- SUITES.find((s) => s.operation === op && !isInjectionSuite(s));
37
- const label = (op: string) => suiteFor(op)?.label ?? op;
38
-
39
- return (
40
- <div className="space-y-8">
41
- <div className="space-y-2">
42
- <BackLink href={EVALS_BASE}>Evals</BackLink>
43
- <h1 className="text-2xl font-semibold">Feedback</h1>
44
- <p className="readable text-muted">
45
- Thumbs up and down from people using the product. A rating on a kept
46
- input can become a draft case, so the next model is tested on the
47
- answer people didn&apos;t like.
48
- </p>
49
- </div>
3
+ // Written by `npx @crowandraven/evalkeeper add pages`: don't edit it.
4
+ // Thumbs up and down, and what to do with each.
50
5
 
51
- <section className="space-y-3">
52
- <h2 className="text-lg font-semibold">
53
- This week
54
- <InfoTip term="thumbs" />
55
- </h2>
56
- {summary.length === 0 ? (
57
- <p className="text-sm text-muted">No ratings this week.</p>
58
- ) : (
59
- <Card className="overflow-x-auto p-0 lg:overflow-visible">
60
- <table className="w-full text-sm">
61
- <thead className="text-left text-muted">
62
- <tr className="border-b border-line">
63
- <th className="p-3 font-normal">Feature</th>
64
- <th className="p-3 font-normal">Thumbs up</th>
65
- <th className="p-3 font-normal">Thumbs down</th>
66
- <th className="p-3 font-normal">Share down</th>
67
- <th className="p-3 font-normal">Waiting</th>
68
- </tr>
69
- </thead>
70
- <tbody>
71
- {summary.map((s) => (
72
- <tr
73
- key={s.operation}
74
- className="border-b border-line last:border-0"
75
- >
76
- <td className="p-3">
77
- <span className="mr-2 font-medium">
78
- {label(s.operation)}
79
- </span>
80
- {s.alert && (
81
- <Tip
82
- text="At least 5 ratings, and at least 20% of them thumbs down: worth a look."
83
- id={`alert-${s.operation}`}
84
- side="bottom"
85
- >
86
- <Chip tone="warn">Needs a look</Chip>
87
- </Tip>
88
- )}
89
- </td>
90
- <td className="p-3 tabular-nums">{s.up}</td>
91
- <td className="p-3 tabular-nums">{s.down}</td>
92
- <td className="p-3 tabular-nums">
93
- {s.downShare === null ? "—" : pct(s.downShare)}
94
- </td>
95
- <td className="p-3 tabular-nums">{s.open}</td>
96
- </tr>
97
- ))}
98
- </tbody>
99
- </table>
100
- </Card>
101
- )}
102
- </section>
103
-
104
- <section className="space-y-3">
105
- <h2 className="text-lg font-semibold">
106
- Waiting for a look ({open.length})
107
- </h2>
108
- {open.length === 0 && (
109
- <p className="text-sm text-muted">
110
- Nothing waiting. Ratings show up here once an AI feature has a
111
- thumbs up and down (step 8 of{" "}
112
- <a
113
- href="https://github.com/seanhudson/evalkeeper/blob/main/docs/adding-to-your-app.md#8-add-thumbs-to-your-ai-answers-optional"
114
- target="_blank"
115
- rel="noreferrer"
116
- className="underline"
117
- >
118
- the guide
119
- </a>
120
- ).
121
- </p>
122
- )}
123
- <div className="space-y-3">
124
- {open.map((f) => (
125
- <Rating
126
- key={f.id}
127
- fields={suiteFor(f.operation)?.fields}
128
- f={f}
129
- feature={label(f.operation)}
130
- why={whyNotACase(f, suiteFor(f.operation))}
131
- />
132
- ))}
133
- </div>
134
- </section>
135
- </div>
136
- );
137
- }
138
-
139
- function Rating({
140
- f,
141
- fields,
142
- feature,
143
- why,
144
- }: {
145
- f: FeedbackRecord;
146
- fields: AnySuite["fields"];
147
- feature: string;
148
- why: string | null;
149
- }) {
150
- return (
151
- <article
152
- aria-label={`Rating: ${feature}${f.reason ? `, ${f.reason}` : ""}`}
153
- >
154
- <Card className="space-y-3 text-sm">
155
- <div className="flex flex-wrap items-center justify-between gap-2">
156
- <span className="flex items-center gap-2">
157
- <Chip tone={f.rating === "DOWN" ? "serious" : "live"}>
158
- {f.rating === "DOWN" ? (
159
- <>
160
- <ThumbsDown aria-hidden className="h-3.5 w-3.5" /> Thumbs down
161
- </>
162
- ) : (
163
- <>
164
- <ThumbsUp aria-hidden className="h-3.5 w-3.5" /> Thumbs up
165
- </>
166
- )}
167
- </Chip>
168
- <span className="font-medium">{feature}</span>
169
- </span>
170
- <span className="text-xs text-muted">
171
- {f.updatedAt.toLocaleString()}
172
- </span>
173
- </div>
174
- {f.reason && <p className="readable">&ldquo;{f.reason}&rdquo;</p>}
175
- <div className="grid gap-4 md:grid-cols-2">
176
- <div className="space-y-1">
177
- <p className="text-xs font-semibold uppercase tracking-wide text-muted">
178
- Input
179
- </p>
180
- {f.input === null ? (
181
- <p className="text-muted">Not kept</p>
182
- ) : fields ? (
183
- <FieldValues
184
- fields={fields.input}
185
- values={f.input}
186
- prefix={`${f.id}-in-`}
187
- />
188
- ) : (
189
- <p className="whitespace-pre-wrap font-mono text-xs">
190
- {asText(f.input)}
191
- </p>
192
- )}
193
- </div>
194
- <div className="space-y-1">
195
- <p className="text-xs font-semibold uppercase tracking-wide text-muted">
196
- Answer
197
- </p>
198
- {fields && f.output !== null ? (
199
- <FieldValues
200
- fields={fields.label}
201
- values={f.output}
202
- prefix={`${f.id}-out-`}
203
- />
204
- ) : (
205
- <p className="whitespace-pre-wrap font-mono text-xs">
206
- {asText(f.output) || f.excerpt || "—"}
207
- </p>
208
- )}
209
- </div>
210
- </div>
211
- <div className="flex flex-wrap items-center gap-2">
212
- {why === null ? (
213
- <form action={makeCase} className="flex items-center gap-1">
214
- <input type="hidden" name="feedback" value={f.id} />
215
- <Submit>Make a case</Submit>
216
- <InfoTip term="makeCase" id={`make-${f.id}`} />
217
- </form>
218
- ) : (
219
- <p className="readable text-xs text-muted">{why}</p>
220
- )}
221
- <form action={dismissFeedback}>
222
- <input type="hidden" name="feedback" value={f.id} />
223
- <Submit variant="quiet">Dismiss</Submit>
224
- </form>
225
- </div>
226
- </Card>
227
- </article>
228
- );
229
- }
6
+ export const dynamic = "force-dynamic";
7
+ export const generateMetadata = pages.feedback.generateMetadata;
8
+ export default pages.feedback.Page;
@@ -0,0 +1,10 @@
1
+ import { AppComponents } from "@/lib/evalkeeper/appComponents";
2
+
3
+ /** Every eval page, drawn with the app's own components. */
4
+ export default function EvalsLayout({
5
+ children,
6
+ }: {
7
+ children: React.ReactNode;
8
+ }) {
9
+ return <AppComponents>{children}</AppComponents>;
10
+ }
@@ -1,367 +1,9 @@
1
- import type { Metadata } from "next";
2
- import Link from "next/link";
3
- import {
4
- attention,
5
- isInjectionSuite,
6
- perAnswer,
7
- seconds,
8
- suiteHealth,
9
- thumbsSummary,
10
- type GlossaryTerm,
11
- type HistoryEntry,
12
- type Settings,
13
- type SettingsVersion,
14
- } from "@crowandraven/evalkeeper";
15
- import { Card, StatusBadge, pct } from "@/components/evalkeeper/ui";
16
- import {
17
- feedbackStore,
18
- MODELS,
19
- requireAdmin,
20
- runner,
21
- settings,
22
- SUITES,
23
- } from "@/lib/evalkeeper";
24
- import { daysAgo } from "@/lib/evalkeeper/time";
25
- import { loadWeekly } from "@/lib/evalkeeper/weekly";
26
- import { WeeklyCheck } from "@/components/evalkeeper/WeeklyCheck";
27
- import { InfoTip } from "@/components/evalkeeper/Tip";
28
- import { evalsPath } from "@/lib/evalkeeper/paths";
29
- import { HistoryEntries } from "@/components/evalkeeper/SettingsHistory";
30
- import { ChevronDown } from "lucide-react";
1
+ import { pages } from "@/lib/evalkeeper/evals";
31
2
 
32
- export const dynamic = "force-dynamic";
33
-
34
- export const metadata: Metadata = { title: "Evals" };
35
-
36
- /** The evals hub: where each suite stands, and what needs attention. */
37
- export default async function EvalsHub() {
38
- await requireAdmin();
39
- const [boards, weekly] = await Promise.all([
40
- Promise.all(SUITES.map((s) => runner.board(s.key))),
41
- loadWeekly(),
42
- ]);
43
- const histories = await Promise.all(
44
- SUITES.map((s) =>
45
- Promise.all([
46
- settings.history(s.operation),
47
- settings.current(s.operation),
48
- ]),
49
- ),
50
- );
51
- const thumbs = thumbsSummary(await feedbackStore.listFeedback(), daysAgo(7));
52
- const down = thumbs.reduce((t, s) => t + s.down, 0);
53
- const waiting = thumbs.reduce((t, s) => t + s.open, 0);
54
- const flagged = thumbs.filter((s) => s.alert).length;
55
- const needs = attention(
56
- boards.map((b) => ({
57
- key: b.suite.key,
58
- label: b.suite.label,
59
- rows: b.rows,
60
- toReview: b.provisional,
61
- })),
62
- );
63
- return (
64
- <div className="space-y-8">
65
- <div className="readable space-y-2">
66
- <h1 className="text-2xl font-semibold">Evals</h1>
67
- <p className="text-muted">
68
- Each suite tests one AI feature against answers people confirmed. Test
69
- models on it, then pick the live one on evidence.
70
- </p>
71
- </div>
72
-
73
- <div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
74
- <Stat
75
- title="Most room to improve"
76
- term="improve"
77
- value={needs.improve ? pct(needs.improve.best) : "—"}
78
- detail={
79
- !needs.improve
80
- ? "Test a suite to see"
81
- : needs.improve.best >= 1
82
- ? "Every suite has a model scoring 100%"
83
- : `${needs.improve.label}, best on ${needs.improve.model}`
84
- }
85
- />
86
- <Stat
87
- title="Slowest live model"
88
- term="slowest"
89
- value={needs.slowest ? seconds(needs.slowest.ms) : "—"}
90
- detail={
91
- needs.slowest
92
- ? `${needs.slowest.label} on ${needs.slowest.model}`
93
- : "—"
94
- }
95
- />
96
- <Stat
97
- title="Costliest live model"
98
- term="costliest"
99
- value={needs.costliest ? perAnswer(needs.costliest.usd) : "—"}
100
- detail={
101
- needs.costliest
102
- ? `${needs.costliest.label} on ${needs.costliest.model}`
103
- : "—"
104
- }
105
- />
106
- <Link href={evalsPath("feedback")}>
107
- <Stat
108
- title="Thumbs down this week"
109
- term="thumbs"
110
- value={String(down)}
111
- detail={
112
- flagged
113
- ? `${flagged} feature${flagged === 1 ? "" : "s"} need a look · ${waiting} waiting`
114
- : `${waiting} waiting for a look`
115
- }
116
- />
117
- </Link>
118
- </div>
119
-
120
- <WeeklyCheck weekly={weekly} />
121
-
122
- <section aria-labelledby="suites" className="space-y-3">
123
- <h2 id="suites" className="text-lg font-semibold">
124
- Suites
125
- <InfoTip term="suites" />
126
- </h2>
127
- {boards.length === 0 && <NoSuites />}
128
- <div className="space-y-4">
129
- {boards.map((b, i) => {
130
- const h = suiteHealth(
131
- b.rows,
132
- b.suite.checks,
133
- b.suite.priority,
134
- b.cases,
135
- b.provisional,
136
- MODELS,
137
- );
138
- const [history, current] = histories[i] ?? [[], null];
139
- return (
140
- <SuiteCard
141
- key={b.suite.key}
142
- board={b}
143
- health={h}
144
- history={history}
145
- current={current}
146
- />
147
- );
148
- })}
149
- </div>
150
- </section>
151
- </div>
152
- );
153
- }
154
-
155
- /** Before the first suite: what a suite is, and how to add one. */
156
- function NoSuites() {
157
- return (
158
- <Card className="readable space-y-3 text-sm">
159
- <p className="font-semibold">No suites yet</p>
160
- <p className="text-muted">
161
- A suite tests one AI feature: its cases, the answers a person confirms,
162
- and the checks that grade any model against them. To add one:
163
- </p>
164
- <ol className="list-decimal space-y-2 pl-4">
165
- <li>
166
- Write it: the input and answer shapes with zod, two or three checks,{" "}
167
- <code>run</code>, and <code>grade</code>.
168
- </li>
169
- <li>
170
- Add it to <code>SUITES</code> in <code>lib/evalkeeper/index.ts</code>,
171
- with its instructions hash.
172
- </li>
173
- <li>
174
- Add cases (here, or with <code>importCases</code> from files you
175
- have), confirm their answers, and test models.
176
- </li>
177
- </ol>
178
- <p className="text-muted">
179
- Step by step:{" "}
180
- <a
181
- href="https://github.com/seanhudson/evalkeeper/blob/main/docs/adding-to-your-app.md#5-write-your-first-suite"
182
- target="_blank"
183
- rel="noreferrer"
184
- className="underline"
185
- >
186
- Write your first suite
187
- </a>
188
- .
189
- </p>
190
- </Card>
191
- );
192
- }
193
-
194
- function Stat({
195
- title,
196
- term,
197
- value,
198
- detail,
199
- }: {
200
- title: string;
201
- term: GlossaryTerm;
202
- value: string;
203
- detail: string;
204
- }) {
205
- return (
206
- <Card className="space-y-1">
207
- <p className="text-sm text-muted">
208
- {title}
209
- <InfoTip term={term} />
210
- </p>
211
- <p className="text-2xl font-semibold tabular-nums">{value}</p>
212
- <p className="text-sm text-muted">{detail}</p>
213
- </Card>
214
- );
215
- }
3
+ // Written by `npx @crowandraven/evalkeeper add pages`. To arrange
4
+ // the hub your own way, replace this file with the sections ("Arrange
5
+ // your own page" in the guide).
216
6
 
217
- type Board = Awaited<ReturnType<typeof runner.board>>;
218
-
219
- const label = (model: string) => MODELS[model]?.label ?? model;
220
- const day = (d: Date) => d.toLocaleDateString();
221
- /** Green at 95% and up, amber from 80%, red below. */
222
- const scoreTone = (rate: number) =>
223
- rate >= 0.95 ? "text-good" : rate >= 0.8 ? "text-warn" : "text-bad";
224
-
225
- /**
226
- * One feature on the hub: its live version and models, what the live
227
- * model costs and how fast it is, its latest test, what needs a look, and
228
- * its settings history.
229
- */
230
- function SuiteCard({
231
- board: b,
232
- health: h,
233
- history,
234
- current,
235
- }: {
236
- board: Board;
237
- health: ReturnType<typeof suiteHealth>;
238
- history: HistoryEntry[];
239
- current: { settings: Settings; version: SettingsVersion | null } | null;
240
- }) {
241
- const live = b.rows.find((r) => r.live && !r.variant);
242
- const t = live?.test;
243
- const version = current?.version ?? null;
244
- const since = version
245
- ? (history.find((e) => e.to.id === version.id)?.createdAt ??
246
- version.createdAt)
247
- : null;
248
- const s = current?.settings;
249
- const price = s ? MODELS[s.model] : undefined;
250
- const versions = Math.max(1, ...history.map((e) => e.to.number));
251
- return (
252
- <Card className="relative space-y-4 transition-colors hover:border-muted">
253
- <div className="flex flex-wrap items-start justify-between gap-4">
254
- <div className="min-w-0 space-y-2">
255
- <div className="flex flex-wrap items-center gap-2">
256
- <h2 className="font-semibold">
257
- {/* Covers the whole card; the versions toggle sits above it. */}
258
- <Link
259
- href={evalsPath(b.suite.key)}
260
- className="after:absolute after:inset-0 after:rounded-lg"
261
- >
262
- {b.suite.label}
263
- </Link>
264
- </h2>
265
- <StatusBadge status={h.status} />
266
- </div>
267
- <p className="readable text-sm text-muted">{b.suite.description}</p>
268
- </div>
269
- {t && (
270
- <div className="shrink-0 space-y-0.5 text-right text-sm">
271
- <p className="font-semibold tabular-nums">
272
- {perAnswer(t.costPerAnswer)} / answer
273
- </p>
274
- <p className="text-xs text-muted">{seconds(t.avgMs)} avg</p>
275
- {price?.inputPer1M !== undefined &&
276
- price.outputPer1M !== undefined && (
277
- <p className="text-xs text-muted">
278
- ${price.inputPer1M} / ${price.outputPer1M} per 1M
279
- </p>
280
- )}
281
- </div>
282
- )}
283
- </div>
284
-
285
- {s && (
286
- <p className="text-sm text-muted">
287
- <span className="font-semibold text-ink">{label(s.model)}</span>
288
- {s.fallbackModel ? (
289
- <>
290
- {" "}
291
- · fallback{" "}
292
- <span className="font-semibold text-ink">
293
- {label(s.fallbackModel)}
294
- </span>
295
- </>
296
- ) : (
297
- " · no fallback"
298
- )}
299
- {s.reasoningEffort ? ` · reasoning ${s.reasoningEffort}` : ""}
300
- </p>
301
- )}
302
-
303
- <p className="text-sm">
304
- {t ? (
305
- <>
306
- Score{" "}
307
- <span className={`font-semibold ${scoreTone(t.right / t.total)}`}>
308
- {pct(t.right / t.total)}
309
- </span>
310
- </>
311
- ) : (
312
- "Live model not tested yet"
313
- )}{" "}
314
- · {b.cases} cases · {h.testedModels} models tested ·{" "}
315
- <Link
316
- href={evalsPath(b.suite.key)}
317
- className="relative text-accent hover:underline"
318
- >
319
- Compare models
320
- </Link>
321
- </p>
322
-
323
- {h.details.length > 0 && (
324
- <ul className="readable list-disc space-y-1 pl-5 text-sm text-muted">
325
- {h.details.slice(0, 3).map((d) => (
326
- <li key={d}>{d}</li>
327
- ))}
328
- </ul>
329
- )}
330
-
331
- {isInjectionSuite(b.suite) ? (
332
- <p className="readable text-sm text-muted">
333
- Shares {b.suite.base.label}&apos;s settings and versions history.
334
- </p>
335
- ) : (
336
- s && (
337
- <details className="group/history relative rounded-md bg-tint">
338
- <summary className="flex list-none items-center justify-between gap-2 p-3 text-sm font-medium">
339
- Versions
340
- <span className="flex items-center gap-1 text-xs font-normal text-muted">
341
- <span className="font-medium text-ink">
342
- v{version?.number ?? 1}
343
- </span>{" "}
344
- {since ? `live since ${day(since)}` : "defaults from code"} ·{" "}
345
- {versions} version{versions === 1 ? "" : "s"}
346
- <ChevronDown
347
- aria-hidden
348
- className="h-4 w-4 transition-transform group-open/history:rotate-180"
349
- />
350
- </span>
351
- </summary>
352
- <div className="px-3 pb-3">
353
- <HistoryEntries
354
- suite={b.suite.key}
355
- entries={history}
356
- liveId={version?.id ?? null}
357
- label={label}
358
- defaults={s}
359
- plain
360
- />
361
- </div>
362
- </details>
363
- )
364
- )}
365
- </Card>
366
- );
367
- }
7
+ export const dynamic = "force-dynamic";
8
+ export const generateMetadata = pages.hub.generateMetadata;
9
+ export default pages.hub.Page;