@crowandraven/evalkeeper 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/ai-sdk/decide.d.ts +35 -0
- package/dist/ai-sdk/decide.js +36 -0
- package/dist/ai-sdk/decide.js.map +1 -0
- package/dist/ai-sdk/hash.d.ts +50 -0
- package/dist/ai-sdk/hash.js +59 -0
- package/dist/ai-sdk/hash.js.map +1 -0
- package/dist/ai-sdk/index.d.ts +15 -0
- package/dist/ai-sdk/index.js +16 -0
- package/dist/ai-sdk/index.js.map +1 -0
- package/dist/ai-sdk/judge.d.ts +69 -0
- package/dist/ai-sdk/judge.js +105 -0
- package/dist/ai-sdk/judge.js.map +1 -0
- package/dist/ai-sdk/usage.d.ts +18 -0
- package/dist/ai-sdk/usage.js +19 -0
- package/dist/ai-sdk/usage.js.map +1 -0
- package/dist/board.d.ts +5 -0
- package/dist/cli/addPages.d.ts +6 -1
- package/dist/cli/addPages.js +14 -8
- package/dist/cli/addPages.js.map +1 -1
- package/dist/cli/main.d.ts +19 -5
- package/dist/cli/main.js +100 -4
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/migration.d.ts +95 -0
- package/dist/cli/migration.js +247 -0
- package/dist/cli/migration.js.map +1 -0
- package/dist/feedback.d.ts +1 -1
- package/dist/glossary.d.ts +8 -1
- package/dist/glossary.js +8 -1
- package/dist/glossary.js.map +1 -1
- package/dist/inInstructions.d.ts +1 -1
- package/dist/inInstructions.js +1 -1
- package/dist/next/RefreshWhile.d.ts +11 -0
- package/dist/next/RefreshWhile.js +28 -0
- package/dist/next/RefreshWhile.js.map +1 -0
- package/dist/next/actions.d.ts +14 -0
- package/dist/next/actions.js +332 -0
- package/dist/next/actions.js.map +1 -0
- package/dist/next/components.d.ts +9 -0
- package/dist/next/components.js +27 -0
- package/dist/next/components.js.map +1 -0
- package/dist/next/cron.d.ts +9 -0
- package/dist/next/cron.js +17 -0
- package/dist/next/cron.js.map +1 -0
- package/dist/next/index.d.ts +15 -0
- package/dist/next/index.js +16 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/pages.d.ts +70 -0
- package/dist/next/pages.js +77 -0
- package/dist/next/pages.js.map +1 -0
- package/dist/next/route.d.ts +19 -0
- package/dist/next/route.js +31 -0
- package/dist/next/route.js.map +1 -0
- package/dist/next/weekly.d.ts +20 -0
- package/dist/next/weekly.js +55 -0
- package/dist/next/weekly.js.map +1 -0
- package/dist/next/wiring.d.ts +19 -0
- package/dist/next/wiring.js +2 -0
- package/dist/next/wiring.js.map +1 -0
- package/dist/prisma/contracts.d.ts +74 -0
- package/dist/prisma/contracts.js +178 -0
- package/dist/prisma/contracts.js.map +1 -0
- package/dist/prisma/index.d.ts +423 -0
- package/dist/prisma/index.js +622 -0
- package/dist/prisma/index.js.map +1 -0
- package/dist/prisma/mapping.d.ts +63 -0
- package/dist/prisma/mapping.js +111 -0
- package/dist/prisma/mapping.js.map +1 -0
- package/dist/prisma/moveIn.d.ts +106 -0
- package/dist/prisma/moveIn.js +299 -0
- package/dist/prisma/moveIn.js.map +1 -0
- package/dist/prune.d.ts +45 -0
- package/dist/prune.js +32 -0
- package/dist/prune.js.map +1 -1
- package/dist/react/AddCase.d.ts +10 -0
- package/dist/react/AddCase.js +19 -0
- package/dist/react/AddCase.js.map +1 -0
- package/dist/react/AnswerKey.d.ts +22 -0
- package/dist/react/AnswerKey.js +83 -0
- package/dist/react/AnswerKey.js.map +1 -0
- package/dist/react/CaseMenu.d.ts +17 -0
- package/dist/react/CaseMenu.js +41 -0
- package/dist/react/CaseMenu.js.map +1 -0
- package/dist/react/CompareView.d.ts +14 -0
- package/dist/react/CompareView.js +51 -0
- package/dist/react/CompareView.js.map +1 -0
- package/dist/react/ConfirmAnswer.d.ts +13 -0
- package/dist/react/ConfirmAnswer.js +27 -0
- package/dist/react/ConfirmAnswer.js.map +1 -0
- package/dist/react/DisagreementChip.d.ts +10 -0
- package/dist/react/DisagreementChip.js +21 -0
- package/dist/react/DisagreementChip.js.map +1 -0
- package/dist/react/FeedbackView.d.ts +10 -0
- package/dist/react/FeedbackView.js +26 -0
- package/dist/react/FeedbackView.js.map +1 -0
- package/dist/react/Fields.d.ts +32 -0
- package/dist/react/Fields.js +33 -0
- package/dist/react/Fields.js.map +1 -0
- package/dist/react/HubSections.d.ts +78 -0
- package/dist/react/HubSections.js +124 -0
- package/dist/react/HubSections.js.map +1 -0
- package/dist/react/ModelMenu.d.ts +16 -0
- package/dist/react/ModelMenu.js +38 -0
- package/dist/react/ModelMenu.js.map +1 -0
- package/dist/react/RateView.d.ts +18 -0
- package/dist/react/RateView.js +30 -0
- package/dist/react/RateView.js.map +1 -0
- package/dist/react/ReadableOutput.d.ts +3 -0
- package/dist/react/ReadableOutput.js +50 -0
- package/dist/react/ReadableOutput.js.map +1 -0
- package/dist/react/RollBack.d.ts +17 -0
- package/dist/react/RollBack.js +26 -0
- package/dist/react/RollBack.js.map +1 -0
- package/dist/react/RunView.d.ts +9 -0
- package/dist/react/RunView.js +41 -0
- package/dist/react/RunView.js.map +1 -0
- package/dist/react/SettingsHistory.d.ts +33 -0
- package/dist/react/SettingsHistory.js +79 -0
- package/dist/react/SettingsHistory.js.map +1 -0
- package/dist/react/SideBySideView.d.ts +14 -0
- package/dist/react/SideBySideView.js +67 -0
- package/dist/react/SideBySideView.js.map +1 -0
- package/dist/react/SuiteSections.d.ts +111 -0
- package/dist/react/SuiteSections.js +224 -0
- package/dist/react/SuiteSections.js.map +1 -0
- package/dist/react/Tabs.d.ts +15 -0
- package/dist/react/Tabs.js +18 -0
- package/dist/react/Tabs.js.map +1 -0
- package/dist/react/Thumbs.d.ts +13 -0
- package/dist/react/Thumbs.js +54 -0
- package/dist/react/Thumbs.js.map +1 -0
- package/dist/react/WeeklyCheck.d.ts +11 -0
- package/dist/react/WeeklyCheck.js +19 -0
- package/dist/react/WeeklyCheck.js.map +1 -0
- package/dist/react/app.d.ts +118 -0
- package/dist/react/app.js +87 -0
- package/dist/react/app.js.map +1 -0
- package/dist/react/format.d.ts +27 -0
- package/dist/react/format.js +38 -0
- package/dist/react/format.js.map +1 -0
- package/dist/react/index.d.ts +31 -0
- package/dist/react/index.js +32 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/pieces.d.ts +191 -0
- package/dist/react/pieces.js +191 -0
- package/dist/react/pieces.js.map +1 -0
- package/dist/readCheck.d.ts +1 -1
- package/dist/runner.d.ts +62 -2
- package/dist/runner.js +123 -3
- package/dist/runner.js.map +1 -1
- package/dist/settings.d.ts +1 -1
- package/dist/store.d.ts +1 -1
- package/dist/suggest.d.ts +1 -1
- package/dist/suggest.js +7 -7
- package/dist/suggest.js.map +1 -1
- package/dist/suiteContract.d.ts +3 -3
- package/dist/suiteContract.js +20 -16
- package/dist/suiteContract.js.map +1 -1
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +56 -6
- package/schema/evalkeeper.prisma +196 -0
- package/src/ai-sdk/decide.ts +57 -0
- package/src/ai-sdk/hash.ts +74 -0
- package/src/ai-sdk/index.ts +15 -0
- package/src/ai-sdk/judge.ts +163 -0
- package/src/ai-sdk/usage.ts +31 -0
- package/src/board.ts +5 -0
- package/src/cli/addPages.ts +15 -7
- package/src/cli/main.ts +135 -9
- package/src/cli/migration.ts +349 -0
- package/src/feedback.ts +1 -1
- package/src/glossary.ts +16 -2
- package/src/inInstructions.ts +1 -1
- package/{templates/components/evalkeeper → src/next}/RefreshWhile.tsx +2 -2
- package/src/next/actions.ts +389 -0
- package/src/next/components.ts +31 -0
- package/{templates/lib/evalkeeper/cronAuth.ts → src/next/cron.ts} +3 -0
- package/src/next/index.ts +15 -0
- package/src/next/pages.tsx +106 -0
- package/src/next/route.ts +35 -0
- package/src/next/weekly.ts +70 -0
- package/src/next/wiring.ts +18 -0
- package/src/prisma/contracts.ts +249 -0
- package/src/prisma/index.ts +1169 -0
- package/src/prisma/mapping.ts +147 -0
- package/src/prisma/moveIn.ts +502 -0
- package/src/prune.ts +77 -0
- package/{templates/components/evalkeeper → src/react}/AddCase.tsx +6 -6
- package/{templates/components/evalkeeper → src/react}/AnswerKey.tsx +92 -61
- package/{templates/components/evalkeeper → src/react}/CaseMenu.tsx +9 -8
- package/src/react/CompareView.tsx +270 -0
- package/{templates/components/evalkeeper → src/react}/ConfirmAnswer.tsx +6 -3
- package/{templates/components/evalkeeper → src/react}/DisagreementChip.tsx +2 -3
- package/src/react/FeedbackView.tsx +230 -0
- package/{templates/components/evalkeeper → src/react}/Fields.tsx +6 -6
- package/src/react/HubSections.tsx +446 -0
- package/src/react/ModelMenu.tsx +89 -0
- package/src/react/RateView.tsx +143 -0
- package/{templates/components/evalkeeper → src/react}/ReadableOutput.tsx +1 -1
- package/{templates/components/evalkeeper → src/react}/RollBack.tsx +9 -10
- package/src/react/RunView.tsx +151 -0
- package/{templates/components/evalkeeper → src/react}/SettingsHistory.tsx +16 -9
- package/src/react/SideBySideView.tsx +307 -0
- package/src/react/SuiteSections.tsx +925 -0
- package/src/react/Tabs.tsx +61 -0
- package/{templates/components/evalkeeper → src/react}/Thumbs.tsx +7 -6
- package/{templates/components/evalkeeper → src/react}/WeeklyCheck.tsx +31 -20
- package/src/react/app.ts +173 -0
- package/src/react/format.ts +45 -0
- package/src/react/index.ts +31 -0
- package/src/react/pieces.tsx +412 -0
- package/src/readCheck.ts +1 -1
- package/src/runner.ts +167 -3
- package/src/settings.ts +1 -1
- package/src/store.ts +1 -1
- package/src/suggest.ts +7 -7
- package/src/suiteContract.ts +35 -28
- package/src/testing.ts +2 -2
- package/src/types.ts +2 -2
- package/starter/index.ts +22 -8
- package/templates/app/api/cron/evals-weekly/route.ts +5 -15
- package/templates/app/evals/[suite]/compare/page.tsx +6 -383
- package/templates/app/evals/[suite]/page.tsx +7 -685
- package/templates/app/evals/[suite]/rate/page.tsx +6 -151
- package/templates/app/evals/[suite]/runs/[runId]/page.tsx +6 -174
- package/templates/app/evals/[suite]/side-by-side/page.tsx +6 -318
- package/templates/app/evals/feedback/page.tsx +6 -227
- package/templates/app/evals/layout.tsx +10 -0
- package/templates/app/evals/page.tsx +7 -397
- package/templates/lib/evalkeeper/actions.ts +34 -317
- package/templates/lib/evalkeeper/appComponents.tsx +21 -0
- package/templates/lib/evalkeeper/evals.ts +14 -0
- package/templates/lib/evalkeeper/paths.ts +2 -7
- package/templates/components/evalkeeper/Submit.tsx +0 -67
- package/templates/components/evalkeeper/Tip.tsx +0 -98
- package/templates/components/evalkeeper/ui.tsx +0 -105
- package/templates/lib/evalkeeper/time.ts +0 -4
- package/templates/lib/evalkeeper/weekly.ts +0 -74
|
@@ -1,153 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Link from "next/link";
|
|
3
|
-
import { notFound } from "next/navigation";
|
|
4
|
-
import { rateQueue } from "@crowandraven/evalkeeper";
|
|
5
|
-
import { AnswerInput, FieldValues } from "@/components/evalkeeper/Fields";
|
|
6
|
-
import { Submit } from "@/components/evalkeeper/Submit";
|
|
7
|
-
import { InfoTip, Tip } from "@/components/evalkeeper/Tip";
|
|
8
|
-
import { BackLink, Card } from "@/components/evalkeeper/ui";
|
|
9
|
-
import {
|
|
10
|
-
answerEditors,
|
|
11
|
-
requireAdmin,
|
|
12
|
-
SUITE_BY_KEY,
|
|
13
|
-
store,
|
|
14
|
-
} from "@/lib/evalkeeper";
|
|
15
|
-
import { rateBlind, skipCase } from "@/lib/evalkeeper/actions";
|
|
16
|
-
import { evalsPath } from "@/lib/evalkeeper/paths";
|
|
1
|
+
import { pages } from "@/lib/evalkeeper/evals";
|
|
17
2
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export async function generateMetadata({
|
|
21
|
-
params,
|
|
22
|
-
}: {
|
|
23
|
-
params: Promise<{ suite: string }>;
|
|
24
|
-
}): Promise<Metadata> {
|
|
25
|
-
const { suite } = await params;
|
|
26
|
-
return { title: `Rate blind: ${SUITE_BY_KEY[suite]?.label ?? "Evals"}` };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Rating an imported suite's cases blind: one case at a time, the oldest
|
|
31
|
-
* this person hasn't rated or skipped, shown by its input alone. The app's
|
|
32
|
-
* output, what anyone did with the item, other answers, tags, and notes
|
|
33
|
-
* stay hidden, because any of them anchors the rating.
|
|
34
|
-
*/
|
|
35
|
-
export default async function RateBlindPage({
|
|
36
|
-
params,
|
|
37
|
-
}: {
|
|
38
|
-
params: Promise<{ suite: string }>;
|
|
39
|
-
}) {
|
|
40
|
-
const admin = await requireAdmin();
|
|
41
|
-
const { suite: key } = await params;
|
|
42
|
-
const suite = SUITE_BY_KEY[key];
|
|
43
|
-
const fields = suite?.fields;
|
|
44
|
-
if (
|
|
45
|
-
!suite ||
|
|
46
|
-
suite.caseKind !== "imported" ||
|
|
47
|
-
!fields ||
|
|
48
|
-
!(suite.labelFromForm || answerEditors[key])
|
|
49
|
-
)
|
|
50
|
-
notFound();
|
|
51
|
-
const queue = rateQueue(await store.listCases(key), admin.id);
|
|
52
|
-
const next = queue.next;
|
|
53
|
-
const input = next ? suite.input.parse(next.input) : null;
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<div className="space-y-8">
|
|
57
|
-
<div className="space-y-2">
|
|
58
|
-
<BackLink href={evalsPath(key)}>{suite.label}</BackLink>
|
|
59
|
-
<h1 className="text-2xl font-semibold">
|
|
60
|
-
Rate blind
|
|
61
|
-
<InfoTip term="rateBlind" />
|
|
62
|
-
</h1>
|
|
63
|
-
<p className="readable text-muted">
|
|
64
|
-
One case at a time, from its input alone. You won't see what the
|
|
65
|
-
app decided or what anyone did with it, so nothing anchors your
|
|
66
|
-
answer. Give the answer and why, or skip it.
|
|
67
|
-
</p>
|
|
68
|
-
<p className="text-sm text-muted">
|
|
69
|
-
<Tip term="rateQueue" id="rate-queue">
|
|
70
|
-
<span>
|
|
71
|
-
{queue.rated} rated · {queue.skipped} skipped · {queue.left} left
|
|
72
|
-
</span>
|
|
73
|
-
</Tip>
|
|
74
|
-
</p>
|
|
75
|
-
</div>
|
|
3
|
+
// Written by `npx @crowandraven/evalkeeper add pages`: don't edit it.
|
|
4
|
+
// Blind rating: one case at a time, by its input only.
|
|
76
5
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<h2 className="font-semibold">{suite.title(input)}</h2>
|
|
81
|
-
{fields.input.length ? (
|
|
82
|
-
<FieldValues
|
|
83
|
-
fields={fields.input}
|
|
84
|
-
values={next.input}
|
|
85
|
-
prefix="rate-in-"
|
|
86
|
-
/>
|
|
87
|
-
) : (
|
|
88
|
-
<pre className="readable whitespace-pre-wrap text-sm">
|
|
89
|
-
{suite.describe?.(input) ?? JSON.stringify(next.input, null, 2)}
|
|
90
|
-
</pre>
|
|
91
|
-
)}
|
|
92
|
-
</section>
|
|
93
|
-
|
|
94
|
-
{/* Keyed by case, so the next case starts with an empty form. */}
|
|
95
|
-
<form key={next.id} action={rateBlind} className="space-y-4">
|
|
96
|
-
<input type="hidden" name="suite" value={key} />
|
|
97
|
-
<input type="hidden" name="case" value={next.id} />
|
|
98
|
-
<AnswerInput
|
|
99
|
-
fields={fields.label}
|
|
100
|
-
editor={answerEditors[key]}
|
|
101
|
-
input={next.input}
|
|
102
|
-
prefix="rate-"
|
|
103
|
-
/>
|
|
104
|
-
<div className="space-y-1">
|
|
105
|
-
<label
|
|
106
|
-
htmlFor="rate-reason"
|
|
107
|
-
className="block text-sm font-medium"
|
|
108
|
-
>
|
|
109
|
-
Why
|
|
110
|
-
</label>
|
|
111
|
-
<textarea
|
|
112
|
-
id="rate-reason"
|
|
113
|
-
name="reason"
|
|
114
|
-
required
|
|
115
|
-
rows={3}
|
|
116
|
-
className="w-full rounded-md border border-line bg-card px-3 py-2 text-sm focus:border-accent focus:outline-none"
|
|
117
|
-
/>
|
|
118
|
-
<p className="readable text-xs text-muted">
|
|
119
|
-
What in the input decided it, in a sentence. Kept with your
|
|
120
|
-
answer, so anyone checking it later sees your reasoning.
|
|
121
|
-
</p>
|
|
122
|
-
</div>
|
|
123
|
-
<p className="readable text-xs text-muted">
|
|
124
|
-
Saves your own confirmed answer beside anyone else's, and
|
|
125
|
-
rescores tests for free.
|
|
126
|
-
</p>
|
|
127
|
-
<Submit>Save rating</Submit>
|
|
128
|
-
</form>
|
|
129
|
-
|
|
130
|
-
<form action={skipCase}>
|
|
131
|
-
<input type="hidden" name="suite" value={key} />
|
|
132
|
-
<input type="hidden" name="case" value={next.id} />
|
|
133
|
-
<Tip control term="skip" id="rate-skip">
|
|
134
|
-
<Submit variant="quiet">Skip</Submit>
|
|
135
|
-
</Tip>
|
|
136
|
-
</form>
|
|
137
|
-
</Card>
|
|
138
|
-
) : (
|
|
139
|
-
<Card className="space-y-2">
|
|
140
|
-
<h2 className="font-semibold">Nothing left for you to rate</h2>
|
|
141
|
-
<p className="readable text-sm text-muted">
|
|
142
|
-
You've rated or skipped every case in this suite.
|
|
143
|
-
{queue.skipped > 0 &&
|
|
144
|
-
" Cases you skipped are still in the answer key, where you can write their answers."}
|
|
145
|
-
</p>
|
|
146
|
-
<Link href={evalsPath(key)} className="text-sm text-accent">
|
|
147
|
-
Back to the answer key
|
|
148
|
-
</Link>
|
|
149
|
-
</Card>
|
|
150
|
-
)}
|
|
151
|
-
</div>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
6
|
+
export const dynamic = "force-dynamic";
|
|
7
|
+
export const generateMetadata = pages.rate.generateMetadata;
|
|
8
|
+
export default pages.rate.Page;
|
|
@@ -1,176 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { notFound } from "next/navigation";
|
|
3
|
-
import { allPassed, money, summarize } from "@crowandraven/evalkeeper";
|
|
4
|
-
import type { Metadata } from "next";
|
|
5
|
-
import { FieldValues } from "@/components/evalkeeper/Fields";
|
|
6
|
-
import { ReadableOutput } from "@/components/evalkeeper/ReadableOutput";
|
|
7
|
-
import { BackLink, Card, pct } from "@/components/evalkeeper/ui";
|
|
8
|
-
import {
|
|
9
|
-
MODELS,
|
|
10
|
-
requireAdmin,
|
|
11
|
-
runner,
|
|
12
|
-
store,
|
|
13
|
-
SUITE_BY_KEY,
|
|
14
|
-
} from "@/lib/evalkeeper";
|
|
15
|
-
import { evalsPath } from "@/lib/evalkeeper/paths";
|
|
1
|
+
import { pages } from "@/lib/evalkeeper/evals";
|
|
16
2
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export async function generateMetadata({
|
|
20
|
-
params,
|
|
21
|
-
}: {
|
|
22
|
-
params: Promise<{ suite: string }>;
|
|
23
|
-
}): Promise<Metadata> {
|
|
24
|
-
const { suite } = await params;
|
|
25
|
-
return { title: `Test: ${SUITE_BY_KEY[suite]?.label ?? "Evals"}` };
|
|
26
|
-
}
|
|
3
|
+
// Written by `npx @crowandraven/evalkeeper add pages`: don't edit it.
|
|
4
|
+
// One test: every answer, with what each check found.
|
|
27
5
|
|
|
28
|
-
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
}: {
|
|
32
|
-
params: Promise<{ suite: string; runId: string }>;
|
|
33
|
-
}) {
|
|
34
|
-
await requireAdmin();
|
|
35
|
-
const { suite: key, runId } = await params;
|
|
36
|
-
const run = await store.getRun(runId);
|
|
37
|
-
if (!run || run.suite !== key) notFound();
|
|
38
|
-
const suite = runner.suiteOrThrow(key);
|
|
39
|
-
const [outputs, cases] = await Promise.all([
|
|
40
|
-
store.listOutputs(runId),
|
|
41
|
-
store.listCases(key).then((cs) => new Map(cs.map((c) => [c.id, c]))),
|
|
42
|
-
]);
|
|
43
|
-
const titleOf = (caseId: string) => {
|
|
44
|
-
const c = cases.get(caseId);
|
|
45
|
-
return c ? suite.title(suite.input.parse(c.input)) : "A retired case";
|
|
46
|
-
};
|
|
47
|
-
const metrics = run.metrics;
|
|
48
|
-
const summary = metrics ? summarize(metrics, suite.checks) : null;
|
|
49
|
-
const label = (k: string) =>
|
|
50
|
-
suite.checks.find((c) => c.key === k)?.label ?? k;
|
|
51
|
-
type Check = {
|
|
52
|
-
key: string;
|
|
53
|
-
pass: boolean | null;
|
|
54
|
-
note?: string;
|
|
55
|
-
given?: string;
|
|
56
|
-
matches?: { expected: string; actual: string; why: string }[];
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<div className="space-y-6">
|
|
61
|
-
<BackLink href={evalsPath(key)}>{suite.label}</BackLink>
|
|
62
|
-
<div className="space-y-1">
|
|
63
|
-
<h1 className="text-2xl font-semibold">
|
|
64
|
-
{MODELS[run.model]?.label ?? run.model} on {suite.label}
|
|
65
|
-
</h1>
|
|
66
|
-
<p className="text-sm text-muted">
|
|
67
|
-
{run.startedAt.toLocaleString()} · {run.status.toLowerCase()}
|
|
68
|
-
{metrics && ` · spent ${money(metrics.costUsd)}`}
|
|
69
|
-
{run.status === "SUCCEEDED" && (
|
|
70
|
-
<>
|
|
71
|
-
{" · "}
|
|
72
|
-
<Link
|
|
73
|
-
href={`${evalsPath(key, "compare")}?${new URLSearchParams({ b: runId })}`}
|
|
74
|
-
className="hover:text-ink"
|
|
75
|
-
>
|
|
76
|
-
Compare with another test
|
|
77
|
-
</Link>
|
|
78
|
-
</>
|
|
79
|
-
)}
|
|
80
|
-
</p>
|
|
81
|
-
{run.error && <p className="readable text-bad">{run.error}</p>}
|
|
82
|
-
</div>
|
|
83
|
-
{summary && (
|
|
84
|
-
<Card className="space-y-2">
|
|
85
|
-
<p className="text-lg">
|
|
86
|
-
{summary.right} of {summary.total} answers fully right (
|
|
87
|
-
{pct(summary.total ? summary.right / summary.total : 0)})
|
|
88
|
-
</p>
|
|
89
|
-
<p className="readable text-sm text-muted">{summary.trust}</p>
|
|
90
|
-
{summary.problems.length > 0 && (
|
|
91
|
-
<ul className="readable list-disc pl-5 text-sm">
|
|
92
|
-
{summary.problems.map((p) => (
|
|
93
|
-
<li key={p.key}>
|
|
94
|
-
{p.label}: failed {p.failed} of {p.of}
|
|
95
|
-
</li>
|
|
96
|
-
))}
|
|
97
|
-
</ul>
|
|
98
|
-
)}
|
|
99
|
-
</Card>
|
|
100
|
-
)}
|
|
101
|
-
<Card className="space-y-3">
|
|
102
|
-
{outputs.map((o) => {
|
|
103
|
-
const checks = (o.scores as Check[] | null) ?? null;
|
|
104
|
-
const ok = allPassed(checks);
|
|
105
|
-
return (
|
|
106
|
-
<div key={o.id} className="rounded-md bg-tint p-3 text-sm">
|
|
107
|
-
<div className="flex justify-between gap-4">
|
|
108
|
-
<span className="font-medium">{titleOf(o.caseId)}</span>
|
|
109
|
-
<span
|
|
110
|
-
className={
|
|
111
|
-
o.error ? "text-bad" : ok ? "text-good" : "text-warn"
|
|
112
|
-
}
|
|
113
|
-
>
|
|
114
|
-
{o.error ? "No answer" : ok ? "Right" : "Wrong"}
|
|
115
|
-
</span>
|
|
116
|
-
</div>
|
|
117
|
-
{o.error && <p className="text-bad">{o.error}</p>}
|
|
118
|
-
{!o.error && o.output !== null && (
|
|
119
|
-
<div className="mt-2">
|
|
120
|
-
{suite.fields && suite.labelFromOutput ? (
|
|
121
|
-
<FieldValues
|
|
122
|
-
fields={suite.fields.label}
|
|
123
|
-
values={suite.labelFromOutput(o.output)}
|
|
124
|
-
prefix={`${o.id}-`}
|
|
125
|
-
/>
|
|
126
|
-
) : (
|
|
127
|
-
<ReadableOutput value={o.output} />
|
|
128
|
-
)}
|
|
129
|
-
</div>
|
|
130
|
-
)}
|
|
131
|
-
{suite.decisions &&
|
|
132
|
-
checks?.some((c) => c.given !== undefined) && (
|
|
133
|
-
<ul className="mt-2 space-y-0.5 text-xs">
|
|
134
|
-
{checks
|
|
135
|
-
.filter((c) => c.given !== undefined)
|
|
136
|
-
.map((c) => (
|
|
137
|
-
<li key={c.key}>
|
|
138
|
-
<span className="text-muted">{label(c.key)}:</span>{" "}
|
|
139
|
-
{c.given}{" "}
|
|
140
|
-
<span className={c.pass ? "text-good" : "text-warn"}>
|
|
141
|
-
{c.pass ? "right" : "wrong"}
|
|
142
|
-
</span>
|
|
143
|
-
</li>
|
|
144
|
-
))}
|
|
145
|
-
</ul>
|
|
146
|
-
)}
|
|
147
|
-
{checks
|
|
148
|
-
?.filter((c) => c.pass === false)
|
|
149
|
-
.map((c) => (
|
|
150
|
-
<p key={c.key} className="readable mt-2 text-muted">
|
|
151
|
-
{label(c.key)}: {c.note ?? "failed"}
|
|
152
|
-
</p>
|
|
153
|
-
))}
|
|
154
|
-
{checks
|
|
155
|
-
?.flatMap((c) => c.matches ?? [])
|
|
156
|
-
.slice(0, 20)
|
|
157
|
-
.map((m, i) => (
|
|
158
|
-
<p key={i} className="readable mt-1 text-xs text-muted">
|
|
159
|
-
Matched “{m.expected}” with “{m.actual}”: {m.why}
|
|
160
|
-
</p>
|
|
161
|
-
))}
|
|
162
|
-
{cases.has(o.caseId) && (
|
|
163
|
-
<Link
|
|
164
|
-
href={`${evalsPath(key)}#case-${o.caseId}`}
|
|
165
|
-
className="mt-2 inline-block text-xs text-accent hover:underline"
|
|
166
|
-
>
|
|
167
|
-
Find the case in the answer key
|
|
168
|
-
</Link>
|
|
169
|
-
)}
|
|
170
|
-
</div>
|
|
171
|
-
);
|
|
172
|
-
})}
|
|
173
|
-
</Card>
|
|
174
|
-
</div>
|
|
175
|
-
);
|
|
176
|
-
}
|
|
6
|
+
export const dynamic = "force-dynamic";
|
|
7
|
+
export const generateMetadata = pages.run.generateMetadata;
|
|
8
|
+
export default pages.run.Page;
|
|
@@ -1,320 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Link from "next/link";
|
|
3
|
-
import { notFound } from "next/navigation";
|
|
4
|
-
import { ArrowLeft, ArrowRight, Check, Minus, X } from "lucide-react";
|
|
5
|
-
import {
|
|
6
|
-
aroundCase,
|
|
7
|
-
type AnySuite,
|
|
8
|
-
type CheckResult,
|
|
9
|
-
type OutputRecord,
|
|
10
|
-
type RunRecord,
|
|
11
|
-
} from "@crowandraven/evalkeeper";
|
|
12
|
-
import { DisagreementChip } from "@/components/evalkeeper/DisagreementChip";
|
|
13
|
-
import { FieldValues } from "@/components/evalkeeper/Fields";
|
|
14
|
-
import { ReadableOutput } from "@/components/evalkeeper/ReadableOutput";
|
|
15
|
-
import { InfoTip, Tip } from "@/components/evalkeeper/Tip";
|
|
16
|
-
import { BackLink, Card, pct } from "@/components/evalkeeper/ui";
|
|
17
|
-
import {
|
|
18
|
-
MODELS,
|
|
19
|
-
requireAdmin,
|
|
20
|
-
runner,
|
|
21
|
-
store,
|
|
22
|
-
SUITE_BY_KEY,
|
|
23
|
-
} from "@/lib/evalkeeper";
|
|
24
|
-
import { evalsPath } from "@/lib/evalkeeper/paths";
|
|
1
|
+
import { pages } from "@/lib/evalkeeper/evals";
|
|
25
2
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export async function generateMetadata({
|
|
29
|
-
params,
|
|
30
|
-
}: {
|
|
31
|
-
params: Promise<{ suite: string }>;
|
|
32
|
-
}): Promise<Metadata> {
|
|
33
|
-
const { suite } = await params;
|
|
34
|
-
return { title: `Side by side: ${SUITE_BY_KEY[suite]?.label ?? "Evals"}` };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** A search parameter as one string, or null when it's missing or repeated. */
|
|
38
|
-
const one = (v: string | string[] | undefined) =>
|
|
39
|
-
typeof v === "string" && v ? v : null;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Two tests' answers to one case, side by side with the expected answer
|
|
43
|
-
* and what each check found, and previous and next through the cases the
|
|
44
|
-
* two graded differently. `a` is the test in place, `b` the challenger,
|
|
45
|
-
* and `case` the case (the first disagreement when left out).
|
|
46
|
-
*/
|
|
47
|
-
export default async function SideBySidePage({
|
|
48
|
-
params,
|
|
49
|
-
searchParams,
|
|
50
|
-
}: {
|
|
51
|
-
params: Promise<{ suite: string }>;
|
|
52
|
-
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
|
53
|
-
}) {
|
|
54
|
-
await requireAdmin();
|
|
55
|
-
const { suite: key } = await params;
|
|
56
|
-
const sp = await searchParams;
|
|
57
|
-
const a = one(sp.a);
|
|
58
|
-
const b = one(sp.b);
|
|
59
|
-
if (!a || !b) notFound();
|
|
60
|
-
const result = await runner.compare(key, a, b);
|
|
61
|
-
if (!result) notFound();
|
|
62
|
-
const { suite, disagreements } = result;
|
|
63
|
-
const caseId = one(sp.case) ?? disagreements[0]?.caseId ?? null;
|
|
64
|
-
const compareHref = `${evalsPath(key, "compare")}?${new URLSearchParams({ a, b })}`;
|
|
65
|
-
const back = <BackLink href={compareHref}>Compare</BackLink>;
|
|
66
|
-
if (!caseId)
|
|
67
|
-
return (
|
|
68
|
-
<div className="space-y-4">
|
|
69
|
-
{back}
|
|
70
|
-
<h1 className="text-2xl font-semibold">Side by side</h1>
|
|
71
|
-
<p className="readable text-muted">
|
|
72
|
-
The two tests graded every shared case alike: there's nothing to
|
|
73
|
-
read side by side.
|
|
74
|
-
</p>
|
|
75
|
-
</div>
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const [cases, outA, outB] = await Promise.all([
|
|
79
|
-
store.listCases(key, { includeRetired: true }),
|
|
80
|
-
store.listOutputs(a),
|
|
81
|
-
store.listOutputs(b),
|
|
82
|
-
]);
|
|
83
|
-
const c = cases.find((x) => x.id === caseId);
|
|
84
|
-
if (!c) notFound();
|
|
85
|
-
const input = suite.input.parse(c.input);
|
|
86
|
-
const expected =
|
|
87
|
-
c.labels.find((l) => l.status === "CONFIRMED") ??
|
|
88
|
-
c.labels.find((l) => l.status === "PROVISIONAL");
|
|
89
|
-
const here = aroundCase(disagreements, caseId);
|
|
90
|
-
const d = disagreements[here.index];
|
|
91
|
-
const to = (id: string) =>
|
|
92
|
-
`${evalsPath(key, "side-by-side")}?${new URLSearchParams({ a, b, case: id })}`;
|
|
93
|
-
const byRepeat = (os: OutputRecord[]) =>
|
|
94
|
-
os.filter((o) => o.caseId === caseId).sort((x, y) => x.repeat - y.repeat);
|
|
3
|
+
// Written by `npx @crowandraven/evalkeeper add pages`: don't edit it.
|
|
4
|
+
// Two tests' answers where they differ, side by side.
|
|
95
5
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
<div className="space-y-2">
|
|
100
|
-
<p className="text-sm text-muted">
|
|
101
|
-
Side by side
|
|
102
|
-
<InfoTip term="sideBySide" />
|
|
103
|
-
{" · "}
|
|
104
|
-
{suite.label}
|
|
105
|
-
</p>
|
|
106
|
-
<h1 className="text-2xl font-semibold">{suite.title(input)}</h1>
|
|
107
|
-
<div className="flex flex-wrap items-center justify-between gap-3">
|
|
108
|
-
<span className="flex items-center gap-2 text-sm text-muted">
|
|
109
|
-
{d ? (
|
|
110
|
-
<>
|
|
111
|
-
<DisagreementChip kind={d.kind} id="kind" />
|
|
112
|
-
<Tip term="disagreements" id="position">
|
|
113
|
-
<span>
|
|
114
|
-
{here.index + 1} of {disagreements.length} where they differ
|
|
115
|
-
</span>
|
|
116
|
-
</Tip>
|
|
117
|
-
</>
|
|
118
|
-
) : (
|
|
119
|
-
<span>Both tests graded this case alike.</span>
|
|
120
|
-
)}
|
|
121
|
-
</span>
|
|
122
|
-
<nav aria-label="Cases where they differ" className="flex gap-2">
|
|
123
|
-
{here.previous ? (
|
|
124
|
-
<StepLink href={to(here.previous)} dir="previous" />
|
|
125
|
-
) : (
|
|
126
|
-
<StepLink dir="previous" />
|
|
127
|
-
)}
|
|
128
|
-
{here.next ? (
|
|
129
|
-
<StepLink href={to(here.next)} dir="next" />
|
|
130
|
-
) : (
|
|
131
|
-
<StepLink dir="next" />
|
|
132
|
-
)}
|
|
133
|
-
</nav>
|
|
134
|
-
</div>
|
|
135
|
-
</div>
|
|
136
|
-
|
|
137
|
-
<Card className="grid gap-5 text-sm md:grid-cols-2">
|
|
138
|
-
<section className="min-w-0 space-y-2">
|
|
139
|
-
<h2 className="text-xs font-semibold uppercase tracking-wide text-muted">
|
|
140
|
-
Input
|
|
141
|
-
</h2>
|
|
142
|
-
{/* A suite's own readable input (describe) reads best. */}
|
|
143
|
-
{suite.describe ? (
|
|
144
|
-
<pre className="readable text-xs whitespace-pre-wrap">
|
|
145
|
-
{suite.describe(input)}
|
|
146
|
-
</pre>
|
|
147
|
-
) : suite.fields ? (
|
|
148
|
-
<FieldValues
|
|
149
|
-
fields={suite.fields.input}
|
|
150
|
-
values={c.input}
|
|
151
|
-
prefix="in-"
|
|
152
|
-
/>
|
|
153
|
-
) : (
|
|
154
|
-
<pre className="readable text-xs whitespace-pre-wrap">
|
|
155
|
-
{JSON.stringify(c.input, null, 2)}
|
|
156
|
-
</pre>
|
|
157
|
-
)}
|
|
158
|
-
</section>
|
|
159
|
-
<section className="min-w-0 space-y-2">
|
|
160
|
-
<h2 className="text-xs font-semibold uppercase tracking-wide text-muted">
|
|
161
|
-
Expected answer
|
|
162
|
-
<InfoTip term="expectedAnswer" />
|
|
163
|
-
</h2>
|
|
164
|
-
{!expected ? (
|
|
165
|
-
<p className="readable text-muted">No answer in use.</p>
|
|
166
|
-
) : suite.fields ? (
|
|
167
|
-
<FieldValues
|
|
168
|
-
fields={suite.fields.label}
|
|
169
|
-
values={expected.value}
|
|
170
|
-
prefix="expected-"
|
|
171
|
-
/>
|
|
172
|
-
) : (
|
|
173
|
-
<pre className="readable whitespace-pre-wrap text-xs">
|
|
174
|
-
{JSON.stringify(expected.value, null, 2)}
|
|
175
|
-
</pre>
|
|
176
|
-
)}
|
|
177
|
-
</section>
|
|
178
|
-
</Card>
|
|
179
|
-
|
|
180
|
-
<div className="grid gap-4 md:grid-cols-2">
|
|
181
|
-
<Side
|
|
182
|
-
side="inPlace"
|
|
183
|
-
run={result.a}
|
|
184
|
-
outputs={byRepeat(outA)}
|
|
185
|
-
suite={suite}
|
|
186
|
-
score={d?.champion ?? null}
|
|
187
|
-
runHref={evalsPath(key, "runs", a)}
|
|
188
|
-
/>
|
|
189
|
-
<Side
|
|
190
|
-
side="challenger"
|
|
191
|
-
run={result.b}
|
|
192
|
-
outputs={byRepeat(outB)}
|
|
193
|
-
suite={suite}
|
|
194
|
-
score={d?.challenger ?? null}
|
|
195
|
-
runHref={evalsPath(key, "runs", b)}
|
|
196
|
-
/>
|
|
197
|
-
</div>
|
|
198
|
-
</div>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/** A link to the previous or next disagreement, or a dimmed one at either end. */
|
|
203
|
-
function StepLink({ href, dir }: { href?: string; dir: "previous" | "next" }) {
|
|
204
|
-
const label = dir === "previous" ? "Previous" : "Next";
|
|
205
|
-
const body =
|
|
206
|
-
dir === "previous" ? (
|
|
207
|
-
<>
|
|
208
|
-
<ArrowLeft aria-hidden className="h-4 w-4" />
|
|
209
|
-
{label}
|
|
210
|
-
</>
|
|
211
|
-
) : (
|
|
212
|
-
<>
|
|
213
|
-
{label}
|
|
214
|
-
<ArrowRight aria-hidden className="h-4 w-4" />
|
|
215
|
-
</>
|
|
216
|
-
);
|
|
217
|
-
const cls =
|
|
218
|
-
"inline-flex items-center gap-1 rounded-md border border-line px-3 py-1.5 text-sm";
|
|
219
|
-
return href ? (
|
|
220
|
-
<Link href={href} className={`${cls} hover:bg-tint`}>
|
|
221
|
-
{body}
|
|
222
|
-
</Link>
|
|
223
|
-
) : (
|
|
224
|
-
<span aria-disabled="true" className={`${cls} text-muted opacity-60`}>
|
|
225
|
-
{body}
|
|
226
|
-
</span>
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/** One test's answers to the case, with what each check found. */
|
|
231
|
-
function Side({
|
|
232
|
-
side,
|
|
233
|
-
run,
|
|
234
|
-
outputs,
|
|
235
|
-
suite,
|
|
236
|
-
score,
|
|
237
|
-
runHref,
|
|
238
|
-
}: {
|
|
239
|
-
side: "inPlace" | "challenger";
|
|
240
|
-
run: RunRecord;
|
|
241
|
-
outputs: OutputRecord[];
|
|
242
|
-
suite: AnySuite;
|
|
243
|
-
score: number | null;
|
|
244
|
-
runHref: string;
|
|
245
|
-
}) {
|
|
246
|
-
const label = (k: string) =>
|
|
247
|
-
suite.checks.find((x) => x.key === k)?.label ?? k;
|
|
248
|
-
return (
|
|
249
|
-
<Card className="space-y-4 text-sm">
|
|
250
|
-
<div className="space-y-1">
|
|
251
|
-
<p className="text-xs font-semibold uppercase tracking-wide text-muted">
|
|
252
|
-
{side === "inPlace" ? "In place" : "Challenger"}
|
|
253
|
-
<InfoTip term={side} id={`${side}-side`} />
|
|
254
|
-
</p>
|
|
255
|
-
<h2 className="text-lg font-semibold">
|
|
256
|
-
<Link href={runHref} className="hover:underline">
|
|
257
|
-
{MODELS[run.model]?.label ?? run.model}
|
|
258
|
-
</Link>
|
|
259
|
-
</h2>
|
|
260
|
-
{score !== null && (
|
|
261
|
-
<Tip term="caseScore" id={`${side}-score`}>
|
|
262
|
-
<span className="text-muted">Scored {pct(score)} on this case</span>
|
|
263
|
-
</Tip>
|
|
264
|
-
)}
|
|
265
|
-
</div>
|
|
266
|
-
{outputs.length === 0 && (
|
|
267
|
-
<p className="readable text-muted">This test has no answer here.</p>
|
|
268
|
-
)}
|
|
269
|
-
{outputs.map((o) => {
|
|
270
|
-
const checks: CheckResult[] = o.scores ?? [];
|
|
271
|
-
return (
|
|
272
|
-
<section key={o.id} className="space-y-3 rounded-md bg-tint p-3">
|
|
273
|
-
{outputs.length > 1 && (
|
|
274
|
-
<p className="text-xs text-muted">Repeat {o.repeat + 1}</p>
|
|
275
|
-
)}
|
|
276
|
-
{o.error ? (
|
|
277
|
-
<p className="readable text-bad">No answer: {o.error}</p>
|
|
278
|
-
) : suite.fields && suite.labelFromOutput ? (
|
|
279
|
-
<FieldValues
|
|
280
|
-
fields={suite.fields.label}
|
|
281
|
-
values={suite.labelFromOutput(o.output)}
|
|
282
|
-
prefix={`${side}-${o.repeat}-`}
|
|
283
|
-
/>
|
|
284
|
-
) : (
|
|
285
|
-
<ReadableOutput value={o.output} />
|
|
286
|
-
)}
|
|
287
|
-
{checks.length > 0 && (
|
|
288
|
-
<ul className="space-y-1">
|
|
289
|
-
{checks.map((x) => (
|
|
290
|
-
<li key={x.key} className="flex items-start gap-1.5">
|
|
291
|
-
{x.pass === null ? (
|
|
292
|
-
<Minus
|
|
293
|
-
aria-label="Doesn't apply"
|
|
294
|
-
className="mt-0.5 h-4 w-4 shrink-0 text-muted"
|
|
295
|
-
/>
|
|
296
|
-
) : x.pass ? (
|
|
297
|
-
<Check
|
|
298
|
-
aria-label="Passed"
|
|
299
|
-
className="mt-0.5 h-4 w-4 shrink-0 text-good"
|
|
300
|
-
/>
|
|
301
|
-
) : (
|
|
302
|
-
<X
|
|
303
|
-
aria-label="Failed"
|
|
304
|
-
className="mt-0.5 h-4 w-4 shrink-0 text-warn"
|
|
305
|
-
/>
|
|
306
|
-
)}
|
|
307
|
-
<span className="readable">
|
|
308
|
-
{label(x.key)}
|
|
309
|
-
{x.note && <span className="text-muted">: {x.note}</span>}
|
|
310
|
-
</span>
|
|
311
|
-
</li>
|
|
312
|
-
))}
|
|
313
|
-
</ul>
|
|
314
|
-
)}
|
|
315
|
-
</section>
|
|
316
|
-
);
|
|
317
|
-
})}
|
|
318
|
-
</Card>
|
|
319
|
-
);
|
|
320
|
-
}
|
|
6
|
+
export const dynamic = "force-dynamic";
|
|
7
|
+
export const generateMetadata = pages.sideBySide.generateMetadata;
|
|
8
|
+
export default pages.sideBySide.Page;
|