@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
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import type { FeedbackStore, EvalStore, ChangeKind, SettingsStore } from "../index.js";
|
|
2
|
+
import { type ColumnMap } from "./mapping.js";
|
|
3
|
+
export type { ColumnMap } from "./mapping.js";
|
|
4
|
+
export * from "./contracts.js";
|
|
5
|
+
/**
|
|
6
|
+
* An EvalStore on your Prisma client, using the models in
|
|
7
|
+
* schema/evalkeeper.prisma. Pass the client you already have:
|
|
8
|
+
*
|
|
9
|
+
* const store = prismaStore(prisma);
|
|
10
|
+
*
|
|
11
|
+
* The client is typed by the rows it returns, not by Prisma's generated
|
|
12
|
+
* types, so this package works with any client generated from the schema.
|
|
13
|
+
*/
|
|
14
|
+
/** A stored JSON value, as Prisma returns it. */
|
|
15
|
+
type Json = unknown;
|
|
16
|
+
/** The rows of Evalkeeper's tables, as the schema defines them. */
|
|
17
|
+
export type EvalCaseRow = {
|
|
18
|
+
id: string;
|
|
19
|
+
suite: string;
|
|
20
|
+
input: Json;
|
|
21
|
+
tags: Json;
|
|
22
|
+
split: string;
|
|
23
|
+
status: string;
|
|
24
|
+
source: string;
|
|
25
|
+
sourceRef: string | null;
|
|
26
|
+
note: string | null;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
updatedAt: Date;
|
|
29
|
+
};
|
|
30
|
+
/** An EvalCaseLabel row. */
|
|
31
|
+
export type EvalCaseLabelRow = {
|
|
32
|
+
id: string;
|
|
33
|
+
caseId: string;
|
|
34
|
+
kind: string;
|
|
35
|
+
status: string;
|
|
36
|
+
value: Json;
|
|
37
|
+
raterRole: string;
|
|
38
|
+
raterId: string | null;
|
|
39
|
+
note: string | null;
|
|
40
|
+
createdAt: Date;
|
|
41
|
+
updatedAt: Date;
|
|
42
|
+
};
|
|
43
|
+
/** An EvalRun row. */
|
|
44
|
+
export type EvalRunRow = {
|
|
45
|
+
id: string;
|
|
46
|
+
suite: string;
|
|
47
|
+
model: string;
|
|
48
|
+
promptVersion: string;
|
|
49
|
+
reasoningEffort: string | null;
|
|
50
|
+
temperature: number | null;
|
|
51
|
+
maxOutputTokens: number | null;
|
|
52
|
+
set: string;
|
|
53
|
+
repeats: number;
|
|
54
|
+
datasetVersion: string | null;
|
|
55
|
+
graderVersion: string;
|
|
56
|
+
status: string;
|
|
57
|
+
metrics: Json;
|
|
58
|
+
error: string | null;
|
|
59
|
+
estimatedCostUsd: number | null;
|
|
60
|
+
startedBy: string | null;
|
|
61
|
+
startedAt: Date;
|
|
62
|
+
finishedAt: Date | null;
|
|
63
|
+
};
|
|
64
|
+
/** An EvalOutput row. */
|
|
65
|
+
export type EvalOutputRow = {
|
|
66
|
+
id: string;
|
|
67
|
+
runId: string;
|
|
68
|
+
caseId: string;
|
|
69
|
+
repeat: number;
|
|
70
|
+
requestHash: string;
|
|
71
|
+
output: Json;
|
|
72
|
+
error: string | null;
|
|
73
|
+
scores: Json;
|
|
74
|
+
costUsd: number;
|
|
75
|
+
ms: number;
|
|
76
|
+
reused: boolean;
|
|
77
|
+
createdAt: Date;
|
|
78
|
+
};
|
|
79
|
+
/** An EvalJudgment row. */
|
|
80
|
+
export type EvalJudgmentRow = {
|
|
81
|
+
key: string;
|
|
82
|
+
value: Json;
|
|
83
|
+
model: string;
|
|
84
|
+
createdAt: Date;
|
|
85
|
+
};
|
|
86
|
+
/** The methods of a Prisma model delegate this package calls. */
|
|
87
|
+
type Delegate<Row> = {
|
|
88
|
+
findMany(args: object): PromiseLike<Row[]>;
|
|
89
|
+
findFirst(args: object): PromiseLike<Row | null>;
|
|
90
|
+
findUnique(args: object): PromiseLike<Row | null>;
|
|
91
|
+
create(args: object): PromiseLike<Row>;
|
|
92
|
+
update(args: object): PromiseLike<Row>;
|
|
93
|
+
updateMany(args: object): PromiseLike<{
|
|
94
|
+
count: number;
|
|
95
|
+
}>;
|
|
96
|
+
};
|
|
97
|
+
/** The part of a generated Prisma client Evalkeeper uses. */
|
|
98
|
+
export type PrismaEvalClient = {
|
|
99
|
+
evalCase: Delegate<EvalCaseRow>;
|
|
100
|
+
evalCaseLabel: Delegate<EvalCaseLabelRow>;
|
|
101
|
+
evalRun: Delegate<EvalRunRow>;
|
|
102
|
+
evalOutput: Delegate<EvalOutputRow>;
|
|
103
|
+
evalJudgment: Delegate<EvalJudgmentRow>;
|
|
104
|
+
};
|
|
105
|
+
/** Evalkeeper's eval tables, by the names its schema gives them. */
|
|
106
|
+
export type EvalTable = "evalCase" | "evalCaseLabel" | "evalRun" | "evalOutput" | "evalJudgment";
|
|
107
|
+
/**
|
|
108
|
+
* How Evalkeeper's eval tables map onto an app's own, for an app that had
|
|
109
|
+
* eval tables before Evalkeeper. Pass it to `prismaStore` and
|
|
110
|
+
* `prismaJudgmentCache`; leave out anything named the same.
|
|
111
|
+
*
|
|
112
|
+
* Types convert on their own: Decimal columns read as numbers, enum
|
|
113
|
+
* columns as their names, and `tags` may be a `String[]` or a `Json`
|
|
114
|
+
* column. Columns Evalkeeper doesn't know (a creator, a legacy results
|
|
115
|
+
* column) are left alone, so they need a default or to be nullable.
|
|
116
|
+
*/
|
|
117
|
+
export type PrismaStoreMap = {
|
|
118
|
+
/**
|
|
119
|
+
* Each table's model on the Prisma client, as the client spells it
|
|
120
|
+
* (`prisma.goldCase` is `"goldCase"`).
|
|
121
|
+
*/
|
|
122
|
+
models?: Partial<Record<EvalTable, string>>;
|
|
123
|
+
/**
|
|
124
|
+
* Column names per table, keyed by Evalkeeper's field name. `null`
|
|
125
|
+
* says the table has no such column (for nullable fields only): reads
|
|
126
|
+
* give null, and writing a value fails rather than losing it.
|
|
127
|
+
*/
|
|
128
|
+
fields?: {
|
|
129
|
+
/** `labels` is the relation from a case to its answers. */
|
|
130
|
+
evalCase?: ColumnMap<EvalCaseRow & {
|
|
131
|
+
labels: unknown;
|
|
132
|
+
}>;
|
|
133
|
+
evalCaseLabel?: ColumnMap<EvalCaseLabelRow>;
|
|
134
|
+
evalRun?: ColumnMap<EvalRunRow>;
|
|
135
|
+
evalOutput?: ColumnMap<EvalOutputRow>;
|
|
136
|
+
evalJudgment?: ColumnMap<EvalJudgmentRow>;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* An EvalStore on your Prisma client, using the models in
|
|
141
|
+
* `schema/evalkeeper.prisma`.
|
|
142
|
+
*
|
|
143
|
+
* @param db - Your Prisma client.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* import { prismaStore } from "@crowandraven/evalkeeper/prisma";
|
|
148
|
+
* const store = prismaStore(prisma);
|
|
149
|
+
* const runner = createRunner({ store, suites, models, promptVersion });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare function prismaStore(db: PrismaEvalClient): EvalStore;
|
|
153
|
+
/**
|
|
154
|
+
* An EvalStore on your own eval tables, through a mapping (see
|
|
155
|
+
* `PrismaStoreMap`), for an app that had eval tables before Evalkeeper.
|
|
156
|
+
*
|
|
157
|
+
* @param db - Your Prisma client.
|
|
158
|
+
* @param map - Where your tables differ from Evalkeeper's.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* const store = prismaStore(prisma, {
|
|
163
|
+
* fields: {
|
|
164
|
+
* evalCaseLabel: { note: "rationale" },
|
|
165
|
+
* evalRun: { set: "split", startedBy: "startedById" },
|
|
166
|
+
* },
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export declare function prismaStore(db: object, map: PrismaStoreMap): EvalStore;
|
|
171
|
+
/**
|
|
172
|
+
* A judgment cache on the EvalJudgment table, for
|
|
173
|
+
* `@crowandraven/evalkeeper/ai-sdk`.
|
|
174
|
+
*
|
|
175
|
+
* @param db - Your Prisma client.
|
|
176
|
+
*/
|
|
177
|
+
export declare function prismaJudgmentCache(db: PrismaEvalClient): PrismaJudgmentCache;
|
|
178
|
+
/**
|
|
179
|
+
* A judgment cache on your own judgment table, through a mapping.
|
|
180
|
+
*
|
|
181
|
+
* @param db - Your Prisma client.
|
|
182
|
+
* @param map - The mapping you pass `prismaStore`; only `evalJudgment` is
|
|
183
|
+
* used.
|
|
184
|
+
*/
|
|
185
|
+
export declare function prismaJudgmentCache(db: object, map: PrismaStoreMap): PrismaJudgmentCache;
|
|
186
|
+
/** Where a judge model's answers are kept, so none is paid for twice. */
|
|
187
|
+
export type PrismaJudgmentCache = {
|
|
188
|
+
get(key: string): Promise<unknown>;
|
|
189
|
+
set(key: string, value: unknown, model: string): Promise<void>;
|
|
190
|
+
};
|
|
191
|
+
/** An EvalFeedback row. */
|
|
192
|
+
export type EvalFeedbackRow = {
|
|
193
|
+
id: string;
|
|
194
|
+
operation: string;
|
|
195
|
+
targetId: string;
|
|
196
|
+
raterId: string;
|
|
197
|
+
rating: string;
|
|
198
|
+
reason: string | null;
|
|
199
|
+
excerpt: string | null;
|
|
200
|
+
input: Json;
|
|
201
|
+
output: Json;
|
|
202
|
+
status: string;
|
|
203
|
+
caseId: string | null;
|
|
204
|
+
createdAt: Date;
|
|
205
|
+
updatedAt: Date;
|
|
206
|
+
};
|
|
207
|
+
/** The part of a generated Prisma client the feedback store uses. */
|
|
208
|
+
export type PrismaFeedbackClient = {
|
|
209
|
+
evalFeedback: Delegate<EvalFeedbackRow> & {
|
|
210
|
+
upsert(args: object): PromiseLike<EvalFeedbackRow>;
|
|
211
|
+
deleteMany(args: object): PromiseLike<{
|
|
212
|
+
count: number;
|
|
213
|
+
}>;
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
/** What the rating column holds for a thumbs up and a thumbs down. */
|
|
217
|
+
export type RatingValues = {
|
|
218
|
+
UP: string;
|
|
219
|
+
DOWN: string;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Column names for the feedback table, keyed by Evalkeeper's field. Like
|
|
223
|
+
* `ColumnMap`, and `status` may be `null` too: a table without it reads
|
|
224
|
+
* every rating as OPEN.
|
|
225
|
+
*/
|
|
226
|
+
export type FeedbackColumnMap = ColumnMap<Omit<EvalFeedbackRow, "status"> & {
|
|
227
|
+
status: string | null;
|
|
228
|
+
}>;
|
|
229
|
+
/**
|
|
230
|
+
* How Evalkeeper's feedback table maps onto an app's own thumbs table, for
|
|
231
|
+
* an app that recorded thumbs up and down before Evalkeeper. Pass it to
|
|
232
|
+
* `prismaFeedbackStore` (and `deleteScopedRows`); leave out anything
|
|
233
|
+
* named the same.
|
|
234
|
+
*
|
|
235
|
+
* A table without `input` (most thumbs tables never kept inputs) still
|
|
236
|
+
* gives the weekly summary's thumbs-down alerts and the hub's counts,
|
|
237
|
+
* which need only the rating, feature, and time; its ratings can't become
|
|
238
|
+
* cases, and `whyNotACase` says so.
|
|
239
|
+
*/
|
|
240
|
+
export type PrismaFeedbackMap = {
|
|
241
|
+
/**
|
|
242
|
+
* The table's model on the Prisma client, as the client spells it
|
|
243
|
+
* (`prisma.aiFeedback` is `"aiFeedback"`).
|
|
244
|
+
*/
|
|
245
|
+
models?: {
|
|
246
|
+
evalFeedback?: string;
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Column names, keyed by Evalkeeper's field (`raterId: "userId"`).
|
|
250
|
+
* `null` says the table has no such column (`reason`, `excerpt`,
|
|
251
|
+
* `input`, `output`, `status`, or `caseId`): reads give null (a status,
|
|
252
|
+
* OPEN), and writing a value fails rather than losing it.
|
|
253
|
+
*/
|
|
254
|
+
fields?: {
|
|
255
|
+
evalFeedback?: FeedbackColumnMap;
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* What your rating column holds for each, when it isn't UP and DOWN (an
|
|
259
|
+
* enum with other names, say `{ UP: "up", DOWN: "down" }`). A value
|
|
260
|
+
* that's neither reads as a thumbs up.
|
|
261
|
+
*/
|
|
262
|
+
ratings?: RatingValues;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* A FeedbackStore on the EvalFeedback table.
|
|
266
|
+
*
|
|
267
|
+
* @param db - Your Prisma client.
|
|
268
|
+
*/
|
|
269
|
+
export declare function prismaFeedbackStore(db: PrismaFeedbackClient): FeedbackStore;
|
|
270
|
+
/**
|
|
271
|
+
* A FeedbackStore on your own thumbs table, through a map (see
|
|
272
|
+
* `PrismaFeedbackMap`), so the weekly summary's alerts and the hub's
|
|
273
|
+
* counts read the ratings your app already keeps.
|
|
274
|
+
*
|
|
275
|
+
* @param db - Your Prisma client.
|
|
276
|
+
* @param map - Where your table differs from Evalkeeper's.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* An `aiFeedback` table with a `userId` column, a rating enum of UP and
|
|
280
|
+
* DOWN, a reason, an excerpt, and times, that never kept inputs:
|
|
281
|
+
* ```ts
|
|
282
|
+
* const feedbackStore = prismaFeedbackStore(prisma, {
|
|
283
|
+
* models: { evalFeedback: "aiFeedback" },
|
|
284
|
+
* fields: {
|
|
285
|
+
* evalFeedback: {
|
|
286
|
+
* raterId: "userId",
|
|
287
|
+
* input: null,
|
|
288
|
+
* output: null,
|
|
289
|
+
* status: null,
|
|
290
|
+
* caseId: null,
|
|
291
|
+
* },
|
|
292
|
+
* },
|
|
293
|
+
* });
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
export declare function prismaFeedbackStore(db: object, map: PrismaFeedbackMap): FeedbackStore;
|
|
297
|
+
/** An EvalSettingsVersion row. */
|
|
298
|
+
export type EvalSettingsVersionRow = {
|
|
299
|
+
id: string;
|
|
300
|
+
operation: string;
|
|
301
|
+
number: number;
|
|
302
|
+
model: string;
|
|
303
|
+
fallbackModel: string | null;
|
|
304
|
+
reasoningEffort: string | null;
|
|
305
|
+
maxOutputTokens: number | null;
|
|
306
|
+
temperature: number | null;
|
|
307
|
+
promptVersion: string | null;
|
|
308
|
+
createdAt: Date;
|
|
309
|
+
};
|
|
310
|
+
/** An EvalSettingsLive row. */
|
|
311
|
+
export type EvalSettingsLiveRow = {
|
|
312
|
+
operation: string;
|
|
313
|
+
versionId: string;
|
|
314
|
+
updatedAt: Date;
|
|
315
|
+
};
|
|
316
|
+
/** An EvalSettingsChange row. */
|
|
317
|
+
export type EvalSettingsChangeRow = {
|
|
318
|
+
id: string;
|
|
319
|
+
operation: string;
|
|
320
|
+
kind: string;
|
|
321
|
+
fromVersionId: string | null;
|
|
322
|
+
toVersionId: string;
|
|
323
|
+
reason: string | null;
|
|
324
|
+
by: string | null;
|
|
325
|
+
evidence: Json;
|
|
326
|
+
createdAt: Date;
|
|
327
|
+
};
|
|
328
|
+
/** The settings tables, inside or outside a transaction. */
|
|
329
|
+
export type PrismaSettingsTables = {
|
|
330
|
+
evalSettingsVersion: Delegate<EvalSettingsVersionRow>;
|
|
331
|
+
evalSettingsLive: Delegate<EvalSettingsLiveRow>;
|
|
332
|
+
evalSettingsChange: Delegate<EvalSettingsChangeRow>;
|
|
333
|
+
};
|
|
334
|
+
/** The part of a generated Prisma client the settings store uses. */
|
|
335
|
+
export type PrismaSettingsClient = PrismaSettingsTables & {
|
|
336
|
+
$transaction<T>(fn: (tx: PrismaSettingsTables) => Promise<T>): Promise<T>;
|
|
337
|
+
};
|
|
338
|
+
/** Evalkeeper's settings tables, by the names its schema gives them. */
|
|
339
|
+
export type SettingsTable = "evalSettingsVersion" | "evalSettingsLive" | "evalSettingsChange";
|
|
340
|
+
/**
|
|
341
|
+
* How Evalkeeper's settings tables map onto an app's own versions tables,
|
|
342
|
+
* so Evalkeeper's rollback and history pages read the same history as the
|
|
343
|
+
* app's own model admin page. Leave out anything named the same.
|
|
344
|
+
*/
|
|
345
|
+
export type PrismaSettingsMap = {
|
|
346
|
+
/** Each table's model on the Prisma client, as the client spells it. */
|
|
347
|
+
models?: Partial<Record<SettingsTable, string>>;
|
|
348
|
+
/**
|
|
349
|
+
* Column names per table, keyed by Evalkeeper's field name. `null`
|
|
350
|
+
* says the table has no such column (for nullable fields only): reads
|
|
351
|
+
* give null, and saving a version that sets it fails rather than losing
|
|
352
|
+
* the setting.
|
|
353
|
+
*/
|
|
354
|
+
fields?: {
|
|
355
|
+
evalSettingsVersion?: ColumnMap<EvalSettingsVersionRow>;
|
|
356
|
+
evalSettingsLive?: ColumnMap<EvalSettingsLiveRow>;
|
|
357
|
+
evalSettingsChange?: ColumnMap<EvalSettingsChangeRow>;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* The kinds your change log's kind column can hold, when it's an enum
|
|
361
|
+
* made before some kinds existed (OUTSIDE and INSTRUCTIONS came later).
|
|
362
|
+
* A kind not listed is stored as CHANGE, with the real kind and the
|
|
363
|
+
* evidence kept in the evidence column (as `{ evalkeeperKind, evidence }`),
|
|
364
|
+
* and read back as itself. Leave it out for a text column or an enum
|
|
365
|
+
* with every kind.
|
|
366
|
+
*/
|
|
367
|
+
kinds?: readonly ChangeKind[];
|
|
368
|
+
/**
|
|
369
|
+
* For a table that keeps who made a change as something other than
|
|
370
|
+
* the `by` your pages pass (a user id with a foreign key, say). Each is
|
|
371
|
+
* called only for a value that isn't null.
|
|
372
|
+
*/
|
|
373
|
+
by?: {
|
|
374
|
+
/** What to store for `by` (e.g. the user id for a name). */
|
|
375
|
+
toColumn(by: string): string | null | Promise<string | null>;
|
|
376
|
+
/** What to show for a stored value (e.g. the name for a user id). */
|
|
377
|
+
fromColumn(stored: string): string | null | Promise<string | null>;
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
/** A Prisma client that runs a function in a transaction, as every one does. */
|
|
381
|
+
export type PrismaTransactionClient = {
|
|
382
|
+
$transaction<T>(fn: (tx: object) => Promise<T>): Promise<T>;
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* A SettingsStore on the EvalSettings tables. Each switch runs in one
|
|
386
|
+
* transaction, and moves the live pointer only if it still points at the
|
|
387
|
+
* version the switch was decided against, so concurrent saves can't
|
|
388
|
+
* silently overwrite each other.
|
|
389
|
+
*
|
|
390
|
+
* @param db - Your Prisma client.
|
|
391
|
+
*/
|
|
392
|
+
export declare function prismaSettingsStore(db: PrismaSettingsClient): SettingsStore;
|
|
393
|
+
/**
|
|
394
|
+
* A SettingsStore on your own versions tables, through a mapping (see
|
|
395
|
+
* `PrismaSettingsMap`), so Evalkeeper's pages and your own read the same
|
|
396
|
+
* history.
|
|
397
|
+
*
|
|
398
|
+
* @param db - Your Prisma client.
|
|
399
|
+
* @param map - Where your tables differ from Evalkeeper's.
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* Your own versions tables, with a user id for who changed what:
|
|
403
|
+
* ```ts
|
|
404
|
+
* const settingsStore = prismaSettingsStore(prisma, {
|
|
405
|
+
* models: {
|
|
406
|
+
* evalSettingsVersion: "operationVersion",
|
|
407
|
+
* evalSettingsLive: "operationLive",
|
|
408
|
+
* evalSettingsChange: "operationChange",
|
|
409
|
+
* },
|
|
410
|
+
* fields: {
|
|
411
|
+
* evalSettingsVersion: { temperature: null },
|
|
412
|
+
* evalSettingsChange: { by: "userId" },
|
|
413
|
+
* },
|
|
414
|
+
* by: {
|
|
415
|
+
* toColumn: (by) => by, // your pages pass the admin's id
|
|
416
|
+
* fromColumn: async (id) =>
|
|
417
|
+
* (await prisma.user.findUnique({ where: { id } }))?.name ?? null,
|
|
418
|
+
* },
|
|
419
|
+
* });
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
export declare function prismaSettingsStore(db: PrismaTransactionClient, map: PrismaSettingsMap): SettingsStore;
|
|
423
|
+
export * from "./moveIn.js";
|