@crowandraven/evalkeeper 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +9 -0
- package/dist/glossary.js +9 -0
- package/dist/glossary.js.map +1 -1
- package/dist/health.d.ts +4 -1
- package/dist/health.js +4 -2
- package/dist/health.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 +76 -3
- package/dist/runner.js +133 -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 +52 -2
- package/dist/suggest.js +101 -8
- 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.d.ts +79 -2
- package/dist/types.js +96 -12
- 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 +18 -0
- package/src/health.ts +4 -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 +96 -59
- 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 +54 -10
- 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 +182 -4
- package/src/settings.ts +1 -1
- package/src/store.ts +1 -1
- package/src/suggest.ts +145 -13
- package/src/suiteContract.ts +35 -28
- package/src/testing.ts +2 -2
- package/src/types.ts +147 -19
- package/starter/index.ts +33 -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 -532
- package/templates/app/evals/[suite]/rate/page.tsx +6 -141
- 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 -365
- package/templates/lib/evalkeeper/actions.ts +34 -296
- 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
package/src/prune.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { confirmedLabel, type LabelLike } from "./labels.js";
|
|
2
|
+
import { pickQuickSet } from "./quickSet.js";
|
|
1
3
|
import { stableJson } from "./stableJson.js";
|
|
2
4
|
import { at } from "./util.js";
|
|
3
5
|
|
|
@@ -93,3 +95,78 @@ export function tagCounts(cases: { tags: string[] }[]): [string, number][] {
|
|
|
93
95
|
for (const t of c.tags) counts.set(t, (counts.get(t) ?? 0) + 1);
|
|
94
96
|
return [...counts].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
95
97
|
}
|
|
98
|
+
|
|
99
|
+
/** A case as answer-key health reads it. */
|
|
100
|
+
type HealthCase = {
|
|
101
|
+
id: string;
|
|
102
|
+
input: unknown;
|
|
103
|
+
tags: string[];
|
|
104
|
+
status: string;
|
|
105
|
+
createdAt: Date;
|
|
106
|
+
labels: readonly LabelLike[];
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A suite's answer key, sorted for upkeep: what the feature's page shows
|
|
111
|
+
* under "Answer key health". Only what needs a look is non-empty.
|
|
112
|
+
*/
|
|
113
|
+
export type AnswerKeyHealth<C> = {
|
|
114
|
+
/** Cases in use: not retired, with a confirmed or provisional answer. */
|
|
115
|
+
inUse: number;
|
|
116
|
+
/** Cases in use every current model gets fully right. */
|
|
117
|
+
easy: C[];
|
|
118
|
+
/** Of the easy ones, those to retire; the rest stay as a floor. */
|
|
119
|
+
easyToRetire: C[];
|
|
120
|
+
/** Cases in use that models divide about evenly on. */
|
|
121
|
+
split: C[];
|
|
122
|
+
/** Pairs of cases in use whose inputs share nearly all their words. */
|
|
123
|
+
duplicates: [C, C][];
|
|
124
|
+
/** Drafts nobody has reviewed in STALE_DRAFT_DAYS. */
|
|
125
|
+
staleDrafts: C[];
|
|
126
|
+
/** How many cases in use carry each tag, most first. */
|
|
127
|
+
tags: [string, number][];
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A suite's answer-key health, from its cases (retired ones are ignored)
|
|
132
|
+
* and how each case fared across the board's current tests. The floor of
|
|
133
|
+
* easy cases keeps the quick set's first, so the weekly check still
|
|
134
|
+
* catches a regression on the basics.
|
|
135
|
+
*
|
|
136
|
+
* @param cases - The suite's cases, with their answers.
|
|
137
|
+
* @param caseResults - Per case, how many current models tested it and
|
|
138
|
+
* got it fully right (the board's `caseResults`).
|
|
139
|
+
* @param today - Now, for old drafts.
|
|
140
|
+
* @returns What needs a look: easy, split, and duplicate cases, old
|
|
141
|
+
* drafts, and how the tags spread.
|
|
142
|
+
*/
|
|
143
|
+
export function answerKeyHealth<C extends HealthCase>(
|
|
144
|
+
cases: readonly C[],
|
|
145
|
+
caseResults: Readonly<Record<string, CaseResult>>,
|
|
146
|
+
today = new Date(),
|
|
147
|
+
): AnswerKeyHealth<C> {
|
|
148
|
+
const live = cases.filter((c) => c.status !== "RETIRED");
|
|
149
|
+
const inUse = live.filter((c) => confirmedLabel(c.labels));
|
|
150
|
+
const drafts = live.filter((c) => !confirmedLabel(c.labels));
|
|
151
|
+
const quick = new Set(
|
|
152
|
+
pickQuickSet(inUse.map((c) => ({ ...c, confirmed: true }))).map(
|
|
153
|
+
(c) => c.id,
|
|
154
|
+
),
|
|
155
|
+
);
|
|
156
|
+
const easy = inUse.filter((c) => isEasy(caseResults[c.id]));
|
|
157
|
+
const retire = new Set(
|
|
158
|
+
easyToRetire(
|
|
159
|
+
easy.map((c) => ({ ...c, smoke: quick.has(c.id) })),
|
|
160
|
+
inUse.length,
|
|
161
|
+
).map((c) => c.id),
|
|
162
|
+
);
|
|
163
|
+
return {
|
|
164
|
+
inUse: inUse.length,
|
|
165
|
+
easy,
|
|
166
|
+
easyToRetire: easy.filter((c) => retire.has(c.id)),
|
|
167
|
+
split: inUse.filter((c) => isSplit(caseResults[c.id])),
|
|
168
|
+
duplicates: nearDuplicates(inUse),
|
|
169
|
+
staleDrafts: drafts.filter((c) => isStaleDraft(c.createdAt, today)),
|
|
170
|
+
tags: tagCounts(inUse),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { Button, Card } from "./pieces.js";
|
|
4
|
+
import { QUIET_BUTTON } from "./format.js";
|
|
3
5
|
import { useState } from "react";
|
|
4
6
|
import { Plus } from "lucide-react";
|
|
5
|
-
import { QUIET_BUTTON } from "./Submit";
|
|
6
|
-
import { Card } from "./ui";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A section's header row with an "Add a case" button at the top right,
|
|
@@ -26,7 +26,7 @@ export function AddCaseHeader({
|
|
|
26
26
|
{heading}
|
|
27
27
|
<div className="flex items-center gap-2">
|
|
28
28
|
{form && (
|
|
29
|
-
<
|
|
29
|
+
<Button
|
|
30
30
|
type="button"
|
|
31
31
|
aria-expanded={open}
|
|
32
32
|
onClick={() => {
|
|
@@ -36,7 +36,7 @@ export function AddCaseHeader({
|
|
|
36
36
|
>
|
|
37
37
|
<Plus aria-hidden className="h-4 w-4" />
|
|
38
38
|
Add a case
|
|
39
|
-
</
|
|
39
|
+
</Button>
|
|
40
40
|
)}
|
|
41
41
|
{tools}
|
|
42
42
|
</div>
|
|
@@ -45,7 +45,7 @@ export function AddCaseHeader({
|
|
|
45
45
|
<Card className="space-y-4">
|
|
46
46
|
<div className="flex items-center justify-between gap-2">
|
|
47
47
|
<h3 className="font-medium">New case</h3>
|
|
48
|
-
<
|
|
48
|
+
<Button
|
|
49
49
|
type="button"
|
|
50
50
|
onClick={() => {
|
|
51
51
|
setOpen(false);
|
|
@@ -53,7 +53,7 @@ export function AddCaseHeader({
|
|
|
53
53
|
className="text-sm text-muted hover:text-ink"
|
|
54
54
|
>
|
|
55
55
|
Cancel
|
|
56
|
-
</
|
|
56
|
+
</Button>
|
|
57
57
|
</div>
|
|
58
58
|
{form}
|
|
59
59
|
</Card>
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Chip,
|
|
3
|
+
InfoTip,
|
|
4
|
+
Select,
|
|
5
|
+
Submit,
|
|
6
|
+
TextInput,
|
|
7
|
+
Tip,
|
|
8
|
+
type ChipTone,
|
|
9
|
+
} from "./pieces.js";
|
|
1
10
|
import {
|
|
2
11
|
allPassed,
|
|
3
12
|
type CaseRecord,
|
|
@@ -9,21 +18,20 @@ import {
|
|
|
9
18
|
EXPERT_REVIEWED,
|
|
10
19
|
FROM_BASE_CASE,
|
|
11
20
|
isShippedReview,
|
|
12
|
-
} from "
|
|
13
|
-
import { addCase, editAnswer, retireCase } from "@/lib/evalkeeper/actions";
|
|
21
|
+
} from "../index.js";
|
|
14
22
|
import { Check, ChevronRight, CircleAlert, X } from "lucide-react";
|
|
15
|
-
import {
|
|
16
|
-
import { FieldValues, Fields } from "./Fields";
|
|
17
|
-
import { AddCaseHeader } from "./AddCase";
|
|
18
|
-
import { CaseMenu } from "./CaseMenu";
|
|
19
|
-
import { ConfirmAnswer } from "./ConfirmAnswer";
|
|
20
|
-
import { Submit } from "./Submit";
|
|
21
|
-
import { Chip, type ChipTone } from "./ui";
|
|
22
|
-
import { InfoTip, Tip } from "./Tip";
|
|
23
|
+
import type { EvalAppConfig } from "./app.js";
|
|
24
|
+
import { AnswerInput, FieldValues, Fields } from "./Fields.js";
|
|
25
|
+
import { AddCaseHeader } from "./AddCase.js";
|
|
26
|
+
import { CaseMenu } from "./CaseMenu.js";
|
|
27
|
+
import { ConfirmAnswer } from "./ConfirmAnswer.js";
|
|
23
28
|
|
|
24
29
|
/** A suite's cases in use, with each case's answers newest first. */
|
|
25
|
-
async function loadCases(
|
|
26
|
-
|
|
30
|
+
async function loadCases(
|
|
31
|
+
app: EvalAppConfig,
|
|
32
|
+
suite: string,
|
|
33
|
+
): Promise<CaseRecord[]> {
|
|
34
|
+
return (await app.store.listCases(suite)).map((c) => ({
|
|
27
35
|
...c,
|
|
28
36
|
labels: [...c.labels].sort((a, b) => +b.updatedAt - +a.updatedAt),
|
|
29
37
|
}));
|
|
@@ -44,6 +52,8 @@ const STATUS: Record<
|
|
|
44
52
|
* case, edit an answer, or retire a case.
|
|
45
53
|
*/
|
|
46
54
|
export async function AnswerKey({
|
|
55
|
+
app,
|
|
56
|
+
readOnly = false,
|
|
47
57
|
suite,
|
|
48
58
|
rows,
|
|
49
59
|
heading,
|
|
@@ -55,8 +65,15 @@ export async function AnswerKey({
|
|
|
55
65
|
heading: React.ReactNode;
|
|
56
66
|
/** More buttons beside "Add a case" (rescore). */
|
|
57
67
|
tools?: React.ReactNode;
|
|
68
|
+
/** Your screens' configuration. */
|
|
69
|
+
app: EvalAppConfig;
|
|
70
|
+
/**
|
|
71
|
+
* Cases made by Evalkeeper (an injection suite's attack cases), shown
|
|
72
|
+
* without adding, editing, confirming, or retiring.
|
|
73
|
+
*/
|
|
74
|
+
readOnly?: boolean;
|
|
58
75
|
}) {
|
|
59
|
-
const cases = await loadCases(suite.key);
|
|
76
|
+
const cases = await loadCases(app, suite.key);
|
|
60
77
|
// Each model's latest test (at the operation's setting), by case.
|
|
61
78
|
const modelByRun = new Map(
|
|
62
79
|
rows.flatMap((r) =>
|
|
@@ -66,9 +83,9 @@ export async function AnswerKey({
|
|
|
66
83
|
// One query where the store can: one per test is slow on a remote
|
|
67
84
|
// database.
|
|
68
85
|
const runIds = [...modelByRun.keys()];
|
|
69
|
-
const outputs = store.listOutputsFor
|
|
70
|
-
? await store.listOutputsFor(runIds)
|
|
71
|
-
: (await Promise.all(runIds.map((id) => store.listOutputs(id)))).flat();
|
|
86
|
+
const outputs = app.store.listOutputsFor
|
|
87
|
+
? await app.store.listOutputsFor(runIds)
|
|
88
|
+
: (await Promise.all(runIds.map((id) => app.store.listOutputs(id)))).flat();
|
|
72
89
|
const byCase = new Map<string, { model: string; output: OutputRecord }[]>();
|
|
73
90
|
for (const o of outputs) {
|
|
74
91
|
byCase.set(o.caseId, [
|
|
@@ -84,15 +101,20 @@ export async function AnswerKey({
|
|
|
84
101
|
heading={heading}
|
|
85
102
|
tools={tools}
|
|
86
103
|
form={
|
|
104
|
+
!readOnly &&
|
|
87
105
|
fields &&
|
|
88
|
-
suite.labelFromForm && (
|
|
89
|
-
<form action={addCase} className="space-y-4">
|
|
106
|
+
(suite.labelFromForm || app.answerEditors[suite.key]) && (
|
|
107
|
+
<form action={app.actions.addCase} className="space-y-4">
|
|
90
108
|
<input type="hidden" name="suite" value={suite.key} />
|
|
91
109
|
<Fields fields={fields.input} prefix="new-" />
|
|
92
110
|
<p className="readable text-sm text-muted">
|
|
93
111
|
What a good answer is. You're writing it, so it's confirmed.
|
|
94
112
|
</p>
|
|
95
|
-
<
|
|
113
|
+
<AnswerInput
|
|
114
|
+
fields={fields.label}
|
|
115
|
+
editor={app.answerEditors[suite.key]}
|
|
116
|
+
prefix="new-"
|
|
117
|
+
/>
|
|
96
118
|
<div className="grid gap-4 sm:grid-cols-2">
|
|
97
119
|
<div className="space-y-1">
|
|
98
120
|
<label
|
|
@@ -102,7 +124,7 @@ export async function AnswerKey({
|
|
|
102
124
|
Tags
|
|
103
125
|
<InfoTip term="tags" id="new-tags" />
|
|
104
126
|
</label>
|
|
105
|
-
<
|
|
127
|
+
<TextInput
|
|
106
128
|
id="new-tags"
|
|
107
129
|
name="tags"
|
|
108
130
|
placeholder="e.g. billing, money now"
|
|
@@ -124,7 +146,7 @@ export async function AnswerKey({
|
|
|
124
146
|
id="new-split"
|
|
125
147
|
/>
|
|
126
148
|
</label>
|
|
127
|
-
<
|
|
149
|
+
<Select
|
|
128
150
|
id="new-split"
|
|
129
151
|
name="split"
|
|
130
152
|
defaultValue="DEV"
|
|
@@ -134,7 +156,7 @@ export async function AnswerKey({
|
|
|
134
156
|
<option value="TEST">
|
|
135
157
|
TEST: check only, never tune against
|
|
136
158
|
</option>
|
|
137
|
-
</
|
|
159
|
+
</Select>
|
|
138
160
|
</div>
|
|
139
161
|
</div>
|
|
140
162
|
<div className="flex gap-2">
|
|
@@ -148,6 +170,8 @@ export async function AnswerKey({
|
|
|
148
170
|
<div className="space-y-2">
|
|
149
171
|
{cases.map((c) => (
|
|
150
172
|
<CaseItem
|
|
173
|
+
app={app}
|
|
174
|
+
readOnly={readOnly}
|
|
151
175
|
key={c.id}
|
|
152
176
|
suite={suite}
|
|
153
177
|
c={c}
|
|
@@ -161,10 +185,14 @@ export async function AnswerKey({
|
|
|
161
185
|
}
|
|
162
186
|
|
|
163
187
|
function CaseItem({
|
|
188
|
+
app,
|
|
189
|
+
readOnly,
|
|
164
190
|
suite,
|
|
165
191
|
c,
|
|
166
192
|
results,
|
|
167
193
|
}: {
|
|
194
|
+
app: EvalAppConfig;
|
|
195
|
+
readOnly: boolean;
|
|
168
196
|
suite: AnySuite;
|
|
169
197
|
c: CaseRecord;
|
|
170
198
|
results: {
|
|
@@ -338,45 +366,54 @@ function CaseItem({
|
|
|
338
366
|
</section>
|
|
339
367
|
)}
|
|
340
368
|
|
|
341
|
-
{answer?.status === "PENDING" && (
|
|
342
|
-
<ConfirmAnswer
|
|
369
|
+
{!readOnly && answer?.status === "PENDING" && (
|
|
370
|
+
<ConfirmAnswer
|
|
371
|
+
action={app.actions.confirmAnswer}
|
|
372
|
+
suite={suite.key}
|
|
373
|
+
labelId={answer.id}
|
|
374
|
+
/>
|
|
343
375
|
)}
|
|
344
376
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
377
|
+
{!readOnly && (
|
|
378
|
+
<CaseMenu
|
|
379
|
+
suite={suite.key}
|
|
380
|
+
caseId={c.id}
|
|
381
|
+
retire={app.actions.retireCase}
|
|
382
|
+
startEditing={!answer}
|
|
383
|
+
editLabel={
|
|
384
|
+
suite.fields &&
|
|
385
|
+
(suite.labelFromForm || app.answerEditors[suite.key])
|
|
386
|
+
? answer
|
|
387
|
+
? "Edit answer"
|
|
388
|
+
: "Write the answer"
|
|
389
|
+
: null
|
|
390
|
+
}
|
|
391
|
+
edit={
|
|
392
|
+
suite.fields && (
|
|
393
|
+
<form
|
|
394
|
+
key={answer?.updatedAt.toISOString() ?? "none"}
|
|
395
|
+
action={app.actions.editAnswer}
|
|
396
|
+
className="space-y-4"
|
|
397
|
+
>
|
|
398
|
+
<input type="hidden" name="suite" value={suite.key} />
|
|
399
|
+
<input type="hidden" name="case" value={c.id} />
|
|
400
|
+
<AnswerInput
|
|
401
|
+
fields={suite.fields.label}
|
|
402
|
+
editor={app.answerEditors[suite.key]}
|
|
403
|
+
input={c.input}
|
|
404
|
+
values={answer?.value}
|
|
405
|
+
prefix={`${c.id}-`}
|
|
406
|
+
/>
|
|
407
|
+
<p className="readable text-xs text-muted">
|
|
408
|
+
Saves a new confirmed answer and keeps the old one in the
|
|
409
|
+
history. Tests are rescored for free.
|
|
410
|
+
</p>
|
|
411
|
+
<Submit>Save answer</Submit>
|
|
412
|
+
</form>
|
|
413
|
+
)
|
|
414
|
+
}
|
|
415
|
+
/>
|
|
416
|
+
)}
|
|
380
417
|
</div>
|
|
381
418
|
</details>
|
|
382
419
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { Button } from "./pieces.js";
|
|
3
4
|
import { useEffect, useRef, useState } from "react";
|
|
4
5
|
import { EllipsisVertical } from "lucide-react";
|
|
5
6
|
|
|
@@ -55,7 +56,7 @@ export function CaseMenu({
|
|
|
55
56
|
return (
|
|
56
57
|
<>
|
|
57
58
|
<div ref={ref} className="absolute right-3 top-0 z-10">
|
|
58
|
-
<
|
|
59
|
+
<Button
|
|
59
60
|
type="button"
|
|
60
61
|
aria-label="Case actions"
|
|
61
62
|
title="Case actions"
|
|
@@ -67,14 +68,14 @@ export function CaseMenu({
|
|
|
67
68
|
className="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted hover:bg-tint hover:text-ink"
|
|
68
69
|
>
|
|
69
70
|
<EllipsisVertical aria-hidden className="h-4 w-4" />
|
|
70
|
-
</
|
|
71
|
+
</Button>
|
|
71
72
|
{open && (
|
|
72
73
|
<div
|
|
73
74
|
role="menu"
|
|
74
75
|
className="absolute right-0 mt-1 w-44 rounded-md border border-line bg-card p-1 shadow-lg"
|
|
75
76
|
>
|
|
76
77
|
{editLabel && (
|
|
77
|
-
<
|
|
78
|
+
<Button
|
|
78
79
|
type="button"
|
|
79
80
|
role="menuitem"
|
|
80
81
|
className={item}
|
|
@@ -84,18 +85,18 @@ export function CaseMenu({
|
|
|
84
85
|
}}
|
|
85
86
|
>
|
|
86
87
|
{editLabel}
|
|
87
|
-
</
|
|
88
|
+
</Button>
|
|
88
89
|
)}
|
|
89
90
|
<form action={retire}>
|
|
90
91
|
<input type="hidden" name="suite" value={suite} />
|
|
91
92
|
<input type="hidden" name="case" value={caseId} />
|
|
92
|
-
<
|
|
93
|
+
<Button
|
|
93
94
|
type="submit"
|
|
94
95
|
role="menuitem"
|
|
95
96
|
className={`${item} text-bad`}
|
|
96
97
|
>
|
|
97
98
|
Retire case
|
|
98
|
-
</
|
|
99
|
+
</Button>
|
|
99
100
|
</form>
|
|
100
101
|
</div>
|
|
101
102
|
)}
|
|
@@ -104,7 +105,7 @@ export function CaseMenu({
|
|
|
104
105
|
<div className="space-y-3 rounded-md bg-tint p-3">
|
|
105
106
|
<div className="flex items-center justify-between gap-2">
|
|
106
107
|
<h4 className="text-sm font-medium">{editLabel}</h4>
|
|
107
|
-
<
|
|
108
|
+
<Button
|
|
108
109
|
type="button"
|
|
109
110
|
onClick={() => {
|
|
110
111
|
setEditing(false);
|
|
@@ -112,7 +113,7 @@ export function CaseMenu({
|
|
|
112
113
|
className="text-sm text-muted hover:text-ink"
|
|
113
114
|
>
|
|
114
115
|
Cancel
|
|
115
|
-
</
|
|
116
|
+
</Button>
|
|
116
117
|
</div>
|
|
117
118
|
{edit}
|
|
118
119
|
</div>
|