@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,412 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
createElement,
|
|
6
|
+
useContext,
|
|
7
|
+
type ComponentType,
|
|
8
|
+
type ReactNode,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { useFormStatus } from "react-dom";
|
|
11
|
+
import { ArrowLeft, Info, LoaderCircle } from "lucide-react";
|
|
12
|
+
import { GLOSSARY, type GlossaryTerm } from "../glossary.js";
|
|
13
|
+
import type { HealthStatus } from "../health.js";
|
|
14
|
+
import { pct, QUIET_BUTTON } from "./format.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The pieces Evalkeeper's screens are built from. Each draws Evalkeeper's
|
|
18
|
+
* own by default, and your app's when you name one in
|
|
19
|
+
* `EvalComponentsProvider`. Every piece is a client component, so yours
|
|
20
|
+
* must be too (a file starting `"use client"`, or a component library's
|
|
21
|
+
* client components).
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const CHIP = {
|
|
25
|
+
live: "bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300",
|
|
26
|
+
fallback: "bg-sky-100 text-sky-800 dark:bg-sky-500/15 dark:text-sky-200",
|
|
27
|
+
warn: "bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-200",
|
|
28
|
+
serious: "bg-red-50 text-red-800 dark:bg-red-500/10 dark:text-red-200",
|
|
29
|
+
neutral: "bg-tint text-muted",
|
|
30
|
+
} as const;
|
|
31
|
+
|
|
32
|
+
/** A chip's color. */
|
|
33
|
+
export type ChipTone = keyof typeof CHIP;
|
|
34
|
+
|
|
35
|
+
/** A box around a section of a page. */
|
|
36
|
+
export type CardProps = { children: ReactNode; className?: string };
|
|
37
|
+
/** A small label and its color. */
|
|
38
|
+
export type ChipProps = { tone: ChipTone; children: ReactNode };
|
|
39
|
+
/** A link: where it goes, its words, and Evalkeeper's classes. */
|
|
40
|
+
export type LinkProps = {
|
|
41
|
+
href: string;
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
className?: string;
|
|
44
|
+
title?: string;
|
|
45
|
+
};
|
|
46
|
+
/** Where a back link goes, and its words. */
|
|
47
|
+
export type BackLinkProps = { href: string; children: ReactNode };
|
|
48
|
+
/** A score: parts right of parts expected. */
|
|
49
|
+
export type ScoreProps = { right: number; total: number };
|
|
50
|
+
/** A form's submit button: its words, its weight, and whether it's off. */
|
|
51
|
+
export type SubmitProps = {
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
variant?: "primary" | "quiet";
|
|
54
|
+
/** Off until the form is ready; wrap it in a `<Tip>` saying why. */
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
};
|
|
57
|
+
/** An icon-only submit button's accessible name and icon. */
|
|
58
|
+
export type IconSubmitProps = { label: string; icon: ReactNode };
|
|
59
|
+
/** What a tooltip explains: a glossary term, or your own text. */
|
|
60
|
+
export type InfoTipProps = {
|
|
61
|
+
/** A glossary entry, or your own text with `text`. */
|
|
62
|
+
term?: GlossaryTerm;
|
|
63
|
+
text?: string;
|
|
64
|
+
/** Unique per page when the same term shows more than once. */
|
|
65
|
+
id?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Where it opens. "bottom" inside a scrolling container (a table), whose
|
|
68
|
+
* top edge would cut it off.
|
|
69
|
+
*/
|
|
70
|
+
side?: "top" | "bottom";
|
|
71
|
+
/** "end" near a container's right edge, so it opens leftward. */
|
|
72
|
+
align?: "center" | "end";
|
|
73
|
+
};
|
|
74
|
+
/** What a tooltip explains, and the thing it wraps. */
|
|
75
|
+
export type TipProps = InfoTipProps & {
|
|
76
|
+
children: ReactNode;
|
|
77
|
+
/**
|
|
78
|
+
* The child is a control that takes focus itself (a button), so the
|
|
79
|
+
* wrapper isn't a second tab stop.
|
|
80
|
+
*/
|
|
81
|
+
control?: boolean;
|
|
82
|
+
};
|
|
83
|
+
/** Whether a test is running, so the page should keep refreshing. */
|
|
84
|
+
export type RefreshWhileProps = { active: boolean };
|
|
85
|
+
/** A plain button: a toggle, a menu item, a step in a form. */
|
|
86
|
+
export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
87
|
+
/** A one-line text field. */
|
|
88
|
+
export type TextInputProps = React.InputHTMLAttributes<HTMLInputElement>;
|
|
89
|
+
/** A multi-line text field. */
|
|
90
|
+
export type TextAreaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
91
|
+
/** A dropdown of options, given as `<option>` children. */
|
|
92
|
+
export type SelectProps = React.SelectHTMLAttributes<HTMLSelectElement>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Every piece you can replace. Each gets the props Evalkeeper's own would,
|
|
96
|
+
* its `className` included, which yours can use or ignore. Controls must
|
|
97
|
+
* render the native element (or pass `name` and the value to one), so
|
|
98
|
+
* forms still submit.
|
|
99
|
+
*/
|
|
100
|
+
export type EvalComponents = {
|
|
101
|
+
Card: ComponentType<CardProps>;
|
|
102
|
+
Chip: ComponentType<ChipProps>;
|
|
103
|
+
Link: ComponentType<LinkProps>;
|
|
104
|
+
BackLink: ComponentType<BackLinkProps>;
|
|
105
|
+
Score: ComponentType<ScoreProps>;
|
|
106
|
+
Submit: ComponentType<SubmitProps>;
|
|
107
|
+
IconSubmit: ComponentType<IconSubmitProps>;
|
|
108
|
+
Spinner: ComponentType;
|
|
109
|
+
Tip: ComponentType<TipProps>;
|
|
110
|
+
InfoTip: ComponentType<InfoTipProps>;
|
|
111
|
+
Button: ComponentType<ButtonProps>;
|
|
112
|
+
TextInput: ComponentType<TextInputProps>;
|
|
113
|
+
TextArea: ComponentType<TextAreaProps>;
|
|
114
|
+
Select: ComponentType<SelectProps>;
|
|
115
|
+
RefreshWhile: ComponentType<RefreshWhileProps>;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const Swapped = createContext<Partial<EvalComponents>>({});
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Draws Evalkeeper's screens inside it with your app's components. Render
|
|
122
|
+
* it once around the eval pages (a layout), from a client component of
|
|
123
|
+
* your own that imports your components:
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```tsx
|
|
127
|
+
* "use client";
|
|
128
|
+
* import Link from "next/link";
|
|
129
|
+
* import { EvalComponentsProvider } from "@crowandraven/evalkeeper/react";
|
|
130
|
+
* import { Button } from "@/components/ui/button";
|
|
131
|
+
*
|
|
132
|
+
* export function AppComponents({ children }: { children: React.ReactNode }) {
|
|
133
|
+
* return (
|
|
134
|
+
* <EvalComponentsProvider components={{ Link, Button }}>
|
|
135
|
+
* {children}
|
|
136
|
+
* </EvalComponentsProvider>
|
|
137
|
+
* );
|
|
138
|
+
* }
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* @param props - Your components (any of `EvalComponents`; the rest stay
|
|
142
|
+
* Evalkeeper's) and the screens to draw with them.
|
|
143
|
+
*/
|
|
144
|
+
export function EvalComponentsProvider({
|
|
145
|
+
components,
|
|
146
|
+
children,
|
|
147
|
+
}: {
|
|
148
|
+
components: Partial<EvalComponents>;
|
|
149
|
+
children: ReactNode;
|
|
150
|
+
}) {
|
|
151
|
+
return <Swapped.Provider value={components}>{children}</Swapped.Provider>;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The app's piece by name, or undefined to draw Evalkeeper's. */
|
|
155
|
+
const useSwapped = <K extends keyof EvalComponents>(
|
|
156
|
+
name: K,
|
|
157
|
+
): EvalComponents[K] | undefined => useContext(Swapped)[name];
|
|
158
|
+
|
|
159
|
+
/** A box around a section of a page. */
|
|
160
|
+
export function Card(props: CardProps) {
|
|
161
|
+
const C = useSwapped("Card");
|
|
162
|
+
if (C) return createElement(C, props);
|
|
163
|
+
const { children, className = "" } = props;
|
|
164
|
+
return (
|
|
165
|
+
<section
|
|
166
|
+
className={`rounded-lg border border-line bg-card p-5 ${className}`}
|
|
167
|
+
>
|
|
168
|
+
{children}
|
|
169
|
+
</section>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** A small rounded label: Live, Fallback, Retires …, serious, minor. */
|
|
174
|
+
export function Chip(props: ChipProps) {
|
|
175
|
+
const C = useSwapped("Chip");
|
|
176
|
+
if (C) return createElement(C, props);
|
|
177
|
+
return (
|
|
178
|
+
<span
|
|
179
|
+
className={`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-full px-2.5 text-xs font-medium leading-none ${CHIP[props.tone]}`}
|
|
180
|
+
>
|
|
181
|
+
{props.children}
|
|
182
|
+
</span>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const STATUS: Record<HealthStatus, { label: string; tone: ChipTone }> = {
|
|
187
|
+
good: { label: "Good", tone: "live" },
|
|
188
|
+
fair: { label: "Fair", tone: "warn" },
|
|
189
|
+
improve: { label: "Needs work", tone: "serious" },
|
|
190
|
+
few: { label: "Few cases", tone: "warn" },
|
|
191
|
+
stale: { label: "Retest", tone: "warn" },
|
|
192
|
+
untested: { label: "Untested", tone: "neutral" },
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/** A suite's health as a chip; the card's details say why. */
|
|
196
|
+
export function StatusBadge({ status }: { status: HealthStatus }) {
|
|
197
|
+
const s = STATUS[status];
|
|
198
|
+
return <Chip tone={s.tone}>{s.label}</Chip>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* A link to another page. A plain `<a>` by default; pass your router's
|
|
203
|
+
* link (Next.js's `Link`, say) to move between pages without a reload.
|
|
204
|
+
*/
|
|
205
|
+
export function Link(props: LinkProps) {
|
|
206
|
+
const C = useSwapped("Link");
|
|
207
|
+
if (C) return createElement(C, props);
|
|
208
|
+
const { href, children, className, title } = props;
|
|
209
|
+
return (
|
|
210
|
+
<a href={href} className={className} title={title}>
|
|
211
|
+
{children}
|
|
212
|
+
</a>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** A link back to the page above, with an arrow. */
|
|
217
|
+
export function BackLink(props: BackLinkProps) {
|
|
218
|
+
const C = useSwapped("BackLink");
|
|
219
|
+
if (C) return createElement(C, props);
|
|
220
|
+
return (
|
|
221
|
+
<Link
|
|
222
|
+
href={props.href}
|
|
223
|
+
className="inline-flex items-center gap-1 text-sm text-muted hover:text-ink"
|
|
224
|
+
>
|
|
225
|
+
<ArrowLeft aria-hidden className="h-4 w-4" />
|
|
226
|
+
{props.children}
|
|
227
|
+
</Link>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** A score with a thin bar, for tables. */
|
|
232
|
+
export function Score(props: ScoreProps) {
|
|
233
|
+
const C = useSwapped("Score");
|
|
234
|
+
if (C) return createElement(C, props);
|
|
235
|
+
const { right, total } = props;
|
|
236
|
+
const rate = total ? right / total : 0;
|
|
237
|
+
return (
|
|
238
|
+
<div className="flex items-center gap-2">
|
|
239
|
+
<span className="w-10 tabular-nums">{pct(rate)}</span>
|
|
240
|
+
<span className="h-1.5 w-20 rounded-full bg-tint">
|
|
241
|
+
<span
|
|
242
|
+
className="block h-1.5 rounded-full bg-accent"
|
|
243
|
+
style={{ width: `${rate * 100}%` }}
|
|
244
|
+
/>
|
|
245
|
+
</span>
|
|
246
|
+
<span className="text-xs text-muted tabular-nums">
|
|
247
|
+
{/* Whole numbers: a failed answer counts a graded answer's average
|
|
248
|
+
parts, which can be a fraction. */}
|
|
249
|
+
{Math.round(right)}/{Math.round(total)}
|
|
250
|
+
</span>
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** The rotating loader, while something runs. */
|
|
256
|
+
export function Spinner() {
|
|
257
|
+
const C = useSwapped("Spinner");
|
|
258
|
+
if (C) return createElement(C);
|
|
259
|
+
return <LoaderCircle aria-hidden className="h-3.5 w-3.5 animate-spin" />;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** A submit button that spins while its form's action runs. */
|
|
263
|
+
export function Submit(props: SubmitProps) {
|
|
264
|
+
const C = useSwapped("Submit");
|
|
265
|
+
const { pending } = useFormStatus();
|
|
266
|
+
if (C) return createElement(C, props);
|
|
267
|
+
const { children, variant = "primary", disabled = false } = props;
|
|
268
|
+
return (
|
|
269
|
+
<button
|
|
270
|
+
type="submit"
|
|
271
|
+
disabled={pending || disabled}
|
|
272
|
+
className={`inline-flex items-center gap-2 whitespace-nowrap rounded-md px-3 py-1.5 text-sm disabled:opacity-60 ${
|
|
273
|
+
variant === "primary" ? "bg-accent text-white" : QUIET_BUTTON
|
|
274
|
+
}`}
|
|
275
|
+
>
|
|
276
|
+
{pending && <Spinner />}
|
|
277
|
+
{children}
|
|
278
|
+
</button>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* An icon-only submit button. `label` is its accessible name; wrap it in a
|
|
284
|
+
* `<Tip control>` for the tooltip. The icon turns into the loader while the
|
|
285
|
+
* action runs.
|
|
286
|
+
*/
|
|
287
|
+
export function IconSubmit(props: IconSubmitProps) {
|
|
288
|
+
const C = useSwapped("IconSubmit");
|
|
289
|
+
const { pending } = useFormStatus();
|
|
290
|
+
if (C) return createElement(C, props);
|
|
291
|
+
return (
|
|
292
|
+
<button
|
|
293
|
+
type="submit"
|
|
294
|
+
aria-label={props.label}
|
|
295
|
+
disabled={pending}
|
|
296
|
+
className="inline-flex h-8 w-8 items-center justify-center rounded-md border border-line bg-card text-ink hover:bg-tint disabled:opacity-60"
|
|
297
|
+
>
|
|
298
|
+
{pending ? <Spinner /> : props.icon}
|
|
299
|
+
</button>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const tipText = (p: InfoTipProps) => p.text ?? (p.term ? GLOSSARY[p.term] : "");
|
|
304
|
+
const tipId = (p: InfoTipProps) => `tip-${p.id ?? p.term ?? "info"}`;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Tooltips explain how things work. They open on hover and on keyboard
|
|
308
|
+
* focus, and screen readers read the text as the element's description.
|
|
309
|
+
* CSS shows them; the named group (group/tip) keeps one from opening when
|
|
310
|
+
* an outer "group" (an open case) is hovered.
|
|
311
|
+
*/
|
|
312
|
+
function Bubble({
|
|
313
|
+
id,
|
|
314
|
+
text,
|
|
315
|
+
side = "top",
|
|
316
|
+
align = "center",
|
|
317
|
+
}: {
|
|
318
|
+
id: string;
|
|
319
|
+
text: string;
|
|
320
|
+
side?: "top" | "bottom" | undefined;
|
|
321
|
+
align?: "center" | "end" | undefined;
|
|
322
|
+
}) {
|
|
323
|
+
return (
|
|
324
|
+
<span
|
|
325
|
+
role="tooltip"
|
|
326
|
+
id={id}
|
|
327
|
+
className={`pointer-events-none invisible absolute ${side === "top" ? "bottom-full mb-2" : "top-full mt-2"} ${align === "end" ? "right-0" : "left-1/2 -translate-x-1/2"} z-20 w-64 rounded-md border border-line bg-card px-3 py-2 text-left text-xs font-normal normal-case leading-snug tracking-normal text-ink opacity-0 shadow-lg transition-opacity group-focus-within/tip:visible group-focus-within/tip:opacity-100 group-hover/tip:visible group-hover/tip:opacity-100`}
|
|
328
|
+
>
|
|
329
|
+
{text}
|
|
330
|
+
</span>
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** A small (i) button that explains the label before it. */
|
|
335
|
+
export function InfoTip(props: InfoTipProps) {
|
|
336
|
+
const C = useSwapped("InfoTip");
|
|
337
|
+
if (C) return createElement(C, props);
|
|
338
|
+
const id = tipId(props);
|
|
339
|
+
return (
|
|
340
|
+
<span className="group/tip relative ml-1 inline-flex align-middle">
|
|
341
|
+
<button
|
|
342
|
+
type="button"
|
|
343
|
+
aria-describedby={id}
|
|
344
|
+
aria-label="What's this?"
|
|
345
|
+
className="inline-flex h-4 w-4 items-center justify-center rounded-full text-muted hover:text-ink"
|
|
346
|
+
>
|
|
347
|
+
<Info aria-hidden className="h-3.5 w-3.5" />
|
|
348
|
+
</button>
|
|
349
|
+
<Bubble
|
|
350
|
+
id={id}
|
|
351
|
+
text={tipText(props)}
|
|
352
|
+
side={props.side}
|
|
353
|
+
align={props.align}
|
|
354
|
+
/>
|
|
355
|
+
</span>
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** Explains whatever it wraps (a chip, a number) on hover and focus. */
|
|
360
|
+
export function Tip(props: TipProps) {
|
|
361
|
+
const C = useSwapped("Tip");
|
|
362
|
+
if (C) return createElement(C, props);
|
|
363
|
+
const id = tipId(props);
|
|
364
|
+
return (
|
|
365
|
+
<span
|
|
366
|
+
className="group/tip relative inline-flex"
|
|
367
|
+
{...(props.control ? {} : { tabIndex: 0, "aria-describedby": id })}
|
|
368
|
+
>
|
|
369
|
+
{props.children}
|
|
370
|
+
<Bubble
|
|
371
|
+
id={id}
|
|
372
|
+
text={tipText(props)}
|
|
373
|
+
side={props.side}
|
|
374
|
+
align={props.align}
|
|
375
|
+
/>
|
|
376
|
+
</span>
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/** A plain button: the native `<button>` unless your app names its own. */
|
|
381
|
+
export function Button(props: ButtonProps) {
|
|
382
|
+
const C = useSwapped("Button");
|
|
383
|
+
return C ? createElement(C, props) : <button {...props} />;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** A one-line text field: the native `<input>` unless your app names its own. */
|
|
387
|
+
export function TextInput(props: TextInputProps) {
|
|
388
|
+
const C = useSwapped("TextInput");
|
|
389
|
+
return C ? createElement(C, props) : <input {...props} />;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** A multi-line text field: the native `<textarea>` unless your app names its own. */
|
|
393
|
+
export function TextArea(props: TextAreaProps) {
|
|
394
|
+
const C = useSwapped("TextArea");
|
|
395
|
+
return C ? createElement(C, props) : <textarea {...props} />;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** A dropdown: the native `<select>` unless your app names its own. */
|
|
399
|
+
export function Select(props: SelectProps) {
|
|
400
|
+
const C = useSwapped("Select");
|
|
401
|
+
return C ? createElement(C, props) : <select {...props} />;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Keeps a page up to date while a test runs. Refreshing is your router's
|
|
406
|
+
* job (Next.js's `router.refresh()`), so this draws nothing unless your
|
|
407
|
+
* app names its own `RefreshWhile`; without one, reload to see results.
|
|
408
|
+
*/
|
|
409
|
+
export function RefreshWhile(props: RefreshWhileProps) {
|
|
410
|
+
const C = useSwapped("RefreshWhile");
|
|
411
|
+
return C ? createElement(C, props) : null;
|
|
412
|
+
}
|
package/src/readCheck.ts
CHANGED
|
@@ -50,7 +50,7 @@ export type ReadRow = Readonly<Record<string, unknown>>;
|
|
|
50
50
|
/**
|
|
51
51
|
* Where a read check reads rows from: a store's records
|
|
52
52
|
* (`checkStoreReads`), or an adapter's raw rows before it fills in
|
|
53
|
-
* defaults (`prismaReadCheck` in `@crowandraven/evalkeeper
|
|
53
|
+
* defaults (`prismaReadCheck` in `@crowandraven/evalkeeper/prisma`), so a
|
|
54
54
|
* value the store would quietly replace still shows. Cases come with
|
|
55
55
|
* their answers in `labels`.
|
|
56
56
|
*/
|
package/src/runner.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import type { BoardRow } from "./board.js";
|
|
17
17
|
import { allPassed } from "./stats.js";
|
|
18
18
|
import { pickQuickSet } from "./quickSet.js";
|
|
19
|
+
import { answerKeyHealth } from "./prune.js";
|
|
19
20
|
import { stableJson } from "./stableJson.js";
|
|
20
21
|
import { suiteMetrics, type ScoredOutput } from "./stats.js";
|
|
21
22
|
import type {
|
|
@@ -39,6 +40,7 @@ import { SCHEDULED } from "./weekly.js";
|
|
|
39
40
|
import { confirmedLabel, isProvisional } from "./labels.js";
|
|
40
41
|
export { confirmedLabel, isProvisional };
|
|
41
42
|
import { injectionSuitesOf, type AnySuite, type CheckResult } from "./types.js";
|
|
43
|
+
import { injectionCases } from "./suites/injection.js";
|
|
42
44
|
import { at } from "./util.js";
|
|
43
45
|
import { mustGet } from "./util.js";
|
|
44
46
|
|
|
@@ -72,14 +74,14 @@ export type RunnerOptions = {
|
|
|
72
74
|
models: ModelCatalog;
|
|
73
75
|
/**
|
|
74
76
|
* The current instructions' hash for an operation (see instructionsHash
|
|
75
|
-
* in `@crowandraven/evalkeeper
|
|
77
|
+
* in `@crowandraven/evalkeeper/ai-sdk`). A test records it, so editing the instructions
|
|
76
78
|
* marks older tests out of date.
|
|
77
79
|
*/
|
|
78
80
|
promptVersion: (operation: string) => string | Promise<string>;
|
|
79
81
|
/**
|
|
80
82
|
* Everything the operation's model is told, as text: system text, prompt
|
|
81
83
|
* templates, schema and tool descriptions (`instructionParts` in
|
|
82
|
-
* `@crowandraven/evalkeeper
|
|
84
|
+
* `@crowandraven/evalkeeper/ai-sdk`, from the parts you hash). Lets
|
|
83
85
|
* `casesInInstructions` warn when a case was copied into them.
|
|
84
86
|
*/
|
|
85
87
|
instructionTexts?: (operation: string) => string[] | Promise<string[]>;
|
|
@@ -238,6 +240,27 @@ export async function mapLimit<T, R>(
|
|
|
238
240
|
return results;
|
|
239
241
|
}
|
|
240
242
|
|
|
243
|
+
/** Several estimates as one; the cost is unknown if any part's is. */
|
|
244
|
+
function totalOf(
|
|
245
|
+
parts: {
|
|
246
|
+
cases: number;
|
|
247
|
+
answers: number;
|
|
248
|
+
reused: number;
|
|
249
|
+
costUsd: number | null;
|
|
250
|
+
}[],
|
|
251
|
+
) {
|
|
252
|
+
return parts.reduce<(typeof parts)[number]>(
|
|
253
|
+
(t, p) => ({
|
|
254
|
+
cases: t.cases + p.cases,
|
|
255
|
+
answers: t.answers + p.answers,
|
|
256
|
+
reused: t.reused + p.reused,
|
|
257
|
+
costUsd:
|
|
258
|
+
t.costUsd === null || p.costUsd === null ? null : t.costUsd + p.costUsd,
|
|
259
|
+
}),
|
|
260
|
+
{ cases: 0, answers: 0, reused: 0, costUsd: 0 },
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
241
264
|
/**
|
|
242
265
|
* The runner: creates and runs tests, rescores them, compares them, and builds each
|
|
243
266
|
* suite's model board, on your store.
|
|
@@ -509,8 +532,12 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
509
532
|
run: RunRecord,
|
|
510
533
|
suite: AnySuite,
|
|
511
534
|
judgeCostUsd: number,
|
|
535
|
+
/** Only these cases' answers count; all when absent. */
|
|
536
|
+
caseIds?: ReadonlySet<string>,
|
|
512
537
|
): Promise<RunMetrics> {
|
|
513
|
-
const outputs = await store.listOutputs(run.id)
|
|
538
|
+
const outputs = (await store.listOutputs(run.id)).filter(
|
|
539
|
+
(o) => !caseIds || caseIds.has(o.caseId),
|
|
540
|
+
);
|
|
514
541
|
const scored: ScoredOutput[] = outputs.map((o) => ({
|
|
515
542
|
caseId: o.caseId,
|
|
516
543
|
repeat: o.repeat,
|
|
@@ -715,10 +742,13 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
715
742
|
await store.updateRun(runId, {
|
|
716
743
|
graderVersion: suite.graderVersion,
|
|
717
744
|
...(madeOnOldInputs ? {} : { datasetVersion: datasetVersion(used) }),
|
|
745
|
+
// A retired case's answers leave the score, as they left the
|
|
746
|
+
// dataset version.
|
|
718
747
|
metrics: await metricsFor(
|
|
719
748
|
run,
|
|
720
749
|
suite,
|
|
721
750
|
(run.metrics?.judgeCostUsd ?? 0) + judgeCost,
|
|
751
|
+
new Set(cases.keys()),
|
|
722
752
|
),
|
|
723
753
|
});
|
|
724
754
|
}
|
|
@@ -732,6 +762,45 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
732
762
|
await rescoreRun(r.id);
|
|
733
763
|
}
|
|
734
764
|
|
|
765
|
+
/**
|
|
766
|
+
* A suite's answer-key health: cases every current model gets right
|
|
767
|
+
* (easy), cases models split on, near-duplicates, old drafts, and how
|
|
768
|
+
* the tags spread, from the board's current tests.
|
|
769
|
+
*/
|
|
770
|
+
async function answerKeyHealthOf(suiteKey: string, today = new Date()) {
|
|
771
|
+
const [b, cases] = await Promise.all([
|
|
772
|
+
board(suiteKey),
|
|
773
|
+
store.listCases(suiteKey),
|
|
774
|
+
]);
|
|
775
|
+
return answerKeyHealth(cases, b.caseResults, today);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Retires a suite's easy cases beyond the floor, then rescores its
|
|
780
|
+
* recent tests (free), so their scores leave the retired cases out.
|
|
781
|
+
* Returns how many it retired.
|
|
782
|
+
*/
|
|
783
|
+
async function retireEasy(suiteKey: string): Promise<number> {
|
|
784
|
+
const { easyToRetire } = await answerKeyHealthOf(suiteKey);
|
|
785
|
+
for (const c of easyToRetire) await store.setCaseStatus(c.id, "RETIRED");
|
|
786
|
+
if (easyToRetire.length) await rescoreRecent(suiteKey);
|
|
787
|
+
return easyToRetire.length;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Retires a suite's drafts nobody reviewed in STALE_DRAFT_DAYS. Drafts
|
|
792
|
+
* are never graded against, so no test changes. Returns how many.
|
|
793
|
+
*/
|
|
794
|
+
async function retireStaleDrafts(
|
|
795
|
+
suiteKey: string,
|
|
796
|
+
today = new Date(),
|
|
797
|
+
): Promise<number> {
|
|
798
|
+
const cases = await store.listCases(suiteOrThrow(suiteKey).key);
|
|
799
|
+
const { staleDrafts } = answerKeyHealth(cases, {}, today);
|
|
800
|
+
for (const c of staleDrafts) await store.setCaseStatus(c.id, "RETIRED");
|
|
801
|
+
return staleDrafts.length;
|
|
802
|
+
}
|
|
803
|
+
|
|
735
804
|
/**
|
|
736
805
|
* Records one suite's weekly drift check without running it: its quick
|
|
737
806
|
* set on its live model, at its live reasoning setting, marked as
|
|
@@ -982,6 +1051,9 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
982
1051
|
);
|
|
983
1052
|
const outputsOf = (runId: string) => outputs.get(runId) ?? [];
|
|
984
1053
|
const checkKeys = suite.checks.map((c) => c.key);
|
|
1054
|
+
const seriousKeys = new Set(
|
|
1055
|
+
suite.checks.filter((c) => c.severity === "serious").map((c) => c.key),
|
|
1056
|
+
);
|
|
985
1057
|
|
|
986
1058
|
const seen = new Set<string>();
|
|
987
1059
|
let keys = [
|
|
@@ -1070,6 +1142,13 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
1070
1142
|
total: m.units?.total ?? m.allPass.n,
|
|
1071
1143
|
answersRight: m.allPass.passed,
|
|
1072
1144
|
answers: m.allPass.n,
|
|
1145
|
+
answersNoSerious: outputsOf(r.id).filter(
|
|
1146
|
+
(x) =>
|
|
1147
|
+
x.checks !== null &&
|
|
1148
|
+
!x.checks.some(
|
|
1149
|
+
(c) => c.pass === false && seriousKeys.has(c.key),
|
|
1150
|
+
),
|
|
1151
|
+
).length,
|
|
1073
1152
|
byCheck: m.byCheck,
|
|
1074
1153
|
measures: m.measures ?? {},
|
|
1075
1154
|
avgMs: m.avgMs || null,
|
|
@@ -1132,6 +1211,77 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
1132
1211
|
};
|
|
1133
1212
|
}
|
|
1134
1213
|
|
|
1214
|
+
/**
|
|
1215
|
+
* The injection suites that attack a suite, with their attack cases
|
|
1216
|
+
* first brought in step with its confirmed answers (`injectionCases`):
|
|
1217
|
+
* the ones with cases in use for `set`.
|
|
1218
|
+
*/
|
|
1219
|
+
async function attacksReady(suiteKey: string, set: EvalSet) {
|
|
1220
|
+
const out: AnySuite[] = [];
|
|
1221
|
+
for (const a of injectionSuitesOf(
|
|
1222
|
+
opts.suites,
|
|
1223
|
+
suiteOrThrow(suiteKey).key,
|
|
1224
|
+
)) {
|
|
1225
|
+
// Trust boundary: injectionSuitesOf returns only suites made by
|
|
1226
|
+
// injectionSuite, which is what injectionCases takes.
|
|
1227
|
+
await injectionCases(
|
|
1228
|
+
store,
|
|
1229
|
+
a as unknown as Parameters<typeof injectionCases>[1],
|
|
1230
|
+
);
|
|
1231
|
+
if ((await casesFor(a.key, set)).length) out.push(a);
|
|
1232
|
+
}
|
|
1233
|
+
return out;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* A test of a model on a feature, as people start one: the suite's cases
|
|
1238
|
+
* and, when injection suites attack it, their attack cases too, kept in
|
|
1239
|
+
* step with the suite's confirmed answers first. One run per suite; run
|
|
1240
|
+
* each with `runEval`. `createRun` tests one suite alone.
|
|
1241
|
+
*
|
|
1242
|
+
* @param args - As for `createRun`, for the feature's suite.
|
|
1243
|
+
* @returns The runs, the suite's first, and what the whole test costs.
|
|
1244
|
+
*/
|
|
1245
|
+
async function createTest(args: Parameters<typeof createRun>[0]) {
|
|
1246
|
+
const attacks = await attacksReady(args.suite, args.set ?? "ALL");
|
|
1247
|
+
const made = [await createRun(args)];
|
|
1248
|
+
for (const a of attacks)
|
|
1249
|
+
made.push(await createRun({ ...args, suite: a.key }));
|
|
1250
|
+
return {
|
|
1251
|
+
runs: made.map((m) => m.run),
|
|
1252
|
+
estimate: totalOf(made.map((m) => m.estimate)),
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* What a test of a model on a feature would cost now (`createTest`): the
|
|
1258
|
+
* suite's cases and its attack cases together. Doesn't sync attack
|
|
1259
|
+
* cases; it counts the ones in use.
|
|
1260
|
+
*
|
|
1261
|
+
* @param suiteKey - The feature's suite.
|
|
1262
|
+
* @param model - The model to test.
|
|
1263
|
+
* @param set - Which cases.
|
|
1264
|
+
* @param repeats - How many times each.
|
|
1265
|
+
* @param o - As for `estimateRun`.
|
|
1266
|
+
*/
|
|
1267
|
+
async function estimateTest(
|
|
1268
|
+
suiteKey: string,
|
|
1269
|
+
model: string,
|
|
1270
|
+
set: EvalSet,
|
|
1271
|
+
repeats: number,
|
|
1272
|
+
o: Parameters<typeof estimateRun>[4] = {},
|
|
1273
|
+
) {
|
|
1274
|
+
const suites = [
|
|
1275
|
+
suiteOrThrow(suiteKey).key,
|
|
1276
|
+
...injectionSuitesOf(opts.suites, suiteKey).map((a) => a.key),
|
|
1277
|
+
];
|
|
1278
|
+
return totalOf(
|
|
1279
|
+
await Promise.all(
|
|
1280
|
+
suites.map((k) => estimateRun(k, model, set, repeats, o)),
|
|
1281
|
+
),
|
|
1282
|
+
);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1135
1285
|
/**
|
|
1136
1286
|
* The boards of the injection suites that attack a suite, for the base
|
|
1137
1287
|
* suite's page and its suggestion (`attacksFrom`). Empty when nothing
|
|
@@ -1145,12 +1295,23 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
1145
1295
|
);
|
|
1146
1296
|
}
|
|
1147
1297
|
|
|
1298
|
+
/**
|
|
1299
|
+
* The models an operation can be tested on: its candidates' `models`,
|
|
1300
|
+
* or none without the `candidates` option.
|
|
1301
|
+
*/
|
|
1302
|
+
function modelsFor(operation: string): string[] {
|
|
1303
|
+
return opts.candidates?.(operation).models ?? [];
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1148
1306
|
return {
|
|
1149
1307
|
startDriftCheck,
|
|
1150
1308
|
runDriftCheck,
|
|
1151
1309
|
draftFromActivity,
|
|
1152
1310
|
board,
|
|
1153
1311
|
attackBoards,
|
|
1312
|
+
modelsFor,
|
|
1313
|
+
createTest,
|
|
1314
|
+
estimateTest,
|
|
1154
1315
|
suiteOrThrow,
|
|
1155
1316
|
casesFor,
|
|
1156
1317
|
estimateRun,
|
|
@@ -1159,6 +1320,9 @@ export function createRunner(opts: RunnerOptions) {
|
|
|
1159
1320
|
gradeOutput,
|
|
1160
1321
|
rescoreRun,
|
|
1161
1322
|
rescoreRecent,
|
|
1323
|
+
answerKeyHealth: answerKeyHealthOf,
|
|
1324
|
+
retireEasy,
|
|
1325
|
+
retireStaleDrafts,
|
|
1162
1326
|
stopStuckRuns,
|
|
1163
1327
|
compare,
|
|
1164
1328
|
casesInInstructions: casesInInstructionsFor,
|
package/src/settings.ts
CHANGED
|
@@ -150,7 +150,7 @@ export type SettingsSwitch = {
|
|
|
150
150
|
expectLive: string | null;
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
/** Where versions live. `@crowandraven/evalkeeper
|
|
153
|
+
/** Where versions live. `@crowandraven/evalkeeper/prisma` and `memoryStore` implement it. */
|
|
154
154
|
export interface SettingsStore {
|
|
155
155
|
liveVersion(operation: string): Promise<SettingsVersion | null>;
|
|
156
156
|
/** Newest first. */
|