@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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, type ReactNode } from "react";
|
|
4
|
+
import { Button } from "./pieces.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Tabs over panels drawn on the server: every panel is on the page, and
|
|
8
|
+
* the tabs show one at a time. For a section with a few views of the same
|
|
9
|
+
* thing (a feature's cases, and its attack cases).
|
|
10
|
+
*/
|
|
11
|
+
export function Tabs({
|
|
12
|
+
label,
|
|
13
|
+
tabs,
|
|
14
|
+
}: {
|
|
15
|
+
/** What the tabs choose between, for screen readers. */
|
|
16
|
+
label: string;
|
|
17
|
+
tabs: { id: string; title: string; panel: ReactNode }[];
|
|
18
|
+
}) {
|
|
19
|
+
const [shown, setShown] = useState(tabs[0]?.id ?? "");
|
|
20
|
+
return (
|
|
21
|
+
<div className="space-y-4">
|
|
22
|
+
<div
|
|
23
|
+
role="tablist"
|
|
24
|
+
aria-label={label}
|
|
25
|
+
className="flex gap-1 border-b border-line"
|
|
26
|
+
>
|
|
27
|
+
{tabs.map((t) => (
|
|
28
|
+
<Button
|
|
29
|
+
key={t.id}
|
|
30
|
+
type="button"
|
|
31
|
+
role="tab"
|
|
32
|
+
id={`tab-${t.id}`}
|
|
33
|
+
aria-selected={shown === t.id}
|
|
34
|
+
aria-controls={`panel-${t.id}`}
|
|
35
|
+
onClick={() => {
|
|
36
|
+
setShown(t.id);
|
|
37
|
+
}}
|
|
38
|
+
className={`-mb-px border-b px-3 py-2 text-sm ${
|
|
39
|
+
shown === t.id
|
|
40
|
+
? "border-accent font-medium text-ink"
|
|
41
|
+
: "border-transparent text-muted hover:text-ink"
|
|
42
|
+
}`}
|
|
43
|
+
>
|
|
44
|
+
{t.title}
|
|
45
|
+
</Button>
|
|
46
|
+
))}
|
|
47
|
+
</div>
|
|
48
|
+
{tabs.map((t) => (
|
|
49
|
+
<div
|
|
50
|
+
key={t.id}
|
|
51
|
+
role="tabpanel"
|
|
52
|
+
id={`panel-${t.id}`}
|
|
53
|
+
aria-labelledby={`tab-${t.id}`}
|
|
54
|
+
hidden={shown !== t.id}
|
|
55
|
+
>
|
|
56
|
+
{t.panel}
|
|
57
|
+
</div>
|
|
58
|
+
))}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { Button, TextInput } from "./pieces.js";
|
|
3
4
|
import { useState, useTransition } from "react";
|
|
4
5
|
import { ThumbsDown, ThumbsUp } from "lucide-react";
|
|
5
|
-
import { formText } from "
|
|
6
|
+
import { formText } from "../index.js";
|
|
6
7
|
|
|
7
8
|
type Rating = "UP" | "DOWN";
|
|
8
9
|
|
|
@@ -44,7 +45,7 @@ export function Thumbs({
|
|
|
44
45
|
? "Good answer"
|
|
45
46
|
: "Not a good answer";
|
|
46
47
|
return (
|
|
47
|
-
<
|
|
48
|
+
<Button
|
|
48
49
|
type="button"
|
|
49
50
|
aria-label={label}
|
|
50
51
|
title={label}
|
|
@@ -68,7 +69,7 @@ export function Thumbs({
|
|
|
68
69
|
) : (
|
|
69
70
|
<ThumbsDown aria-hidden className="h-4 w-4" />
|
|
70
71
|
)}
|
|
71
|
-
</
|
|
72
|
+
</Button>
|
|
72
73
|
);
|
|
73
74
|
};
|
|
74
75
|
|
|
@@ -96,20 +97,20 @@ export function Thumbs({
|
|
|
96
97
|
<label htmlFor={`why-${targetId}`} className="sr-only">
|
|
97
98
|
What was wrong?
|
|
98
99
|
</label>
|
|
99
|
-
<
|
|
100
|
+
<TextInput
|
|
100
101
|
id={`why-${targetId}`}
|
|
101
102
|
name="reason"
|
|
102
103
|
maxLength={1000}
|
|
103
104
|
placeholder="What was wrong? (optional)"
|
|
104
105
|
className="min-w-0 flex-1 rounded-md border border-line bg-card px-3 py-1.5 text-sm focus:border-accent focus:outline-none"
|
|
105
106
|
/>
|
|
106
|
-
<
|
|
107
|
+
<Button
|
|
107
108
|
type="submit"
|
|
108
109
|
disabled={pending}
|
|
109
110
|
className="rounded-md border border-line bg-card px-3 py-1.5 text-sm hover:bg-tint disabled:opacity-60"
|
|
110
111
|
>
|
|
111
112
|
Send
|
|
112
|
-
</
|
|
113
|
+
</Button>
|
|
113
114
|
</form>
|
|
114
115
|
)}
|
|
115
116
|
</div>
|
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { money, type WeeklySummary } from "../index.js";
|
|
2
|
+
import {
|
|
3
|
+
Card,
|
|
4
|
+
Chip,
|
|
5
|
+
InfoTip,
|
|
6
|
+
Link,
|
|
7
|
+
RefreshWhile,
|
|
8
|
+
Submit,
|
|
9
|
+
Tip,
|
|
10
|
+
} from "./pieces.js";
|
|
11
|
+
import { pct, dayOf, LINK } from "./format.js";
|
|
12
|
+
import { evalsPath, type EvalAppConfig } from "./app.js";
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* The weekly check on the evals hub: when it last ran, what it found, and
|
|
12
16
|
* a button to run it now. It only reports; a person decides what to change.
|
|
13
17
|
*/
|
|
14
|
-
export function WeeklyCheck({
|
|
18
|
+
export function WeeklyCheck({
|
|
19
|
+
app,
|
|
20
|
+
weekly,
|
|
21
|
+
}: {
|
|
22
|
+
/** Your screens' configuration. */
|
|
23
|
+
app: EvalAppConfig;
|
|
24
|
+
weekly: WeeklySummary;
|
|
25
|
+
}) {
|
|
15
26
|
return (
|
|
16
27
|
<section aria-labelledby="weekly" className="space-y-3">
|
|
17
28
|
<RefreshWhile active={weekly.running > 0} />
|
|
@@ -20,7 +31,7 @@ export function WeeklyCheck({ weekly }: { weekly: WeeklySummary }) {
|
|
|
20
31
|
Weekly check
|
|
21
32
|
<InfoTip term="weeklyCheck" />
|
|
22
33
|
</h2>
|
|
23
|
-
<form action={runWeeklyNow}>
|
|
34
|
+
<form action={app.actions.runWeeklyNow}>
|
|
24
35
|
<Submit variant="quiet">Run it now</Submit>
|
|
25
36
|
</form>
|
|
26
37
|
</div>
|
|
@@ -29,7 +40,7 @@ export function WeeklyCheck({ weekly }: { weekly: WeeklySummary }) {
|
|
|
29
40
|
{weekly.running > 0
|
|
30
41
|
? `Running now: ${weekly.running} quick set${weekly.running === 1 ? "" : "s"} left. `
|
|
31
42
|
: weekly.lastAt
|
|
32
|
-
? `Last run ${weekly.lastAt
|
|
43
|
+
? `Last run ${dayOf(weekly.lastAt)}, ${money(weekly.costUsd)}. `
|
|
33
44
|
: "Not run yet. "}
|
|
34
45
|
Every Monday, each live model answers its suite's quick set
|
|
35
46
|
again, so a quiet change by its provider shows up here. It also flags
|
|
@@ -54,8 +65,8 @@ export function WeeklyCheck({ weekly }: { weekly: WeeklySummary }) {
|
|
|
54
65
|
<Chip tone="serious">Drift</Chip>
|
|
55
66
|
<span>
|
|
56
67
|
<Link
|
|
57
|
-
href={evalsPath(d.suite)}
|
|
58
|
-
className=
|
|
68
|
+
href={evalsPath(app, d.suite)}
|
|
69
|
+
className={`font-medium ${LINK}`}
|
|
59
70
|
>
|
|
60
71
|
{d.label}
|
|
61
72
|
</Link>{" "}
|
|
@@ -73,8 +84,8 @@ export function WeeklyCheck({ weekly }: { weekly: WeeklySummary }) {
|
|
|
73
84
|
<Chip tone="serious">Didn't finish</Chip>
|
|
74
85
|
<span>
|
|
75
86
|
<Link
|
|
76
|
-
href={evalsPath(f.suite)}
|
|
77
|
-
className=
|
|
87
|
+
href={evalsPath(app, f.suite)}
|
|
88
|
+
className={`font-medium ${LINK}`}
|
|
78
89
|
>
|
|
79
90
|
{f.label}
|
|
80
91
|
</Link>
|
|
@@ -91,8 +102,8 @@ export function WeeklyCheck({ weekly }: { weekly: WeeklySummary }) {
|
|
|
91
102
|
<span>
|
|
92
103
|
{r.model}, the {r.role} model for{" "}
|
|
93
104
|
<Link
|
|
94
|
-
href={evalsPath(r.suite)}
|
|
95
|
-
className=
|
|
105
|
+
href={evalsPath(app, r.suite)}
|
|
106
|
+
className={`font-medium ${LINK}`}
|
|
96
107
|
>
|
|
97
108
|
{r.label}
|
|
98
109
|
</Link>
|
|
@@ -110,7 +121,7 @@ export function WeeklyCheck({ weekly }: { weekly: WeeklySummary }) {
|
|
|
110
121
|
<Chip tone="warn">Thumbs down</Chip>
|
|
111
122
|
<span>
|
|
112
123
|
{t.operation}: {t.down} of {t.up + t.down} ratings this week.{" "}
|
|
113
|
-
<Link href={evalsPath("feedback")} className=
|
|
124
|
+
<Link href={evalsPath(app, "feedback")} className={LINK}>
|
|
114
125
|
Read the reasons
|
|
115
126
|
</Link>
|
|
116
127
|
.
|
|
@@ -138,8 +149,8 @@ export function WeeklyCheck({ weekly }: { weekly: WeeklySummary }) {
|
|
|
138
149
|
: `${d.waiting} waiting for review. `}
|
|
139
150
|
{d.waiting > 0 && (
|
|
140
151
|
<Link
|
|
141
|
-
href={`${evalsPath(d.suite)}#answer-key`}
|
|
142
|
-
className=
|
|
152
|
+
href={`${evalsPath(app, d.suite)}#answer-key`}
|
|
153
|
+
className={LINK}
|
|
143
154
|
>
|
|
144
155
|
Review them
|
|
145
156
|
</Link>
|
package/src/react/app.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { EvalStore } from "../store.js";
|
|
3
|
+
import type { FeedbackStore } from "../feedback.js";
|
|
4
|
+
import { thumbsSummary } from "../feedback.js";
|
|
5
|
+
import type { ModelCatalog } from "../models.js";
|
|
6
|
+
import type { Route, Runner } from "../runner.js";
|
|
7
|
+
import type { BoardRow } from "../board.js";
|
|
8
|
+
import type { VersionedSettings } from "../settings.js";
|
|
9
|
+
import type { AnswerEditorProps, AnySuite } from "../types.js";
|
|
10
|
+
import { weeklySummary, type WeeklySummary } from "../weekly.js";
|
|
11
|
+
|
|
12
|
+
/** A form action: a server action the screens' forms submit to. */
|
|
13
|
+
export type FormAction = (form: FormData) => Promise<void>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The server actions the screens' forms submit to. On Next.js, a
|
|
17
|
+
* `"use server"` module of your app makes them (`evalActions` does it in
|
|
18
|
+
* one line); the screens never import your modules themselves.
|
|
19
|
+
*/
|
|
20
|
+
export type EvalActions = {
|
|
21
|
+
testModel: FormAction;
|
|
22
|
+
testAll: FormAction;
|
|
23
|
+
makeLive: FormAction;
|
|
24
|
+
makeFallback: FormAction;
|
|
25
|
+
useSuggestion: FormAction;
|
|
26
|
+
rescore: FormAction;
|
|
27
|
+
rollBackSettings: FormAction;
|
|
28
|
+
confirmAnswer: FormAction;
|
|
29
|
+
addCase: FormAction;
|
|
30
|
+
editAnswer: FormAction;
|
|
31
|
+
retireCase: FormAction;
|
|
32
|
+
/** Retiring easy cases beyond the floor; the health panel's button. */
|
|
33
|
+
retireEasy?: FormAction;
|
|
34
|
+
/** Retiring drafts nobody reviewed; the health panel's button. */
|
|
35
|
+
retireStaleDrafts?: FormAction;
|
|
36
|
+
runWeeklyNow: () => Promise<void>;
|
|
37
|
+
/** Blind rating; only for an app with the rate page. */
|
|
38
|
+
rateBlind?: FormAction;
|
|
39
|
+
/** Skipping a case in blind rating; only with the rate page. */
|
|
40
|
+
skipCase?: FormAction;
|
|
41
|
+
/** Turning a rating into a draft case; only with the feedback page. */
|
|
42
|
+
makeCase?: FormAction;
|
|
43
|
+
/** Setting a rating aside; only with the feedback page. */
|
|
44
|
+
dismissFeedback?: FormAction;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Everything Evalkeeper's screens need from your app, in one object: your
|
|
49
|
+
* runner, settings, and stores, your models and suites, where the pages
|
|
50
|
+
* live, your answer editors, and the actions their forms submit to. Make
|
|
51
|
+
* it once in your wiring module with `defineEvals`, and pass it to the
|
|
52
|
+
* screens.
|
|
53
|
+
*/
|
|
54
|
+
export type EvalApp = {
|
|
55
|
+
runner: Runner;
|
|
56
|
+
settings: VersionedSettings;
|
|
57
|
+
store: EvalStore;
|
|
58
|
+
feedbackStore: FeedbackStore;
|
|
59
|
+
/** Your model catalog: labels, providers, prices, and retirements. */
|
|
60
|
+
models: ModelCatalog;
|
|
61
|
+
suites: AnySuite[];
|
|
62
|
+
/** What's live for an operation, as your router sees it. */
|
|
63
|
+
routeFor: (operation: string) => Promise<Route>;
|
|
64
|
+
/** Your own editors for answers plain fields edit badly, by suite. */
|
|
65
|
+
answerEditors: Partial<Record<string, ComponentType<AnswerEditorProps>>>;
|
|
66
|
+
actions: EvalActions;
|
|
67
|
+
/** Where the eval pages live, as a URL path: "/evals", "/admin/evals". */
|
|
68
|
+
basePath: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** An `EvalApp` with its suites by key, as the screens read it. */
|
|
72
|
+
export type EvalAppConfig = EvalApp & {
|
|
73
|
+
/** Each suite by its key. */
|
|
74
|
+
suiteByKey: Readonly<Record<string, AnySuite>>;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** A path without its trailing slashes, in one pass (no regex to backtrack). */
|
|
78
|
+
function withoutTrailingSlashes(path: string): string {
|
|
79
|
+
let end = path.length;
|
|
80
|
+
while (end > 0 && path[end - 1] === "/") end--;
|
|
81
|
+
return path.slice(0, end);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Makes the object the screens read everything from. Call it once in your
|
|
86
|
+
* wiring module and pass the result to the pages.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* export const evals = defineEvals({
|
|
91
|
+
* runner, settings, store, feedbackStore, models: MODELS, suites: SUITES,
|
|
92
|
+
* routeFor, answerEditors: {}, actions, basePath: "/admin/evals",
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @param app - Your runner, stores, models, suites, editors, actions, and
|
|
97
|
+
* where the pages live.
|
|
98
|
+
*/
|
|
99
|
+
export function defineEvals(app: EvalApp): EvalAppConfig {
|
|
100
|
+
return {
|
|
101
|
+
...app,
|
|
102
|
+
basePath: withoutTrailingSlashes(app.basePath) || "/",
|
|
103
|
+
suiteByKey: Object.fromEntries(app.suites.map((s) => [s.key, s])),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A link to an eval page: the base path, then each part, escaped.
|
|
109
|
+
*
|
|
110
|
+
* @param app - Your screens' configuration (for the base path).
|
|
111
|
+
* @param parts - The path below it: a suite's key, "runs", a test's id.
|
|
112
|
+
*/
|
|
113
|
+
export function evalsPath(app: { basePath: string }, ...parts: string[]) {
|
|
114
|
+
return [app.basePath, ...parts.map(encodeURIComponent)].join("/");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The moment `days` days before now. */
|
|
118
|
+
export const daysAgo = (days: number) => new Date(Date.now() - days * 864e5);
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Where the weekly check stands, for the hub: the last week's tests,
|
|
122
|
+
* what's live, thumbs, and drafts.
|
|
123
|
+
*
|
|
124
|
+
* @param app - Your screens' configuration.
|
|
125
|
+
*/
|
|
126
|
+
export async function loadWeekly(app: EvalApp): Promise<WeeklySummary> {
|
|
127
|
+
const [runs, routes, feedback, cases] = await Promise.all([
|
|
128
|
+
Promise.all(
|
|
129
|
+
app.suites.map((s) => app.store.listRuns(s.key, { limit: 50 })),
|
|
130
|
+
).then((r) => r.flat()),
|
|
131
|
+
Promise.all(
|
|
132
|
+
app.suites.map(
|
|
133
|
+
async (s) => [s.operation, await app.routeFor(s.operation)] as const,
|
|
134
|
+
),
|
|
135
|
+
).then((r) => Object.fromEntries(r)),
|
|
136
|
+
app.feedbackStore.listFeedback({ since: daysAgo(7) }),
|
|
137
|
+
Promise.all(app.suites.map((s) => app.store.listCases(s.key))).then((c) =>
|
|
138
|
+
c.flat(),
|
|
139
|
+
),
|
|
140
|
+
]);
|
|
141
|
+
return weeklySummary({
|
|
142
|
+
runs,
|
|
143
|
+
suites: app.suites,
|
|
144
|
+
routes,
|
|
145
|
+
models: app.models,
|
|
146
|
+
thumbs: thumbsSummary(feedback, daysAgo(7)),
|
|
147
|
+
cases,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* A model's attacks resisted: of the answers to a feature's attack cases,
|
|
153
|
+
* how many had no serious mistake, across its injection suites. Null
|
|
154
|
+
* until each has a current, complete test of the model.
|
|
155
|
+
*
|
|
156
|
+
* @param key - The model's row key (model and reasoning setting).
|
|
157
|
+
* @param boards - The feature's injection suites' boards.
|
|
158
|
+
*/
|
|
159
|
+
export function attacksResisted(
|
|
160
|
+
key: string,
|
|
161
|
+
boards: readonly { rows: readonly BoardRow[] }[],
|
|
162
|
+
): { resisted: number; of: number } | null {
|
|
163
|
+
if (!boards.length) return null;
|
|
164
|
+
let resisted = 0;
|
|
165
|
+
let of = 0;
|
|
166
|
+
for (const b of boards) {
|
|
167
|
+
const t = b.rows.find((r) => r.key === key)?.test;
|
|
168
|
+
if (!t || t.stale || t.failedAnswers) return null;
|
|
169
|
+
resisted += t.answersNoSerious;
|
|
170
|
+
of += t.answers;
|
|
171
|
+
}
|
|
172
|
+
return of ? { resisted, of } : null;
|
|
173
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers the screens share on the server and in the browser. They live
|
|
3
|
+
* outside the client components' module because Next.js makes every
|
|
4
|
+
* export of a `"use client"` module a client reference, which server code
|
|
5
|
+
* can't call.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** A share as a whole percent: 0.874 is "87%". */
|
|
9
|
+
export const pct = (x: number): string => `${Math.round(x * 100)}%`;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A button that isn't the page's main action: the app's accent as an
|
|
13
|
+
* outline, so it still reads as a button in the app's colors (set
|
|
14
|
+
* `--accent` in evalkeeper.css).
|
|
15
|
+
*/
|
|
16
|
+
export const QUIET_BUTTON =
|
|
17
|
+
"border border-accent/40 bg-card text-accent hover:bg-accent/10";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A day, with the month as a word so no reader mistakes it:
|
|
21
|
+
* "Oct 28, 2026" (10/28 is the 10th of the 28th month in most of the world).
|
|
22
|
+
*/
|
|
23
|
+
export const dayOf = (d: Date): string =>
|
|
24
|
+
d.toLocaleDateString("en-US", {
|
|
25
|
+
month: "short",
|
|
26
|
+
day: "numeric",
|
|
27
|
+
year: "numeric",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/** A day and time, the same way: "Oct 28, 2026, 3:04 PM". */
|
|
31
|
+
export const momentOf = (d: Date): string =>
|
|
32
|
+
d.toLocaleString("en-US", {
|
|
33
|
+
month: "short",
|
|
34
|
+
day: "numeric",
|
|
35
|
+
year: "numeric",
|
|
36
|
+
hour: "numeric",
|
|
37
|
+
minute: "2-digit",
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Every link that reads as words: the app's accent, underlined on hover.
|
|
42
|
+
* Numbers that link (a score, a count) keep their own color, and links
|
|
43
|
+
* styled as buttons, card titles, and the back link have their own look.
|
|
44
|
+
*/
|
|
45
|
+
export const LINK = "text-accent hover:underline";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evalkeeper's screens for React apps. Import from
|
|
3
|
+
* `@crowandraven/evalkeeper/react`; it needs React and `lucide-react`.
|
|
4
|
+
* Draw the screens with your app's own components through
|
|
5
|
+
* `EvalComponentsProvider`.
|
|
6
|
+
*
|
|
7
|
+
* @module evalkeeper/react
|
|
8
|
+
*/
|
|
9
|
+
export * from "./pieces.js";
|
|
10
|
+
export * from "./format.js";
|
|
11
|
+
export * from "./app.js";
|
|
12
|
+
export * from "./SuiteSections.js";
|
|
13
|
+
export * from "./HubSections.js";
|
|
14
|
+
export * from "./AnswerKey.js";
|
|
15
|
+
export * from "./SettingsHistory.js";
|
|
16
|
+
export * from "./WeeklyCheck.js";
|
|
17
|
+
export * from "./Fields.js";
|
|
18
|
+
export * from "./ReadableOutput.js";
|
|
19
|
+
export * from "./DisagreementChip.js";
|
|
20
|
+
export * from "./AddCase.js";
|
|
21
|
+
export * from "./CaseMenu.js";
|
|
22
|
+
export * from "./ConfirmAnswer.js";
|
|
23
|
+
export * from "./RollBack.js";
|
|
24
|
+
export * from "./Thumbs.js";
|
|
25
|
+
export * from "./RunView.js";
|
|
26
|
+
export * from "./CompareView.js";
|
|
27
|
+
export * from "./SideBySideView.js";
|
|
28
|
+
export * from "./RateView.js";
|
|
29
|
+
export * from "./FeedbackView.js";
|
|
30
|
+
export * from "./ModelMenu.js";
|
|
31
|
+
export * from "./Tabs.js";
|