@fabricorg/experiments-evals 0.1.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 +15 -0
- package/dist/databricks.cjs +120 -0
- package/dist/databricks.cjs.map +1 -0
- package/dist/databricks.d.cts +50 -0
- package/dist/databricks.d.ts +50 -0
- package/dist/databricks.js +118 -0
- package/dist/databricks.js.map +1 -0
- package/dist/index.cjs +512 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +257 -0
- package/dist/index.d.ts +257 -0
- package/dist/index.js +478 -0
- package/dist/index.js.map +1 -0
- package/dist/model-client-B7yk_i1s.d.cts +601 -0
- package/dist/model-client-B7yk_i1s.d.ts +601 -0
- package/package.json +38 -0
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const EvaluatorKind: z.ZodEnum<["llm-judge", "code", "heuristic"]>;
|
|
4
|
+
type EvaluatorKind = z.infer<typeof EvaluatorKind>;
|
|
5
|
+
declare const TokenUsage: z.ZodObject<{
|
|
6
|
+
inputTokens: z.ZodNumber;
|
|
7
|
+
outputTokens: z.ZodNumber;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
inputTokens: number;
|
|
10
|
+
outputTokens: number;
|
|
11
|
+
}, {
|
|
12
|
+
inputTokens: number;
|
|
13
|
+
outputTokens: number;
|
|
14
|
+
}>;
|
|
15
|
+
type TokenUsage = z.infer<typeof TokenUsage>;
|
|
16
|
+
/**
|
|
17
|
+
* One evaluator's verdict on one example (or, later, one span). `score` is
|
|
18
|
+
* normalized to [0, 1] where defined; `label` carries the categorical verdict
|
|
19
|
+
* ("hallucinated", "correct", …). Provenance fields are mandatory — every
|
|
20
|
+
* score must be traceable to evaluator name+version and, for judges, the
|
|
21
|
+
* prompt hash and model endpoint (governance: evals-judge-provenance).
|
|
22
|
+
*/
|
|
23
|
+
declare const EvalScore: z.ZodObject<{
|
|
24
|
+
evaluatorName: z.ZodString;
|
|
25
|
+
evaluatorVersion: z.ZodString;
|
|
26
|
+
label: z.ZodOptional<z.ZodString>;
|
|
27
|
+
score: z.ZodNullable<z.ZodNumber>;
|
|
28
|
+
explanation: z.ZodOptional<z.ZodString>;
|
|
29
|
+
/** SHA-256 of the rendered judge prompt; absent for code/heuristic evaluators. */
|
|
30
|
+
promptHash: z.ZodOptional<z.ZodString>;
|
|
31
|
+
/** Model Serving endpoint name; absent for code/heuristic evaluators. */
|
|
32
|
+
modelEndpoint: z.ZodOptional<z.ZodString>;
|
|
33
|
+
tokens: z.ZodOptional<z.ZodObject<{
|
|
34
|
+
inputTokens: z.ZodNumber;
|
|
35
|
+
outputTokens: z.ZodNumber;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
inputTokens: number;
|
|
38
|
+
outputTokens: number;
|
|
39
|
+
}, {
|
|
40
|
+
inputTokens: number;
|
|
41
|
+
outputTokens: number;
|
|
42
|
+
}>>;
|
|
43
|
+
latencyMs: z.ZodNumber;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
evaluatorName: string;
|
|
46
|
+
evaluatorVersion: string;
|
|
47
|
+
score: number | null;
|
|
48
|
+
latencyMs: number;
|
|
49
|
+
label?: string | undefined;
|
|
50
|
+
explanation?: string | undefined;
|
|
51
|
+
promptHash?: string | undefined;
|
|
52
|
+
modelEndpoint?: string | undefined;
|
|
53
|
+
tokens?: {
|
|
54
|
+
inputTokens: number;
|
|
55
|
+
outputTokens: number;
|
|
56
|
+
} | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
evaluatorName: string;
|
|
59
|
+
evaluatorVersion: string;
|
|
60
|
+
score: number | null;
|
|
61
|
+
latencyMs: number;
|
|
62
|
+
label?: string | undefined;
|
|
63
|
+
explanation?: string | undefined;
|
|
64
|
+
promptHash?: string | undefined;
|
|
65
|
+
modelEndpoint?: string | undefined;
|
|
66
|
+
tokens?: {
|
|
67
|
+
inputTokens: number;
|
|
68
|
+
outputTokens: number;
|
|
69
|
+
} | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
type EvalScore = z.infer<typeof EvalScore>;
|
|
72
|
+
declare const EvalRunStatus: z.ZodEnum<["pending", "running", "succeeded", "failed", "cancelled"]>;
|
|
73
|
+
type EvalRunStatus = z.infer<typeof EvalRunStatus>;
|
|
74
|
+
/** Target of a run: a frozen dataset version, or a live experiment's variants. */
|
|
75
|
+
declare const EvalRunTarget: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
76
|
+
kind: z.ZodLiteral<"dataset">;
|
|
77
|
+
datasetId: z.ZodString;
|
|
78
|
+
version: z.ZodNumber;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
kind: "dataset";
|
|
81
|
+
datasetId: string;
|
|
82
|
+
version: number;
|
|
83
|
+
}, {
|
|
84
|
+
kind: "dataset";
|
|
85
|
+
datasetId: string;
|
|
86
|
+
version: number;
|
|
87
|
+
}>, z.ZodObject<{
|
|
88
|
+
kind: z.ZodLiteral<"experiment">;
|
|
89
|
+
experimentId: z.ZodString;
|
|
90
|
+
/** Optional metric event to correlate scored outputs with conversions. */
|
|
91
|
+
metricEventName: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
kind: "experiment";
|
|
94
|
+
experimentId: string;
|
|
95
|
+
metricEventName?: string | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
kind: "experiment";
|
|
98
|
+
experimentId: string;
|
|
99
|
+
metricEventName?: string | undefined;
|
|
100
|
+
}>]>;
|
|
101
|
+
type EvalRunTarget = z.infer<typeof EvalRunTarget>;
|
|
102
|
+
/** One rendered conversation the generation phase completes through the model. */
|
|
103
|
+
declare const GenerationSignalItem: z.ZodObject<{
|
|
104
|
+
itemId: z.ZodString;
|
|
105
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
106
|
+
role: z.ZodEnum<["system", "user", "assistant"]>;
|
|
107
|
+
content: z.ZodString;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
role: "system" | "user" | "assistant";
|
|
110
|
+
content: string;
|
|
111
|
+
}, {
|
|
112
|
+
role: "system" | "user" | "assistant";
|
|
113
|
+
content: string;
|
|
114
|
+
}>, "many">;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
itemId: string;
|
|
117
|
+
messages: {
|
|
118
|
+
role: "system" | "user" | "assistant";
|
|
119
|
+
content: string;
|
|
120
|
+
}[];
|
|
121
|
+
}, {
|
|
122
|
+
itemId: string;
|
|
123
|
+
messages: {
|
|
124
|
+
role: "system" | "user" | "assistant";
|
|
125
|
+
content: string;
|
|
126
|
+
}[];
|
|
127
|
+
}>;
|
|
128
|
+
type GenerationSignalItem = z.infer<typeof GenerationSignalItem>;
|
|
129
|
+
/**
|
|
130
|
+
* Generation phase of a playground-replay run (rendered prompt version per
|
|
131
|
+
* example). Rendering happens at dispatch time (pure); the model calls
|
|
132
|
+
* happen in the durable executor, and their tokens count inside
|
|
133
|
+
* `maxJudgeTokens` — the run's SHARED budget (review fix: generation must
|
|
134
|
+
* not occur outside the budget or the request-side lifecycle).
|
|
135
|
+
*/
|
|
136
|
+
declare const GenerationSignal: z.ZodObject<{
|
|
137
|
+
promptId: z.ZodString;
|
|
138
|
+
promptVersion: z.ZodNumber;
|
|
139
|
+
/** Worst-case tokens reserved per generation call under the shared budget. */
|
|
140
|
+
reserveTokensPerCall: z.ZodNumber;
|
|
141
|
+
/** Provider-enforced generation completion ceiling from the prompt version. */
|
|
142
|
+
maxOutputTokens: z.ZodNumber;
|
|
143
|
+
/** Sampling temperature frozen from the prompt version. */
|
|
144
|
+
temperature: z.ZodNumber;
|
|
145
|
+
items: z.ZodArray<z.ZodObject<{
|
|
146
|
+
itemId: z.ZodString;
|
|
147
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
148
|
+
role: z.ZodEnum<["system", "user", "assistant"]>;
|
|
149
|
+
content: z.ZodString;
|
|
150
|
+
}, "strip", z.ZodTypeAny, {
|
|
151
|
+
role: "system" | "user" | "assistant";
|
|
152
|
+
content: string;
|
|
153
|
+
}, {
|
|
154
|
+
role: "system" | "user" | "assistant";
|
|
155
|
+
content: string;
|
|
156
|
+
}>, "many">;
|
|
157
|
+
}, "strip", z.ZodTypeAny, {
|
|
158
|
+
itemId: string;
|
|
159
|
+
messages: {
|
|
160
|
+
role: "system" | "user" | "assistant";
|
|
161
|
+
content: string;
|
|
162
|
+
}[];
|
|
163
|
+
}, {
|
|
164
|
+
itemId: string;
|
|
165
|
+
messages: {
|
|
166
|
+
role: "system" | "user" | "assistant";
|
|
167
|
+
content: string;
|
|
168
|
+
}[];
|
|
169
|
+
}>, "many">;
|
|
170
|
+
}, "strip", z.ZodTypeAny, {
|
|
171
|
+
promptId: string;
|
|
172
|
+
promptVersion: number;
|
|
173
|
+
reserveTokensPerCall: number;
|
|
174
|
+
maxOutputTokens: number;
|
|
175
|
+
temperature: number;
|
|
176
|
+
items: {
|
|
177
|
+
itemId: string;
|
|
178
|
+
messages: {
|
|
179
|
+
role: "system" | "user" | "assistant";
|
|
180
|
+
content: string;
|
|
181
|
+
}[];
|
|
182
|
+
}[];
|
|
183
|
+
}, {
|
|
184
|
+
promptId: string;
|
|
185
|
+
promptVersion: number;
|
|
186
|
+
reserveTokensPerCall: number;
|
|
187
|
+
maxOutputTokens: number;
|
|
188
|
+
temperature: number;
|
|
189
|
+
items: {
|
|
190
|
+
itemId: string;
|
|
191
|
+
messages: {
|
|
192
|
+
role: "system" | "user" | "assistant";
|
|
193
|
+
content: string;
|
|
194
|
+
}[];
|
|
195
|
+
}[];
|
|
196
|
+
}>;
|
|
197
|
+
type GenerationSignal = z.infer<typeof GenerationSignal>;
|
|
198
|
+
declare const EvalRunSpec: z.ZodObject<{
|
|
199
|
+
runId: z.ZodString;
|
|
200
|
+
tenantId: z.ZodString;
|
|
201
|
+
target: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
202
|
+
kind: z.ZodLiteral<"dataset">;
|
|
203
|
+
datasetId: z.ZodString;
|
|
204
|
+
version: z.ZodNumber;
|
|
205
|
+
}, "strip", z.ZodTypeAny, {
|
|
206
|
+
kind: "dataset";
|
|
207
|
+
datasetId: string;
|
|
208
|
+
version: number;
|
|
209
|
+
}, {
|
|
210
|
+
kind: "dataset";
|
|
211
|
+
datasetId: string;
|
|
212
|
+
version: number;
|
|
213
|
+
}>, z.ZodObject<{
|
|
214
|
+
kind: z.ZodLiteral<"experiment">;
|
|
215
|
+
experimentId: z.ZodString;
|
|
216
|
+
/** Optional metric event to correlate scored outputs with conversions. */
|
|
217
|
+
metricEventName: z.ZodOptional<z.ZodString>;
|
|
218
|
+
}, "strip", z.ZodTypeAny, {
|
|
219
|
+
kind: "experiment";
|
|
220
|
+
experimentId: string;
|
|
221
|
+
metricEventName?: string | undefined;
|
|
222
|
+
}, {
|
|
223
|
+
kind: "experiment";
|
|
224
|
+
experimentId: string;
|
|
225
|
+
metricEventName?: string | undefined;
|
|
226
|
+
}>]>;
|
|
227
|
+
/** Present on playground-replay runs; executors generate before judging. */
|
|
228
|
+
generation: z.ZodOptional<z.ZodObject<{
|
|
229
|
+
promptId: z.ZodString;
|
|
230
|
+
promptVersion: z.ZodNumber;
|
|
231
|
+
/** Worst-case tokens reserved per generation call under the shared budget. */
|
|
232
|
+
reserveTokensPerCall: z.ZodNumber;
|
|
233
|
+
/** Provider-enforced generation completion ceiling from the prompt version. */
|
|
234
|
+
maxOutputTokens: z.ZodNumber;
|
|
235
|
+
/** Sampling temperature frozen from the prompt version. */
|
|
236
|
+
temperature: z.ZodNumber;
|
|
237
|
+
items: z.ZodArray<z.ZodObject<{
|
|
238
|
+
itemId: z.ZodString;
|
|
239
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
240
|
+
role: z.ZodEnum<["system", "user", "assistant"]>;
|
|
241
|
+
content: z.ZodString;
|
|
242
|
+
}, "strip", z.ZodTypeAny, {
|
|
243
|
+
role: "system" | "user" | "assistant";
|
|
244
|
+
content: string;
|
|
245
|
+
}, {
|
|
246
|
+
role: "system" | "user" | "assistant";
|
|
247
|
+
content: string;
|
|
248
|
+
}>, "many">;
|
|
249
|
+
}, "strip", z.ZodTypeAny, {
|
|
250
|
+
itemId: string;
|
|
251
|
+
messages: {
|
|
252
|
+
role: "system" | "user" | "assistant";
|
|
253
|
+
content: string;
|
|
254
|
+
}[];
|
|
255
|
+
}, {
|
|
256
|
+
itemId: string;
|
|
257
|
+
messages: {
|
|
258
|
+
role: "system" | "user" | "assistant";
|
|
259
|
+
content: string;
|
|
260
|
+
}[];
|
|
261
|
+
}>, "many">;
|
|
262
|
+
}, "strip", z.ZodTypeAny, {
|
|
263
|
+
promptId: string;
|
|
264
|
+
promptVersion: number;
|
|
265
|
+
reserveTokensPerCall: number;
|
|
266
|
+
maxOutputTokens: number;
|
|
267
|
+
temperature: number;
|
|
268
|
+
items: {
|
|
269
|
+
itemId: string;
|
|
270
|
+
messages: {
|
|
271
|
+
role: "system" | "user" | "assistant";
|
|
272
|
+
content: string;
|
|
273
|
+
}[];
|
|
274
|
+
}[];
|
|
275
|
+
}, {
|
|
276
|
+
promptId: string;
|
|
277
|
+
promptVersion: number;
|
|
278
|
+
reserveTokensPerCall: number;
|
|
279
|
+
maxOutputTokens: number;
|
|
280
|
+
temperature: number;
|
|
281
|
+
items: {
|
|
282
|
+
itemId: string;
|
|
283
|
+
messages: {
|
|
284
|
+
role: "system" | "user" | "assistant";
|
|
285
|
+
content: string;
|
|
286
|
+
}[];
|
|
287
|
+
}[];
|
|
288
|
+
}>>;
|
|
289
|
+
evaluatorNames: z.ZodArray<z.ZodString, "many">;
|
|
290
|
+
/** Judge-token budget for the whole run; runner aborts when exceeded. */
|
|
291
|
+
maxJudgeTokens: z.ZodOptional<z.ZodNumber>;
|
|
292
|
+
/**
|
|
293
|
+
* Worst-case tokens reserved per judge call under the hard budget (see
|
|
294
|
+
* ExecuteOptions.reserveTokensPerCall). Derived at run creation from the
|
|
295
|
+
* selected judges' prompt template sizes plus a completion cap, and
|
|
296
|
+
* threaded through the dispatch signal so the durable runner enforces the
|
|
297
|
+
* same reservation discipline as the inline executor.
|
|
298
|
+
*/
|
|
299
|
+
reserveTokensPerCall: z.ZodOptional<z.ZodNumber>;
|
|
300
|
+
createdAtIso: z.ZodString;
|
|
301
|
+
}, "strip", z.ZodTypeAny, {
|
|
302
|
+
runId: string;
|
|
303
|
+
tenantId: string;
|
|
304
|
+
target: {
|
|
305
|
+
kind: "dataset";
|
|
306
|
+
datasetId: string;
|
|
307
|
+
version: number;
|
|
308
|
+
} | {
|
|
309
|
+
kind: "experiment";
|
|
310
|
+
experimentId: string;
|
|
311
|
+
metricEventName?: string | undefined;
|
|
312
|
+
};
|
|
313
|
+
evaluatorNames: string[];
|
|
314
|
+
createdAtIso: string;
|
|
315
|
+
reserveTokensPerCall?: number | undefined;
|
|
316
|
+
generation?: {
|
|
317
|
+
promptId: string;
|
|
318
|
+
promptVersion: number;
|
|
319
|
+
reserveTokensPerCall: number;
|
|
320
|
+
maxOutputTokens: number;
|
|
321
|
+
temperature: number;
|
|
322
|
+
items: {
|
|
323
|
+
itemId: string;
|
|
324
|
+
messages: {
|
|
325
|
+
role: "system" | "user" | "assistant";
|
|
326
|
+
content: string;
|
|
327
|
+
}[];
|
|
328
|
+
}[];
|
|
329
|
+
} | undefined;
|
|
330
|
+
maxJudgeTokens?: number | undefined;
|
|
331
|
+
}, {
|
|
332
|
+
runId: string;
|
|
333
|
+
tenantId: string;
|
|
334
|
+
target: {
|
|
335
|
+
kind: "dataset";
|
|
336
|
+
datasetId: string;
|
|
337
|
+
version: number;
|
|
338
|
+
} | {
|
|
339
|
+
kind: "experiment";
|
|
340
|
+
experimentId: string;
|
|
341
|
+
metricEventName?: string | undefined;
|
|
342
|
+
};
|
|
343
|
+
evaluatorNames: string[];
|
|
344
|
+
createdAtIso: string;
|
|
345
|
+
reserveTokensPerCall?: number | undefined;
|
|
346
|
+
generation?: {
|
|
347
|
+
promptId: string;
|
|
348
|
+
promptVersion: number;
|
|
349
|
+
reserveTokensPerCall: number;
|
|
350
|
+
maxOutputTokens: number;
|
|
351
|
+
temperature: number;
|
|
352
|
+
items: {
|
|
353
|
+
itemId: string;
|
|
354
|
+
messages: {
|
|
355
|
+
role: "system" | "user" | "assistant";
|
|
356
|
+
content: string;
|
|
357
|
+
}[];
|
|
358
|
+
}[];
|
|
359
|
+
} | undefined;
|
|
360
|
+
maxJudgeTokens?: number | undefined;
|
|
361
|
+
}>;
|
|
362
|
+
type EvalRunSpec = z.infer<typeof EvalRunSpec>;
|
|
363
|
+
declare const EvalRun: z.ZodObject<{
|
|
364
|
+
runId: z.ZodString;
|
|
365
|
+
tenantId: z.ZodString;
|
|
366
|
+
target: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
367
|
+
kind: z.ZodLiteral<"dataset">;
|
|
368
|
+
datasetId: z.ZodString;
|
|
369
|
+
version: z.ZodNumber;
|
|
370
|
+
}, "strip", z.ZodTypeAny, {
|
|
371
|
+
kind: "dataset";
|
|
372
|
+
datasetId: string;
|
|
373
|
+
version: number;
|
|
374
|
+
}, {
|
|
375
|
+
kind: "dataset";
|
|
376
|
+
datasetId: string;
|
|
377
|
+
version: number;
|
|
378
|
+
}>, z.ZodObject<{
|
|
379
|
+
kind: z.ZodLiteral<"experiment">;
|
|
380
|
+
experimentId: z.ZodString;
|
|
381
|
+
/** Optional metric event to correlate scored outputs with conversions. */
|
|
382
|
+
metricEventName: z.ZodOptional<z.ZodString>;
|
|
383
|
+
}, "strip", z.ZodTypeAny, {
|
|
384
|
+
kind: "experiment";
|
|
385
|
+
experimentId: string;
|
|
386
|
+
metricEventName?: string | undefined;
|
|
387
|
+
}, {
|
|
388
|
+
kind: "experiment";
|
|
389
|
+
experimentId: string;
|
|
390
|
+
metricEventName?: string | undefined;
|
|
391
|
+
}>]>;
|
|
392
|
+
/** Present on playground-replay runs; executors generate before judging. */
|
|
393
|
+
generation: z.ZodOptional<z.ZodObject<{
|
|
394
|
+
promptId: z.ZodString;
|
|
395
|
+
promptVersion: z.ZodNumber;
|
|
396
|
+
/** Worst-case tokens reserved per generation call under the shared budget. */
|
|
397
|
+
reserveTokensPerCall: z.ZodNumber;
|
|
398
|
+
/** Provider-enforced generation completion ceiling from the prompt version. */
|
|
399
|
+
maxOutputTokens: z.ZodNumber;
|
|
400
|
+
/** Sampling temperature frozen from the prompt version. */
|
|
401
|
+
temperature: z.ZodNumber;
|
|
402
|
+
items: z.ZodArray<z.ZodObject<{
|
|
403
|
+
itemId: z.ZodString;
|
|
404
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
405
|
+
role: z.ZodEnum<["system", "user", "assistant"]>;
|
|
406
|
+
content: z.ZodString;
|
|
407
|
+
}, "strip", z.ZodTypeAny, {
|
|
408
|
+
role: "system" | "user" | "assistant";
|
|
409
|
+
content: string;
|
|
410
|
+
}, {
|
|
411
|
+
role: "system" | "user" | "assistant";
|
|
412
|
+
content: string;
|
|
413
|
+
}>, "many">;
|
|
414
|
+
}, "strip", z.ZodTypeAny, {
|
|
415
|
+
itemId: string;
|
|
416
|
+
messages: {
|
|
417
|
+
role: "system" | "user" | "assistant";
|
|
418
|
+
content: string;
|
|
419
|
+
}[];
|
|
420
|
+
}, {
|
|
421
|
+
itemId: string;
|
|
422
|
+
messages: {
|
|
423
|
+
role: "system" | "user" | "assistant";
|
|
424
|
+
content: string;
|
|
425
|
+
}[];
|
|
426
|
+
}>, "many">;
|
|
427
|
+
}, "strip", z.ZodTypeAny, {
|
|
428
|
+
promptId: string;
|
|
429
|
+
promptVersion: number;
|
|
430
|
+
reserveTokensPerCall: number;
|
|
431
|
+
maxOutputTokens: number;
|
|
432
|
+
temperature: number;
|
|
433
|
+
items: {
|
|
434
|
+
itemId: string;
|
|
435
|
+
messages: {
|
|
436
|
+
role: "system" | "user" | "assistant";
|
|
437
|
+
content: string;
|
|
438
|
+
}[];
|
|
439
|
+
}[];
|
|
440
|
+
}, {
|
|
441
|
+
promptId: string;
|
|
442
|
+
promptVersion: number;
|
|
443
|
+
reserveTokensPerCall: number;
|
|
444
|
+
maxOutputTokens: number;
|
|
445
|
+
temperature: number;
|
|
446
|
+
items: {
|
|
447
|
+
itemId: string;
|
|
448
|
+
messages: {
|
|
449
|
+
role: "system" | "user" | "assistant";
|
|
450
|
+
content: string;
|
|
451
|
+
}[];
|
|
452
|
+
}[];
|
|
453
|
+
}>>;
|
|
454
|
+
evaluatorNames: z.ZodArray<z.ZodString, "many">;
|
|
455
|
+
/** Judge-token budget for the whole run; runner aborts when exceeded. */
|
|
456
|
+
maxJudgeTokens: z.ZodOptional<z.ZodNumber>;
|
|
457
|
+
/**
|
|
458
|
+
* Worst-case tokens reserved per judge call under the hard budget (see
|
|
459
|
+
* ExecuteOptions.reserveTokensPerCall). Derived at run creation from the
|
|
460
|
+
* selected judges' prompt template sizes plus a completion cap, and
|
|
461
|
+
* threaded through the dispatch signal so the durable runner enforces the
|
|
462
|
+
* same reservation discipline as the inline executor.
|
|
463
|
+
*/
|
|
464
|
+
reserveTokensPerCall: z.ZodOptional<z.ZodNumber>;
|
|
465
|
+
createdAtIso: z.ZodString;
|
|
466
|
+
} & {
|
|
467
|
+
status: z.ZodEnum<["pending", "running", "succeeded", "failed", "cancelled"]>;
|
|
468
|
+
scoredExamples: z.ZodNumber;
|
|
469
|
+
totalExamples: z.ZodNumber;
|
|
470
|
+
tokensSpent: z.ZodNumber;
|
|
471
|
+
costUsd: z.ZodNullable<z.ZodNumber>;
|
|
472
|
+
startedAtIso: z.ZodOptional<z.ZodString>;
|
|
473
|
+
finishedAtIso: z.ZodOptional<z.ZodString>;
|
|
474
|
+
error: z.ZodOptional<z.ZodString>;
|
|
475
|
+
}, "strip", z.ZodTypeAny, {
|
|
476
|
+
status: "pending" | "running" | "succeeded" | "failed" | "cancelled";
|
|
477
|
+
runId: string;
|
|
478
|
+
tenantId: string;
|
|
479
|
+
target: {
|
|
480
|
+
kind: "dataset";
|
|
481
|
+
datasetId: string;
|
|
482
|
+
version: number;
|
|
483
|
+
} | {
|
|
484
|
+
kind: "experiment";
|
|
485
|
+
experimentId: string;
|
|
486
|
+
metricEventName?: string | undefined;
|
|
487
|
+
};
|
|
488
|
+
evaluatorNames: string[];
|
|
489
|
+
createdAtIso: string;
|
|
490
|
+
scoredExamples: number;
|
|
491
|
+
totalExamples: number;
|
|
492
|
+
tokensSpent: number;
|
|
493
|
+
costUsd: number | null;
|
|
494
|
+
reserveTokensPerCall?: number | undefined;
|
|
495
|
+
generation?: {
|
|
496
|
+
promptId: string;
|
|
497
|
+
promptVersion: number;
|
|
498
|
+
reserveTokensPerCall: number;
|
|
499
|
+
maxOutputTokens: number;
|
|
500
|
+
temperature: number;
|
|
501
|
+
items: {
|
|
502
|
+
itemId: string;
|
|
503
|
+
messages: {
|
|
504
|
+
role: "system" | "user" | "assistant";
|
|
505
|
+
content: string;
|
|
506
|
+
}[];
|
|
507
|
+
}[];
|
|
508
|
+
} | undefined;
|
|
509
|
+
maxJudgeTokens?: number | undefined;
|
|
510
|
+
startedAtIso?: string | undefined;
|
|
511
|
+
finishedAtIso?: string | undefined;
|
|
512
|
+
error?: string | undefined;
|
|
513
|
+
}, {
|
|
514
|
+
status: "pending" | "running" | "succeeded" | "failed" | "cancelled";
|
|
515
|
+
runId: string;
|
|
516
|
+
tenantId: string;
|
|
517
|
+
target: {
|
|
518
|
+
kind: "dataset";
|
|
519
|
+
datasetId: string;
|
|
520
|
+
version: number;
|
|
521
|
+
} | {
|
|
522
|
+
kind: "experiment";
|
|
523
|
+
experimentId: string;
|
|
524
|
+
metricEventName?: string | undefined;
|
|
525
|
+
};
|
|
526
|
+
evaluatorNames: string[];
|
|
527
|
+
createdAtIso: string;
|
|
528
|
+
scoredExamples: number;
|
|
529
|
+
totalExamples: number;
|
|
530
|
+
tokensSpent: number;
|
|
531
|
+
costUsd: number | null;
|
|
532
|
+
reserveTokensPerCall?: number | undefined;
|
|
533
|
+
generation?: {
|
|
534
|
+
promptId: string;
|
|
535
|
+
promptVersion: number;
|
|
536
|
+
reserveTokensPerCall: number;
|
|
537
|
+
maxOutputTokens: number;
|
|
538
|
+
temperature: number;
|
|
539
|
+
items: {
|
|
540
|
+
itemId: string;
|
|
541
|
+
messages: {
|
|
542
|
+
role: "system" | "user" | "assistant";
|
|
543
|
+
content: string;
|
|
544
|
+
}[];
|
|
545
|
+
}[];
|
|
546
|
+
} | undefined;
|
|
547
|
+
maxJudgeTokens?: number | undefined;
|
|
548
|
+
startedAtIso?: string | undefined;
|
|
549
|
+
finishedAtIso?: string | undefined;
|
|
550
|
+
error?: string | undefined;
|
|
551
|
+
}>;
|
|
552
|
+
type EvalRun = z.infer<typeof EvalRun>;
|
|
553
|
+
|
|
554
|
+
interface ChatMessage {
|
|
555
|
+
role: 'system' | 'user' | 'assistant';
|
|
556
|
+
content: string;
|
|
557
|
+
}
|
|
558
|
+
interface ModelResponse {
|
|
559
|
+
text: string;
|
|
560
|
+
tokens: TokenUsage;
|
|
561
|
+
}
|
|
562
|
+
interface ModelCompletionOptions {
|
|
563
|
+
/** Judges must be deterministic unless a caller explicitly builds another evaluator. */
|
|
564
|
+
temperature: number;
|
|
565
|
+
/** Provider-enforced completion ceiling used by the run budget reservation. */
|
|
566
|
+
maxOutputTokens: number;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* The only surface through which evaluators reach a model. Production ships
|
|
570
|
+
* a Databricks Model Serving adapter at the explicit `/databricks` package
|
|
571
|
+
* subpath; the provider-neutral root never imports a provider client. Tests
|
|
572
|
+
* use `StaticModelClient`.
|
|
573
|
+
*/
|
|
574
|
+
interface ModelClient {
|
|
575
|
+
/** Identifier recorded in EvalScore.modelEndpoint for provenance. */
|
|
576
|
+
readonly endpoint: string;
|
|
577
|
+
complete(messages: readonly ChatMessage[], options: ModelCompletionOptions): Promise<ModelResponse>;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Deterministic client for unit tests and `fx dev`: responses are matched by
|
|
581
|
+
* substring of the last user message, mirroring the frozen-vector discipline
|
|
582
|
+
* in `@fabricorg/experiments-testkit`.
|
|
583
|
+
*/
|
|
584
|
+
declare class StaticModelClient implements ModelClient {
|
|
585
|
+
private readonly rules;
|
|
586
|
+
private readonly fallback;
|
|
587
|
+
readonly endpoint = "static-test-endpoint";
|
|
588
|
+
constructor(rules: Array<{
|
|
589
|
+
match: string;
|
|
590
|
+
respond: string;
|
|
591
|
+
}>, fallback?: string);
|
|
592
|
+
complete(messages: readonly ChatMessage[], options: ModelCompletionOptions): Promise<ModelResponse>;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Conservative provider-independent upper bound used before a judge call.
|
|
596
|
+
* A tokenizer cannot emit more tokens than the UTF-8 bytes representing the
|
|
597
|
+
* message content; the fixed allowance covers chat framing and role markers.
|
|
598
|
+
*/
|
|
599
|
+
declare function maxCompletionTokenUsage(messages: readonly ChatMessage[], options: ModelCompletionOptions): number;
|
|
600
|
+
|
|
601
|
+
export { type ChatMessage as C, EvaluatorKind as E, GenerationSignal as G, type ModelClient as M, StaticModelClient as S, TokenUsage as T, EvalScore as a, EvalRun as b, EvalRunSpec as c, EvalRunStatus as d, EvalRunTarget as e, GenerationSignalItem as f, type ModelCompletionOptions as g, type ModelResponse as h, maxCompletionTokenUsage as m };
|