@crowandraven/evalkeeper 0.12.0 → 0.14.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/dist/drafts.d.ts +2 -0
- package/dist/drafts.js +3 -1
- package/dist/drafts.js.map +1 -1
- package/dist/failures.d.ts +16 -0
- package/dist/failures.js +40 -0
- package/dist/failures.js.map +1 -0
- package/dist/glossary.d.ts +4 -2
- package/dist/glossary.js +4 -2
- package/dist/glossary.js.map +1 -1
- package/dist/health.d.ts +35 -2
- package/dist/health.js +31 -6
- package/dist/health.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/legs.d.ts +4 -1
- package/dist/legs.js +6 -2
- package/dist/legs.js.map +1 -1
- package/dist/next/actions.js +79 -15
- package/dist/next/actions.js.map +1 -1
- package/dist/next/route.js +2 -1
- package/dist/next/route.js.map +1 -1
- package/dist/next/weekly.d.ts +7 -2
- package/dist/next/weekly.js +5 -3
- package/dist/next/weekly.js.map +1 -1
- package/dist/next/wiring.d.ts +6 -0
- package/dist/order.d.ts +18 -0
- package/dist/order.js +53 -0
- package/dist/order.js.map +1 -0
- package/dist/prisma/index.d.ts +1 -0
- package/dist/prisma/index.js +3 -0
- package/dist/prisma/index.js.map +1 -1
- package/dist/prune.d.ts +4 -1
- package/dist/prune.js +11 -2
- package/dist/prune.js.map +1 -1
- package/dist/react/AddCase.d.ts +12 -2
- package/dist/react/AddCase.js +70 -8
- package/dist/react/AddCase.js.map +1 -1
- package/dist/react/AnswerKey.js +11 -5
- package/dist/react/AnswerKey.js.map +1 -1
- package/dist/react/CaseMenu.d.ts +6 -1
- package/dist/react/CaseMenu.js +5 -2
- package/dist/react/CaseMenu.js.map +1 -1
- package/dist/react/CompareView.js +4 -4
- package/dist/react/CompareView.js.map +1 -1
- package/dist/react/FeedbackView.js +3 -3
- package/dist/react/FeedbackView.js.map +1 -1
- package/dist/react/HubSections.js +11 -10
- package/dist/react/HubSections.js.map +1 -1
- package/dist/react/ModelMenu.d.ts +13 -4
- package/dist/react/ModelMenu.js +12 -7
- package/dist/react/ModelMenu.js.map +1 -1
- package/dist/react/PriorityPicker.d.ts +21 -0
- package/dist/react/PriorityPicker.js +47 -0
- package/dist/react/PriorityPicker.js.map +1 -0
- package/dist/react/RateView.js +1 -0
- package/dist/react/RateView.js.map +1 -1
- package/dist/react/RunView.js +21 -5
- package/dist/react/RunView.js.map +1 -1
- package/dist/react/SettingsHistory.js +3 -3
- package/dist/react/SettingsHistory.js.map +1 -1
- package/dist/react/SuiteSections.d.ts +6 -0
- package/dist/react/SuiteSections.js +100 -39
- package/dist/react/SuiteSections.js.map +1 -1
- package/dist/react/WeeklyCheck.js +4 -8
- package/dist/react/WeeklyCheck.js.map +1 -1
- package/dist/react/app.d.ts +4 -0
- package/dist/react/app.js.map +1 -1
- package/dist/react/format.d.ts +2 -2
- package/dist/react/format.js +4 -2
- package/dist/react/format.js.map +1 -1
- package/dist/react/pieces.d.ts +21 -1
- package/dist/react/pieces.js +67 -2
- package/dist/react/pieces.js.map +1 -1
- package/dist/runner.d.ts +7 -2
- package/dist/runner.js +5 -2
- package/dist/runner.js.map +1 -1
- package/dist/settings.d.ts +14 -0
- package/dist/settings.js +24 -2
- package/dist/settings.js.map +1 -1
- package/dist/suggest.js +25 -7
- package/dist/suggest.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +32 -0
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -1
- package/package.json +10 -10
- package/schema/evalkeeper.prisma +3 -0
- package/src/drafts.ts +6 -1
- package/src/failures.ts +50 -0
- package/src/glossary.ts +6 -2
- package/src/health.ts +55 -7
- package/src/index.ts +2 -0
- package/src/legs.ts +8 -2
- package/src/next/actions.ts +96 -17
- package/src/next/route.ts +2 -1
- package/src/next/weekly.ts +15 -4
- package/src/next/wiring.ts +6 -0
- package/src/order.ts +64 -0
- package/src/prisma/index.ts +5 -0
- package/src/prune.ts +15 -1
- package/src/react/AddCase.tsx +98 -11
- package/src/react/AnswerKey.tsx +74 -14
- package/src/react/CaseMenu.tsx +24 -0
- package/src/react/CompareView.tsx +19 -4
- package/src/react/FeedbackView.tsx +13 -3
- package/src/react/HubSections.tsx +18 -11
- package/src/react/ModelMenu.tsx +24 -7
- package/src/react/PriorityPicker.tsx +143 -0
- package/src/react/RateView.tsx +1 -0
- package/src/react/RunView.tsx +41 -6
- package/src/react/SettingsHistory.tsx +3 -3
- package/src/react/SuiteSections.tsx +418 -251
- package/src/react/WeeklyCheck.tsx +12 -6
- package/src/react/app.ts +4 -0
- package/src/react/format.ts +4 -2
- package/src/react/pieces.tsx +96 -2
- package/src/runner.ts +11 -4
- package/src/settings.ts +37 -2
- package/src/suggest.ts +26 -7
- package/src/testing.ts +35 -1
- package/src/types.ts +18 -0
- package/templates/lib/evalkeeper/actions.ts +8 -0
package/src/react/AnswerKey.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
InfoTip,
|
|
4
4
|
Select,
|
|
5
5
|
Submit,
|
|
6
|
+
TextArea,
|
|
6
7
|
TextInput,
|
|
7
8
|
Tip,
|
|
8
9
|
type ChipTone,
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
import { Check, ChevronRight, CircleAlert, X } from "lucide-react";
|
|
23
24
|
import type { EvalAppConfig } from "./app.js";
|
|
24
25
|
import { AnswerInput, FieldValues, Fields } from "./Fields.js";
|
|
25
|
-
import { AddCaseHeader } from "./AddCase.js";
|
|
26
|
+
import { AddCaseHeader, OpenLinkedCase } from "./AddCase.js";
|
|
26
27
|
import { CaseMenu } from "./CaseMenu.js";
|
|
27
28
|
import { ConfirmAnswer } from "./ConfirmAnswer.js";
|
|
28
29
|
|
|
@@ -97,9 +98,62 @@ export async function AnswerKey({
|
|
|
97
98
|
|
|
98
99
|
return (
|
|
99
100
|
<div className="space-y-4">
|
|
101
|
+
<OpenLinkedCase />
|
|
100
102
|
<AddCaseHeader
|
|
101
103
|
heading={heading}
|
|
102
104
|
tools={tools}
|
|
105
|
+
draft={
|
|
106
|
+
!readOnly &&
|
|
107
|
+
suite.draftMore &&
|
|
108
|
+
app.actions.draftMore && (
|
|
109
|
+
<form action={app.actions.draftMore} className="space-y-4">
|
|
110
|
+
<input type="hidden" name="suite" value={suite.key} />
|
|
111
|
+
<div className="space-y-1">
|
|
112
|
+
<label
|
|
113
|
+
htmlFor="draft-request"
|
|
114
|
+
className="block text-sm font-medium"
|
|
115
|
+
>
|
|
116
|
+
Describe the cases you want
|
|
117
|
+
</label>
|
|
118
|
+
<TextArea
|
|
119
|
+
id="draft-request"
|
|
120
|
+
name="focus"
|
|
121
|
+
required
|
|
122
|
+
rows={3}
|
|
123
|
+
maxLength={500}
|
|
124
|
+
placeholder="e.g. three guardrail cases where the person states a salary floor"
|
|
125
|
+
className="w-full rounded-md border border-line bg-card px-3 py-2 text-sm focus:border-accent focus:outline-none"
|
|
126
|
+
/>
|
|
127
|
+
</div>
|
|
128
|
+
<div className="space-y-1">
|
|
129
|
+
<label
|
|
130
|
+
htmlFor="draft-count"
|
|
131
|
+
className="block text-sm font-medium"
|
|
132
|
+
>
|
|
133
|
+
How many
|
|
134
|
+
</label>
|
|
135
|
+
<Select
|
|
136
|
+
id="draft-count"
|
|
137
|
+
name="count"
|
|
138
|
+
defaultValue="3"
|
|
139
|
+
className="rounded-md border border-line bg-card px-3 py-2 text-sm"
|
|
140
|
+
>
|
|
141
|
+
{[1, 2, 3, 5, 10].map((n) => (
|
|
142
|
+
<option key={n} value={n}>
|
|
143
|
+
{n}
|
|
144
|
+
</option>
|
|
145
|
+
))}
|
|
146
|
+
</Select>
|
|
147
|
+
</div>
|
|
148
|
+
<p className="readable text-xs text-muted">
|
|
149
|
+
A model writes them from your description and the cases you
|
|
150
|
+
have. They arrive as drafts: nothing counts until you confirm
|
|
151
|
+
each one.
|
|
152
|
+
</p>
|
|
153
|
+
<Submit>Draft them</Submit>
|
|
154
|
+
</form>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
103
157
|
form={
|
|
104
158
|
!readOnly &&
|
|
105
159
|
fields &&
|
|
@@ -237,15 +291,17 @@ function CaseItem({
|
|
|
237
291
|
// Where ConfirmAnswer moves on to after confirming the case above.
|
|
238
292
|
data-pending={answer?.status === "PENDING" ? "true" : undefined}
|
|
239
293
|
>
|
|
240
|
-
|
|
241
|
-
|
|
294
|
+
{/* The chips keep their place on the right; a long title wraps
|
|
295
|
+
beside them (below them only on a phone). */}
|
|
296
|
+
<summary className="flex cursor-pointer list-none flex-wrap items-start justify-between gap-2 p-3 text-sm sm:flex-nowrap">
|
|
297
|
+
<span className="flex min-w-0 flex-1 items-start pt-0.5 font-medium">
|
|
242
298
|
<ChevronRight
|
|
243
299
|
aria-hidden
|
|
244
|
-
className="mr-1.5
|
|
300
|
+
className="mr-1.5 mt-0.5 h-4 w-4 shrink-0 text-muted transition-transform group-open:rotate-90"
|
|
245
301
|
/>
|
|
246
|
-
{suite.title(input)}
|
|
302
|
+
<span className="readable min-w-0">{suite.title(input)}</span>
|
|
247
303
|
</span>
|
|
248
|
-
<span className="flex items-center gap-1.5">
|
|
304
|
+
<span className="flex shrink-0 items-center gap-1.5">
|
|
249
305
|
<Tip term={status.term} id={`status-${c.id}`}>
|
|
250
306
|
<Chip tone={status.tone}>{status.text}</Chip>
|
|
251
307
|
</Tip>
|
|
@@ -366,20 +422,24 @@ function CaseItem({
|
|
|
366
422
|
</section>
|
|
367
423
|
)}
|
|
368
424
|
|
|
369
|
-
{!readOnly && answer?.status === "PENDING" && (
|
|
370
|
-
<ConfirmAnswer
|
|
371
|
-
action={app.actions.confirmAnswer}
|
|
372
|
-
suite={suite.key}
|
|
373
|
-
labelId={answer.id}
|
|
374
|
-
/>
|
|
375
|
-
)}
|
|
376
|
-
|
|
377
425
|
{!readOnly && (
|
|
378
426
|
<CaseMenu
|
|
379
427
|
suite={suite.key}
|
|
380
428
|
caseId={c.id}
|
|
381
429
|
retire={app.actions.retireCase}
|
|
382
430
|
startEditing={!answer}
|
|
431
|
+
// Pending or provisional: confirm it as it is, or change it.
|
|
432
|
+
review={
|
|
433
|
+
answer &&
|
|
434
|
+
(answer.status === "PENDING" ||
|
|
435
|
+
answer.status === "PROVISIONAL") && (
|
|
436
|
+
<ConfirmAnswer
|
|
437
|
+
action={app.actions.confirmAnswer}
|
|
438
|
+
suite={suite.key}
|
|
439
|
+
labelId={answer.id}
|
|
440
|
+
/>
|
|
441
|
+
)
|
|
442
|
+
}
|
|
383
443
|
editLabel={
|
|
384
444
|
suite.fields &&
|
|
385
445
|
(suite.labelFromForm || app.answerEditors[suite.key])
|
package/src/react/CaseMenu.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { QUIET_BUTTON } from "./format.js";
|
|
4
|
+
|
|
3
5
|
import { Button } from "./pieces.js";
|
|
4
6
|
import { useEffect, useRef, useState } from "react";
|
|
5
7
|
import { EllipsisVertical } from "lucide-react";
|
|
@@ -16,6 +18,7 @@ export function CaseMenu({
|
|
|
16
18
|
edit,
|
|
17
19
|
retire,
|
|
18
20
|
startEditing = false,
|
|
21
|
+
review,
|
|
19
22
|
}: {
|
|
20
23
|
suite: string;
|
|
21
24
|
caseId: string;
|
|
@@ -27,6 +30,11 @@ export function CaseMenu({
|
|
|
27
30
|
retire: (form: FormData) => Promise<void>;
|
|
28
31
|
/** Open the form from the start, for a case with no answer yet. */
|
|
29
32
|
startEditing?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* For an answer nobody has confirmed yet (pending or provisional): the
|
|
35
|
+
* confirm button, shown with **Edit answer** beside it, in plain sight.
|
|
36
|
+
*/
|
|
37
|
+
review?: React.ReactNode;
|
|
30
38
|
}) {
|
|
31
39
|
const [open, setOpen] = useState(false);
|
|
32
40
|
const [editing, setEditing] = useState(startEditing);
|
|
@@ -101,6 +109,22 @@ export function CaseMenu({
|
|
|
101
109
|
</div>
|
|
102
110
|
)}
|
|
103
111
|
</div>
|
|
112
|
+
{review && !editing && (
|
|
113
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
114
|
+
{review}
|
|
115
|
+
{editLabel && (
|
|
116
|
+
<Button
|
|
117
|
+
type="button"
|
|
118
|
+
onClick={() => {
|
|
119
|
+
setEditing(true);
|
|
120
|
+
}}
|
|
121
|
+
className={`rounded-md px-3 py-1.5 text-sm ${QUIET_BUTTON}`}
|
|
122
|
+
>
|
|
123
|
+
{editLabel}
|
|
124
|
+
</Button>
|
|
125
|
+
)}
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
104
128
|
{editing && (
|
|
105
129
|
<div className="space-y-3 rounded-md bg-tint p-3">
|
|
106
130
|
<div className="flex items-center justify-between gap-2">
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
import { evalsPath, type EvalAppConfig } from "./app.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
3
|
+
import {
|
|
4
|
+
BackLink,
|
|
5
|
+
Card,
|
|
6
|
+
Chip,
|
|
7
|
+
InfoTip,
|
|
8
|
+
Link,
|
|
9
|
+
Tip,
|
|
10
|
+
LocalDate,
|
|
11
|
+
} from "./pieces.js";
|
|
12
|
+
import { pct, LINK } from "./format.js";
|
|
4
13
|
import {
|
|
5
14
|
checkBar,
|
|
6
15
|
perAnswer,
|
|
@@ -17,11 +26,17 @@ const one = (v: string | string[] | undefined) =>
|
|
|
17
26
|
typeof v === "string" && v ? v : null;
|
|
18
27
|
|
|
19
28
|
/** A test's name: its model, reasoning setting, set, and when it ran. */
|
|
20
|
-
function testName(models: ModelCatalog, r: RunRecord):
|
|
29
|
+
function testName(models: ModelCatalog, r: RunRecord): ReactNode {
|
|
21
30
|
const model = models[r.model]?.label ?? r.model;
|
|
22
31
|
const effort = r.reasoningEffort ? `, ${r.reasoningEffort} reasoning` : "";
|
|
23
32
|
const set = r.set === "ALL" ? "" : `, ${r.set.toLowerCase()} set`;
|
|
24
|
-
return
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
{model}
|
|
36
|
+
{effort}
|
|
37
|
+
{set} · <LocalDate date={r.startedAt} time />
|
|
38
|
+
</>
|
|
39
|
+
);
|
|
25
40
|
}
|
|
26
41
|
|
|
27
42
|
/** A pass rate as "80% (8/10)", or a dash when the check never applied. */
|
|
@@ -8,8 +8,16 @@ import {
|
|
|
8
8
|
type FeedbackRecord,
|
|
9
9
|
} from "../index.js";
|
|
10
10
|
import { FieldValues } from "./Fields.js";
|
|
11
|
-
import {
|
|
12
|
-
|
|
11
|
+
import {
|
|
12
|
+
BackLink,
|
|
13
|
+
Card,
|
|
14
|
+
Chip,
|
|
15
|
+
InfoTip,
|
|
16
|
+
Submit,
|
|
17
|
+
Tip,
|
|
18
|
+
LocalDate,
|
|
19
|
+
} from "./pieces.js";
|
|
20
|
+
import { pct } from "./format.js";
|
|
13
21
|
import { ThumbsDown, ThumbsUp } from "lucide-react";
|
|
14
22
|
|
|
15
23
|
/**
|
|
@@ -167,7 +175,9 @@ function Rating({
|
|
|
167
175
|
</Chip>
|
|
168
176
|
<span className="font-medium">{feature}</span>
|
|
169
177
|
</span>
|
|
170
|
-
<span className="text-xs text-muted">
|
|
178
|
+
<span className="text-xs text-muted">
|
|
179
|
+
<LocalDate date={f.updatedAt} time />
|
|
180
|
+
</span>
|
|
171
181
|
</div>
|
|
172
182
|
{f.reason && <p className="readable">“{f.reason}”</p>}
|
|
173
183
|
<div className="grid gap-4 md:grid-cols-2">
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
attention,
|
|
4
4
|
isInjectionSuite,
|
|
5
5
|
perAnswer,
|
|
6
|
+
priorityOf,
|
|
6
7
|
seconds,
|
|
7
8
|
suiteHealth,
|
|
8
9
|
thumbsSummary,
|
|
@@ -11,8 +12,8 @@ import {
|
|
|
11
12
|
type Settings,
|
|
12
13
|
type SettingsVersion,
|
|
13
14
|
} from "../index.js";
|
|
14
|
-
import { Link, Card, InfoTip,
|
|
15
|
-
import { pct
|
|
15
|
+
import { Link, Card, InfoTip, HealthChips, LocalDate } from "./pieces.js";
|
|
16
|
+
import { pct } from "./format.js";
|
|
16
17
|
import { HistoryEntries } from "./SettingsHistory.js";
|
|
17
18
|
import {
|
|
18
19
|
daysAgo,
|
|
@@ -134,7 +135,7 @@ export function HubStats({ data }: { data: HubData }) {
|
|
|
134
135
|
: "—"
|
|
135
136
|
}
|
|
136
137
|
/>
|
|
137
|
-
<Link href={evalsPath(app, "feedback")}>
|
|
138
|
+
<Link href={evalsPath(app, "feedback")} className="block h-full">
|
|
138
139
|
<Stat
|
|
139
140
|
title="Thumbs down this week"
|
|
140
141
|
term="thumbs"
|
|
@@ -165,16 +166,16 @@ export function SuiteList({ data }: { data: HubData }) {
|
|
|
165
166
|
<div className="space-y-4">
|
|
166
167
|
{cards.map(({ b, i }) => {
|
|
167
168
|
const attacked = attacksOn(b.suite.key);
|
|
169
|
+
const [history, current] = histories[i] ?? [[], null];
|
|
168
170
|
const h = suiteHealth(
|
|
169
171
|
b.rows,
|
|
170
172
|
b.suite.checks,
|
|
171
|
-
b.suite
|
|
173
|
+
priorityOf(b.suite, current?.settings),
|
|
172
174
|
b.cases,
|
|
173
175
|
b.provisional,
|
|
174
176
|
app.models,
|
|
175
177
|
{ attacks: attacksFrom(attacked) },
|
|
176
178
|
);
|
|
177
|
-
const [history, current] = histories[i] ?? [[], null];
|
|
178
179
|
return (
|
|
179
180
|
<SuiteCard
|
|
180
181
|
app={app}
|
|
@@ -244,7 +245,8 @@ function Stat({
|
|
|
244
245
|
detail: string;
|
|
245
246
|
}) {
|
|
246
247
|
return (
|
|
247
|
-
|
|
248
|
+
// Full height, so the four cards line up however much each says.
|
|
249
|
+
<Card className="h-full space-y-1">
|
|
248
250
|
<p className="text-sm text-muted">
|
|
249
251
|
{title}
|
|
250
252
|
<InfoTip term={term} />
|
|
@@ -257,7 +259,6 @@ function Stat({
|
|
|
257
259
|
|
|
258
260
|
type Board = Awaited<ReturnType<Runner["board"]>>;
|
|
259
261
|
|
|
260
|
-
const day = dayOf;
|
|
261
262
|
/** Green at 95% and up, amber from 80%, red below. */
|
|
262
263
|
const scoreTone = (rate: number) =>
|
|
263
264
|
rate >= 0.95 ? "text-good" : rate >= 0.8 ? "text-warn" : "text-bad";
|
|
@@ -308,7 +309,7 @@ function SuiteCard({
|
|
|
308
309
|
{b.suite.label}
|
|
309
310
|
</Link>
|
|
310
311
|
</h2>
|
|
311
|
-
<
|
|
312
|
+
<HealthChips flags={h.flags} />
|
|
312
313
|
</div>
|
|
313
314
|
<p className="readable text-sm text-muted">{b.suite.description}</p>
|
|
314
315
|
</div>
|
|
@@ -351,7 +352,7 @@ function SuiteCard({
|
|
|
351
352
|
<p className="text-sm">
|
|
352
353
|
{t ? (
|
|
353
354
|
<>
|
|
354
|
-
|
|
355
|
+
Accuracy{" "}
|
|
355
356
|
<span className={`font-semibold ${scoreTone(t.right / t.total)}`}>
|
|
356
357
|
{pct(t.right / t.total)}
|
|
357
358
|
</span>
|
|
@@ -403,8 +404,14 @@ function SuiteCard({
|
|
|
403
404
|
<span className="font-medium text-ink">
|
|
404
405
|
v{version?.number ?? 1}
|
|
405
406
|
</span>{" "}
|
|
406
|
-
{since ?
|
|
407
|
-
|
|
407
|
+
{since ? (
|
|
408
|
+
<>
|
|
409
|
+
live since <LocalDate date={since} />
|
|
410
|
+
</>
|
|
411
|
+
) : (
|
|
412
|
+
"defaults from code"
|
|
413
|
+
)}{" "}
|
|
414
|
+
· {versions} version{versions === 1 ? "" : "s"}
|
|
408
415
|
<ChevronDown
|
|
409
416
|
aria-hidden
|
|
410
417
|
className="h-4 w-4 transition-transform group-open/history:rotate-180"
|
package/src/react/ModelMenu.tsx
CHANGED
|
@@ -6,14 +6,15 @@ import { Button } from "./pieces.js";
|
|
|
6
6
|
import type { FormAction } from "./app.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* A model row's menu:
|
|
10
|
-
* row allows either. Keeps the model
|
|
11
|
-
* outside or Escape.
|
|
9
|
+
* A model row's menu: test it (with what that costs now), make it live,
|
|
10
|
+
* or make it the fallback, where the row allows either. Keeps the model
|
|
11
|
+
* table narrow. Closes on a click outside or Escape.
|
|
12
12
|
*/
|
|
13
13
|
export function ModelMenu({
|
|
14
14
|
suite,
|
|
15
15
|
model,
|
|
16
16
|
label,
|
|
17
|
+
test,
|
|
17
18
|
makeLive,
|
|
18
19
|
makeFallback,
|
|
19
20
|
effort,
|
|
@@ -22,6 +23,11 @@ export function ModelMenu({
|
|
|
22
23
|
model: string;
|
|
23
24
|
/** The model's name, for the button's accessible name. */
|
|
24
25
|
label: string;
|
|
26
|
+
/**
|
|
27
|
+
* Your testModel action, its words ("Test", "Test again"), and what
|
|
28
|
+
* testing costs now ("free, all 34 reused"), when known.
|
|
29
|
+
*/
|
|
30
|
+
test?: { action: FormAction; text: string; note: string | null };
|
|
25
31
|
/** Your makeLive action, when the model can be made live. */
|
|
26
32
|
makeLive: FormAction | null;
|
|
27
33
|
/** Your makeFallback action, when it can be the fallback. */
|
|
@@ -53,11 +59,20 @@ export function ModelMenu({
|
|
|
53
59
|
};
|
|
54
60
|
}, [open]);
|
|
55
61
|
|
|
56
|
-
if (!makeLive && !makeFallback) return null;
|
|
62
|
+
if (!test && !makeLive && !makeFallback) return null;
|
|
57
63
|
const item =
|
|
58
64
|
"block w-full rounded px-3 py-1.5 text-left text-sm hover:bg-tint";
|
|
59
|
-
const choice = (action: FormAction, text: string) => (
|
|
60
|
-
|
|
65
|
+
const choice = (action: FormAction, text: string, note?: string | null) => (
|
|
66
|
+
// Closes once chosen (after the submit is read), so the open menu
|
|
67
|
+
// doesn't cover the rows below it.
|
|
68
|
+
<form
|
|
69
|
+
action={action}
|
|
70
|
+
onSubmit={() =>
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
setOpen(false);
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
>
|
|
61
76
|
<input type="hidden" name="suite" value={suite} />
|
|
62
77
|
<input type="hidden" name="model" value={model} />
|
|
63
78
|
{effort !== undefined && (
|
|
@@ -65,6 +80,7 @@ export function ModelMenu({
|
|
|
65
80
|
)}
|
|
66
81
|
<Button type="submit" role="menuitem" className={item}>
|
|
67
82
|
{text}
|
|
83
|
+
{note && <span className="block text-xs text-muted">{note}</span>}
|
|
68
84
|
</Button>
|
|
69
85
|
</form>
|
|
70
86
|
);
|
|
@@ -87,8 +103,9 @@ export function ModelMenu({
|
|
|
87
103
|
{open && (
|
|
88
104
|
<div
|
|
89
105
|
role="menu"
|
|
90
|
-
className="absolute right-0 z-20 mt-1 w-
|
|
106
|
+
className="absolute right-0 z-20 mt-1 w-56 rounded-md border border-line bg-card p-1 shadow-lg"
|
|
91
107
|
>
|
|
108
|
+
{test && choice(test.action, test.text, test.note)}
|
|
92
109
|
{makeLive && choice(makeLive, "Make live")}
|
|
93
110
|
{makeFallback && choice(makeFallback, "Make fallback")}
|
|
94
111
|
</div>
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { ChevronDown, X } from "lucide-react";
|
|
5
|
+
import { Button, Select, Submit, TextInput } from "./pieces.js";
|
|
6
|
+
import type { FormAction } from "./app.js";
|
|
7
|
+
import type { SuitePriority } from "../types.js";
|
|
8
|
+
|
|
9
|
+
type Favor = SuitePriority["favor"];
|
|
10
|
+
|
|
11
|
+
/** The choices when changing it: accuracy is always held. */
|
|
12
|
+
const CHOICES = {
|
|
13
|
+
quality: "Accuracy alone",
|
|
14
|
+
speed: "Speed",
|
|
15
|
+
cost: "Cost",
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The "Favors …" chip as a button: it opens what the priority means and
|
|
20
|
+
* a form to change it, saved as a new settings version with an optional
|
|
21
|
+
* reason, so it shows under Versions and can be rolled back. Closes with
|
|
22
|
+
* its X, Escape, or a click outside.
|
|
23
|
+
*/
|
|
24
|
+
export function PriorityPicker({
|
|
25
|
+
action,
|
|
26
|
+
suite,
|
|
27
|
+
favor,
|
|
28
|
+
own,
|
|
29
|
+
label,
|
|
30
|
+
why,
|
|
31
|
+
}: {
|
|
32
|
+
action: FormAction;
|
|
33
|
+
suite: string;
|
|
34
|
+
favor: Favor;
|
|
35
|
+
/** The suite's own priority, from its code. */
|
|
36
|
+
own: Favor;
|
|
37
|
+
/** The chip's words: "Favors speed". */
|
|
38
|
+
label: string;
|
|
39
|
+
/** What the priority means for the suggestion, as a sentence. */
|
|
40
|
+
why: string;
|
|
41
|
+
}) {
|
|
42
|
+
const [open, setOpen] = useState(false);
|
|
43
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!open) return;
|
|
47
|
+
const close = (e: MouseEvent | KeyboardEvent) => {
|
|
48
|
+
if (
|
|
49
|
+
e instanceof KeyboardEvent
|
|
50
|
+
? e.key === "Escape"
|
|
51
|
+
: !ref.current?.contains(e.target as Node)
|
|
52
|
+
)
|
|
53
|
+
setOpen(false);
|
|
54
|
+
};
|
|
55
|
+
document.addEventListener("mousedown", close);
|
|
56
|
+
document.addEventListener("keydown", close);
|
|
57
|
+
return () => {
|
|
58
|
+
document.removeEventListener("mousedown", close);
|
|
59
|
+
document.removeEventListener("keydown", close);
|
|
60
|
+
};
|
|
61
|
+
}, [open]);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div ref={ref} className="relative text-sm font-normal">
|
|
65
|
+
<Button
|
|
66
|
+
type="button"
|
|
67
|
+
aria-haspopup="dialog"
|
|
68
|
+
aria-expanded={open}
|
|
69
|
+
onClick={() => {
|
|
70
|
+
setOpen(!open);
|
|
71
|
+
}}
|
|
72
|
+
className="inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-full bg-tint px-2.5 text-xs font-medium leading-none text-muted hover:text-ink"
|
|
73
|
+
>
|
|
74
|
+
{label}
|
|
75
|
+
<ChevronDown aria-hidden className="h-3 w-3" />
|
|
76
|
+
</Button>
|
|
77
|
+
{open && (
|
|
78
|
+
<div
|
|
79
|
+
role="dialog"
|
|
80
|
+
aria-label="What this feature favors"
|
|
81
|
+
className="absolute left-0 z-20 mt-2 w-80 rounded-md border border-line bg-card p-4 shadow-lg"
|
|
82
|
+
>
|
|
83
|
+
<div className="flex items-start justify-between gap-3">
|
|
84
|
+
<p className="text-muted">{why}</p>
|
|
85
|
+
<Button
|
|
86
|
+
type="button"
|
|
87
|
+
aria-label="Close"
|
|
88
|
+
title="Close"
|
|
89
|
+
onClick={() => {
|
|
90
|
+
setOpen(false);
|
|
91
|
+
}}
|
|
92
|
+
className="-mr-1 -mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-tint hover:text-ink"
|
|
93
|
+
>
|
|
94
|
+
<X aria-hidden className="h-4 w-4" />
|
|
95
|
+
</Button>
|
|
96
|
+
</div>
|
|
97
|
+
<form
|
|
98
|
+
action={action}
|
|
99
|
+
// Closes once saved (after the submit is read).
|
|
100
|
+
onSubmit={() =>
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
setOpen(false);
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
className="mt-4 space-y-3"
|
|
106
|
+
>
|
|
107
|
+
<input type="hidden" name="suite" value={suite} />
|
|
108
|
+
<div>
|
|
109
|
+
<label htmlFor="favor" className="block font-medium">
|
|
110
|
+
Once accuracy holds, favor
|
|
111
|
+
</label>
|
|
112
|
+
<Select
|
|
113
|
+
id="favor"
|
|
114
|
+
name="favor"
|
|
115
|
+
defaultValue={favor}
|
|
116
|
+
className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2"
|
|
117
|
+
>
|
|
118
|
+
{(["quality", "speed", "cost"] as const).map((f) => (
|
|
119
|
+
<option key={f} value={f}>
|
|
120
|
+
{CHOICES[f]}
|
|
121
|
+
{f === own ? " (the suite's own)" : ""}
|
|
122
|
+
</option>
|
|
123
|
+
))}
|
|
124
|
+
</Select>
|
|
125
|
+
</div>
|
|
126
|
+
<div>
|
|
127
|
+
<label htmlFor="favor-reason" className="block font-medium">
|
|
128
|
+
Why? <span className="font-normal text-muted">(optional)</span>
|
|
129
|
+
</label>
|
|
130
|
+
<TextInput
|
|
131
|
+
id="favor-reason"
|
|
132
|
+
name="reason"
|
|
133
|
+
maxLength={300}
|
|
134
|
+
className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2"
|
|
135
|
+
/>
|
|
136
|
+
</div>
|
|
137
|
+
<Submit>Save as a new version</Submit>
|
|
138
|
+
</form>
|
|
139
|
+
</div>
|
|
140
|
+
)}
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
}
|
package/src/react/RateView.tsx
CHANGED
package/src/react/RunView.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { evalsPath, type EvalAppConfig } from "./app.js";
|
|
2
|
-
import { Link } from "./pieces.js";
|
|
3
|
-
import { allPassed, money, summarize } from "../index.js";
|
|
2
|
+
import { Link, LocalDate } from "./pieces.js";
|
|
3
|
+
import { allPassed, failureHints, money, summarize } from "../index.js";
|
|
4
4
|
import { FieldValues } from "./Fields.js";
|
|
5
5
|
import { ReadableOutput } from "./ReadableOutput.js";
|
|
6
6
|
import { BackLink, Card } from "./pieces.js";
|
|
7
|
-
import { pct,
|
|
7
|
+
import { pct, LINK } from "./format.js";
|
|
8
8
|
|
|
9
9
|
/** One test: every answer, with what each check found. */
|
|
10
10
|
|
|
@@ -32,6 +32,21 @@ export async function RunView({
|
|
|
32
32
|
};
|
|
33
33
|
const metrics = run.metrics;
|
|
34
34
|
const summary = metrics ? summarize(metrics, suite.checks) : null;
|
|
35
|
+
// Answers that never came back first, then wrong ones, then right ones,
|
|
36
|
+
// so what needs a look is at the top.
|
|
37
|
+
const rank = (o: (typeof outputs)[number]) =>
|
|
38
|
+
o.error ? 0 : allPassed(o.scores ?? null) ? 2 : 1;
|
|
39
|
+
const ordered = [...outputs].sort((a, b) => rank(a) - rank(b));
|
|
40
|
+
const failed = outputs.filter((o) => o.error);
|
|
41
|
+
// Why they failed, counted: "timed out after 60s (3)".
|
|
42
|
+
const reasons = [
|
|
43
|
+
...failed
|
|
44
|
+
.reduce((m, o) => {
|
|
45
|
+
const why = (o.error ?? "").split("\n")[0]?.slice(0, 120) ?? "";
|
|
46
|
+
return m.set(why, (m.get(why) ?? 0) + 1);
|
|
47
|
+
}, new Map<string, number>())
|
|
48
|
+
.entries(),
|
|
49
|
+
];
|
|
35
50
|
const label = (k: string) =>
|
|
36
51
|
suite.checks.find((c) => c.key === k)?.label ?? k;
|
|
37
52
|
type Check = {
|
|
@@ -50,7 +65,7 @@ export async function RunView({
|
|
|
50
65
|
{app.models[run.model]?.label ?? run.model} on {suite.label}
|
|
51
66
|
</h1>
|
|
52
67
|
<p className="text-sm text-muted">
|
|
53
|
-
{
|
|
68
|
+
<LocalDate date={run.startedAt} time /> · {run.status.toLowerCase()}
|
|
54
69
|
{metrics && ` · spent ${money(metrics.costUsd)}`}
|
|
55
70
|
</p>
|
|
56
71
|
{run.error && <p className="readable text-bad">{run.error}</p>}
|
|
@@ -62,6 +77,21 @@ export async function RunView({
|
|
|
62
77
|
{pct(summary.total ? summary.right / summary.total : 0)})
|
|
63
78
|
</p>
|
|
64
79
|
<p className="readable text-sm text-muted">{summary.trust}</p>
|
|
80
|
+
{failed.length > 0 && (
|
|
81
|
+
<p className="readable text-sm text-bad">
|
|
82
|
+
{failed.length} {failed.length === 1 ? "answer" : "answers"}{" "}
|
|
83
|
+
didn't come back:{" "}
|
|
84
|
+
{reasons.map(([why, n]) => `${why} (${n})`).join("; ")}.{" "}
|
|
85
|
+
<a href="#failed" className={LINK}>
|
|
86
|
+
See {failed.length === 1 ? "it" : "them"}
|
|
87
|
+
</a>
|
|
88
|
+
</p>
|
|
89
|
+
)}
|
|
90
|
+
{failureHints(failed.map((o) => o.error)).map((hint) => (
|
|
91
|
+
<p key={hint} className="readable text-sm text-muted">
|
|
92
|
+
{hint}
|
|
93
|
+
</p>
|
|
94
|
+
))}
|
|
65
95
|
{summary.problems.length > 0 && (
|
|
66
96
|
<ul className="readable list-disc pl-5 text-sm">
|
|
67
97
|
{summary.problems.map((p) => (
|
|
@@ -74,11 +104,16 @@ export async function RunView({
|
|
|
74
104
|
</Card>
|
|
75
105
|
)}
|
|
76
106
|
<Card className="space-y-3">
|
|
77
|
-
{
|
|
107
|
+
{ordered.map((o, i) => {
|
|
78
108
|
const checks = (o.scores as Check[] | null) ?? null;
|
|
79
109
|
const ok = allPassed(checks);
|
|
80
110
|
return (
|
|
81
|
-
<div
|
|
111
|
+
<div
|
|
112
|
+
key={o.id}
|
|
113
|
+
// The summary's "See them" lands on the first failed answer.
|
|
114
|
+
id={o.error && i === 0 ? "failed" : undefined}
|
|
115
|
+
className="scroll-mt-4 rounded-md bg-tint p-3 text-sm"
|
|
116
|
+
>
|
|
82
117
|
<div className="flex justify-between gap-4">
|
|
83
118
|
<span className="font-medium">{titleOf(o.caseId)}</span>
|
|
84
119
|
<span
|