@anvia/core 0.23.0 → 0.25.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/dist/agent/index.js +7 -7
- package/dist/{chunk-HYUYZEAJ.js → chunk-2NDQHV7V.js} +5 -5
- package/dist/{chunk-MELYDKWQ.js → chunk-4BGN6PYF.js} +4 -4
- package/dist/{chunk-JI5YZWNT.js → chunk-4HWN7734.js} +3 -3
- package/dist/{chunk-NCPN4SJR.js → chunk-BCA4VZ5W.js} +2 -2
- package/dist/{chunk-YLMDBQO4.js → chunk-KYEBWN3E.js} +4 -4
- package/dist/{chunk-BALBBVI3.js → chunk-VXONXP2G.js} +5 -5
- package/dist/{chunk-DALYP4PX.js → chunk-YEBIVZM2.js} +4 -4
- package/dist/evals/index.d.ts +397 -42
- package/dist/evals/index.js +971 -201
- package/dist/evals/index.js.map +1 -1
- package/dist/extractor/index.js +8 -8
- package/dist/index.js +8 -8
- package/dist/internal/agent.js +6 -6
- package/dist/request/index.js +5 -5
- package/dist/skills/index.js +5 -5
- package/dist/tool/index.js +4 -4
- package/dist/vector-store/index.js +2 -2
- package/package.json +1 -1
- /package/dist/{chunk-HYUYZEAJ.js.map → chunk-2NDQHV7V.js.map} +0 -0
- /package/dist/{chunk-MELYDKWQ.js.map → chunk-4BGN6PYF.js.map} +0 -0
- /package/dist/{chunk-JI5YZWNT.js.map → chunk-4HWN7734.js.map} +0 -0
- /package/dist/{chunk-NCPN4SJR.js.map → chunk-BCA4VZ5W.js.map} +0 -0
- /package/dist/{chunk-YLMDBQO4.js.map → chunk-KYEBWN3E.js.map} +0 -0
- /package/dist/{chunk-BALBBVI3.js.map → chunk-VXONXP2G.js.map} +0 -0
- /package/dist/{chunk-DALYP4PX.js.map → chunk-YEBIVZM2.js.map} +0 -0
package/dist/evals/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
|
|
2
|
-
import { l as JsonValue, C as CompletionModel, M as Message } from '../types-G12i56s2.js';
|
|
2
|
+
import { U as Usage, l as JsonValue, C as CompletionModel, M as Message } from '../types-G12i56s2.js';
|
|
3
3
|
import { A as Agent } from '../agent-x3YTyv5i.js';
|
|
4
4
|
import { P as PromptResponse } from '../index-BxSbmOMr.js';
|
|
5
5
|
import { E as EmbeddingModel } from '../types-BCTRUGex.js';
|
|
@@ -16,35 +16,54 @@ type EvalOutcome<Score = unknown> = {
|
|
|
16
16
|
score?: Score | undefined;
|
|
17
17
|
comment?: string | undefined;
|
|
18
18
|
metadata?: EvalMetadata | undefined;
|
|
19
|
+
usage?: Usage | undefined;
|
|
19
20
|
} | {
|
|
20
21
|
outcome: "fail";
|
|
21
22
|
score?: Score | undefined;
|
|
22
23
|
comment?: string | undefined;
|
|
23
24
|
metadata?: EvalMetadata | undefined;
|
|
25
|
+
usage?: Usage | undefined;
|
|
24
26
|
} | {
|
|
25
27
|
outcome: "invalid";
|
|
26
28
|
reason: string;
|
|
27
29
|
score?: Score | undefined;
|
|
28
30
|
comment?: string | undefined;
|
|
29
31
|
metadata?: EvalMetadata | undefined;
|
|
32
|
+
usage?: Usage | undefined;
|
|
30
33
|
};
|
|
31
34
|
declare const EvalOutcome: {
|
|
32
35
|
pass<Score>(score?: Score, options?: {
|
|
33
36
|
comment?: string | undefined;
|
|
34
37
|
metadata?: EvalMetadata | undefined;
|
|
38
|
+
usage?: Usage | undefined;
|
|
35
39
|
}): EvalOutcome<Score>;
|
|
36
40
|
fail<Score>(score?: Score, options?: {
|
|
37
41
|
comment?: string | undefined;
|
|
38
42
|
metadata?: EvalMetadata | undefined;
|
|
43
|
+
usage?: Usage | undefined;
|
|
39
44
|
}): EvalOutcome<Score>;
|
|
40
45
|
invalid<Score = never>(reason: string, options?: {
|
|
41
46
|
score?: Score | undefined;
|
|
42
47
|
comment?: string | undefined;
|
|
43
48
|
metadata?: EvalMetadata | undefined;
|
|
49
|
+
usage?: Usage | undefined;
|
|
44
50
|
}): EvalOutcome<Score>;
|
|
45
51
|
};
|
|
46
52
|
|
|
47
53
|
type EvalMetadata = Record<string, JsonValue | undefined>;
|
|
54
|
+
type EvalRunOptions = {
|
|
55
|
+
id?: string | undefined;
|
|
56
|
+
datasetName?: string | undefined;
|
|
57
|
+
datasetVersion?: string | undefined;
|
|
58
|
+
metadata?: EvalMetadata | undefined;
|
|
59
|
+
};
|
|
60
|
+
type EvalRunContext = {
|
|
61
|
+
id: string;
|
|
62
|
+
startedAt: string;
|
|
63
|
+
datasetName?: string | undefined;
|
|
64
|
+
datasetVersion?: string | undefined;
|
|
65
|
+
metadata?: EvalMetadata | undefined;
|
|
66
|
+
};
|
|
48
67
|
type EvalCase<Input, Expected = unknown> = {
|
|
49
68
|
id: string;
|
|
50
69
|
input: Input;
|
|
@@ -65,6 +84,36 @@ type EvalTraceRef = {
|
|
|
65
84
|
};
|
|
66
85
|
type EvalTarget<Input, Output, Expected = unknown> = (input: Input, testCase: EvalCase<Input, Expected>) => Output | Promise<Output>;
|
|
67
86
|
type EvalOutcomeStatus = "pass" | "fail" | "invalid";
|
|
87
|
+
type EvalScoreDirection = "higher_is_better" | "lower_is_better";
|
|
88
|
+
type EvalDataType = "NUMERIC" | "CATEGORICAL" | "BOOLEAN";
|
|
89
|
+
type EvalTraceCarrier = {
|
|
90
|
+
trace: EvalTraceRef;
|
|
91
|
+
};
|
|
92
|
+
type DefaultEvalActual<Output> = Output extends {
|
|
93
|
+
output: infer Text extends string;
|
|
94
|
+
} ? Text : Output;
|
|
95
|
+
type EvalCaseRequirements = {
|
|
96
|
+
expected?: unknown;
|
|
97
|
+
context?: string[];
|
|
98
|
+
retrievalContext?: string[];
|
|
99
|
+
};
|
|
100
|
+
type EvalTotals = {
|
|
101
|
+
total: number;
|
|
102
|
+
passed: number;
|
|
103
|
+
failed: number;
|
|
104
|
+
invalid: number;
|
|
105
|
+
};
|
|
106
|
+
type EvalUsageSummary = {
|
|
107
|
+
target: Usage;
|
|
108
|
+
evaluation: Usage;
|
|
109
|
+
total: Usage;
|
|
110
|
+
};
|
|
111
|
+
type EvalCostSummary = {
|
|
112
|
+
currency: string;
|
|
113
|
+
target: number;
|
|
114
|
+
evaluation: number;
|
|
115
|
+
total: number;
|
|
116
|
+
};
|
|
68
117
|
type EvalScoreProjection = {
|
|
69
118
|
outcome: EvalOutcomeStatus;
|
|
70
119
|
value: number | string;
|
|
@@ -78,42 +127,87 @@ type EvalMetricArgs<Input, Output, Expected = unknown> = {
|
|
|
78
127
|
case: EvalCase<Input, Expected>;
|
|
79
128
|
output: Output;
|
|
80
129
|
};
|
|
81
|
-
type EvalMetric<Input, Output, Score = unknown, Expected = unknown
|
|
82
|
-
name:
|
|
83
|
-
|
|
130
|
+
type EvalMetric<Input, Output, Score = unknown, Expected = unknown, Name extends string = string, Requirements extends EvalCaseRequirements = Record<never, never>> = {
|
|
131
|
+
name: Name;
|
|
132
|
+
required?: boolean | undefined;
|
|
133
|
+
direction?: EvalScoreDirection | undefined;
|
|
134
|
+
threshold?: number | undefined;
|
|
135
|
+
dataType?: EvalDataType | undefined;
|
|
136
|
+
projectScore?(score: Score): number | string | boolean;
|
|
84
137
|
scoreConfigId?: string | undefined;
|
|
85
138
|
configId?: string | undefined;
|
|
86
139
|
metadata?: EvalMetadata | undefined;
|
|
140
|
+
readonly caseRequirements?: Requirements | undefined;
|
|
87
141
|
evaluate(args: EvalMetricArgs<Input, Output, Expected>): EvalOutcome<Score> | Promise<EvalOutcome<Score>>;
|
|
88
142
|
};
|
|
89
|
-
type EvalMetricResult<Score = unknown> = {
|
|
90
|
-
metricName:
|
|
143
|
+
type EvalMetricResult<Score = unknown, Name extends string = string> = {
|
|
144
|
+
metricName: Name;
|
|
145
|
+
required: boolean;
|
|
146
|
+
direction?: EvalScoreDirection | undefined;
|
|
147
|
+
threshold?: number | undefined;
|
|
91
148
|
outcome: EvalOutcome<Score>;
|
|
92
149
|
reporterErrors: unknown[];
|
|
93
150
|
};
|
|
94
|
-
type
|
|
151
|
+
type AnyEvalMetric = EvalMetric<never, never, unknown, never, string>;
|
|
152
|
+
type EvalMetricScore<Metric> = Metric extends {
|
|
153
|
+
evaluate(...args: never[]): infer Result;
|
|
154
|
+
} ? Awaited<Result> extends EvalOutcome<infer Score> ? Score : never : never;
|
|
155
|
+
type EvalMetricResultFor<Metric> = Metric extends {
|
|
156
|
+
name: infer Name extends string;
|
|
157
|
+
} ? EvalMetricResult<EvalMetricScore<Metric>, Name> : never;
|
|
158
|
+
type EvalScoreMap<Metrics extends readonly AnyEvalMetric[]> = {
|
|
159
|
+
[Metric in Metrics[number] as Metric["name"]]: EvalOutcome<EvalMetricScore<Metric>>;
|
|
160
|
+
};
|
|
161
|
+
type EvalCaseResult<Input, Output, Expected = unknown, Metrics extends readonly AnyEvalMetric[] = readonly AnyEvalMetric[]> = {
|
|
95
162
|
case: EvalCase<Input, Expected>;
|
|
163
|
+
outcome: EvalOutcomeStatus;
|
|
96
164
|
output?: Output | undefined;
|
|
97
165
|
targetError?: unknown;
|
|
98
|
-
metrics:
|
|
166
|
+
metrics: Array<EvalMetricResultFor<Metrics[number]>>;
|
|
167
|
+
scores: EvalScoreMap<Metrics>;
|
|
99
168
|
};
|
|
100
|
-
type EvalSuiteResult<Input, Output, Expected = unknown> = {
|
|
169
|
+
type EvalSuiteResult<Input, Output, Expected = unknown, Metrics extends readonly AnyEvalMetric[] = readonly AnyEvalMetric[]> = {
|
|
101
170
|
name: string;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
171
|
+
run: EvalRunContext & {
|
|
172
|
+
completedAt: string;
|
|
173
|
+
};
|
|
174
|
+
results: Array<EvalCaseResult<Input, Output, Expected, Metrics>>;
|
|
175
|
+
metrics: EvalTotals;
|
|
176
|
+
cases: EvalTotals;
|
|
177
|
+
usage: EvalUsageSummary;
|
|
178
|
+
cost?: EvalCostSummary | undefined;
|
|
106
179
|
durationMs: number;
|
|
180
|
+
reporterErrors: unknown[];
|
|
181
|
+
};
|
|
182
|
+
type EvalMetricDescriptor<Score = unknown, Name extends string = string> = Omit<EvalMetric<never, never, Score, never, Name>, "evaluate"> & {
|
|
183
|
+
evaluate?: EvalMetric<never, never, Score, never, Name>["evaluate"];
|
|
107
184
|
};
|
|
108
185
|
type EvalReportArgs<Input, Output, Score = unknown, Expected = unknown> = {
|
|
186
|
+
run?: EvalRunContext | undefined;
|
|
109
187
|
suiteName: string;
|
|
110
188
|
case: EvalCase<Input, Expected>;
|
|
111
189
|
output?: Output | undefined;
|
|
112
190
|
targetError?: unknown;
|
|
113
191
|
trace?: EvalTraceRef | undefined;
|
|
114
|
-
metric:
|
|
192
|
+
metric: EvalMetricDescriptor<Score>;
|
|
115
193
|
outcome: EvalOutcome<Score>;
|
|
116
194
|
};
|
|
195
|
+
type EvalRunStartArgs = {
|
|
196
|
+
run: EvalRunContext;
|
|
197
|
+
suiteName: string;
|
|
198
|
+
caseCount: number;
|
|
199
|
+
metricNames: string[];
|
|
200
|
+
};
|
|
201
|
+
type EvalRunEndArgs = EvalRunStartArgs & {
|
|
202
|
+
status: "completed" | "failed";
|
|
203
|
+
completedAt: string;
|
|
204
|
+
durationMs: number;
|
|
205
|
+
metrics?: EvalTotals | undefined;
|
|
206
|
+
cases?: EvalTotals | undefined;
|
|
207
|
+
usage?: EvalUsageSummary | undefined;
|
|
208
|
+
cost?: EvalCostSummary | undefined;
|
|
209
|
+
error?: unknown;
|
|
210
|
+
};
|
|
117
211
|
type EvalTraceSelectorArgs<Input, Output, Expected = unknown> = {
|
|
118
212
|
suiteName: string;
|
|
119
213
|
case: EvalCase<Input, Expected>;
|
|
@@ -121,24 +215,49 @@ type EvalTraceSelectorArgs<Input, Output, Expected = unknown> = {
|
|
|
121
215
|
targetError?: unknown;
|
|
122
216
|
};
|
|
123
217
|
type EvalTraceSelector<Input, Output, Expected = unknown> = (args: EvalTraceSelectorArgs<Input, Output, Expected>) => EvalTraceRef | undefined | Promise<EvalTraceRef | undefined>;
|
|
124
|
-
type EvalReporter<Input = unknown, Output = unknown, Expected = unknown> = {
|
|
218
|
+
type EvalReporter<in Input = unknown, in Output = unknown, in Expected = unknown> = {
|
|
219
|
+
onRunStart?(args: EvalRunStartArgs): void | Promise<void>;
|
|
125
220
|
report(args: EvalReportArgs<Input, Output, unknown, Expected>): void | Promise<void>;
|
|
221
|
+
onRunEnd?(args: EvalRunEndArgs): void | Promise<void>;
|
|
222
|
+
};
|
|
223
|
+
type EvalTargetUsageSelector<Input, Output, Expected = unknown> = (args: EvalMetricArgs<Input, Output, Expected>) => Usage | undefined | Promise<Usage | undefined>;
|
|
224
|
+
type EvalCostCalculatorArgs<Input, Output, Expected = unknown> = {
|
|
225
|
+
kind: "target";
|
|
226
|
+
suiteName: string;
|
|
227
|
+
case: EvalCase<Input, Expected>;
|
|
228
|
+
output: Output;
|
|
229
|
+
usage: Usage;
|
|
230
|
+
} | {
|
|
231
|
+
kind: "evaluation";
|
|
232
|
+
suiteName: string;
|
|
233
|
+
case: EvalCase<Input, Expected>;
|
|
234
|
+
output: Output;
|
|
235
|
+
metric: EvalMetric<Input, Output, unknown, Expected>;
|
|
236
|
+
usage: Usage;
|
|
237
|
+
};
|
|
238
|
+
type EvalCostOptions<Input, Output, Expected = unknown> = {
|
|
239
|
+
currency: string;
|
|
240
|
+
calculate(args: EvalCostCalculatorArgs<Input, Output, Expected>): number | Promise<number>;
|
|
126
241
|
};
|
|
127
|
-
type RunEvalSuiteOptions<Input, Output, Expected = unknown> = {
|
|
242
|
+
type RunEvalSuiteOptions<Input, Output, Expected = unknown, Metrics extends readonly EvalMetric<NoInfer<Input>, NoInfer<Output>, unknown, NoInfer<Expected>, string>[] = readonly EvalMetric<NoInfer<Input>, NoInfer<Output>, unknown, NoInfer<Expected>, string>[]> = {
|
|
128
243
|
name: string;
|
|
129
|
-
|
|
244
|
+
run?: EvalRunOptions | undefined;
|
|
245
|
+
cases: readonly EvalCase<Input, Expected>[];
|
|
130
246
|
target: EvalTarget<Input, Output, Expected>;
|
|
131
|
-
metrics:
|
|
247
|
+
metrics: Metrics;
|
|
132
248
|
concurrency?: number | undefined;
|
|
133
249
|
trace?: EvalTraceSelector<NoInfer<Input>, NoInfer<Output>, NoInfer<Expected>> | undefined;
|
|
134
|
-
reporters?:
|
|
250
|
+
reporters?: readonly EvalReporter<NoInfer<Input>, NoInfer<Output>, NoInfer<Expected>>[] | undefined;
|
|
135
251
|
failOnReporterError?: boolean | undefined;
|
|
252
|
+
targetUsage?: EvalTargetUsageSelector<NoInfer<Input>, NoInfer<Output>, NoInfer<Expected>> | undefined;
|
|
253
|
+
cost?: EvalCostOptions<NoInfer<Input>, NoInfer<Output>, NoInfer<Expected>> | undefined;
|
|
136
254
|
};
|
|
137
255
|
type ValueSelector<Input, Output, Expected, Value> = (args: EvalMetricArgs<Input, Output, Expected>) => Value | Promise<Value>;
|
|
138
256
|
type SelectorOrValue<Input, Output, Expected, Value> = Value | ValueSelector<Input, Output, Expected, Value>;
|
|
139
257
|
|
|
140
258
|
type LlmEvalOptions<Input, Output, Expected = unknown> = {
|
|
141
259
|
name?: string | undefined;
|
|
260
|
+
required?: boolean | undefined;
|
|
142
261
|
model: CompletionModel;
|
|
143
262
|
threshold?: number | undefined;
|
|
144
263
|
strictMode?: boolean | undefined;
|
|
@@ -148,13 +267,18 @@ type LlmEvalOptions<Input, Output, Expected = unknown> = {
|
|
|
148
267
|
actual?: ValueSelector<Input, Output, Expected, string> | undefined;
|
|
149
268
|
};
|
|
150
269
|
type AnswerRelevancyOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected>;
|
|
151
|
-
declare function answerRelevancy<Input, Output, Expected = unknown>(options: AnswerRelevancyOptions<Input, Output, Expected>
|
|
270
|
+
declare function answerRelevancy<Input, Output, Expected = unknown, const Name extends string = string>(options: AnswerRelevancyOptions<Input, Output, Expected> & {
|
|
271
|
+
name?: Name | undefined;
|
|
272
|
+
}): EvalMetric<Input, Output, number, Expected, Name>;
|
|
152
273
|
type PromptAlignmentOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
|
|
153
274
|
promptInstructions: string[];
|
|
154
275
|
};
|
|
155
|
-
declare function promptAlignment<Input, Output, Expected = unknown>(options: PromptAlignmentOptions<Input, Output, Expected>
|
|
276
|
+
declare function promptAlignment<Input, Output, Expected = unknown, const Name extends string = string>(options: PromptAlignmentOptions<Input, Output, Expected> & {
|
|
277
|
+
name?: Name | undefined;
|
|
278
|
+
}): EvalMetric<Input, Output, number, Expected, Name>;
|
|
156
279
|
type JsonCorrectnessOptions<Input, Output, SchemaOutput, Expected = unknown> = {
|
|
157
280
|
name?: string | undefined;
|
|
281
|
+
required?: boolean | undefined;
|
|
158
282
|
schema: ZodSchema<SchemaOutput>;
|
|
159
283
|
model?: CompletionModel | undefined;
|
|
160
284
|
threshold?: number | undefined;
|
|
@@ -163,23 +287,59 @@ type JsonCorrectnessOptions<Input, Output, SchemaOutput, Expected = unknown> = {
|
|
|
163
287
|
retries?: number | undefined;
|
|
164
288
|
actual?: ValueSelector<Input, Output, Expected, string> | undefined;
|
|
165
289
|
};
|
|
166
|
-
declare function jsonCorrectness<Input, Output, SchemaOutput, Expected = unknown>(options: JsonCorrectnessOptions<Input, Output, SchemaOutput, Expected>
|
|
290
|
+
declare function jsonCorrectness<Input, Output, SchemaOutput, Expected = unknown, const Name extends string = string>(options: JsonCorrectnessOptions<Input, Output, SchemaOutput, Expected> & {
|
|
291
|
+
name?: Name | undefined;
|
|
292
|
+
}): EvalMetric<Input, Output, number, Expected, Name>;
|
|
167
293
|
type HallucinationOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
|
|
168
294
|
context?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
|
|
169
295
|
};
|
|
170
|
-
declare function hallucination<Input, Output, Expected = unknown>(options: HallucinationOptions<Input, Output, Expected>
|
|
296
|
+
declare function hallucination<Input, Output, Expected = unknown, const Name extends string = string>(options: HallucinationOptions<Input, Output, Expected> & {
|
|
297
|
+
context: Exclude<HallucinationOptions<Input, Output, Expected>["context"], undefined>;
|
|
298
|
+
name?: Name | undefined;
|
|
299
|
+
}): EvalMetric<Input, Output, number, Expected, Name>;
|
|
300
|
+
declare function hallucination<Input, Output, Expected = unknown, const Name extends string = string>(options: Omit<HallucinationOptions<Input, Output, Expected>, "context"> & {
|
|
301
|
+
context?: undefined;
|
|
302
|
+
name?: Name | undefined;
|
|
303
|
+
}): EvalMetric<Input, Output, number, Expected, Name, {
|
|
304
|
+
context: string[];
|
|
305
|
+
}>;
|
|
171
306
|
type FaithfulnessOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
|
|
172
307
|
retrievalContext?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
|
|
173
308
|
truthsExtractionLimit?: number | undefined;
|
|
174
309
|
penalizeAmbiguousClaims?: boolean | undefined;
|
|
175
310
|
};
|
|
176
|
-
declare function faithfulness<Input, Output, Expected = unknown>(options: FaithfulnessOptions<Input, Output, Expected>
|
|
311
|
+
declare function faithfulness<Input, Output, Expected = unknown, const Name extends string = string>(options: FaithfulnessOptions<Input, Output, Expected> & {
|
|
312
|
+
name?: Name | undefined;
|
|
313
|
+
retrievalContext: Exclude<FaithfulnessOptions<Input, Output, Expected>["retrievalContext"], undefined>;
|
|
314
|
+
}): EvalMetric<Input, Output, number, Expected, Name>;
|
|
315
|
+
declare function faithfulness<Input, Output, Expected = unknown, const Name extends string = string>(options: Omit<FaithfulnessOptions<Input, Output, Expected>, "retrievalContext"> & {
|
|
316
|
+
name?: Name | undefined;
|
|
317
|
+
retrievalContext?: undefined;
|
|
318
|
+
}): EvalMetric<Input, Output, number, Expected, Name, {
|
|
319
|
+
retrievalContext: string[];
|
|
320
|
+
}>;
|
|
321
|
+
type AbstentionCategory = "correct_abstention" | "unnecessary_abstention" | "unsupported_confident_answer" | "correct_grounded_answer";
|
|
322
|
+
type AbstentionOptions<Input, Output, Expected = unknown> = {
|
|
323
|
+
name?: string | undefined;
|
|
324
|
+
required?: boolean | undefined;
|
|
325
|
+
model: CompletionModel;
|
|
326
|
+
shouldAbstain: SelectorOrValue<Input, Output, Expected, boolean>;
|
|
327
|
+
context?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
|
|
328
|
+
actual?: ValueSelector<Input, Output, Expected, string> | undefined;
|
|
329
|
+
includeReason?: boolean | undefined;
|
|
330
|
+
retries?: number | undefined;
|
|
331
|
+
};
|
|
332
|
+
declare function abstention<Input, Output, Expected = unknown, const Name extends string = string>(options: AbstentionOptions<Input, Output, Expected> & {
|
|
333
|
+
name?: Name | undefined;
|
|
334
|
+
}): EvalMetric<Input, Output, AbstentionCategory, Expected, Name>;
|
|
177
335
|
type SummarizationOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
|
|
178
336
|
assessmentQuestions?: string[] | undefined;
|
|
179
337
|
questionCount?: number | undefined;
|
|
180
338
|
truthsExtractionLimit?: number | undefined;
|
|
181
339
|
};
|
|
182
|
-
declare function summarization<Input, Output, Expected = unknown>(options: SummarizationOptions<Input, Output, Expected>
|
|
340
|
+
declare function summarization<Input, Output, Expected = unknown, const Name extends string = string>(options: SummarizationOptions<Input, Output, Expected> & {
|
|
341
|
+
name?: Name | undefined;
|
|
342
|
+
}): EvalMetric<Input, Output, number, Expected, Name>;
|
|
183
343
|
type GEvalParameter = "input" | "actualOutput" | "expectedOutput" | "context" | "retrievalContext" | "metadata";
|
|
184
344
|
type GEvalRubric = {
|
|
185
345
|
scoreRange: readonly [number, number];
|
|
@@ -195,9 +355,12 @@ type GEvalOptions<Input, Output, Expected = unknown> = Omit<LlmEvalOptions<Input
|
|
|
195
355
|
context?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
|
|
196
356
|
retrievalContext?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
|
|
197
357
|
};
|
|
198
|
-
declare function gEval<Input, Output, Expected = unknown>(options: GEvalOptions<Input, Output, Expected>
|
|
358
|
+
declare function gEval<Input, Output, Expected = unknown, const Name extends string = string>(options: GEvalOptions<Input, Output, Expected> & {
|
|
359
|
+
name: Name;
|
|
360
|
+
}): EvalMetric<Input, Output, number, Expected, Name>;
|
|
199
361
|
type ConversationEvalOptions<Input, Output, Expected = unknown> = {
|
|
200
362
|
name?: string | undefined;
|
|
363
|
+
required?: boolean | undefined;
|
|
201
364
|
model: CompletionModel;
|
|
202
365
|
threshold?: number | undefined;
|
|
203
366
|
strictMode?: boolean | undefined;
|
|
@@ -209,42 +372,160 @@ type ConversationEvalOptions<Input, Output, Expected = unknown> = {
|
|
|
209
372
|
type TurnRelevancyOptions<Input, Output, Expected = unknown> = ConversationEvalOptions<Input, Output, Expected> & {
|
|
210
373
|
windowSize?: number | undefined;
|
|
211
374
|
};
|
|
212
|
-
declare function turnRelevancy<Input, Output, Expected = unknown>(options: TurnRelevancyOptions<Input, Output, Expected>
|
|
375
|
+
declare function turnRelevancy<Input, Output, Expected = unknown, const Name extends string = string>(options: TurnRelevancyOptions<Input, Output, Expected> & {
|
|
376
|
+
name?: Name | undefined;
|
|
377
|
+
}): EvalMetric<Input, Output, number, Expected, Name>;
|
|
213
378
|
type KnowledgeRetentionOptions<Input, Output, Expected = unknown> = ConversationEvalOptions<Input, Output, Expected>;
|
|
214
|
-
declare function knowledgeRetention<Input, Output, Expected = unknown>(options: KnowledgeRetentionOptions<Input, Output, Expected>
|
|
379
|
+
declare function knowledgeRetention<Input, Output, Expected = unknown, const Name extends string = string>(options: KnowledgeRetentionOptions<Input, Output, Expected> & {
|
|
380
|
+
name?: Name | undefined;
|
|
381
|
+
}): EvalMetric<Input, Output, number, Expected, Name>;
|
|
215
382
|
type ConversationSource = EvalTurn[] | Message[];
|
|
216
383
|
|
|
217
|
-
type AgentEvalTargetOptions<Input, Output = PromptResponse> = {
|
|
218
|
-
prompt?: ((input: Input, testCase: EvalCase<Input>) => string | Message) | undefined;
|
|
219
|
-
output?: ((response: PromptResponse, testCase: EvalCase<Input>) => Output) | undefined;
|
|
384
|
+
type AgentEvalTargetOptions<Input, Output = PromptResponse, Expected = unknown> = {
|
|
385
|
+
prompt?: ((input: Input, testCase: EvalCase<Input, Expected>) => string | Message) | undefined;
|
|
386
|
+
output?: ((response: PromptResponse, testCase: EvalCase<Input, Expected>) => Output) | undefined;
|
|
220
387
|
};
|
|
221
|
-
declare function agentEvalTarget<Input>(agent: Agent, options?: AgentEvalTargetOptions<Input, PromptResponse>): EvalTarget<Input, PromptResponse>;
|
|
222
|
-
declare function agentEvalTarget<Input, Output>(agent: Agent, options: AgentEvalTargetOptions<Input, Output>): EvalTarget<Input, Output>;
|
|
388
|
+
declare function agentEvalTarget<Input, Expected = unknown>(agent: Agent, options?: AgentEvalTargetOptions<Input, PromptResponse, Expected>): EvalTarget<Input, PromptResponse, Expected>;
|
|
389
|
+
declare function agentEvalTarget<Input, Output, Expected = unknown>(agent: Agent, options: AgentEvalTargetOptions<Input, Output, Expected>): EvalTarget<Input, Output, Expected>;
|
|
390
|
+
|
|
391
|
+
type EvalOutputFormat = "pretty" | "json" | "quiet";
|
|
392
|
+
type EvalExpectedTotals = Partial<EvalTotals> & {
|
|
393
|
+
metrics?: Partial<EvalTotals> | undefined;
|
|
394
|
+
cases?: Partial<EvalTotals> | undefined;
|
|
395
|
+
};
|
|
396
|
+
type EvalExpectedOutcomes = Record<string, Record<string, EvalOutcomeStatus>>;
|
|
397
|
+
type EvalExpectations = {
|
|
398
|
+
totals?: EvalExpectedTotals | undefined;
|
|
399
|
+
outcomes?: EvalExpectedOutcomes | undefined;
|
|
400
|
+
};
|
|
401
|
+
type EvalOutputWriters = {
|
|
402
|
+
stdout?(text: string): void;
|
|
403
|
+
stderr?(text: string): void;
|
|
404
|
+
};
|
|
405
|
+
type PrintEvalResultOptions = {
|
|
406
|
+
format?: EvalOutputFormat | undefined;
|
|
407
|
+
output?: EvalOutputWriters | undefined;
|
|
408
|
+
};
|
|
409
|
+
type RunEvalCliOptions<Input, Output, Expected = unknown, Metrics extends readonly EvalMetric<NoInfer<Input>, NoInfer<Output>, unknown, NoInfer<Expected>, string>[] = readonly EvalMetric<NoInfer<Input>, NoInfer<Output>, unknown, NoInfer<Expected>, string>[]> = RunEvalSuiteOptions<Input, Output, Expected, Metrics> & {
|
|
410
|
+
format?: EvalOutputFormat | undefined;
|
|
411
|
+
exitCode?: boolean | undefined;
|
|
412
|
+
expectations?: EvalExpectations | undefined;
|
|
413
|
+
output?: EvalOutputWriters | undefined;
|
|
414
|
+
};
|
|
415
|
+
declare class EvalAssertionError extends Error {
|
|
416
|
+
readonly mismatches: string[];
|
|
417
|
+
constructor(message: string, mismatches: string[]);
|
|
418
|
+
}
|
|
419
|
+
declare function printEvalResult(result: EvalSuiteResult<unknown, unknown, unknown>, options?: PrintEvalResultOptions): void;
|
|
420
|
+
declare function evalExitCode(result: EvalSuiteResult<unknown, unknown, unknown>, expectations?: EvalExpectations): 0 | 1 | 2;
|
|
421
|
+
declare function assertEvalTotals(result: EvalSuiteResult<unknown, unknown, unknown>, expected: EvalExpectedTotals): void;
|
|
422
|
+
declare function assertEvalOutcomes(result: EvalSuiteResult<unknown, unknown, unknown>, expected: EvalExpectedOutcomes): void;
|
|
423
|
+
declare function runEvalCli<Input, Output, Expected = unknown, const Metrics extends readonly EvalMetric<NoInfer<Input>, NoInfer<Output>, unknown, NoInfer<Expected>, string>[] = readonly EvalMetric<NoInfer<Input>, NoInfer<Output>, unknown, NoInfer<Expected>, string>[]>(options: RunEvalCliOptions<Input, Output, Expected, Metrics>): Promise<EvalSuiteResult<Input, Output, Expected, Metrics>>;
|
|
223
424
|
|
|
224
|
-
declare function defineMetric<Input, Output, Score, Expected>(metric: EvalMetric<Input, Output, Score, Expected>): EvalMetric<Input, Output, Score, Expected>;
|
|
425
|
+
declare function defineMetric<Input, Output, Score, Expected, const Name extends string = string>(metric: EvalMetric<Input, Output, Score, Expected, Name>): EvalMetric<Input, Output, Score, Expected, Name>;
|
|
225
426
|
|
|
226
427
|
type ExactMatchOptions<Input, Output, Expected = unknown> = {
|
|
227
428
|
name?: string | undefined;
|
|
429
|
+
required?: boolean | undefined;
|
|
228
430
|
actual?: ValueSelector<Input, Output, Expected, unknown> | undefined;
|
|
229
431
|
expected?: SelectorOrValue<Input, Output, Expected, unknown> | undefined;
|
|
230
432
|
};
|
|
231
|
-
declare function exactMatch<Input, Output, Expected = unknown>(options
|
|
433
|
+
declare function exactMatch<Input, Output, Expected = unknown, const Name extends string = string>(options: ExactMatchOptions<Input, Output, Expected> & {
|
|
434
|
+
expected: Exclude<ExactMatchOptions<Input, Output, Expected>["expected"], undefined>;
|
|
435
|
+
name?: Name | undefined;
|
|
436
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name>;
|
|
437
|
+
declare function exactMatch<Input, Output, Expected = unknown, const Name extends string = string>(options?: Omit<ExactMatchOptions<Input, Output, Expected>, "expected"> & {
|
|
438
|
+
expected?: undefined;
|
|
439
|
+
name?: Name | undefined;
|
|
440
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name, {
|
|
441
|
+
expected: unknown;
|
|
442
|
+
}>;
|
|
232
443
|
type ContainsOptions<Input, Output, Expected = unknown> = {
|
|
233
444
|
name?: string | undefined;
|
|
445
|
+
required?: boolean | undefined;
|
|
234
446
|
actual?: ValueSelector<Input, Output, Expected, string> | undefined;
|
|
235
447
|
expected?: SelectorOrValue<Input, Output, Expected, string | RegExp> | undefined;
|
|
236
448
|
};
|
|
237
|
-
declare function contains<Input, Output, Expected = unknown>(options
|
|
449
|
+
declare function contains<Input, Output, Expected = unknown, const Name extends string = string>(options: ContainsOptions<Input, Output, Expected> & {
|
|
450
|
+
expected: Exclude<ContainsOptions<Input, Output, Expected>["expected"], undefined>;
|
|
451
|
+
name?: Name | undefined;
|
|
452
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name>;
|
|
453
|
+
declare function contains<Input, Output, Expected = unknown, const Name extends string = string>(options?: Omit<ContainsOptions<Input, Output, Expected>, "expected"> & {
|
|
454
|
+
expected?: undefined;
|
|
455
|
+
name?: Name | undefined;
|
|
456
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name, {
|
|
457
|
+
expected: string | RegExp;
|
|
458
|
+
}>;
|
|
459
|
+
type NotContainsOptions<Input, Output, Expected = unknown> = ContainsOptions<Input, Output, Expected>;
|
|
460
|
+
declare function notContains<Input, Output, Expected = unknown, const Name extends string = string>(options?: NotContainsOptions<Input, Output, Expected> & {
|
|
461
|
+
name?: Name | undefined;
|
|
462
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name>;
|
|
463
|
+
type ContainsListOptions<Input, Output, Expected = unknown> = {
|
|
464
|
+
name?: string | undefined;
|
|
465
|
+
required?: boolean | undefined;
|
|
466
|
+
actual?: ValueSelector<Input, Output, Expected, string> | undefined;
|
|
467
|
+
expected?: SelectorOrValue<Input, Output, Expected, ReadonlyArray<string | RegExp>> | undefined;
|
|
468
|
+
};
|
|
469
|
+
type ContainsAllOptions<Input, Output, Expected = unknown> = ContainsListOptions<Input, Output, Expected>;
|
|
470
|
+
declare function containsAll<Input, Output, Expected = unknown, const Name extends string = string>(options: ContainsAllOptions<Input, Output, Expected> & {
|
|
471
|
+
name?: Name | undefined;
|
|
472
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name>;
|
|
473
|
+
type ContainsAnyOptions<Input, Output, Expected = unknown> = ContainsListOptions<Input, Output, Expected>;
|
|
474
|
+
declare function containsAny<Input, Output, Expected = unknown, const Name extends string = string>(options: ContainsAnyOptions<Input, Output, Expected> & {
|
|
475
|
+
name?: Name | undefined;
|
|
476
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name>;
|
|
477
|
+
type MatchesOptions<Input, Output, Expected = unknown> = {
|
|
478
|
+
name?: string | undefined;
|
|
479
|
+
required?: boolean | undefined;
|
|
480
|
+
actual?: ValueSelector<Input, Output, Expected, string> | undefined;
|
|
481
|
+
expected?: SelectorOrValue<Input, Output, Expected, RegExp> | undefined;
|
|
482
|
+
};
|
|
483
|
+
declare function matches<Input, Output, Expected = unknown, const Name extends string = string>(options: MatchesOptions<Input, Output, Expected> & {
|
|
484
|
+
name?: Name | undefined;
|
|
485
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name>;
|
|
486
|
+
type DoesNotMatchOptions<Input, Output, Expected = unknown> = MatchesOptions<Input, Output, Expected>;
|
|
487
|
+
declare function doesNotMatch<Input, Output, Expected = unknown, const Name extends string = string>(options: DoesNotMatchOptions<Input, Output, Expected> & {
|
|
488
|
+
name?: Name | undefined;
|
|
489
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name>;
|
|
490
|
+
type MaxLengthOptions<Input, Output, Expected = unknown> = {
|
|
491
|
+
name?: string | undefined;
|
|
492
|
+
required?: boolean | undefined;
|
|
493
|
+
actual?: ValueSelector<Input, Output, Expected, string> | undefined;
|
|
494
|
+
max: SelectorOrValue<Input, Output, Expected, number>;
|
|
495
|
+
};
|
|
496
|
+
declare function maxLength<Input, Output, Expected = unknown, const Name extends string = string>(options: MaxLengthOptions<Input, Output, Expected> & {
|
|
497
|
+
name?: Name | undefined;
|
|
498
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name>;
|
|
499
|
+
type RequiredFieldsOptions<Input, Output, Expected = unknown> = {
|
|
500
|
+
name?: string | undefined;
|
|
501
|
+
required?: boolean | undefined;
|
|
502
|
+
actual?: ValueSelector<Input, Output, Expected, unknown> | undefined;
|
|
503
|
+
expected: SelectorOrValue<Input, Output, Expected, readonly string[]>;
|
|
504
|
+
};
|
|
505
|
+
declare function requiredFields<Input, Output, Expected = unknown, const Name extends string = string>(options: RequiredFieldsOptions<Input, Output, Expected> & {
|
|
506
|
+
name?: Name | undefined;
|
|
507
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name>;
|
|
238
508
|
type SemanticSimilarityOptions<Input, Output, Expected = unknown> = {
|
|
239
509
|
name?: string | undefined;
|
|
510
|
+
required?: boolean | undefined;
|
|
240
511
|
model: EmbeddingModel;
|
|
241
512
|
threshold: number;
|
|
242
513
|
actual?: ValueSelector<Input, Output, Expected, string> | undefined;
|
|
243
514
|
expected?: SelectorOrValue<Input, Output, Expected, string> | undefined;
|
|
244
515
|
};
|
|
245
|
-
declare function semanticSimilarity<Input, Output, Expected = unknown>(options: SemanticSimilarityOptions<Input, Output, Expected>
|
|
516
|
+
declare function semanticSimilarity<Input, Output, Expected = unknown, const Name extends string = string>(options: SemanticSimilarityOptions<Input, Output, Expected> & {
|
|
517
|
+
expected: Exclude<SemanticSimilarityOptions<Input, Output, Expected>["expected"], undefined>;
|
|
518
|
+
name?: Name | undefined;
|
|
519
|
+
}): EvalMetric<Input, Output, number, Expected, Name>;
|
|
520
|
+
declare function semanticSimilarity<Input, Output, Expected = unknown, const Name extends string = string>(options: Omit<SemanticSimilarityOptions<Input, Output, Expected>, "expected"> & {
|
|
521
|
+
expected?: undefined;
|
|
522
|
+
name?: Name | undefined;
|
|
523
|
+
}): EvalMetric<Input, Output, number, Expected, Name, {
|
|
524
|
+
expected: string;
|
|
525
|
+
}>;
|
|
246
526
|
type LlmJudgeOptions<Input, Output, SchemaOutput, Expected = unknown> = {
|
|
247
527
|
name?: string | undefined;
|
|
528
|
+
required?: boolean | undefined;
|
|
248
529
|
model: CompletionModel;
|
|
249
530
|
schema: ZodSchema<SchemaOutput>;
|
|
250
531
|
passes(value: SchemaOutput): boolean;
|
|
@@ -252,13 +533,16 @@ type LlmJudgeOptions<Input, Output, SchemaOutput, Expected = unknown> = {
|
|
|
252
533
|
retries?: number | undefined;
|
|
253
534
|
prompt?: ValueSelector<Input, Output, Expected, string> | undefined;
|
|
254
535
|
};
|
|
255
|
-
declare function llmJudge<Input, Output, SchemaOutput, Expected = unknown>(options: LlmJudgeOptions<Input, Output, SchemaOutput, Expected>
|
|
536
|
+
declare function llmJudge<Input, Output, SchemaOutput, Expected = unknown, const Name extends string = string>(options: LlmJudgeOptions<Input, Output, SchemaOutput, Expected> & {
|
|
537
|
+
name?: Name | undefined;
|
|
538
|
+
}): EvalMetric<Input, Output, SchemaOutput, Expected, Name>;
|
|
256
539
|
type LlmScoreMetricScore = {
|
|
257
540
|
score: number;
|
|
258
541
|
feedback: string;
|
|
259
542
|
};
|
|
260
543
|
type LlmScoreOptions<Input, Output, Expected = unknown> = {
|
|
261
544
|
name?: string | undefined;
|
|
545
|
+
required?: boolean | undefined;
|
|
262
546
|
model: CompletionModel;
|
|
263
547
|
threshold: number;
|
|
264
548
|
criteria: string | string[];
|
|
@@ -266,9 +550,11 @@ type LlmScoreOptions<Input, Output, Expected = unknown> = {
|
|
|
266
550
|
retries?: number | undefined;
|
|
267
551
|
prompt?: ValueSelector<Input, Output, Expected, string> | undefined;
|
|
268
552
|
};
|
|
269
|
-
declare function llmScore<Input, Output, Expected = unknown>(options: LlmScoreOptions<Input, Output, Expected>
|
|
553
|
+
declare function llmScore<Input, Output, Expected = unknown, const Name extends string = string>(options: LlmScoreOptions<Input, Output, Expected> & {
|
|
554
|
+
name?: Name | undefined;
|
|
555
|
+
}): EvalMetric<Input, Output, LlmScoreMetricScore, Expected, Name>;
|
|
270
556
|
|
|
271
|
-
declare function projectEvalOutcome(outcome: EvalOutcome
|
|
557
|
+
declare function projectEvalOutcome<Score>(outcome: EvalOutcome<Score>, dataType: EvalMetric<unknown, unknown>["dataType"], projectScore?: ((score: Score) => number | string | boolean) | undefined): EvalScoreProjection;
|
|
272
558
|
declare function resolveEvalTraceRef(args: {
|
|
273
559
|
output?: unknown;
|
|
274
560
|
input?: unknown;
|
|
@@ -276,6 +562,75 @@ declare function resolveEvalTraceRef(args: {
|
|
|
276
562
|
}): EvalTraceRef | undefined;
|
|
277
563
|
declare function defaultEvalTraceSelector<Input, Output, Expected>(args: EvalTraceSelectorArgs<Input, Output, Expected>): EvalTraceRef | undefined;
|
|
278
564
|
|
|
279
|
-
declare function runEvalSuite<Input, Output, Expected = unknown>(options: RunEvalSuiteOptions<Input, Output, Expected>): Promise<EvalSuiteResult<Input, Output, Expected>>;
|
|
565
|
+
declare function runEvalSuite<Input, Output, Expected = unknown, const Metrics extends readonly EvalMetric<NoInfer<Input>, NoInfer<Output>, unknown, NoInfer<Expected>, string>[] = readonly EvalMetric<NoInfer<Input>, NoInfer<Output>, unknown, NoInfer<Expected>, string>[]>(options: RunEvalSuiteOptions<Input, Output, Expected, Metrics>): Promise<EvalSuiteResult<Input, Output, Expected, Metrics>>;
|
|
566
|
+
|
|
567
|
+
declare function selectPromptOutput(args: EvalMetricArgs<unknown, unknown, unknown>): string;
|
|
568
|
+
|
|
569
|
+
type EvalCaseLike = EvalCase<unknown, unknown>;
|
|
570
|
+
type EvalCasesInput<Cases extends readonly EvalCaseLike[]> = Cases[number]["input"];
|
|
571
|
+
type EvalCaseExpected<Case> = Case extends {
|
|
572
|
+
expected: infer Expected;
|
|
573
|
+
} ? Expected : unknown;
|
|
574
|
+
type EvalCasesExpected<Cases extends readonly EvalCaseLike[]> = EvalCaseExpected<Cases[number]>;
|
|
575
|
+
type EvalMetricRequirements<Metric> = Metric extends EvalMetric<infer _Input, infer _Output, infer _Score, infer _Expected, infer _Name, infer Requirements> ? Requirements : Record<never, never>;
|
|
576
|
+
type RequiredExpected<Metrics extends readonly EvalMetric<never, never>[]> = Extract<EvalMetricRequirements<Metrics[number]>, {
|
|
577
|
+
expected: unknown;
|
|
578
|
+
}>;
|
|
579
|
+
type RequiredContext<Metrics extends readonly EvalMetric<never, never>[]> = Extract<EvalMetricRequirements<Metrics[number]>, {
|
|
580
|
+
context: string[];
|
|
581
|
+
}>;
|
|
582
|
+
type RequiredRetrievalContext<Metrics extends readonly EvalMetric<never, never>[]> = Extract<EvalMetricRequirements<Metrics[number]>, {
|
|
583
|
+
retrievalContext: string[];
|
|
584
|
+
}>;
|
|
585
|
+
type EvalCaseFieldsForMetrics<Metrics extends readonly EvalMetric<never, never>[]> = ([
|
|
586
|
+
RequiredExpected<Metrics>
|
|
587
|
+
] extends [never] ? Record<never, never> : {
|
|
588
|
+
expected: RequiredExpected<Metrics>["expected"];
|
|
589
|
+
}) & ([RequiredContext<Metrics>] extends [never] ? Record<never, never> : {
|
|
590
|
+
context: string[];
|
|
591
|
+
}) & ([RequiredRetrievalContext<Metrics>] extends [never] ? Record<never, never> : {
|
|
592
|
+
retrievalContext: string[];
|
|
593
|
+
});
|
|
594
|
+
type EvalCasesForMetrics<Cases extends readonly EvalCaseLike[], Metrics extends readonly EvalMetric<never, never>[]> = {
|
|
595
|
+
readonly [Index in keyof Cases]: Cases[Index] & EvalCaseFieldsForMetrics<Metrics>;
|
|
596
|
+
};
|
|
597
|
+
type DefinedEvalSuite<Cases extends readonly EvalCaseLike[], Output, Metrics extends readonly EvalMetric<EvalCasesInput<Cases>, Output, unknown, EvalCasesExpected<Cases>, string>[]> = Omit<RunEvalSuiteOptions<EvalCasesInput<Cases>, Output, EvalCasesExpected<Cases>, Metrics>, "cases" | "target" | "metrics"> & {
|
|
598
|
+
cases: Cases & EvalCasesForMetrics<NoInfer<Cases>, NoInfer<Metrics>>;
|
|
599
|
+
target: EvalTarget<EvalCasesInput<Cases>, Output, EvalCasesExpected<Cases>>;
|
|
600
|
+
metrics: Metrics;
|
|
601
|
+
};
|
|
602
|
+
type EvalSuiteTypeBuilder<Input, Output, Expected = unknown> = {
|
|
603
|
+
defineMetric<const Name extends string = string>(metric: EvalMetric<Input, Output, boolean, Expected, Name> & {
|
|
604
|
+
dataType: "BOOLEAN";
|
|
605
|
+
}): EvalMetric<Input, Output, boolean, Expected, Name>;
|
|
606
|
+
defineMetric<const Name extends string = string>(metric: EvalMetric<Input, Output, number, Expected, Name> & {
|
|
607
|
+
dataType: "NUMERIC";
|
|
608
|
+
}): EvalMetric<Input, Output, number, Expected, Name>;
|
|
609
|
+
defineMetric<const Name extends string = string>(metric: EvalMetric<Input, Output, string, Expected, Name> & {
|
|
610
|
+
dataType: "CATEGORICAL";
|
|
611
|
+
}): EvalMetric<Input, Output, string, Expected, Name>;
|
|
612
|
+
defineMetric<Score, const Name extends string = string>(metric: EvalMetric<Input, Output, Score, Expected, Name> & {
|
|
613
|
+
dataType: "BOOLEAN";
|
|
614
|
+
projectScore(score: Score): boolean;
|
|
615
|
+
}): EvalMetric<Input, Output, Score, Expected, Name>;
|
|
616
|
+
defineMetric<Score, const Name extends string = string>(metric: EvalMetric<Input, Output, Score, Expected, Name> & {
|
|
617
|
+
dataType: "NUMERIC";
|
|
618
|
+
projectScore(score: Score): number;
|
|
619
|
+
}): EvalMetric<Input, Output, Score, Expected, Name>;
|
|
620
|
+
defineMetric<Score, const Name extends string = string>(metric: EvalMetric<Input, Output, Score, Expected, Name> & {
|
|
621
|
+
dataType: "CATEGORICAL";
|
|
622
|
+
projectScore(score: Score): string;
|
|
623
|
+
}): EvalMetric<Input, Output, Score, Expected, Name>;
|
|
624
|
+
defineMetric<Score, const Name extends string = string>(metric: EvalMetric<Input, Output, Score, Expected, Name> & {
|
|
625
|
+
dataType?: undefined;
|
|
626
|
+
}): EvalMetric<Input, Output, Score, Expected, Name>;
|
|
627
|
+
};
|
|
628
|
+
declare function defineEvalCases<const Cases extends readonly EvalCaseLike[]>(cases: Cases): Cases;
|
|
629
|
+
declare function defineEvalSuite<Input, Output, Expected = unknown>(): EvalSuiteTypeBuilder<Input, Output, Expected>;
|
|
630
|
+
declare function defineEvalSuite<const Cases extends readonly EvalCaseLike[], const Target extends (input: EvalCasesInput<Cases>, testCase: EvalCase<EvalCasesInput<Cases>, EvalCasesExpected<Cases>>) => unknown, const Metrics extends readonly EvalMetric<EvalCasesInput<Cases>, Awaited<ReturnType<Target>>, unknown, EvalCasesExpected<Cases>, string>[]>(options: DefinedEvalSuite<Cases, Awaited<ReturnType<Target>>, Metrics> & {
|
|
631
|
+
target: Target;
|
|
632
|
+
}): DefinedEvalSuite<Cases, Awaited<ReturnType<Target>>, Metrics> & {
|
|
633
|
+
target: Target;
|
|
634
|
+
};
|
|
280
635
|
|
|
281
|
-
export { type AgentEvalTargetOptions, type AnswerRelevancyOptions, type ContainsOptions, type EvalCase, type EvalCaseResult, type EvalMetadata, type EvalMetric, type EvalMetricArgs, type EvalMetricResult, EvalOutcome, type EvalOutcomeStatus, type EvalReportArgs, type EvalReporter, type EvalScoreProjection, type EvalSuiteResult, type EvalTarget, type EvalTraceRef, type EvalTraceSelector, type EvalTraceSelectorArgs, type EvalTurn, type ExactMatchOptions, type FaithfulnessOptions, type GEvalOptions, type GEvalParameter, type GEvalRubric, type HallucinationOptions, type JsonCorrectnessOptions, type KnowledgeRetentionOptions, type LlmJudgeOptions, type LlmScoreMetricScore, type LlmScoreOptions, type PromptAlignmentOptions, type RunEvalSuiteOptions, type SelectorOrValue, type SemanticSimilarityOptions, type SummarizationOptions, type TurnRelevancyOptions, type ValueSelector, agentEvalTarget, answerRelevancy, contains, defaultEvalTraceSelector, defineMetric, exactMatch, faithfulness, gEval, hallucination, jsonCorrectness, knowledgeRetention, llmJudge, llmScore, projectEvalOutcome, promptAlignment, resolveEvalTraceRef, runEvalSuite, semanticSimilarity, summarization, turnRelevancy };
|
|
636
|
+
export { type AbstentionCategory, type AbstentionOptions, type AgentEvalTargetOptions, type AnswerRelevancyOptions, type AnyEvalMetric, type ContainsAllOptions, type ContainsAnyOptions, type ContainsListOptions, type ContainsOptions, type DefaultEvalActual, type DefinedEvalSuite, type DoesNotMatchOptions, EvalAssertionError, type EvalCase, type EvalCaseRequirements, type EvalCaseResult, type EvalCasesExpected, type EvalCasesForMetrics, type EvalCasesInput, type EvalCostCalculatorArgs, type EvalCostOptions, type EvalCostSummary, type EvalDataType, type EvalExpectations, type EvalExpectedOutcomes, type EvalExpectedTotals, type EvalMetadata, type EvalMetric, type EvalMetricArgs, type EvalMetricDescriptor, type EvalMetricResult, type EvalMetricResultFor, type EvalMetricScore, EvalOutcome, type EvalOutcomeStatus, type EvalOutputFormat, type EvalOutputWriters, type EvalReportArgs, type EvalReporter, type EvalRunContext, type EvalRunEndArgs, type EvalRunOptions, type EvalRunStartArgs, type EvalScoreDirection, type EvalScoreMap, type EvalScoreProjection, type EvalSuiteResult, type EvalSuiteTypeBuilder, type EvalTarget, type EvalTargetUsageSelector, type EvalTotals, type EvalTraceCarrier, type EvalTraceRef, type EvalTraceSelector, type EvalTraceSelectorArgs, type EvalTurn, type EvalUsageSummary, type ExactMatchOptions, type FaithfulnessOptions, type GEvalOptions, type GEvalParameter, type GEvalRubric, type HallucinationOptions, type JsonCorrectnessOptions, type KnowledgeRetentionOptions, type LlmJudgeOptions, type LlmScoreMetricScore, type LlmScoreOptions, type MatchesOptions, type MaxLengthOptions, type NotContainsOptions, type PrintEvalResultOptions, type PromptAlignmentOptions, type RequiredFieldsOptions, type RunEvalCliOptions, type RunEvalSuiteOptions, type SelectorOrValue, type SemanticSimilarityOptions, type SummarizationOptions, type TurnRelevancyOptions, type ValueSelector, abstention, agentEvalTarget, answerRelevancy, assertEvalOutcomes, assertEvalTotals, contains, containsAll, containsAny, defaultEvalTraceSelector, defineEvalCases, defineEvalSuite, defineMetric, doesNotMatch, evalExitCode, exactMatch, faithfulness, gEval, hallucination, jsonCorrectness, knowledgeRetention, llmJudge, llmScore, matches, maxLength, notContains, printEvalResult, projectEvalOutcome, promptAlignment, requiredFields, resolveEvalTraceRef, runEvalCli, runEvalSuite, selectPromptOutput, semanticSimilarity, summarization, turnRelevancy };
|