@crowandraven/evalkeeper 0.7.0 → 0.8.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 +9 -0
- package/dist/cli/addPages.d.ts +5 -0
- package/dist/cli/addPages.js +15 -3
- package/dist/cli/addPages.js.map +1 -1
- package/dist/decisions.js +8 -0
- package/dist/decisions.js.map +1 -1
- package/dist/feedback.d.ts +17 -2
- package/dist/feedback.js +13 -2
- package/dist/feedback.js.map +1 -1
- package/dist/glossary.d.ts +3 -1
- package/dist/glossary.js +3 -1
- package/dist/glossary.js.map +1 -1
- package/dist/inInstructions.d.ts +47 -0
- package/dist/inInstructions.js +95 -0
- package/dist/inInstructions.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runner.d.ts +9 -0
- package/dist/runner.js +26 -0
- package/dist/runner.js.map +1 -1
- package/dist/suiteContract.d.ts +10 -4
- package/dist/suiteContract.js +43 -6
- package/dist/suiteContract.js.map +1 -1
- package/dist/suites/hopelessness.d.ts +116 -0
- package/dist/suites/hopelessness.js +293 -0
- package/dist/suites/hopelessness.js.map +1 -0
- package/dist/suites/hopelessnessCases.d.ts +61 -0
- package/dist/suites/hopelessnessCases.js +242 -0
- package/dist/suites/hopelessnessCases.js.map +1 -0
- package/dist/suites/index.d.ts +2 -0
- package/dist/suites/index.js +2 -0
- package/dist/suites/index.js.map +1 -1
- package/dist/testing.d.ts +36 -2
- package/dist/testing.js +104 -14
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/addPages.ts +16 -3
- package/src/decisions.ts +10 -0
- package/src/feedback.ts +20 -2
- package/src/glossary.ts +5 -1
- package/src/inInstructions.ts +105 -0
- package/src/index.ts +1 -0
- package/src/runner.ts +41 -0
- package/src/suiteContract.ts +52 -6
- package/src/suites/hopelessness.ts +410 -0
- package/src/suites/hopelessnessCases.ts +286 -0
- package/src/suites/index.ts +2 -0
- package/src/testing.ts +144 -18
- package/src/types.ts +6 -0
- package/starter/index.ts +8 -0
- package/templates/app/evals/[suite]/compare/page.tsx +10 -0
- package/templates/app/evals/[suite]/page.tsx +55 -18
- package/templates/app/evals/[suite]/rate/page.tsx +10 -0
- package/templates/app/evals/[suite]/runs/[runId]/page.tsx +72 -3
- package/templates/app/evals/[suite]/side-by-side/page.tsx +37 -17
- package/templates/app/evals/feedback/page.tsx +3 -0
- package/templates/app/evals/page.tsx +3 -0
- package/templates/components/evalkeeper/AnswerKey.tsx +2 -1
- package/templates/components/evalkeeper/ReadableOutput.tsx +97 -0
- package/templates/components/evalkeeper/SettingsHistory.tsx +10 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
1
2
|
import Link from "next/link";
|
|
2
3
|
import { notFound } from "next/navigation";
|
|
3
4
|
import {
|
|
@@ -38,6 +39,15 @@ import { EVALS_BASE, evalsPath } from "@/lib/evalkeeper/paths";
|
|
|
38
39
|
|
|
39
40
|
export const dynamic = "force-dynamic";
|
|
40
41
|
|
|
42
|
+
export async function generateMetadata({
|
|
43
|
+
params,
|
|
44
|
+
}: {
|
|
45
|
+
params: Promise<{ suite: string }>;
|
|
46
|
+
}): Promise<Metadata> {
|
|
47
|
+
const { suite } = await params;
|
|
48
|
+
return { title: `Evals: ${SUITE_BY_KEY[suite]?.label ?? "Evals"}` };
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
/** A share as a whole percent, or a dash when there's nothing to show. */
|
|
42
52
|
const asPct = (x: number | null) => (x === null ? "—" : pct(x));
|
|
43
53
|
|
|
@@ -59,7 +69,7 @@ export default async function SuitePage({
|
|
|
59
69
|
if (!operation) notFound();
|
|
60
70
|
// The board and the settings load together: on a remote database each
|
|
61
71
|
// waits on round trips, so one after the other doubles the wait.
|
|
62
|
-
const [b, [history, liveSettings]] = await Promise.all([
|
|
72
|
+
const [b, [history, liveSettings], inInstructions] = await Promise.all([
|
|
63
73
|
runner.board(key),
|
|
64
74
|
// Records a deploy if the instructions changed under the live
|
|
65
75
|
// settings, before reading them.
|
|
@@ -68,6 +78,7 @@ export default async function SuitePage({
|
|
|
68
78
|
.then(() =>
|
|
69
79
|
Promise.all([settings.history(operation), settings.current(operation)]),
|
|
70
80
|
),
|
|
81
|
+
runner.casesInInstructions(key),
|
|
71
82
|
]);
|
|
72
83
|
const { suite, rows } = b;
|
|
73
84
|
const s = suggest(rows, suite.checks, suite.priority, MODELS);
|
|
@@ -101,30 +112,35 @@ export default async function SuitePage({
|
|
|
101
112
|
</p>
|
|
102
113
|
</div>
|
|
103
114
|
|
|
104
|
-
{
|
|
115
|
+
{/* Shown when nothing would change too, so a higher score that
|
|
116
|
+
isn't enough to switch for comes with its reason. */}
|
|
117
|
+
{s && (
|
|
105
118
|
<Card className="space-y-3">
|
|
106
119
|
<div className="flex flex-wrap items-start justify-between gap-3">
|
|
107
120
|
<h2 className="font-semibold">
|
|
108
|
-
Suggested
|
|
121
|
+
{s.same ? "No change suggested" : "Suggested"}
|
|
109
122
|
<InfoTip term="suggestion" />
|
|
110
123
|
</h2>
|
|
111
124
|
{/* Retesting live changes nothing until the fallback would. */}
|
|
112
|
-
{!
|
|
113
|
-
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
125
|
+
{!s.same &&
|
|
126
|
+
!(s.retestLive && (!s.fallback || s.fallback.fallback)) && (
|
|
127
|
+
<form action={useSuggestion}>
|
|
128
|
+
<input type="hidden" name="suite" value={key} />
|
|
129
|
+
<Submit>Use these</Submit>
|
|
130
|
+
</form>
|
|
131
|
+
)}
|
|
118
132
|
</div>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
{!s.same && (
|
|
134
|
+
<p>
|
|
135
|
+
Live: <strong>{s.live.label}</strong>
|
|
136
|
+
{s.fallback && (
|
|
137
|
+
<>
|
|
138
|
+
{" "}
|
|
139
|
+
· Fallback: <strong>{s.fallback.label}</strong>
|
|
140
|
+
</>
|
|
141
|
+
)}
|
|
142
|
+
</p>
|
|
143
|
+
)}
|
|
128
144
|
<ul className="readable list-disc space-y-1 pl-5 text-sm text-muted">
|
|
129
145
|
{s.reasons.map((r) => (
|
|
130
146
|
<li key={r}>{r}</li>
|
|
@@ -133,6 +149,27 @@ export default async function SuitePage({
|
|
|
133
149
|
</Card>
|
|
134
150
|
)}
|
|
135
151
|
|
|
152
|
+
{inInstructions.length > 0 && (
|
|
153
|
+
<Card className="space-y-2">
|
|
154
|
+
<h2 className="font-semibold text-warn">
|
|
155
|
+
Cases in the instructions
|
|
156
|
+
<InfoTip term="inInstructions" />
|
|
157
|
+
</h2>
|
|
158
|
+
<p className="readable text-sm text-muted">
|
|
159
|
+
These cases' words appear in what the model is told, so a test
|
|
160
|
+
grades it on answers it was handed. Take the example out of the
|
|
161
|
+
instructions, or rewrite or retire the case.
|
|
162
|
+
</p>
|
|
163
|
+
<ul className="readable list-disc space-y-1 pl-5 text-sm">
|
|
164
|
+
{inInstructions.map((c) => (
|
|
165
|
+
<li key={c.caseId}>
|
|
166
|
+
{c.title}: “{c.found}”
|
|
167
|
+
</li>
|
|
168
|
+
))}
|
|
169
|
+
</ul>
|
|
170
|
+
</Card>
|
|
171
|
+
)}
|
|
172
|
+
|
|
136
173
|
<section className="space-y-3">
|
|
137
174
|
<div className="flex items-center justify-between gap-4">
|
|
138
175
|
<h2 className="text-lg font-semibold">Models</h2>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
1
2
|
import Link from "next/link";
|
|
2
3
|
import { notFound } from "next/navigation";
|
|
3
4
|
import { rateQueue } from "@crowandraven/evalkeeper";
|
|
@@ -11,6 +12,15 @@ import { evalsPath } from "@/lib/evalkeeper/paths";
|
|
|
11
12
|
|
|
12
13
|
export const dynamic = "force-dynamic";
|
|
13
14
|
|
|
15
|
+
export async function generateMetadata({
|
|
16
|
+
params,
|
|
17
|
+
}: {
|
|
18
|
+
params: Promise<{ suite: string }>;
|
|
19
|
+
}): Promise<Metadata> {
|
|
20
|
+
const { suite } = await params;
|
|
21
|
+
return { title: `Rate blind: ${SUITE_BY_KEY[suite]?.label ?? "Evals"}` };
|
|
22
|
+
}
|
|
23
|
+
|
|
14
24
|
/**
|
|
15
25
|
* Rating an imported suite's cases blind: one case at a time, the oldest
|
|
16
26
|
* this person hasn't rated or skipped, shown by its input alone. The app's
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import Link from "next/link";
|
|
2
2
|
import { notFound } from "next/navigation";
|
|
3
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";
|
|
4
7
|
import { BackLink, Card, pct } from "@/components/evalkeeper/ui";
|
|
5
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
MODELS,
|
|
10
|
+
requireAdmin,
|
|
11
|
+
runner,
|
|
12
|
+
store,
|
|
13
|
+
SUITE_BY_KEY,
|
|
14
|
+
} from "@/lib/evalkeeper";
|
|
6
15
|
import { evalsPath } from "@/lib/evalkeeper/paths";
|
|
7
16
|
|
|
8
17
|
export const dynamic = "force-dynamic";
|
|
9
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
|
+
}
|
|
27
|
+
|
|
10
28
|
/** One test: every answer, with what each check found. */
|
|
11
29
|
export default async function RunPage({
|
|
12
30
|
params,
|
|
@@ -30,7 +48,13 @@ export default async function RunPage({
|
|
|
30
48
|
const summary = metrics ? summarize(metrics, suite.checks) : null;
|
|
31
49
|
const label = (k: string) =>
|
|
32
50
|
suite.checks.find((c) => c.key === k)?.label ?? k;
|
|
33
|
-
type Check = {
|
|
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
|
+
};
|
|
34
58
|
|
|
35
59
|
return (
|
|
36
60
|
<div className="space-y-6">
|
|
@@ -91,13 +115,58 @@ export default async function RunPage({
|
|
|
91
115
|
</span>
|
|
92
116
|
</div>
|
|
93
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
|
+
)}
|
|
94
147
|
{checks
|
|
95
148
|
?.filter((c) => c.pass === false)
|
|
96
149
|
.map((c) => (
|
|
97
|
-
<p key={c.key} className="readable text-muted">
|
|
150
|
+
<p key={c.key} className="readable mt-2 text-muted">
|
|
98
151
|
{label(c.key)}: {c.note ?? "failed"}
|
|
99
152
|
</p>
|
|
100
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
|
+
)}
|
|
101
170
|
</div>
|
|
102
171
|
);
|
|
103
172
|
})}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
1
2
|
import Link from "next/link";
|
|
2
3
|
import { notFound } from "next/navigation";
|
|
3
4
|
import { ArrowLeft, ArrowRight, Check, Minus, X } from "lucide-react";
|
|
@@ -10,13 +11,29 @@ import {
|
|
|
10
11
|
} from "@crowandraven/evalkeeper";
|
|
11
12
|
import { DisagreementChip } from "@/components/evalkeeper/DisagreementChip";
|
|
12
13
|
import { FieldValues } from "@/components/evalkeeper/Fields";
|
|
14
|
+
import { ReadableOutput } from "@/components/evalkeeper/ReadableOutput";
|
|
13
15
|
import { InfoTip, Tip } from "@/components/evalkeeper/Tip";
|
|
14
16
|
import { BackLink, Card, pct } from "@/components/evalkeeper/ui";
|
|
15
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
MODELS,
|
|
19
|
+
requireAdmin,
|
|
20
|
+
runner,
|
|
21
|
+
store,
|
|
22
|
+
SUITE_BY_KEY,
|
|
23
|
+
} from "@/lib/evalkeeper";
|
|
16
24
|
import { evalsPath } from "@/lib/evalkeeper/paths";
|
|
17
25
|
|
|
18
26
|
export const dynamic = "force-dynamic";
|
|
19
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
|
+
|
|
20
37
|
/** A search parameter as one string, or null when it's missing or repeated. */
|
|
21
38
|
const one = (v: string | string[] | undefined) =>
|
|
22
39
|
typeof v === "string" && v ? v : null;
|
|
@@ -118,23 +135,28 @@ export default async function SideBySidePage({
|
|
|
118
135
|
</div>
|
|
119
136
|
|
|
120
137
|
<Card className="grid gap-5 text-sm md:grid-cols-2">
|
|
121
|
-
<section className="space-y-2">
|
|
138
|
+
<section className="min-w-0 space-y-2">
|
|
122
139
|
<h2 className="text-xs font-semibold uppercase tracking-wide text-muted">
|
|
123
140
|
Input
|
|
124
141
|
</h2>
|
|
125
|
-
{suite
|
|
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 ? (
|
|
126
148
|
<FieldValues
|
|
127
149
|
fields={suite.fields.input}
|
|
128
150
|
values={c.input}
|
|
129
151
|
prefix="in-"
|
|
130
152
|
/>
|
|
131
153
|
) : (
|
|
132
|
-
<pre className="readable whitespace-pre-wrap
|
|
133
|
-
{
|
|
154
|
+
<pre className="readable text-xs whitespace-pre-wrap">
|
|
155
|
+
{JSON.stringify(c.input, null, 2)}
|
|
134
156
|
</pre>
|
|
135
157
|
)}
|
|
136
158
|
</section>
|
|
137
|
-
<section className="space-y-2">
|
|
159
|
+
<section className="min-w-0 space-y-2">
|
|
138
160
|
<h2 className="text-xs font-semibold uppercase tracking-wide text-muted">
|
|
139
161
|
Expected answer
|
|
140
162
|
<InfoTip term="expectedAnswer" />
|
|
@@ -157,7 +179,7 @@ export default async function SideBySidePage({
|
|
|
157
179
|
|
|
158
180
|
<div className="grid gap-4 md:grid-cols-2">
|
|
159
181
|
<Side
|
|
160
|
-
|
|
182
|
+
side="inPlace"
|
|
161
183
|
run={result.a}
|
|
162
184
|
outputs={byRepeat(outA)}
|
|
163
185
|
suite={suite}
|
|
@@ -165,7 +187,7 @@ export default async function SideBySidePage({
|
|
|
165
187
|
runHref={evalsPath(key, "runs", a)}
|
|
166
188
|
/>
|
|
167
189
|
<Side
|
|
168
|
-
|
|
190
|
+
side="challenger"
|
|
169
191
|
run={result.b}
|
|
170
192
|
outputs={byRepeat(outB)}
|
|
171
193
|
suite={suite}
|
|
@@ -207,14 +229,14 @@ function StepLink({ href, dir }: { href?: string; dir: "previous" | "next" }) {
|
|
|
207
229
|
|
|
208
230
|
/** One test's answers to the case, with what each check found. */
|
|
209
231
|
function Side({
|
|
210
|
-
|
|
232
|
+
side,
|
|
211
233
|
run,
|
|
212
234
|
outputs,
|
|
213
235
|
suite,
|
|
214
236
|
score,
|
|
215
237
|
runHref,
|
|
216
238
|
}: {
|
|
217
|
-
|
|
239
|
+
side: "inPlace" | "challenger";
|
|
218
240
|
run: RunRecord;
|
|
219
241
|
outputs: OutputRecord[];
|
|
220
242
|
suite: AnySuite;
|
|
@@ -227,8 +249,8 @@ function Side({
|
|
|
227
249
|
<Card className="space-y-4 text-sm">
|
|
228
250
|
<div className="space-y-1">
|
|
229
251
|
<p className="text-xs font-semibold uppercase tracking-wide text-muted">
|
|
230
|
-
{
|
|
231
|
-
<InfoTip term={
|
|
252
|
+
{side === "inPlace" ? "In place" : "Challenger"}
|
|
253
|
+
<InfoTip term={side} id={`${side}-side`} />
|
|
232
254
|
</p>
|
|
233
255
|
<h2 className="text-lg font-semibold">
|
|
234
256
|
<Link href={runHref} className="hover:underline">
|
|
@@ -236,7 +258,7 @@ function Side({
|
|
|
236
258
|
</Link>
|
|
237
259
|
</h2>
|
|
238
260
|
{score !== null && (
|
|
239
|
-
<Tip term="caseScore" id={`${
|
|
261
|
+
<Tip term="caseScore" id={`${side}-score`}>
|
|
240
262
|
<span className="text-muted">Scored {pct(score)} on this case</span>
|
|
241
263
|
</Tip>
|
|
242
264
|
)}
|
|
@@ -257,12 +279,10 @@ function Side({
|
|
|
257
279
|
<FieldValues
|
|
258
280
|
fields={suite.fields.label}
|
|
259
281
|
values={suite.labelFromOutput(o.output)}
|
|
260
|
-
prefix={`${
|
|
282
|
+
prefix={`${side}-${o.repeat}-`}
|
|
261
283
|
/>
|
|
262
284
|
) : (
|
|
263
|
-
<
|
|
264
|
-
{JSON.stringify(o.output, null, 2)}
|
|
265
|
-
</pre>
|
|
285
|
+
<ReadableOutput value={o.output} />
|
|
266
286
|
)}
|
|
267
287
|
{checks.length > 0 && (
|
|
268
288
|
<ul className="space-y-1">
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
1
2
|
import {
|
|
2
3
|
asText,
|
|
3
4
|
thumbsSummary,
|
|
@@ -17,6 +18,8 @@ import { EVALS_BASE } from "@/lib/evalkeeper/paths";
|
|
|
17
18
|
|
|
18
19
|
export const dynamic = "force-dynamic";
|
|
19
20
|
|
|
21
|
+
export const metadata: Metadata = { title: "Feedback: Evals" };
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
24
|
* What people thought of the AI's answers: thumbs per feature this week,
|
|
22
25
|
* and each rating waiting for a look, to make into a case or dismiss.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
1
2
|
import Link from "next/link";
|
|
2
3
|
import {
|
|
3
4
|
attention,
|
|
@@ -29,6 +30,8 @@ import { ChevronDown } from "lucide-react";
|
|
|
29
30
|
|
|
30
31
|
export const dynamic = "force-dynamic";
|
|
31
32
|
|
|
33
|
+
export const metadata: Metadata = { title: "Evals" };
|
|
34
|
+
|
|
32
35
|
/** The evals hub: where each suite stands, and what needs attention. */
|
|
33
36
|
export default async function EvalsHub() {
|
|
34
37
|
await requireAdmin();
|
|
@@ -189,7 +189,8 @@ function CaseItem({
|
|
|
189
189
|
|
|
190
190
|
return (
|
|
191
191
|
<details
|
|
192
|
-
|
|
192
|
+
id={`case-${c.id}`}
|
|
193
|
+
className="group scroll-mt-4 rounded-md border border-line bg-card"
|
|
193
194
|
// Where ConfirmAnswer moves on to after confirming the case above.
|
|
194
195
|
data-pending={answer?.status === "PENDING" ? "true" : undefined}
|
|
195
196
|
>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { asText } from "@crowandraven/evalkeeper";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Any answer, readable, for suites without their own way to show it (no
|
|
5
|
+
* `labelFromOutput`): text as paragraphs, lists as bullets, small objects
|
|
6
|
+
* as one line each, and fields with their names, never raw JSON.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const label = (key: string) =>
|
|
10
|
+
key
|
|
11
|
+
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
12
|
+
.replace(/_/g, " ")
|
|
13
|
+
.replace(/^./, (c) => c.toUpperCase());
|
|
14
|
+
|
|
15
|
+
function isPlain(v: unknown): v is string | number | boolean | null {
|
|
16
|
+
return v === null || ["string", "number", "boolean"].includes(typeof v);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function Inline({ value }: { value: unknown }) {
|
|
20
|
+
if (value === null || value === undefined || value === "")
|
|
21
|
+
return <span className="text-muted">–</span>;
|
|
22
|
+
if (typeof value === "boolean") return <>{value ? "Yes" : "No"}</>;
|
|
23
|
+
return <>{asText(value)}</>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** One line for a small object: its longest text first, then the rest. */
|
|
27
|
+
function Row({ value }: { value: Record<string, unknown> }) {
|
|
28
|
+
const entries = Object.entries(value);
|
|
29
|
+
const main = entries.find(([, v]) => typeof v === "string" && v.length > 20);
|
|
30
|
+
const rest = entries.filter(([k, v]) => k !== main?.[0] && isPlain(v));
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
{main ? asText(main[1]) : null}
|
|
34
|
+
{rest.length > 0 && (
|
|
35
|
+
<span className="text-xs text-muted">
|
|
36
|
+
{main ? " · " : ""}
|
|
37
|
+
{rest
|
|
38
|
+
.map(([k, v]) => `${label(k)}: ${v === null ? "–" : asText(v)}`)
|
|
39
|
+
.join(" · ")}
|
|
40
|
+
</span>
|
|
41
|
+
)}
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function ReadableOutput({ value }: { value: unknown }) {
|
|
47
|
+
if (isPlain(value))
|
|
48
|
+
return typeof value === "string" && value.length > 80 ? (
|
|
49
|
+
<p className="readable break-words whitespace-pre-wrap">{value}</p>
|
|
50
|
+
) : (
|
|
51
|
+
<span className="break-words">
|
|
52
|
+
<Inline value={value} />
|
|
53
|
+
</span>
|
|
54
|
+
);
|
|
55
|
+
if (Array.isArray(value)) {
|
|
56
|
+
if (!value.length) return <span className="text-muted">None</span>;
|
|
57
|
+
return (
|
|
58
|
+
<ul className="readable list-disc space-y-1 pl-5 break-words">
|
|
59
|
+
{value.map((v: unknown, i) => (
|
|
60
|
+
<li key={i}>
|
|
61
|
+
{isPlain(v) ? (
|
|
62
|
+
<Inline value={v} />
|
|
63
|
+
) : v &&
|
|
64
|
+
typeof v === "object" &&
|
|
65
|
+
!Array.isArray(v) &&
|
|
66
|
+
Object.values(v).every(isPlain) ? (
|
|
67
|
+
<Row value={v as Record<string, unknown>} />
|
|
68
|
+
) : (
|
|
69
|
+
<ReadableOutput value={v} />
|
|
70
|
+
)}
|
|
71
|
+
</li>
|
|
72
|
+
))}
|
|
73
|
+
</ul>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (value && typeof value === "object") {
|
|
77
|
+
// Long text (a letter, a summary) reads best first and in full.
|
|
78
|
+
const entries = Object.entries(value as Record<string, unknown>).sort(
|
|
79
|
+
(a, b) =>
|
|
80
|
+
Number(typeof b[1] === "string" && b[1].length > 80) -
|
|
81
|
+
Number(typeof a[1] === "string" && a[1].length > 80),
|
|
82
|
+
);
|
|
83
|
+
return (
|
|
84
|
+
<dl className="space-y-2">
|
|
85
|
+
{entries.map(([k, v]) => (
|
|
86
|
+
<div key={k}>
|
|
87
|
+
<dt className="text-xs text-muted">{label(k)}</dt>
|
|
88
|
+
<dd>
|
|
89
|
+
<ReadableOutput value={v} />
|
|
90
|
+
</dd>
|
|
91
|
+
</div>
|
|
92
|
+
))}
|
|
93
|
+
</dl>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return <span className="text-muted">–</span>;
|
|
97
|
+
}
|
|
@@ -31,9 +31,9 @@ const KIND: Record<
|
|
|
31
31
|
help: "An earlier version made live again.",
|
|
32
32
|
},
|
|
33
33
|
DEPLOY: {
|
|
34
|
-
text: "
|
|
34
|
+
text: "New instructions",
|
|
35
35
|
tone: "fallback",
|
|
36
|
-
help:
|
|
36
|
+
help: GLOSSARY.newInstructions,
|
|
37
37
|
},
|
|
38
38
|
OUTSIDE: {
|
|
39
39
|
text: "Changed outside",
|
|
@@ -134,6 +134,9 @@ export function HistoryEntries({
|
|
|
134
134
|
const ev = (e.evidence ?? {}) as Evidence;
|
|
135
135
|
const testId = ev.runId ?? ev.live ?? null;
|
|
136
136
|
const isLive = e.to.id === liveId;
|
|
137
|
+
// Said outright: "same models" read as the app switching models.
|
|
138
|
+
const unchanged = (v: typeof e.to) =>
|
|
139
|
+
`Models unchanged: ${label(v.model)} live${v.fallbackModel ? `, ${label(v.fallbackModel)} fallback` : ""}`;
|
|
137
140
|
return (
|
|
138
141
|
<article
|
|
139
142
|
key={e.id}
|
|
@@ -160,9 +163,12 @@ export function HistoryEntries({
|
|
|
160
163
|
{(e.kind === "ROLLBACK"
|
|
161
164
|
? [`Back to v${e.to.number}: ${label(e.to.model)} live`]
|
|
162
165
|
: e.kind === "DEPLOY"
|
|
163
|
-
? ["
|
|
166
|
+
? [unchanged(e.to), "The instructions in code changed"]
|
|
164
167
|
: e.kind === "INSTRUCTIONS"
|
|
165
|
-
? [
|
|
168
|
+
? [
|
|
169
|
+
unchanged(e.to),
|
|
170
|
+
"The instructions were edited at runtime",
|
|
171
|
+
]
|
|
166
172
|
: describeChange(e.from, e.to, label)
|
|
167
173
|
).map((line) => (
|
|
168
174
|
<li key={line}>{line}</li>
|