@verdict-ai/sdk 0.0.0-stage → 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/LICENSE +9 -0
- package/README.md +21 -2
- package/dist/index.d.ts +435 -0
- package/dist/index.js +135 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Verdict contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @verdict-ai/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Typed HTTP client for the Verdict REST API.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @verdict-ai/sdk
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { Verdict } from "@verdict-ai/sdk";
|
|
11
|
+
const verdict = new Verdict({ baseUrl: "http://localhost:8787" });
|
|
12
|
+
const rubric = await verdict.rubrics.create({
|
|
13
|
+
name: "Presence", criteria: [{ id: "present", name: "Has text",
|
|
14
|
+
judge: { type: "benchmark", method: "length", min: 1 } }],
|
|
15
|
+
});
|
|
16
|
+
const evaluation = await verdict.evaluations.create({
|
|
17
|
+
rubric: rubric.id, inputs: [{ type: "text", text: "Hello Verdict" }],
|
|
18
|
+
});
|
|
19
|
+
console.log(evaluation.aggregate.score);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Requires Node 20 or newer. [Documentation](https://verdict-docs.developerolim.workers.dev/reference/sdk). MIT licensed.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides a typed client for Verdict REST operations and polling.
|
|
3
|
+
* Idempotency replay metadata is preserved; transport failures use VerdictError and Workers-safe fetch.
|
|
4
|
+
*/
|
|
5
|
+
import type { CalibrationReport, Aggregation, Evaluation, Input, Rubric, RubricInput, Subject } from "@verdict-ai/core";
|
|
6
|
+
export interface VerdictOptions {
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
/** Request timeout in ms (sync evaluations can take a while). Default 10 min. */
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Carries transport status, error type and optional API issues for failed client requests. */
|
|
14
|
+
export declare class VerdictError extends Error {
|
|
15
|
+
status: number;
|
|
16
|
+
type: string;
|
|
17
|
+
issues?: unknown | undefined;
|
|
18
|
+
constructor(status: number, type: string, message: string, issues?: unknown | undefined);
|
|
19
|
+
}
|
|
20
|
+
export interface EvaluateParams {
|
|
21
|
+
rubric: string | RubricInput;
|
|
22
|
+
inputs?: Input[];
|
|
23
|
+
subject?: Subject;
|
|
24
|
+
name?: string;
|
|
25
|
+
metadata?: Record<string, unknown>;
|
|
26
|
+
webhook?: string;
|
|
27
|
+
includeEvidence?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export type EvaluationView = Omit<Evaluation, "rubric" | "evidence"> & {
|
|
30
|
+
rubric: Pick<Rubric, "id" | "name" | "version" | "aggregation">;
|
|
31
|
+
evidence: Array<Record<string, unknown>>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Verdict client — mirrors the REST API 1:1.
|
|
35
|
+
*
|
|
36
|
+
* const verdict = new Verdict({ apiKey: "sk_..." });
|
|
37
|
+
* const ev = await verdict.evaluations.create({ rubric: "rub_123", inputs: [{ type: "url", url: "https://..." }] });
|
|
38
|
+
* console.log(ev.aggregate.score, ev.aggregate.grade);
|
|
39
|
+
*/
|
|
40
|
+
export declare class Verdict {
|
|
41
|
+
private apiKey?;
|
|
42
|
+
private baseUrl;
|
|
43
|
+
private f;
|
|
44
|
+
private timeoutMs;
|
|
45
|
+
constructor(opts?: VerdictOptions);
|
|
46
|
+
request<T>(method: string, path: string, body?: unknown, contentType?: string, headers?: Record<string, string>): Promise<T>;
|
|
47
|
+
requestWithMeta<T>(method: string, path: string, body?: unknown, contentType?: string, headers?: Record<string, string>): Promise<{
|
|
48
|
+
data: T;
|
|
49
|
+
replayed: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
rubrics: {
|
|
52
|
+
calibration: (id: string, options?: {
|
|
53
|
+
target?: number;
|
|
54
|
+
buckets?: number;
|
|
55
|
+
limit?: number;
|
|
56
|
+
}) => Promise<CalibrationReport>;
|
|
57
|
+
create: (rubric: RubricInput | string) => Promise<{
|
|
58
|
+
name: string;
|
|
59
|
+
version: string;
|
|
60
|
+
scale: {
|
|
61
|
+
type: "numeric";
|
|
62
|
+
min: number;
|
|
63
|
+
max: number;
|
|
64
|
+
step?: number | undefined;
|
|
65
|
+
} | {
|
|
66
|
+
type: "binary";
|
|
67
|
+
labels?: [string, string] | undefined;
|
|
68
|
+
} | {
|
|
69
|
+
type: "ordinal";
|
|
70
|
+
labels: string[];
|
|
71
|
+
values?: number[] | undefined;
|
|
72
|
+
};
|
|
73
|
+
judges: Record<string, import("@verdict-ai/core").JudgeSpec>;
|
|
74
|
+
defaultJudge: import("@verdict-ai/core").JudgeSpec;
|
|
75
|
+
criteria: {
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
weight: number;
|
|
79
|
+
optional: boolean;
|
|
80
|
+
description?: string | undefined;
|
|
81
|
+
scale?: {
|
|
82
|
+
type: "numeric";
|
|
83
|
+
min: number;
|
|
84
|
+
max: number;
|
|
85
|
+
step?: number | undefined;
|
|
86
|
+
} | {
|
|
87
|
+
type: "binary";
|
|
88
|
+
labels?: [string, string] | undefined;
|
|
89
|
+
} | {
|
|
90
|
+
type: "ordinal";
|
|
91
|
+
labels: string[];
|
|
92
|
+
values?: number[] | undefined;
|
|
93
|
+
} | undefined;
|
|
94
|
+
anchors?: Record<string, string> | undefined;
|
|
95
|
+
choices?: Record<string, string> | undefined;
|
|
96
|
+
values?: Record<string, number> | undefined;
|
|
97
|
+
levels?: {
|
|
98
|
+
value: number;
|
|
99
|
+
description: string;
|
|
100
|
+
label?: string | undefined;
|
|
101
|
+
}[] | undefined;
|
|
102
|
+
judge?: import("@verdict-ai/core").JudgeSpec | import("@verdict-ai/core").JudgeSpec[] | undefined;
|
|
103
|
+
rater?: "min" | "max" | "mean" | "median" | "majority" | "trimmed_mean" | undefined;
|
|
104
|
+
inputs?: string[] | undefined;
|
|
105
|
+
group?: string | undefined;
|
|
106
|
+
}[];
|
|
107
|
+
aggregation: {
|
|
108
|
+
method: "min" | "max" | "formula" | "mean" | "median" | "weighted_mean" | "weighted_sum" | "geometric_mean";
|
|
109
|
+
rater: "min" | "max" | "mean" | "median" | "majority" | "trimmed_mean";
|
|
110
|
+
normalize: false | [number, number];
|
|
111
|
+
missing: "fail" | "exclude" | "zero";
|
|
112
|
+
gates: {
|
|
113
|
+
criterion: string;
|
|
114
|
+
min?: number | undefined;
|
|
115
|
+
max?: number | undefined;
|
|
116
|
+
message?: string | undefined;
|
|
117
|
+
}[];
|
|
118
|
+
precision: number;
|
|
119
|
+
formula?: string | undefined;
|
|
120
|
+
grades?: {
|
|
121
|
+
label: string;
|
|
122
|
+
min: number;
|
|
123
|
+
}[] | undefined;
|
|
124
|
+
passThreshold?: number | undefined;
|
|
125
|
+
};
|
|
126
|
+
id?: string | undefined;
|
|
127
|
+
description?: string | undefined;
|
|
128
|
+
context?: string | undefined;
|
|
129
|
+
language?: string | undefined;
|
|
130
|
+
checks?: {
|
|
131
|
+
id: string;
|
|
132
|
+
question: string;
|
|
133
|
+
expect: boolean;
|
|
134
|
+
threshold: number;
|
|
135
|
+
action: "abort" | "fail" | "flag";
|
|
136
|
+
criteria?: {
|
|
137
|
+
true: string;
|
|
138
|
+
false: string;
|
|
139
|
+
} | undefined;
|
|
140
|
+
message?: string | undefined;
|
|
141
|
+
}[] | undefined;
|
|
142
|
+
checksJudge?: import("@verdict-ai/core").JudgeSpec | undefined;
|
|
143
|
+
metadata?: Record<string, unknown> | undefined;
|
|
144
|
+
} & {
|
|
145
|
+
id: string;
|
|
146
|
+
}>;
|
|
147
|
+
validate: (rubric: RubricInput | string) => Promise<{
|
|
148
|
+
valid: boolean;
|
|
149
|
+
rubric?: Rubric;
|
|
150
|
+
error?: unknown;
|
|
151
|
+
}>;
|
|
152
|
+
get: (id: string) => Promise<{
|
|
153
|
+
name: string;
|
|
154
|
+
version: string;
|
|
155
|
+
scale: {
|
|
156
|
+
type: "numeric";
|
|
157
|
+
min: number;
|
|
158
|
+
max: number;
|
|
159
|
+
step?: number | undefined;
|
|
160
|
+
} | {
|
|
161
|
+
type: "binary";
|
|
162
|
+
labels?: [string, string] | undefined;
|
|
163
|
+
} | {
|
|
164
|
+
type: "ordinal";
|
|
165
|
+
labels: string[];
|
|
166
|
+
values?: number[] | undefined;
|
|
167
|
+
};
|
|
168
|
+
judges: Record<string, import("@verdict-ai/core").JudgeSpec>;
|
|
169
|
+
defaultJudge: import("@verdict-ai/core").JudgeSpec;
|
|
170
|
+
criteria: {
|
|
171
|
+
id: string;
|
|
172
|
+
name: string;
|
|
173
|
+
weight: number;
|
|
174
|
+
optional: boolean;
|
|
175
|
+
description?: string | undefined;
|
|
176
|
+
scale?: {
|
|
177
|
+
type: "numeric";
|
|
178
|
+
min: number;
|
|
179
|
+
max: number;
|
|
180
|
+
step?: number | undefined;
|
|
181
|
+
} | {
|
|
182
|
+
type: "binary";
|
|
183
|
+
labels?: [string, string] | undefined;
|
|
184
|
+
} | {
|
|
185
|
+
type: "ordinal";
|
|
186
|
+
labels: string[];
|
|
187
|
+
values?: number[] | undefined;
|
|
188
|
+
} | undefined;
|
|
189
|
+
anchors?: Record<string, string> | undefined;
|
|
190
|
+
choices?: Record<string, string> | undefined;
|
|
191
|
+
values?: Record<string, number> | undefined;
|
|
192
|
+
levels?: {
|
|
193
|
+
value: number;
|
|
194
|
+
description: string;
|
|
195
|
+
label?: string | undefined;
|
|
196
|
+
}[] | undefined;
|
|
197
|
+
judge?: import("@verdict-ai/core").JudgeSpec | import("@verdict-ai/core").JudgeSpec[] | undefined;
|
|
198
|
+
rater?: "min" | "max" | "mean" | "median" | "majority" | "trimmed_mean" | undefined;
|
|
199
|
+
inputs?: string[] | undefined;
|
|
200
|
+
group?: string | undefined;
|
|
201
|
+
}[];
|
|
202
|
+
aggregation: {
|
|
203
|
+
method: "min" | "max" | "formula" | "mean" | "median" | "weighted_mean" | "weighted_sum" | "geometric_mean";
|
|
204
|
+
rater: "min" | "max" | "mean" | "median" | "majority" | "trimmed_mean";
|
|
205
|
+
normalize: false | [number, number];
|
|
206
|
+
missing: "fail" | "exclude" | "zero";
|
|
207
|
+
gates: {
|
|
208
|
+
criterion: string;
|
|
209
|
+
min?: number | undefined;
|
|
210
|
+
max?: number | undefined;
|
|
211
|
+
message?: string | undefined;
|
|
212
|
+
}[];
|
|
213
|
+
precision: number;
|
|
214
|
+
formula?: string | undefined;
|
|
215
|
+
grades?: {
|
|
216
|
+
label: string;
|
|
217
|
+
min: number;
|
|
218
|
+
}[] | undefined;
|
|
219
|
+
passThreshold?: number | undefined;
|
|
220
|
+
};
|
|
221
|
+
id?: string | undefined;
|
|
222
|
+
description?: string | undefined;
|
|
223
|
+
context?: string | undefined;
|
|
224
|
+
language?: string | undefined;
|
|
225
|
+
checks?: {
|
|
226
|
+
id: string;
|
|
227
|
+
question: string;
|
|
228
|
+
expect: boolean;
|
|
229
|
+
threshold: number;
|
|
230
|
+
action: "abort" | "fail" | "flag";
|
|
231
|
+
criteria?: {
|
|
232
|
+
true: string;
|
|
233
|
+
false: string;
|
|
234
|
+
} | undefined;
|
|
235
|
+
message?: string | undefined;
|
|
236
|
+
}[] | undefined;
|
|
237
|
+
checksJudge?: import("@verdict-ai/core").JudgeSpec | undefined;
|
|
238
|
+
metadata?: Record<string, unknown> | undefined;
|
|
239
|
+
} & {
|
|
240
|
+
id: string;
|
|
241
|
+
}>;
|
|
242
|
+
list: () => Promise<{
|
|
243
|
+
data: Array<Rubric & {
|
|
244
|
+
id: string;
|
|
245
|
+
}>;
|
|
246
|
+
}>;
|
|
247
|
+
update: (id: string, rubric: RubricInput) => Promise<{
|
|
248
|
+
name: string;
|
|
249
|
+
version: string;
|
|
250
|
+
scale: {
|
|
251
|
+
type: "numeric";
|
|
252
|
+
min: number;
|
|
253
|
+
max: number;
|
|
254
|
+
step?: number | undefined;
|
|
255
|
+
} | {
|
|
256
|
+
type: "binary";
|
|
257
|
+
labels?: [string, string] | undefined;
|
|
258
|
+
} | {
|
|
259
|
+
type: "ordinal";
|
|
260
|
+
labels: string[];
|
|
261
|
+
values?: number[] | undefined;
|
|
262
|
+
};
|
|
263
|
+
judges: Record<string, import("@verdict-ai/core").JudgeSpec>;
|
|
264
|
+
defaultJudge: import("@verdict-ai/core").JudgeSpec;
|
|
265
|
+
criteria: {
|
|
266
|
+
id: string;
|
|
267
|
+
name: string;
|
|
268
|
+
weight: number;
|
|
269
|
+
optional: boolean;
|
|
270
|
+
description?: string | undefined;
|
|
271
|
+
scale?: {
|
|
272
|
+
type: "numeric";
|
|
273
|
+
min: number;
|
|
274
|
+
max: number;
|
|
275
|
+
step?: number | undefined;
|
|
276
|
+
} | {
|
|
277
|
+
type: "binary";
|
|
278
|
+
labels?: [string, string] | undefined;
|
|
279
|
+
} | {
|
|
280
|
+
type: "ordinal";
|
|
281
|
+
labels: string[];
|
|
282
|
+
values?: number[] | undefined;
|
|
283
|
+
} | undefined;
|
|
284
|
+
anchors?: Record<string, string> | undefined;
|
|
285
|
+
choices?: Record<string, string> | undefined;
|
|
286
|
+
values?: Record<string, number> | undefined;
|
|
287
|
+
levels?: {
|
|
288
|
+
value: number;
|
|
289
|
+
description: string;
|
|
290
|
+
label?: string | undefined;
|
|
291
|
+
}[] | undefined;
|
|
292
|
+
judge?: import("@verdict-ai/core").JudgeSpec | import("@verdict-ai/core").JudgeSpec[] | undefined;
|
|
293
|
+
rater?: "min" | "max" | "mean" | "median" | "majority" | "trimmed_mean" | undefined;
|
|
294
|
+
inputs?: string[] | undefined;
|
|
295
|
+
group?: string | undefined;
|
|
296
|
+
}[];
|
|
297
|
+
aggregation: {
|
|
298
|
+
method: "min" | "max" | "formula" | "mean" | "median" | "weighted_mean" | "weighted_sum" | "geometric_mean";
|
|
299
|
+
rater: "min" | "max" | "mean" | "median" | "majority" | "trimmed_mean";
|
|
300
|
+
normalize: false | [number, number];
|
|
301
|
+
missing: "fail" | "exclude" | "zero";
|
|
302
|
+
gates: {
|
|
303
|
+
criterion: string;
|
|
304
|
+
min?: number | undefined;
|
|
305
|
+
max?: number | undefined;
|
|
306
|
+
message?: string | undefined;
|
|
307
|
+
}[];
|
|
308
|
+
precision: number;
|
|
309
|
+
formula?: string | undefined;
|
|
310
|
+
grades?: {
|
|
311
|
+
label: string;
|
|
312
|
+
min: number;
|
|
313
|
+
}[] | undefined;
|
|
314
|
+
passThreshold?: number | undefined;
|
|
315
|
+
};
|
|
316
|
+
id?: string | undefined;
|
|
317
|
+
description?: string | undefined;
|
|
318
|
+
context?: string | undefined;
|
|
319
|
+
language?: string | undefined;
|
|
320
|
+
checks?: {
|
|
321
|
+
id: string;
|
|
322
|
+
question: string;
|
|
323
|
+
expect: boolean;
|
|
324
|
+
threshold: number;
|
|
325
|
+
action: "abort" | "fail" | "flag";
|
|
326
|
+
criteria?: {
|
|
327
|
+
true: string;
|
|
328
|
+
false: string;
|
|
329
|
+
} | undefined;
|
|
330
|
+
message?: string | undefined;
|
|
331
|
+
}[] | undefined;
|
|
332
|
+
checksJudge?: import("@verdict-ai/core").JudgeSpec | undefined;
|
|
333
|
+
metadata?: Record<string, unknown> | undefined;
|
|
334
|
+
} & {
|
|
335
|
+
id: string;
|
|
336
|
+
}>;
|
|
337
|
+
delete: (id: string) => Promise<void>;
|
|
338
|
+
};
|
|
339
|
+
evaluations: {
|
|
340
|
+
retry: (id: string) => Promise<{
|
|
341
|
+
id: string;
|
|
342
|
+
status: "queued";
|
|
343
|
+
url: string;
|
|
344
|
+
}>;
|
|
345
|
+
create: (params: EvaluateParams, opts?: {
|
|
346
|
+
idempotencyKey?: string;
|
|
347
|
+
}) => Promise<EvaluationView>;
|
|
348
|
+
createIdempotent: (params: EvaluateParams, key: string) => Promise<{
|
|
349
|
+
evaluation: EvaluationView;
|
|
350
|
+
replayed: boolean;
|
|
351
|
+
}>;
|
|
352
|
+
/** Returns {id,status:"queued"}; poll with `get`, or use a webhook. */
|
|
353
|
+
createAsync: (params: EvaluateParams, opts?: {
|
|
354
|
+
idempotencyKey?: string;
|
|
355
|
+
}) => Promise<{
|
|
356
|
+
id: string;
|
|
357
|
+
status: string;
|
|
358
|
+
url: string;
|
|
359
|
+
}>;
|
|
360
|
+
get: (id: string, opts?: {
|
|
361
|
+
evidence?: boolean;
|
|
362
|
+
}) => Promise<EvaluationView>;
|
|
363
|
+
list: (q?: {
|
|
364
|
+
rubric?: string;
|
|
365
|
+
status?: string;
|
|
366
|
+
limit?: number;
|
|
367
|
+
}) => Promise<{
|
|
368
|
+
data: EvaluationView[];
|
|
369
|
+
}>;
|
|
370
|
+
submitScore: (id: string, s: {
|
|
371
|
+
criterionId: string;
|
|
372
|
+
raterId: string;
|
|
373
|
+
score: number | string;
|
|
374
|
+
rationale?: string;
|
|
375
|
+
confidence?: number;
|
|
376
|
+
}) => Promise<EvaluationView>;
|
|
377
|
+
reaggregate: (id: string, aggregation: Partial<Aggregation>, persist?: boolean) => Promise<EvaluationView>;
|
|
378
|
+
/** Poll until the evaluation leaves running/queued (does not wait for humans unless `waitForHumans`). */
|
|
379
|
+
wait: (id: string, opts?: {
|
|
380
|
+
intervalMs?: number;
|
|
381
|
+
waitForHumans?: boolean;
|
|
382
|
+
timeoutMs?: number;
|
|
383
|
+
}) => Promise<EvaluationView>;
|
|
384
|
+
};
|
|
385
|
+
tasks: {
|
|
386
|
+
list: (rater?: string) => Promise<{
|
|
387
|
+
data: Array<{
|
|
388
|
+
evaluationId: string;
|
|
389
|
+
criterionId: string;
|
|
390
|
+
raterId?: string;
|
|
391
|
+
allowedRaters?: string[];
|
|
392
|
+
instructions?: string;
|
|
393
|
+
rubric: string;
|
|
394
|
+
subject?: string;
|
|
395
|
+
}>;
|
|
396
|
+
}>;
|
|
397
|
+
};
|
|
398
|
+
batches: {
|
|
399
|
+
create: (params: BatchParams, opts?: {
|
|
400
|
+
idempotencyKey?: string;
|
|
401
|
+
}) => Promise<BatchResult>;
|
|
402
|
+
createIdempotent: (params: BatchParams, key: string) => Promise<{
|
|
403
|
+
replayed: boolean;
|
|
404
|
+
ranking: Array<{
|
|
405
|
+
rank: number;
|
|
406
|
+
evaluationId: string;
|
|
407
|
+
subject: string;
|
|
408
|
+
score?: number;
|
|
409
|
+
grade?: string;
|
|
410
|
+
passed?: boolean;
|
|
411
|
+
status: string;
|
|
412
|
+
}>;
|
|
413
|
+
evaluations: EvaluationView[];
|
|
414
|
+
}>;
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
export default Verdict;
|
|
418
|
+
export interface BatchParams {
|
|
419
|
+
rubric: string | RubricInput;
|
|
420
|
+
subjects: Subject[];
|
|
421
|
+
metadata?: Record<string, unknown>;
|
|
422
|
+
webhook?: string;
|
|
423
|
+
}
|
|
424
|
+
export interface BatchResult {
|
|
425
|
+
ranking: Array<{
|
|
426
|
+
rank: number;
|
|
427
|
+
evaluationId: string;
|
|
428
|
+
subject: string;
|
|
429
|
+
score?: number;
|
|
430
|
+
grade?: string;
|
|
431
|
+
passed?: boolean;
|
|
432
|
+
status: string;
|
|
433
|
+
}>;
|
|
434
|
+
evaluations: EvaluationView[];
|
|
435
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/** Carries transport status, error type and optional API issues for failed client requests. */
|
|
2
|
+
export class VerdictError extends Error {
|
|
3
|
+
status;
|
|
4
|
+
type;
|
|
5
|
+
issues;
|
|
6
|
+
constructor(status, type, message, issues) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.type = type;
|
|
10
|
+
this.issues = issues;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
// why: synchronous judging can be slow; polling uses the same ten-minute default as individual requests.
|
|
14
|
+
const DEFAULT_TIMEOUT_MS = 600_000;
|
|
15
|
+
const DEFAULT_POLL_INTERVAL_MS = 1500;
|
|
16
|
+
/**
|
|
17
|
+
* Verdict client — mirrors the REST API 1:1.
|
|
18
|
+
*
|
|
19
|
+
* const verdict = new Verdict({ apiKey: "sk_..." });
|
|
20
|
+
* const ev = await verdict.evaluations.create({ rubric: "rub_123", inputs: [{ type: "url", url: "https://..." }] });
|
|
21
|
+
* console.log(ev.aggregate.score, ev.aggregate.grade);
|
|
22
|
+
*/
|
|
23
|
+
export class Verdict {
|
|
24
|
+
apiKey;
|
|
25
|
+
baseUrl;
|
|
26
|
+
f;
|
|
27
|
+
timeoutMs;
|
|
28
|
+
constructor(opts = {}) {
|
|
29
|
+
this.apiKey = opts.apiKey ?? globalThis.process?.env?.VERDICT_API_KEY;
|
|
30
|
+
this.baseUrl = (opts.baseUrl ?? globalThis.process?.env?.VERDICT_API_URL ?? "http://localhost:8787").replace(/\/$/, "");
|
|
31
|
+
this.f = opts.fetch ?? ((input, init) => globalThis.fetch(input, init)); // bound call: Workers reject a detached fetch
|
|
32
|
+
this.timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
33
|
+
}
|
|
34
|
+
async request(method, path, body, contentType = "application/json", headers) {
|
|
35
|
+
return (await this.requestWithMeta(method, path, body, contentType, headers)).data;
|
|
36
|
+
}
|
|
37
|
+
async requestWithMeta(method, path, body, contentType = "application/json", headers) {
|
|
38
|
+
const ctrl = new AbortController();
|
|
39
|
+
const t = setTimeout(() => ctrl.abort(), this.timeoutMs);
|
|
40
|
+
try {
|
|
41
|
+
const res = await this.f(`${this.baseUrl}${path}`, {
|
|
42
|
+
method,
|
|
43
|
+
signal: ctrl.signal,
|
|
44
|
+
headers: { "content-type": contentType, ...(this.apiKey ? { authorization: `Bearer ${this.apiKey}` } : {}), ...headers },
|
|
45
|
+
body: body === undefined ? undefined : typeof body === "string" ? body : JSON.stringify(body),
|
|
46
|
+
});
|
|
47
|
+
// why: successful deletes have no JSON body to decode.
|
|
48
|
+
if (res.status === 204)
|
|
49
|
+
return { data: undefined, replayed: res.headers.get("Idempotency-Replayed") === "true" };
|
|
50
|
+
const data = await responseBody(res);
|
|
51
|
+
const error = apiError(data);
|
|
52
|
+
// The API returns failed evaluations with 422; these documents remain readable client results.
|
|
53
|
+
if (!res.ok && !(res.status === 422 && !error))
|
|
54
|
+
throw new VerdictError(res.status, error?.type ?? "http", error?.message ?? `HTTP ${res.status}`, error?.issues);
|
|
55
|
+
return { data: data, replayed: res.headers.get("Idempotency-Replayed") === "true" };
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof VerdictError)
|
|
59
|
+
throw error;
|
|
60
|
+
throw new VerdictError(0, "network", `Verdict request failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
clearTimeout(t);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
rubrics = {
|
|
67
|
+
calibration: (id, options = {}) => this.request("GET", `/v1/rubrics/${encodeURIComponent(id)}/calibration?${new URLSearchParams(Object.entries(options).filter(([, v]) => v !== undefined).map(([k, v]) => [k, String(v)]))}`),
|
|
68
|
+
create: (rubric) => typeof rubric === "string" ? this.request("POST", "/v1/rubrics", rubric, "application/yaml") : this.request("POST", "/v1/rubrics", rubric),
|
|
69
|
+
validate: (rubric) => this.request("POST", "/v1/rubrics/validate", rubric, typeof rubric === "string" ? "application/yaml" : "application/json"),
|
|
70
|
+
get: (id) => this.request("GET", `/v1/rubrics/${id}`),
|
|
71
|
+
list: () => this.request("GET", "/v1/rubrics"),
|
|
72
|
+
update: (id, rubric) => this.request("PUT", `/v1/rubrics/${id}`, rubric),
|
|
73
|
+
delete: (id) => this.request("DELETE", `/v1/rubrics/${id}`),
|
|
74
|
+
};
|
|
75
|
+
evaluations = {
|
|
76
|
+
retry: (id) => this.request("POST", `/v1/evaluations/${encodeURIComponent(id)}/retry`),
|
|
77
|
+
create: (params, opts = {}) => this.request("POST", "/v1/evaluations", params, "application/json", keyHeaders(opts.idempotencyKey)),
|
|
78
|
+
createIdempotent: async (params, key) => {
|
|
79
|
+
const { data: evaluation, replayed } = await this.requestWithMeta("POST", "/v1/evaluations", params, "application/json", keyHeaders(key));
|
|
80
|
+
return { evaluation, replayed };
|
|
81
|
+
},
|
|
82
|
+
/** Returns {id,status:"queued"}; poll with `get`, or use a webhook. */
|
|
83
|
+
createAsync: (params, opts = {}) => this.request("POST", "/v1/evaluations", { ...params, async: true }, "application/json", keyHeaders(opts.idempotencyKey)),
|
|
84
|
+
get: (id, opts = {}) => this.request("GET", `/v1/evaluations/${id}${opts.evidence ? "?evidence=true" : ""}`),
|
|
85
|
+
list: (q = {}) => this.request("GET", `/v1/evaluations?${new URLSearchParams(Object.entries(q).filter(([, v]) => v !== undefined).map(([k, v]) => [k, String(v)]))}`),
|
|
86
|
+
submitScore: (id, s) => this.request("POST", `/v1/evaluations/${id}/scores`, s),
|
|
87
|
+
reaggregate: (id, aggregation, persist = false) => this.request("POST", `/v1/evaluations/${id}/aggregate`, { aggregation, persist }),
|
|
88
|
+
/** Poll until the evaluation leaves running/queued (does not wait for humans unless `waitForHumans`). */
|
|
89
|
+
wait: async (id, opts = {}) => {
|
|
90
|
+
const start = Date.now();
|
|
91
|
+
for (;;) {
|
|
92
|
+
const ev = await this.evaluations.get(id);
|
|
93
|
+
// why: human review can be unbounded, so polling stops at that state unless explicitly requested.
|
|
94
|
+
const settled = ev.status === "completed" || ev.status === "failed" || (ev.status === "pending_human" && !opts.waitForHumans);
|
|
95
|
+
if (settled)
|
|
96
|
+
return ev;
|
|
97
|
+
if (Date.now() - start > (opts.timeoutMs ?? DEFAULT_TIMEOUT_MS))
|
|
98
|
+
throw new VerdictError(408, "timeout", `evaluation ${id} still ${ev.status}`);
|
|
99
|
+
await new Promise((r) => setTimeout(r, opts.intervalMs ?? DEFAULT_POLL_INTERVAL_MS));
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
tasks = {
|
|
104
|
+
list: (rater) => this.request("GET", `/v1/tasks${rater ? `?rater=${encodeURIComponent(rater)}` : ""}`),
|
|
105
|
+
};
|
|
106
|
+
batches = {
|
|
107
|
+
create: (params, opts = {}) => this.request("POST", "/v1/batches", params, "application/json", keyHeaders(opts.idempotencyKey)),
|
|
108
|
+
createIdempotent: async (params, key) => {
|
|
109
|
+
const { data, replayed } = await this.requestWithMeta("POST", "/v1/batches", params, "application/json", keyHeaders(key));
|
|
110
|
+
return { ...data, replayed };
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export default Verdict;
|
|
115
|
+
function keyHeaders(key) { return key === undefined ? {} : { "Idempotency-Key": key }; }
|
|
116
|
+
async function responseBody(response) {
|
|
117
|
+
try {
|
|
118
|
+
return await response.json();
|
|
119
|
+
}
|
|
120
|
+
catch (cause) {
|
|
121
|
+
const type = response.ok ? "invalid_response" : "http";
|
|
122
|
+
throw new VerdictError(response.status, type, response.ok ? "Verdict returned invalid JSON" : `HTTP ${response.status}`, { cause: cause instanceof Error ? cause.message : String(cause) });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function apiError(data) {
|
|
126
|
+
if (!data || typeof data !== "object" || !("error" in data))
|
|
127
|
+
return undefined;
|
|
128
|
+
const error = data.error;
|
|
129
|
+
if (!error || typeof error !== "object" || !("type" in error) || !("message" in error))
|
|
130
|
+
return undefined;
|
|
131
|
+
if (typeof error.type !== "string" || typeof error.message !== "string")
|
|
132
|
+
return undefined;
|
|
133
|
+
return { type: error.type, message: error.message, issues: "issues" in error ? error.issues : undefined };
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,+FAA+F;AAC/F,MAAM,OAAO,YAAa,SAAQ,KAAK;IAClB;IAAuB;IAAsC;IAAhF,YAAmB,MAAc,EAAS,IAAY,EAAE,OAAe,EAAS,MAAgB;QAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAAhG,WAAM,GAAN,MAAM,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAQ;QAA0B,WAAM,GAAN,MAAM,CAAU;IAAoB,CAAC;CACtH;AAiBD,yGAAyG;AACzG,MAAM,kBAAkB,GAAG,OAAO,CAAC;AACnC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,OAAO,OAAO;IACV,MAAM,CAAU;IAChB,OAAO,CAAS;IAChB,CAAC,CAAe;IAChB,SAAS,CAAS;IAE1B,YAAY,OAAuB,EAAE;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI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O,KAAK,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC1F,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AAC5G,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdict-ai/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Verdict TypeScript SDK — a Resend-style client for the evaluation API.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@verdict-ai/core": "0.1.0"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/Ustay-coder/verdict.git",
|
|
21
|
+
"directory": "packages/sdk"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/Ustay-coder/verdict#readme",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/Ustay-coder/verdict/issues"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"evaluation",
|
|
29
|
+
"rubric",
|
|
30
|
+
"decision-model",
|
|
31
|
+
"jev",
|
|
32
|
+
"clef",
|
|
33
|
+
"scoring",
|
|
34
|
+
"llm-judge",
|
|
35
|
+
"mcp"
|
|
36
|
+
],
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"README.md",
|
|
46
|
+
"LICENSE"
|
|
47
|
+
],
|
|
48
|
+
"sideEffects": false,
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -p tsconfig.json",
|
|
51
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
52
|
+
"test": "vitest run --passWithNoTests"
|
|
53
|
+
}
|
|
6
54
|
}
|