peerbench 0.0.1 → 0.0.2-alpha-dev.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 +332 -2
- package/dist/abstract-Dec9Sc5O.d.ts +12 -0
- package/dist/aggregators/index.d.ts +67 -0
- package/dist/aggregators/index.js +46 -0
- package/dist/aggregators/index.js.map +1 -0
- package/dist/benchmarks/index.d.ts +1041 -0
- package/dist/benchmarks/index.js +458 -0
- package/dist/benchmarks/index.js.map +1 -0
- package/dist/chunk-4UBK6452.js +128 -0
- package/dist/chunk-4UBK6452.js.map +1 -0
- package/dist/chunk-ERALDEZY.js +112 -0
- package/dist/chunk-ERALDEZY.js.map +1 -0
- package/dist/chunk-HMQYGCKI.js +11 -0
- package/dist/chunk-HMQYGCKI.js.map +1 -0
- package/dist/chunk-NUEOE3K5.js +8 -0
- package/dist/chunk-NUEOE3K5.js.map +1 -0
- package/dist/chunk-OQE6TQXZ.js +42 -0
- package/dist/chunk-OQE6TQXZ.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-Q6GSOHOP.js +44 -0
- package/dist/chunk-Q6GSOHOP.js.map +1 -0
- package/dist/chunk-QY5MPNNB.js +28 -0
- package/dist/chunk-QY5MPNNB.js.map +1 -0
- package/dist/chunk-R76XA2K6.js +229 -0
- package/dist/chunk-R76XA2K6.js.map +1 -0
- package/dist/chunk-TRNCF2BG.js +35 -0
- package/dist/chunk-TRNCF2BG.js.map +1 -0
- package/dist/chunk-UHHHSYVE.js +11 -0
- package/dist/chunk-UHHHSYVE.js.map +1 -0
- package/dist/chunk-YY33MNMV.js +65 -0
- package/dist/chunk-YY33MNMV.js.map +1 -0
- package/dist/chunk-ZEWI24CV.js +365 -0
- package/dist/chunk-ZEWI24CV.js.map +1 -0
- package/dist/index-BAioQhp2.d.ts +27 -0
- package/dist/index.d.ts +59 -3841
- package/dist/index.js +31 -3545
- package/dist/index.js.map +1 -1
- package/dist/json-file-ZwzLUbje.d.ts +73 -0
- package/dist/llm-DNj_tp2T.d.ts +22 -0
- package/dist/llm-judge-QThCZ9TQ.d.ts +67 -0
- package/dist/provider-BDjGp2y-.d.ts +10 -0
- package/dist/providers/index.d.ts +69 -0
- package/dist/providers/index.js +18 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/rate-limiter-CSmVIRsM.d.ts +60 -0
- package/dist/schemas/extensions/index.d.ts +28 -0
- package/dist/schemas/extensions/index.js +19 -0
- package/dist/schemas/extensions/index.js.map +1 -0
- package/dist/schemas/index.d.ts +200 -0
- package/dist/schemas/index.js +24 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/llm/index.d.ts +116 -0
- package/dist/schemas/llm/index.js +15 -0
- package/dist/schemas/llm/index.js.map +1 -0
- package/dist/scorers/index.d.ts +64 -0
- package/dist/scorers/index.js +16 -0
- package/dist/scorers/index.js.map +1 -0
- package/dist/storages/index.d.ts +69 -0
- package/dist/storages/index.js +98 -0
- package/dist/storages/index.js.map +1 -0
- package/package.json +46 -22
- package/LICENSE +0 -21
package/dist/index.d.ts
CHANGED
|
@@ -1,3864 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { CID } from 'multiformats/cid';
|
|
1
|
+
import { I as IdGenerator, P as ProviderCtor, S as ScorerCtor } from './index-BAioQhp2.js';
|
|
2
|
+
export { A as AbstractClassConstructor, C as ClassConstructor, b as Id, a as InferExtension, M as MaybePromise, c as ScoringMethod, W as WidenZodObject } from './index-BAioQhp2.js';
|
|
3
|
+
export { R as RateLimiter, b as RateLimiterCallOptions, a as RateLimiterOptions } from './rate-limiter-CSmVIRsM.js';
|
|
4
|
+
import z__default from 'zod';
|
|
5
|
+
import { A as AbstractProvider } from './provider-BDjGp2y-.js';
|
|
6
|
+
import { A as AbstractScorer } from './abstract-Dec9Sc5O.js';
|
|
8
7
|
|
|
9
|
-
declare
|
|
10
|
-
readonly MultipleChoice: "multiple-choice";
|
|
11
|
-
readonly OrderSentences: "order-sentences";
|
|
12
|
-
readonly TextReplacement: "text-replacement";
|
|
13
|
-
readonly Typo: "typo";
|
|
14
|
-
readonly OpenEnded: "open-ended";
|
|
15
|
-
readonly OpenEndedWithDocs: "open-ended-with-docs";
|
|
16
|
-
};
|
|
17
|
-
type PromptType = (typeof PromptTypes)[keyof typeof PromptTypes];
|
|
18
|
-
declare const ScoringMethods: {
|
|
19
|
-
/**
|
|
20
|
-
* Scored by a human
|
|
21
|
-
*/
|
|
22
|
-
readonly human: "human";
|
|
23
|
-
/**
|
|
24
|
-
* Scored using an AI model
|
|
25
|
-
*/
|
|
26
|
-
readonly ai: "ai";
|
|
27
|
-
/**
|
|
28
|
-
* Scored using an algorithm
|
|
29
|
-
*/
|
|
30
|
-
readonly algo: "algo";
|
|
31
|
-
};
|
|
32
|
-
type ScoringMethod = (typeof ScoringMethods)[keyof typeof ScoringMethods];
|
|
33
|
-
declare const PromptSchema: z.ZodEffects<z.ZodObject<{
|
|
34
|
-
/**
|
|
35
|
-
* Decentralized identifier of the Prompt
|
|
36
|
-
*/
|
|
37
|
-
did: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodType<string, z.ZodTypeDef, string>>;
|
|
38
|
-
/**
|
|
39
|
-
* The question that is going to be asked to the model
|
|
40
|
-
*/
|
|
41
|
-
question: z.ZodObject<{
|
|
42
|
-
/**
|
|
43
|
-
* Question data itself
|
|
44
|
-
*/
|
|
45
|
-
data: z.ZodString;
|
|
46
|
-
/**
|
|
47
|
-
* CID v1 calculation of the question string
|
|
48
|
-
*/
|
|
49
|
-
cid: z.ZodString;
|
|
50
|
-
/**
|
|
51
|
-
* SHA256 hash of the question string
|
|
52
|
-
*/
|
|
53
|
-
sha256: z.ZodString;
|
|
54
|
-
}, "strip", z.ZodTypeAny, {
|
|
55
|
-
sha256: string;
|
|
56
|
-
data: string;
|
|
57
|
-
cid: string;
|
|
58
|
-
}, {
|
|
59
|
-
sha256: string;
|
|
60
|
-
data: string;
|
|
61
|
-
cid: string;
|
|
62
|
-
}>;
|
|
63
|
-
/**
|
|
64
|
-
* Multiple choice answers for the question where the keys are letters and the values are the answers.
|
|
65
|
-
*/
|
|
66
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
67
|
-
/**
|
|
68
|
-
* Full prompt that is going to be sent to the model
|
|
69
|
-
*/
|
|
70
|
-
fullPrompt: z.ZodObject<{
|
|
71
|
-
/**
|
|
72
|
-
* Full prompt itself
|
|
73
|
-
*/
|
|
74
|
-
data: z.ZodString;
|
|
75
|
-
/**
|
|
76
|
-
* CID v1 calculation of the full prompt string
|
|
77
|
-
*/
|
|
78
|
-
cid: z.ZodString;
|
|
79
|
-
/**
|
|
80
|
-
* SHA256 hash of the full prompt string
|
|
81
|
-
*/
|
|
82
|
-
sha256: z.ZodString;
|
|
83
|
-
}, "strip", z.ZodTypeAny, {
|
|
84
|
-
sha256: string;
|
|
85
|
-
data: string;
|
|
86
|
-
cid: string;
|
|
87
|
-
}, {
|
|
88
|
-
sha256: string;
|
|
89
|
-
data: string;
|
|
90
|
-
cid: string;
|
|
91
|
-
}>;
|
|
92
|
-
/**
|
|
93
|
-
* Type of the Prompt
|
|
94
|
-
*/
|
|
95
|
-
type: z.ZodNativeEnum<{
|
|
96
|
-
readonly MultipleChoice: "multiple-choice";
|
|
97
|
-
readonly OrderSentences: "order-sentences";
|
|
98
|
-
readonly TextReplacement: "text-replacement";
|
|
99
|
-
readonly Typo: "typo";
|
|
100
|
-
readonly OpenEnded: "open-ended";
|
|
101
|
-
readonly OpenEndedWithDocs: "open-ended-with-docs";
|
|
102
|
-
}>;
|
|
103
|
-
/**
|
|
104
|
-
* Expected option value for the question
|
|
105
|
-
*/
|
|
106
|
-
answer: z.ZodOptional<z.ZodString>;
|
|
107
|
-
/**
|
|
108
|
-
* Expected letter of the answer (e.g "A", "B" or "C")
|
|
109
|
-
*/
|
|
110
|
-
answerKey: z.ZodOptional<z.ZodString>;
|
|
111
|
-
/**
|
|
112
|
-
* Additional metadata related to the Prompt
|
|
113
|
-
*/
|
|
114
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
115
|
-
/**
|
|
116
|
-
* Expected Scorer identifiers that can be used to
|
|
117
|
-
* score the Responses for this Prompt
|
|
118
|
-
*/
|
|
119
|
-
scorers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
120
|
-
}, "strip", z.ZodTypeAny, {
|
|
121
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
122
|
-
did: string;
|
|
123
|
-
question: {
|
|
124
|
-
sha256: string;
|
|
125
|
-
data: string;
|
|
126
|
-
cid: string;
|
|
127
|
-
};
|
|
128
|
-
fullPrompt: {
|
|
129
|
-
sha256: string;
|
|
130
|
-
data: string;
|
|
131
|
-
cid: string;
|
|
132
|
-
};
|
|
133
|
-
answer?: string | undefined;
|
|
134
|
-
metadata?: Record<string, any> | undefined;
|
|
135
|
-
options?: Record<string, string> | undefined;
|
|
136
|
-
answerKey?: string | undefined;
|
|
137
|
-
scorers?: string[] | undefined;
|
|
138
|
-
}, {
|
|
139
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
140
|
-
did: string;
|
|
141
|
-
question: {
|
|
142
|
-
sha256: string;
|
|
143
|
-
data: string;
|
|
144
|
-
cid: string;
|
|
145
|
-
};
|
|
146
|
-
fullPrompt: {
|
|
147
|
-
sha256: string;
|
|
148
|
-
data: string;
|
|
149
|
-
cid: string;
|
|
150
|
-
};
|
|
151
|
-
answer?: string | undefined;
|
|
152
|
-
metadata?: Record<string, any> | undefined;
|
|
153
|
-
options?: Record<string, string> | undefined;
|
|
154
|
-
answerKey?: string | undefined;
|
|
155
|
-
scorers?: string[] | undefined;
|
|
156
|
-
}>, {
|
|
157
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
158
|
-
did: string;
|
|
159
|
-
question: {
|
|
160
|
-
sha256: string;
|
|
161
|
-
data: string;
|
|
162
|
-
cid: string;
|
|
163
|
-
};
|
|
164
|
-
fullPrompt: {
|
|
165
|
-
sha256: string;
|
|
166
|
-
data: string;
|
|
167
|
-
cid: string;
|
|
168
|
-
};
|
|
169
|
-
answer?: string | undefined;
|
|
170
|
-
metadata?: Record<string, any> | undefined;
|
|
171
|
-
options?: Record<string, string> | undefined;
|
|
172
|
-
answerKey?: string | undefined;
|
|
173
|
-
scorers?: string[] | undefined;
|
|
174
|
-
}, {
|
|
175
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
176
|
-
did: string;
|
|
177
|
-
question: {
|
|
178
|
-
sha256: string;
|
|
179
|
-
data: string;
|
|
180
|
-
cid: string;
|
|
181
|
-
};
|
|
182
|
-
fullPrompt: {
|
|
183
|
-
sha256: string;
|
|
184
|
-
data: string;
|
|
185
|
-
cid: string;
|
|
186
|
-
};
|
|
187
|
-
answer?: string | undefined;
|
|
188
|
-
metadata?: Record<string, any> | undefined;
|
|
189
|
-
options?: Record<string, string> | undefined;
|
|
190
|
-
answerKey?: string | undefined;
|
|
191
|
-
scorers?: string[] | undefined;
|
|
192
|
-
}>;
|
|
193
|
-
/**
|
|
194
|
-
* PeerBench Prompt object
|
|
195
|
-
*/
|
|
196
|
-
type Prompt = z.infer<typeof PromptSchema>;
|
|
197
|
-
declare const TaskSchema: z.ZodObject<{
|
|
198
|
-
/**
|
|
199
|
-
* Decentralized identifier of the Task
|
|
200
|
-
*/
|
|
201
|
-
did: z.ZodString;
|
|
202
|
-
/**
|
|
203
|
-
* The Prompts that the Task has
|
|
204
|
-
*/
|
|
205
|
-
prompts: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
206
|
-
/**
|
|
207
|
-
* Decentralized identifier of the Prompt
|
|
208
|
-
*/
|
|
209
|
-
did: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodType<string, z.ZodTypeDef, string>>;
|
|
210
|
-
/**
|
|
211
|
-
* The question that is going to be asked to the model
|
|
212
|
-
*/
|
|
213
|
-
question: z.ZodObject<{
|
|
214
|
-
/**
|
|
215
|
-
* Question data itself
|
|
216
|
-
*/
|
|
217
|
-
data: z.ZodString;
|
|
218
|
-
/**
|
|
219
|
-
* CID v1 calculation of the question string
|
|
220
|
-
*/
|
|
221
|
-
cid: z.ZodString;
|
|
222
|
-
/**
|
|
223
|
-
* SHA256 hash of the question string
|
|
224
|
-
*/
|
|
225
|
-
sha256: z.ZodString;
|
|
226
|
-
}, "strip", z.ZodTypeAny, {
|
|
227
|
-
sha256: string;
|
|
228
|
-
data: string;
|
|
229
|
-
cid: string;
|
|
230
|
-
}, {
|
|
231
|
-
sha256: string;
|
|
232
|
-
data: string;
|
|
233
|
-
cid: string;
|
|
234
|
-
}>;
|
|
235
|
-
/**
|
|
236
|
-
* Multiple choice answers for the question where the keys are letters and the values are the answers.
|
|
237
|
-
*/
|
|
238
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
239
|
-
/**
|
|
240
|
-
* Full prompt that is going to be sent to the model
|
|
241
|
-
*/
|
|
242
|
-
fullPrompt: z.ZodObject<{
|
|
243
|
-
/**
|
|
244
|
-
* Full prompt itself
|
|
245
|
-
*/
|
|
246
|
-
data: z.ZodString;
|
|
247
|
-
/**
|
|
248
|
-
* CID v1 calculation of the full prompt string
|
|
249
|
-
*/
|
|
250
|
-
cid: z.ZodString;
|
|
251
|
-
/**
|
|
252
|
-
* SHA256 hash of the full prompt string
|
|
253
|
-
*/
|
|
254
|
-
sha256: z.ZodString;
|
|
255
|
-
}, "strip", z.ZodTypeAny, {
|
|
256
|
-
sha256: string;
|
|
257
|
-
data: string;
|
|
258
|
-
cid: string;
|
|
259
|
-
}, {
|
|
260
|
-
sha256: string;
|
|
261
|
-
data: string;
|
|
262
|
-
cid: string;
|
|
263
|
-
}>;
|
|
264
|
-
/**
|
|
265
|
-
* Type of the Prompt
|
|
266
|
-
*/
|
|
267
|
-
type: z.ZodNativeEnum<{
|
|
268
|
-
readonly MultipleChoice: "multiple-choice";
|
|
269
|
-
readonly OrderSentences: "order-sentences";
|
|
270
|
-
readonly TextReplacement: "text-replacement";
|
|
271
|
-
readonly Typo: "typo";
|
|
272
|
-
readonly OpenEnded: "open-ended";
|
|
273
|
-
readonly OpenEndedWithDocs: "open-ended-with-docs";
|
|
274
|
-
}>;
|
|
275
|
-
/**
|
|
276
|
-
* Expected option value for the question
|
|
277
|
-
*/
|
|
278
|
-
answer: z.ZodOptional<z.ZodString>;
|
|
279
|
-
/**
|
|
280
|
-
* Expected letter of the answer (e.g "A", "B" or "C")
|
|
281
|
-
*/
|
|
282
|
-
answerKey: z.ZodOptional<z.ZodString>;
|
|
283
|
-
/**
|
|
284
|
-
* Additional metadata related to the Prompt
|
|
285
|
-
*/
|
|
286
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
287
|
-
/**
|
|
288
|
-
* Expected Scorer identifiers that can be used to
|
|
289
|
-
* score the Responses for this Prompt
|
|
290
|
-
*/
|
|
291
|
-
scorers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
292
|
-
}, "strip", z.ZodTypeAny, {
|
|
293
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
294
|
-
did: string;
|
|
295
|
-
question: {
|
|
296
|
-
sha256: string;
|
|
297
|
-
data: string;
|
|
298
|
-
cid: string;
|
|
299
|
-
};
|
|
300
|
-
fullPrompt: {
|
|
301
|
-
sha256: string;
|
|
302
|
-
data: string;
|
|
303
|
-
cid: string;
|
|
304
|
-
};
|
|
305
|
-
answer?: string | undefined;
|
|
306
|
-
metadata?: Record<string, any> | undefined;
|
|
307
|
-
options?: Record<string, string> | undefined;
|
|
308
|
-
answerKey?: string | undefined;
|
|
309
|
-
scorers?: string[] | undefined;
|
|
310
|
-
}, {
|
|
311
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
312
|
-
did: string;
|
|
313
|
-
question: {
|
|
314
|
-
sha256: string;
|
|
315
|
-
data: string;
|
|
316
|
-
cid: string;
|
|
317
|
-
};
|
|
318
|
-
fullPrompt: {
|
|
319
|
-
sha256: string;
|
|
320
|
-
data: string;
|
|
321
|
-
cid: string;
|
|
322
|
-
};
|
|
323
|
-
answer?: string | undefined;
|
|
324
|
-
metadata?: Record<string, any> | undefined;
|
|
325
|
-
options?: Record<string, string> | undefined;
|
|
326
|
-
answerKey?: string | undefined;
|
|
327
|
-
scorers?: string[] | undefined;
|
|
328
|
-
}>, {
|
|
329
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
330
|
-
did: string;
|
|
331
|
-
question: {
|
|
332
|
-
sha256: string;
|
|
333
|
-
data: string;
|
|
334
|
-
cid: string;
|
|
335
|
-
};
|
|
336
|
-
fullPrompt: {
|
|
337
|
-
sha256: string;
|
|
338
|
-
data: string;
|
|
339
|
-
cid: string;
|
|
340
|
-
};
|
|
341
|
-
answer?: string | undefined;
|
|
342
|
-
metadata?: Record<string, any> | undefined;
|
|
343
|
-
options?: Record<string, string> | undefined;
|
|
344
|
-
answerKey?: string | undefined;
|
|
345
|
-
scorers?: string[] | undefined;
|
|
346
|
-
}, {
|
|
347
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
348
|
-
did: string;
|
|
349
|
-
question: {
|
|
350
|
-
sha256: string;
|
|
351
|
-
data: string;
|
|
352
|
-
cid: string;
|
|
353
|
-
};
|
|
354
|
-
fullPrompt: {
|
|
355
|
-
sha256: string;
|
|
356
|
-
data: string;
|
|
357
|
-
cid: string;
|
|
358
|
-
};
|
|
359
|
-
answer?: string | undefined;
|
|
360
|
-
metadata?: Record<string, any> | undefined;
|
|
361
|
-
options?: Record<string, string> | undefined;
|
|
362
|
-
answerKey?: string | undefined;
|
|
363
|
-
scorers?: string[] | undefined;
|
|
364
|
-
}>, "many">;
|
|
365
|
-
/**
|
|
366
|
-
* CID v1 calculation of the Task file
|
|
367
|
-
*/
|
|
368
|
-
cid: z.ZodString;
|
|
369
|
-
/**
|
|
370
|
-
* SHA256 calculation of the Task file
|
|
371
|
-
*/
|
|
372
|
-
sha256: z.ZodString;
|
|
373
|
-
/**
|
|
374
|
-
* Basename of the Task file
|
|
375
|
-
*/
|
|
376
|
-
fileName: z.ZodString;
|
|
377
|
-
/**
|
|
378
|
-
* Full path of the Task file
|
|
379
|
-
*/
|
|
380
|
-
path: z.ZodString;
|
|
381
|
-
}, "strip", z.ZodTypeAny, {
|
|
382
|
-
sha256: string;
|
|
383
|
-
path: string;
|
|
384
|
-
did: string;
|
|
385
|
-
cid: string;
|
|
386
|
-
prompts: {
|
|
387
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
388
|
-
did: string;
|
|
389
|
-
question: {
|
|
390
|
-
sha256: string;
|
|
391
|
-
data: string;
|
|
392
|
-
cid: string;
|
|
393
|
-
};
|
|
394
|
-
fullPrompt: {
|
|
395
|
-
sha256: string;
|
|
396
|
-
data: string;
|
|
397
|
-
cid: string;
|
|
398
|
-
};
|
|
399
|
-
answer?: string | undefined;
|
|
400
|
-
metadata?: Record<string, any> | undefined;
|
|
401
|
-
options?: Record<string, string> | undefined;
|
|
402
|
-
answerKey?: string | undefined;
|
|
403
|
-
scorers?: string[] | undefined;
|
|
404
|
-
}[];
|
|
405
|
-
fileName: string;
|
|
406
|
-
}, {
|
|
407
|
-
sha256: string;
|
|
408
|
-
path: string;
|
|
409
|
-
did: string;
|
|
410
|
-
cid: string;
|
|
411
|
-
prompts: {
|
|
412
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
413
|
-
did: string;
|
|
414
|
-
question: {
|
|
415
|
-
sha256: string;
|
|
416
|
-
data: string;
|
|
417
|
-
cid: string;
|
|
418
|
-
};
|
|
419
|
-
fullPrompt: {
|
|
420
|
-
sha256: string;
|
|
421
|
-
data: string;
|
|
422
|
-
cid: string;
|
|
423
|
-
};
|
|
424
|
-
answer?: string | undefined;
|
|
425
|
-
metadata?: Record<string, any> | undefined;
|
|
426
|
-
options?: Record<string, string> | undefined;
|
|
427
|
-
answerKey?: string | undefined;
|
|
428
|
-
scorers?: string[] | undefined;
|
|
429
|
-
}[];
|
|
430
|
-
fileName: string;
|
|
431
|
-
}>;
|
|
432
|
-
/**
|
|
433
|
-
* Task object that includes the prompts and the Task file metadata
|
|
434
|
-
*/
|
|
435
|
-
type Task = z.infer<typeof TaskSchema>;
|
|
436
|
-
declare const PromptResponseSchema: z.ZodObject<{
|
|
437
|
-
/**
|
|
438
|
-
* Unique identifier of the Response
|
|
439
|
-
*/
|
|
440
|
-
did: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodType<string, z.ZodTypeDef, string>>;
|
|
441
|
-
/**
|
|
442
|
-
* Name of the Provider that the Response comes from
|
|
443
|
-
*/
|
|
444
|
-
provider: z.ZodString;
|
|
445
|
-
/**
|
|
446
|
-
* ID of the Model that was used by the Provider
|
|
447
|
-
*/
|
|
448
|
-
modelId: z.ZodString;
|
|
449
|
-
/**
|
|
450
|
-
* Known name of the model by peerBench
|
|
451
|
-
*/
|
|
452
|
-
modelName: z.ZodString;
|
|
453
|
-
/**
|
|
454
|
-
* Owner of the model
|
|
455
|
-
*/
|
|
456
|
-
modelOwner: z.ZodString;
|
|
457
|
-
/**
|
|
458
|
-
* The entity that responsible for hosting the model
|
|
459
|
-
*/
|
|
460
|
-
modelHost: z.ZodString;
|
|
461
|
-
/**
|
|
462
|
-
* The Prompt that used to achieve this Response.
|
|
463
|
-
*/
|
|
464
|
-
prompt: z.ZodEffects<z.ZodObject<{
|
|
465
|
-
/**
|
|
466
|
-
* Decentralized identifier of the Prompt
|
|
467
|
-
*/
|
|
468
|
-
did: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodType<string, z.ZodTypeDef, string>>;
|
|
469
|
-
/**
|
|
470
|
-
* The question that is going to be asked to the model
|
|
471
|
-
*/
|
|
472
|
-
question: z.ZodObject<{
|
|
473
|
-
/**
|
|
474
|
-
* Question data itself
|
|
475
|
-
*/
|
|
476
|
-
data: z.ZodString;
|
|
477
|
-
/**
|
|
478
|
-
* CID v1 calculation of the question string
|
|
479
|
-
*/
|
|
480
|
-
cid: z.ZodString;
|
|
481
|
-
/**
|
|
482
|
-
* SHA256 hash of the question string
|
|
483
|
-
*/
|
|
484
|
-
sha256: z.ZodString;
|
|
485
|
-
}, "strip", z.ZodTypeAny, {
|
|
486
|
-
sha256: string;
|
|
487
|
-
data: string;
|
|
488
|
-
cid: string;
|
|
489
|
-
}, {
|
|
490
|
-
sha256: string;
|
|
491
|
-
data: string;
|
|
492
|
-
cid: string;
|
|
493
|
-
}>;
|
|
494
|
-
/**
|
|
495
|
-
* Multiple choice answers for the question where the keys are letters and the values are the answers.
|
|
496
|
-
*/
|
|
497
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
498
|
-
/**
|
|
499
|
-
* Full prompt that is going to be sent to the model
|
|
500
|
-
*/
|
|
501
|
-
fullPrompt: z.ZodObject<{
|
|
502
|
-
/**
|
|
503
|
-
* Full prompt itself
|
|
504
|
-
*/
|
|
505
|
-
data: z.ZodString;
|
|
506
|
-
/**
|
|
507
|
-
* CID v1 calculation of the full prompt string
|
|
508
|
-
*/
|
|
509
|
-
cid: z.ZodString;
|
|
510
|
-
/**
|
|
511
|
-
* SHA256 hash of the full prompt string
|
|
512
|
-
*/
|
|
513
|
-
sha256: z.ZodString;
|
|
514
|
-
}, "strip", z.ZodTypeAny, {
|
|
515
|
-
sha256: string;
|
|
516
|
-
data: string;
|
|
517
|
-
cid: string;
|
|
518
|
-
}, {
|
|
519
|
-
sha256: string;
|
|
520
|
-
data: string;
|
|
521
|
-
cid: string;
|
|
522
|
-
}>;
|
|
523
|
-
/**
|
|
524
|
-
* Type of the Prompt
|
|
525
|
-
*/
|
|
526
|
-
type: z.ZodNativeEnum<{
|
|
527
|
-
readonly MultipleChoice: "multiple-choice";
|
|
528
|
-
readonly OrderSentences: "order-sentences";
|
|
529
|
-
readonly TextReplacement: "text-replacement";
|
|
530
|
-
readonly Typo: "typo";
|
|
531
|
-
readonly OpenEnded: "open-ended";
|
|
532
|
-
readonly OpenEndedWithDocs: "open-ended-with-docs";
|
|
533
|
-
}>;
|
|
534
|
-
/**
|
|
535
|
-
* Expected option value for the question
|
|
536
|
-
*/
|
|
537
|
-
answer: z.ZodOptional<z.ZodString>;
|
|
538
|
-
/**
|
|
539
|
-
* Expected letter of the answer (e.g "A", "B" or "C")
|
|
540
|
-
*/
|
|
541
|
-
answerKey: z.ZodOptional<z.ZodString>;
|
|
542
|
-
/**
|
|
543
|
-
* Additional metadata related to the Prompt
|
|
544
|
-
*/
|
|
545
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
546
|
-
/**
|
|
547
|
-
* Expected Scorer identifiers that can be used to
|
|
548
|
-
* score the Responses for this Prompt
|
|
549
|
-
*/
|
|
550
|
-
scorers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
551
|
-
}, "strip", z.ZodTypeAny, {
|
|
552
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
553
|
-
did: string;
|
|
554
|
-
question: {
|
|
555
|
-
sha256: string;
|
|
556
|
-
data: string;
|
|
557
|
-
cid: string;
|
|
558
|
-
};
|
|
559
|
-
fullPrompt: {
|
|
560
|
-
sha256: string;
|
|
561
|
-
data: string;
|
|
562
|
-
cid: string;
|
|
563
|
-
};
|
|
564
|
-
answer?: string | undefined;
|
|
565
|
-
metadata?: Record<string, any> | undefined;
|
|
566
|
-
options?: Record<string, string> | undefined;
|
|
567
|
-
answerKey?: string | undefined;
|
|
568
|
-
scorers?: string[] | undefined;
|
|
569
|
-
}, {
|
|
570
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
571
|
-
did: string;
|
|
572
|
-
question: {
|
|
573
|
-
sha256: string;
|
|
574
|
-
data: string;
|
|
575
|
-
cid: string;
|
|
576
|
-
};
|
|
577
|
-
fullPrompt: {
|
|
578
|
-
sha256: string;
|
|
579
|
-
data: string;
|
|
580
|
-
cid: string;
|
|
581
|
-
};
|
|
582
|
-
answer?: string | undefined;
|
|
583
|
-
metadata?: Record<string, any> | undefined;
|
|
584
|
-
options?: Record<string, string> | undefined;
|
|
585
|
-
answerKey?: string | undefined;
|
|
586
|
-
scorers?: string[] | undefined;
|
|
587
|
-
}>, {
|
|
588
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
589
|
-
did: string;
|
|
590
|
-
question: {
|
|
591
|
-
sha256: string;
|
|
592
|
-
data: string;
|
|
593
|
-
cid: string;
|
|
594
|
-
};
|
|
595
|
-
fullPrompt: {
|
|
596
|
-
sha256: string;
|
|
597
|
-
data: string;
|
|
598
|
-
cid: string;
|
|
599
|
-
};
|
|
600
|
-
answer?: string | undefined;
|
|
601
|
-
metadata?: Record<string, any> | undefined;
|
|
602
|
-
options?: Record<string, string> | undefined;
|
|
603
|
-
answerKey?: string | undefined;
|
|
604
|
-
scorers?: string[] | undefined;
|
|
605
|
-
}, {
|
|
606
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
607
|
-
did: string;
|
|
608
|
-
question: {
|
|
609
|
-
sha256: string;
|
|
610
|
-
data: string;
|
|
611
|
-
cid: string;
|
|
612
|
-
};
|
|
613
|
-
fullPrompt: {
|
|
614
|
-
sha256: string;
|
|
615
|
-
data: string;
|
|
616
|
-
cid: string;
|
|
617
|
-
};
|
|
618
|
-
answer?: string | undefined;
|
|
619
|
-
metadata?: Record<string, any> | undefined;
|
|
620
|
-
options?: Record<string, string> | undefined;
|
|
621
|
-
answerKey?: string | undefined;
|
|
622
|
-
scorers?: string[] | undefined;
|
|
623
|
-
}>;
|
|
624
|
-
/**
|
|
625
|
-
* CID v1 calculation of the Response data.
|
|
626
|
-
*/
|
|
627
|
-
cid: z.ZodString;
|
|
628
|
-
/**
|
|
629
|
-
* SHA256 calculation of the Response data.
|
|
630
|
-
*/
|
|
631
|
-
sha256: z.ZodString;
|
|
632
|
-
/**
|
|
633
|
-
* Response data itself.
|
|
634
|
-
*/
|
|
635
|
-
data: z.ZodString;
|
|
636
|
-
/**
|
|
637
|
-
* Timestamp when the Prompt sent to the Model
|
|
638
|
-
*/
|
|
639
|
-
startedAt: z.ZodNumber;
|
|
640
|
-
/**
|
|
641
|
-
* Timestamp when the Model responded this particular Prompt.
|
|
642
|
-
*/
|
|
643
|
-
finishedAt: z.ZodNumber;
|
|
644
|
-
/**
|
|
645
|
-
* Unique identifier of which run this Response belongs to
|
|
646
|
-
*/
|
|
647
|
-
runId: z.ZodString;
|
|
648
|
-
inputTokensUsed: z.ZodOptional<z.ZodNumber>;
|
|
649
|
-
outputTokensUsed: z.ZodOptional<z.ZodNumber>;
|
|
650
|
-
inputCost: z.ZodOptional<z.ZodString>;
|
|
651
|
-
outputCost: z.ZodOptional<z.ZodString>;
|
|
652
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
653
|
-
}, "strip", z.ZodTypeAny, {
|
|
654
|
-
sha256: string;
|
|
655
|
-
startedAt: number;
|
|
656
|
-
data: string;
|
|
657
|
-
modelName: string;
|
|
658
|
-
did: string;
|
|
659
|
-
cid: string;
|
|
660
|
-
provider: string;
|
|
661
|
-
modelId: string;
|
|
662
|
-
modelOwner: string;
|
|
663
|
-
modelHost: string;
|
|
664
|
-
prompt: {
|
|
665
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
666
|
-
did: string;
|
|
667
|
-
question: {
|
|
668
|
-
sha256: string;
|
|
669
|
-
data: string;
|
|
670
|
-
cid: string;
|
|
671
|
-
};
|
|
672
|
-
fullPrompt: {
|
|
673
|
-
sha256: string;
|
|
674
|
-
data: string;
|
|
675
|
-
cid: string;
|
|
676
|
-
};
|
|
677
|
-
answer?: string | undefined;
|
|
678
|
-
metadata?: Record<string, any> | undefined;
|
|
679
|
-
options?: Record<string, string> | undefined;
|
|
680
|
-
answerKey?: string | undefined;
|
|
681
|
-
scorers?: string[] | undefined;
|
|
682
|
-
};
|
|
683
|
-
finishedAt: number;
|
|
684
|
-
runId: string;
|
|
685
|
-
metadata?: Record<string, any> | undefined;
|
|
686
|
-
inputTokensUsed?: number | undefined;
|
|
687
|
-
outputTokensUsed?: number | undefined;
|
|
688
|
-
inputCost?: string | undefined;
|
|
689
|
-
outputCost?: string | undefined;
|
|
690
|
-
}, {
|
|
691
|
-
sha256: string;
|
|
692
|
-
startedAt: number;
|
|
693
|
-
data: string;
|
|
694
|
-
modelName: string;
|
|
695
|
-
did: string;
|
|
696
|
-
cid: string;
|
|
697
|
-
provider: string;
|
|
698
|
-
modelId: string;
|
|
699
|
-
modelOwner: string;
|
|
700
|
-
modelHost: string;
|
|
701
|
-
prompt: {
|
|
702
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
703
|
-
did: string;
|
|
704
|
-
question: {
|
|
705
|
-
sha256: string;
|
|
706
|
-
data: string;
|
|
707
|
-
cid: string;
|
|
708
|
-
};
|
|
709
|
-
fullPrompt: {
|
|
710
|
-
sha256: string;
|
|
711
|
-
data: string;
|
|
712
|
-
cid: string;
|
|
713
|
-
};
|
|
714
|
-
answer?: string | undefined;
|
|
715
|
-
metadata?: Record<string, any> | undefined;
|
|
716
|
-
options?: Record<string, string> | undefined;
|
|
717
|
-
answerKey?: string | undefined;
|
|
718
|
-
scorers?: string[] | undefined;
|
|
719
|
-
};
|
|
720
|
-
finishedAt: number;
|
|
721
|
-
runId: string;
|
|
722
|
-
metadata?: Record<string, any> | undefined;
|
|
723
|
-
inputTokensUsed?: number | undefined;
|
|
724
|
-
outputTokensUsed?: number | undefined;
|
|
725
|
-
inputCost?: string | undefined;
|
|
726
|
-
outputCost?: string | undefined;
|
|
727
|
-
}>;
|
|
728
|
-
type PromptResponse = z.infer<typeof PromptResponseSchema>;
|
|
729
|
-
declare const PromptScoreSchema: z.ZodObject<{
|
|
730
|
-
did: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodType<string, z.ZodTypeDef, string>>;
|
|
731
|
-
provider: z.ZodString;
|
|
732
|
-
modelId: z.ZodString;
|
|
733
|
-
modelName: z.ZodString;
|
|
734
|
-
modelOwner: z.ZodString;
|
|
735
|
-
modelHost: z.ZodString;
|
|
736
|
-
cid: z.ZodString;
|
|
737
|
-
sha256: z.ZodString;
|
|
738
|
-
startedAt: z.ZodNumber;
|
|
739
|
-
finishedAt: z.ZodNumber;
|
|
740
|
-
runId: z.ZodString;
|
|
741
|
-
inputTokensUsed: z.ZodOptional<z.ZodNumber>;
|
|
742
|
-
outputTokensUsed: z.ZodOptional<z.ZodNumber>;
|
|
743
|
-
inputCost: z.ZodOptional<z.ZodString>;
|
|
744
|
-
outputCost: z.ZodOptional<z.ZodString>;
|
|
745
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
746
|
-
} & {
|
|
747
|
-
prompt: z.ZodOptional<z.ZodObject<{
|
|
748
|
-
did: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodType<string, z.ZodTypeDef, string>>;
|
|
749
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
750
|
-
scorers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
751
|
-
} & {
|
|
752
|
-
options: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
753
|
-
question: z.ZodObject<{
|
|
754
|
-
cid: z.ZodString;
|
|
755
|
-
sha256: z.ZodString;
|
|
756
|
-
} & {
|
|
757
|
-
data: z.ZodOptional<z.ZodString>;
|
|
758
|
-
}, "strip", z.ZodTypeAny, {
|
|
759
|
-
sha256: string;
|
|
760
|
-
cid: string;
|
|
761
|
-
data?: string | undefined;
|
|
762
|
-
}, {
|
|
763
|
-
sha256: string;
|
|
764
|
-
cid: string;
|
|
765
|
-
data?: string | undefined;
|
|
766
|
-
}>;
|
|
767
|
-
fullPrompt: z.ZodObject<{
|
|
768
|
-
cid: z.ZodString;
|
|
769
|
-
sha256: z.ZodString;
|
|
770
|
-
} & {
|
|
771
|
-
data: z.ZodOptional<z.ZodString>;
|
|
772
|
-
}, "strip", z.ZodTypeAny, {
|
|
773
|
-
sha256: string;
|
|
774
|
-
cid: string;
|
|
775
|
-
data?: string | undefined;
|
|
776
|
-
}, {
|
|
777
|
-
sha256: string;
|
|
778
|
-
cid: string;
|
|
779
|
-
data?: string | undefined;
|
|
780
|
-
}>;
|
|
781
|
-
type: z.ZodOptional<z.ZodNativeEnum<{
|
|
782
|
-
readonly MultipleChoice: "multiple-choice";
|
|
783
|
-
readonly OrderSentences: "order-sentences";
|
|
784
|
-
readonly TextReplacement: "text-replacement";
|
|
785
|
-
readonly Typo: "typo";
|
|
786
|
-
readonly OpenEnded: "open-ended";
|
|
787
|
-
readonly OpenEndedWithDocs: "open-ended-with-docs";
|
|
788
|
-
}>>;
|
|
789
|
-
answer: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
790
|
-
answerKey: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
791
|
-
}, "strip", z.ZodTypeAny, {
|
|
792
|
-
did: string;
|
|
793
|
-
question: {
|
|
794
|
-
sha256: string;
|
|
795
|
-
cid: string;
|
|
796
|
-
data?: string | undefined;
|
|
797
|
-
};
|
|
798
|
-
fullPrompt: {
|
|
799
|
-
sha256: string;
|
|
800
|
-
cid: string;
|
|
801
|
-
data?: string | undefined;
|
|
802
|
-
};
|
|
803
|
-
answer?: string | undefined;
|
|
804
|
-
metadata?: Record<string, any> | undefined;
|
|
805
|
-
options?: Record<string, string> | undefined;
|
|
806
|
-
type?: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs" | undefined;
|
|
807
|
-
answerKey?: string | undefined;
|
|
808
|
-
scorers?: string[] | undefined;
|
|
809
|
-
}, {
|
|
810
|
-
did: string;
|
|
811
|
-
question: {
|
|
812
|
-
sha256: string;
|
|
813
|
-
cid: string;
|
|
814
|
-
data?: string | undefined;
|
|
815
|
-
};
|
|
816
|
-
fullPrompt: {
|
|
817
|
-
sha256: string;
|
|
818
|
-
cid: string;
|
|
819
|
-
data?: string | undefined;
|
|
820
|
-
};
|
|
821
|
-
answer?: string | undefined;
|
|
822
|
-
metadata?: Record<string, any> | undefined;
|
|
823
|
-
options?: Record<string, string> | undefined;
|
|
824
|
-
type?: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs" | undefined;
|
|
825
|
-
answerKey?: string | undefined;
|
|
826
|
-
scorers?: string[] | undefined;
|
|
827
|
-
}>>;
|
|
828
|
-
data: z.ZodOptional<z.ZodString>;
|
|
829
|
-
scoreDID: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodType<string, z.ZodTypeDef, string>>;
|
|
830
|
-
scoreMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
831
|
-
score: z.ZodNumber;
|
|
832
|
-
method: z.ZodNativeEnum<{
|
|
833
|
-
/**
|
|
834
|
-
* Scored by a human
|
|
835
|
-
*/
|
|
836
|
-
readonly human: "human";
|
|
837
|
-
/**
|
|
838
|
-
* Scored using an AI model
|
|
839
|
-
*/
|
|
840
|
-
readonly ai: "ai";
|
|
841
|
-
/**
|
|
842
|
-
* Scored using an algorithm
|
|
843
|
-
*/
|
|
844
|
-
readonly algo: "algo";
|
|
845
|
-
}>;
|
|
846
|
-
explanation: z.ZodOptional<z.ZodString>;
|
|
847
|
-
scorerAI: z.ZodOptional<z.ZodObject<{
|
|
848
|
-
provider: z.ZodString;
|
|
849
|
-
modelName: z.ZodString;
|
|
850
|
-
modelHost: z.ZodString;
|
|
851
|
-
modelOwner: z.ZodString;
|
|
852
|
-
modelId: z.ZodString;
|
|
853
|
-
inputTokensUsed: z.ZodOptional<z.ZodNumber>;
|
|
854
|
-
outputTokensUsed: z.ZodOptional<z.ZodNumber>;
|
|
855
|
-
inputCost: z.ZodOptional<z.ZodString>;
|
|
856
|
-
outputCost: z.ZodOptional<z.ZodString>;
|
|
857
|
-
}, "strip", z.ZodTypeAny, {
|
|
858
|
-
modelName: string;
|
|
859
|
-
provider: string;
|
|
860
|
-
modelId: string;
|
|
861
|
-
modelOwner: string;
|
|
862
|
-
modelHost: string;
|
|
863
|
-
inputTokensUsed?: number | undefined;
|
|
864
|
-
outputTokensUsed?: number | undefined;
|
|
865
|
-
inputCost?: string | undefined;
|
|
866
|
-
outputCost?: string | undefined;
|
|
867
|
-
}, {
|
|
868
|
-
modelName: string;
|
|
869
|
-
provider: string;
|
|
870
|
-
modelId: string;
|
|
871
|
-
modelOwner: string;
|
|
872
|
-
modelHost: string;
|
|
873
|
-
inputTokensUsed?: number | undefined;
|
|
874
|
-
outputTokensUsed?: number | undefined;
|
|
875
|
-
inputCost?: string | undefined;
|
|
876
|
-
outputCost?: string | undefined;
|
|
877
|
-
}>>;
|
|
878
|
-
}, "strip", z.ZodTypeAny, {
|
|
879
|
-
sha256: string;
|
|
880
|
-
startedAt: number;
|
|
881
|
-
modelName: string;
|
|
882
|
-
did: string;
|
|
883
|
-
cid: string;
|
|
884
|
-
provider: string;
|
|
885
|
-
modelId: string;
|
|
886
|
-
modelOwner: string;
|
|
887
|
-
modelHost: string;
|
|
888
|
-
finishedAt: number;
|
|
889
|
-
runId: string;
|
|
890
|
-
scoreDID: string;
|
|
891
|
-
score: number;
|
|
892
|
-
method: "human" | "ai" | "algo";
|
|
893
|
-
metadata?: Record<string, any> | undefined;
|
|
894
|
-
inputTokensUsed?: number | undefined;
|
|
895
|
-
outputTokensUsed?: number | undefined;
|
|
896
|
-
data?: string | undefined;
|
|
897
|
-
inputCost?: string | undefined;
|
|
898
|
-
outputCost?: string | undefined;
|
|
899
|
-
prompt?: {
|
|
900
|
-
did: string;
|
|
901
|
-
question: {
|
|
902
|
-
sha256: string;
|
|
903
|
-
cid: string;
|
|
904
|
-
data?: string | undefined;
|
|
905
|
-
};
|
|
906
|
-
fullPrompt: {
|
|
907
|
-
sha256: string;
|
|
908
|
-
cid: string;
|
|
909
|
-
data?: string | undefined;
|
|
910
|
-
};
|
|
911
|
-
answer?: string | undefined;
|
|
912
|
-
metadata?: Record<string, any> | undefined;
|
|
913
|
-
options?: Record<string, string> | undefined;
|
|
914
|
-
type?: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs" | undefined;
|
|
915
|
-
answerKey?: string | undefined;
|
|
916
|
-
scorers?: string[] | undefined;
|
|
917
|
-
} | undefined;
|
|
918
|
-
scoreMetadata?: Record<string, any> | undefined;
|
|
919
|
-
explanation?: string | undefined;
|
|
920
|
-
scorerAI?: {
|
|
921
|
-
modelName: string;
|
|
922
|
-
provider: string;
|
|
923
|
-
modelId: string;
|
|
924
|
-
modelOwner: string;
|
|
925
|
-
modelHost: string;
|
|
926
|
-
inputTokensUsed?: number | undefined;
|
|
927
|
-
outputTokensUsed?: number | undefined;
|
|
928
|
-
inputCost?: string | undefined;
|
|
929
|
-
outputCost?: string | undefined;
|
|
930
|
-
} | undefined;
|
|
931
|
-
}, {
|
|
932
|
-
sha256: string;
|
|
933
|
-
startedAt: number;
|
|
934
|
-
modelName: string;
|
|
935
|
-
did: string;
|
|
936
|
-
cid: string;
|
|
937
|
-
provider: string;
|
|
938
|
-
modelId: string;
|
|
939
|
-
modelOwner: string;
|
|
940
|
-
modelHost: string;
|
|
941
|
-
finishedAt: number;
|
|
942
|
-
runId: string;
|
|
943
|
-
scoreDID: string;
|
|
944
|
-
score: number;
|
|
945
|
-
method: "human" | "ai" | "algo";
|
|
946
|
-
metadata?: Record<string, any> | undefined;
|
|
947
|
-
inputTokensUsed?: number | undefined;
|
|
948
|
-
outputTokensUsed?: number | undefined;
|
|
949
|
-
data?: string | undefined;
|
|
950
|
-
inputCost?: string | undefined;
|
|
951
|
-
outputCost?: string | undefined;
|
|
952
|
-
prompt?: {
|
|
953
|
-
did: string;
|
|
954
|
-
question: {
|
|
955
|
-
sha256: string;
|
|
956
|
-
cid: string;
|
|
957
|
-
data?: string | undefined;
|
|
958
|
-
};
|
|
959
|
-
fullPrompt: {
|
|
960
|
-
sha256: string;
|
|
961
|
-
cid: string;
|
|
962
|
-
data?: string | undefined;
|
|
963
|
-
};
|
|
964
|
-
answer?: string | undefined;
|
|
965
|
-
metadata?: Record<string, any> | undefined;
|
|
966
|
-
options?: Record<string, string> | undefined;
|
|
967
|
-
type?: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs" | undefined;
|
|
968
|
-
answerKey?: string | undefined;
|
|
969
|
-
scorers?: string[] | undefined;
|
|
970
|
-
} | undefined;
|
|
971
|
-
scoreMetadata?: Record<string, any> | undefined;
|
|
972
|
-
explanation?: string | undefined;
|
|
973
|
-
scorerAI?: {
|
|
974
|
-
modelName: string;
|
|
975
|
-
provider: string;
|
|
976
|
-
modelId: string;
|
|
977
|
-
modelOwner: string;
|
|
978
|
-
modelHost: string;
|
|
979
|
-
inputTokensUsed?: number | undefined;
|
|
980
|
-
outputTokensUsed?: number | undefined;
|
|
981
|
-
inputCost?: string | undefined;
|
|
982
|
-
outputCost?: string | undefined;
|
|
983
|
-
} | undefined;
|
|
984
|
-
}>;
|
|
985
|
-
type PromptScore = z.infer<typeof PromptScoreSchema>;
|
|
986
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
987
|
-
type PromptOptions = Record<string, string>;
|
|
988
|
-
|
|
989
|
-
declare abstract class AbstractCollector<TOutput> {
|
|
990
|
-
/**
|
|
991
|
-
* String identifier of the collector.
|
|
992
|
-
*/
|
|
993
|
-
abstract readonly identifier: string;
|
|
994
|
-
/**
|
|
995
|
-
* Collects data from a source
|
|
996
|
-
* @param sourceUrl The URL or identifier of the source
|
|
997
|
-
* @param options Additional options for collection (optional)
|
|
998
|
-
* @returns Promise resolving to the collected data or null if failed
|
|
999
|
-
*/
|
|
1000
|
-
abstract collect(source: unknown, options?: Record<string, any>): Promise<TOutput | undefined>;
|
|
1001
|
-
/**
|
|
1002
|
-
* Initializes the collector (depends on the implementation)
|
|
1003
|
-
*/
|
|
1004
|
-
initialize(...args: any[]): Promise<void>;
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
declare abstract class AbstractRSSCollector<TOutput> extends AbstractCollector<TOutput> {
|
|
1008
|
-
protected parser: XMLParser;
|
|
1009
|
-
abstract feedSchema: z.ZodSchema<unknown>;
|
|
1010
|
-
constructor();
|
|
1011
|
-
/**
|
|
1012
|
-
* Helper function to fetch the feed from the URL
|
|
1013
|
-
* @param url The URL of the feed
|
|
1014
|
-
* @returns Raw XML string of the feed
|
|
1015
|
-
*/
|
|
1016
|
-
protected fetchFeed(url: string): Promise<string>;
|
|
1017
|
-
/**
|
|
1018
|
-
* Parses the raw XML string and validates it
|
|
1019
|
-
* against the defined `FeedStructure` schema
|
|
1020
|
-
* @param xml The raw XML string
|
|
1021
|
-
* @returns Structured data of the RSS feed
|
|
1022
|
-
*/
|
|
1023
|
-
protected parseFeedXML(xml: string): Promise<z.infer<(typeof this)["feedSchema"]>>;
|
|
1024
|
-
}
|
|
8
|
+
declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
1025
9
|
|
|
1026
10
|
/**
|
|
1027
|
-
*
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
feedSchema: z.ZodObject<{
|
|
1032
|
-
rss: z.ZodObject<{
|
|
1033
|
-
channel: z.ZodObject<{
|
|
1034
|
-
title: z.ZodString;
|
|
1035
|
-
link: z.ZodString;
|
|
1036
|
-
description: z.ZodString;
|
|
1037
|
-
pubDate: z.ZodString;
|
|
1038
|
-
lastBuildDate: z.ZodOptional<z.ZodString>;
|
|
1039
|
-
language: z.ZodOptional<z.ZodString>;
|
|
1040
|
-
item: z.ZodPipeline<z.ZodEffects<z.ZodAny, any[], any>, z.ZodArray<z.ZodObject<{
|
|
1041
|
-
title: z.ZodString;
|
|
1042
|
-
link: z.ZodString;
|
|
1043
|
-
description: z.ZodString;
|
|
1044
|
-
guid: z.ZodString;
|
|
1045
|
-
pubDate: z.ZodString;
|
|
1046
|
-
"content:encoded": z.ZodString;
|
|
1047
|
-
}, "strip", z.ZodTypeAny, {
|
|
1048
|
-
link: string;
|
|
1049
|
-
title: string;
|
|
1050
|
-
description: string;
|
|
1051
|
-
pubDate: string;
|
|
1052
|
-
guid: string;
|
|
1053
|
-
"content:encoded": string;
|
|
1054
|
-
}, {
|
|
1055
|
-
link: string;
|
|
1056
|
-
title: string;
|
|
1057
|
-
description: string;
|
|
1058
|
-
pubDate: string;
|
|
1059
|
-
guid: string;
|
|
1060
|
-
"content:encoded": string;
|
|
1061
|
-
}>, "many">>;
|
|
1062
|
-
}, "strip", z.ZodTypeAny, {
|
|
1063
|
-
link: string;
|
|
1064
|
-
title: string;
|
|
1065
|
-
description: string;
|
|
1066
|
-
pubDate: string;
|
|
1067
|
-
item: {
|
|
1068
|
-
link: string;
|
|
1069
|
-
title: string;
|
|
1070
|
-
description: string;
|
|
1071
|
-
pubDate: string;
|
|
1072
|
-
guid: string;
|
|
1073
|
-
"content:encoded": string;
|
|
1074
|
-
}[];
|
|
1075
|
-
lastBuildDate?: string | undefined;
|
|
1076
|
-
language?: string | undefined;
|
|
1077
|
-
}, {
|
|
1078
|
-
link: string;
|
|
1079
|
-
title: string;
|
|
1080
|
-
description: string;
|
|
1081
|
-
pubDate: string;
|
|
1082
|
-
lastBuildDate?: string | undefined;
|
|
1083
|
-
language?: string | undefined;
|
|
1084
|
-
item?: any;
|
|
1085
|
-
}>;
|
|
1086
|
-
}, "strip", z.ZodTypeAny, {
|
|
1087
|
-
channel: {
|
|
1088
|
-
link: string;
|
|
1089
|
-
title: string;
|
|
1090
|
-
description: string;
|
|
1091
|
-
pubDate: string;
|
|
1092
|
-
item: {
|
|
1093
|
-
link: string;
|
|
1094
|
-
title: string;
|
|
1095
|
-
description: string;
|
|
1096
|
-
pubDate: string;
|
|
1097
|
-
guid: string;
|
|
1098
|
-
"content:encoded": string;
|
|
1099
|
-
}[];
|
|
1100
|
-
lastBuildDate?: string | undefined;
|
|
1101
|
-
language?: string | undefined;
|
|
1102
|
-
};
|
|
1103
|
-
}, {
|
|
1104
|
-
channel: {
|
|
1105
|
-
link: string;
|
|
1106
|
-
title: string;
|
|
1107
|
-
description: string;
|
|
1108
|
-
pubDate: string;
|
|
1109
|
-
lastBuildDate?: string | undefined;
|
|
1110
|
-
language?: string | undefined;
|
|
1111
|
-
item?: any;
|
|
1112
|
-
};
|
|
1113
|
-
}>;
|
|
1114
|
-
}, "strip", z.ZodTypeAny, {
|
|
1115
|
-
rss: {
|
|
1116
|
-
channel: {
|
|
1117
|
-
link: string;
|
|
1118
|
-
title: string;
|
|
1119
|
-
description: string;
|
|
1120
|
-
pubDate: string;
|
|
1121
|
-
item: {
|
|
1122
|
-
link: string;
|
|
1123
|
-
title: string;
|
|
1124
|
-
description: string;
|
|
1125
|
-
pubDate: string;
|
|
1126
|
-
guid: string;
|
|
1127
|
-
"content:encoded": string;
|
|
1128
|
-
}[];
|
|
1129
|
-
lastBuildDate?: string | undefined;
|
|
1130
|
-
language?: string | undefined;
|
|
1131
|
-
};
|
|
1132
|
-
};
|
|
1133
|
-
}, {
|
|
1134
|
-
rss: {
|
|
1135
|
-
channel: {
|
|
1136
|
-
link: string;
|
|
1137
|
-
title: string;
|
|
1138
|
-
description: string;
|
|
1139
|
-
pubDate: string;
|
|
1140
|
-
lastBuildDate?: string | undefined;
|
|
1141
|
-
language?: string | undefined;
|
|
1142
|
-
item?: any;
|
|
1143
|
-
};
|
|
1144
|
-
};
|
|
1145
|
-
}>;
|
|
1146
|
-
collect(url: string): Promise<{
|
|
1147
|
-
pmid: string;
|
|
1148
|
-
title: string;
|
|
1149
|
-
paragraphs: Record<string, string>;
|
|
1150
|
-
tags: string[];
|
|
1151
|
-
}[]>;
|
|
1152
|
-
/**
|
|
1153
|
-
* Parses the title of a paragraph which
|
|
1154
|
-
* is in the format of "TITLE:"
|
|
1155
|
-
*/
|
|
1156
|
-
private parseParagraphTitle;
|
|
1157
|
-
}
|
|
1158
|
-
type PubMedCollectedData = {
|
|
1159
|
-
pmid: string;
|
|
1160
|
-
title: string;
|
|
1161
|
-
paragraphs: Record<string, string>;
|
|
1162
|
-
tags: string[];
|
|
1163
|
-
}[];
|
|
1164
|
-
|
|
1165
|
-
/**
|
|
1166
|
-
* A general-purpose RSS collector that can handle heterogeneous RSS feeds.
|
|
1167
|
-
* Intelligently extracts and cleans text content while preserving raw XML data.
|
|
11
|
+
* Tries to repair and parse LLM response as a JSON object. LLM must
|
|
12
|
+
* be configured to return a JSON object. This function only helps to
|
|
13
|
+
* get rid out of some additional formatting (e.g. ```json) and repair
|
|
14
|
+
* the JSON syntax (e.g missing comma, single quotes instead double).
|
|
1168
15
|
*/
|
|
1169
|
-
declare
|
|
1170
|
-
readonly identifier = "simple-general-rss";
|
|
1171
|
-
feedSchema: z.ZodObject<{
|
|
1172
|
-
rss: z.ZodOptional<z.ZodObject<{
|
|
1173
|
-
channel: z.ZodObject<{
|
|
1174
|
-
title: z.ZodOptional<z.ZodString>;
|
|
1175
|
-
link: z.ZodOptional<z.ZodString>;
|
|
1176
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1177
|
-
pubDate: z.ZodOptional<z.ZodString>;
|
|
1178
|
-
lastBuildDate: z.ZodOptional<z.ZodString>;
|
|
1179
|
-
language: z.ZodOptional<z.ZodString>;
|
|
1180
|
-
item: z.ZodPipeline<z.ZodEffects<z.ZodAny, any[], any>, z.ZodArray<z.ZodObject<{
|
|
1181
|
-
title: z.ZodString;
|
|
1182
|
-
link: z.ZodOptional<z.ZodString>;
|
|
1183
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1184
|
-
guid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>]>>;
|
|
1185
|
-
pubDate: z.ZodOptional<z.ZodString>;
|
|
1186
|
-
"content:encoded": z.ZodOptional<z.ZodString>;
|
|
1187
|
-
"dc:creator": z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1188
|
-
"dc:date": z.ZodOptional<z.ZodString>;
|
|
1189
|
-
"dc:title": z.ZodOptional<z.ZodString>;
|
|
1190
|
-
"dc:subject": z.ZodOptional<z.ZodString>;
|
|
1191
|
-
"dc:publisher": z.ZodOptional<z.ZodString>;
|
|
1192
|
-
"dc:identifier": z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1193
|
-
"dc:rights": z.ZodOptional<z.ZodString>;
|
|
1194
|
-
"dc:source": z.ZodOptional<z.ZodString>;
|
|
1195
|
-
"prism:publicationDate": z.ZodOptional<z.ZodString>;
|
|
1196
|
-
"prism:section": z.ZodOptional<z.ZodString>;
|
|
1197
|
-
"prism:volume": z.ZodOptional<z.ZodString>;
|
|
1198
|
-
"prism:number": z.ZodOptional<z.ZodString>;
|
|
1199
|
-
"prism:startingPage": z.ZodOptional<z.ZodString>;
|
|
1200
|
-
"prism:endingPage": z.ZodOptional<z.ZodString>;
|
|
1201
|
-
"arxiv:announce_type": z.ZodOptional<z.ZodString>;
|
|
1202
|
-
category: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1203
|
-
}, "strip", z.ZodTypeAny, {
|
|
1204
|
-
title: string;
|
|
1205
|
-
link?: string | undefined;
|
|
1206
|
-
description?: string | undefined;
|
|
1207
|
-
pubDate?: string | undefined;
|
|
1208
|
-
guid?: string | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1209
|
-
"content:encoded"?: string | undefined;
|
|
1210
|
-
"dc:creator"?: string | string[] | undefined;
|
|
1211
|
-
"dc:date"?: string | undefined;
|
|
1212
|
-
"dc:title"?: string | undefined;
|
|
1213
|
-
"dc:subject"?: string | undefined;
|
|
1214
|
-
"dc:publisher"?: string | undefined;
|
|
1215
|
-
"dc:identifier"?: string | string[] | undefined;
|
|
1216
|
-
"dc:rights"?: string | undefined;
|
|
1217
|
-
"dc:source"?: string | undefined;
|
|
1218
|
-
"prism:publicationDate"?: string | undefined;
|
|
1219
|
-
"prism:section"?: string | undefined;
|
|
1220
|
-
"prism:volume"?: string | undefined;
|
|
1221
|
-
"prism:number"?: string | undefined;
|
|
1222
|
-
"prism:startingPage"?: string | undefined;
|
|
1223
|
-
"prism:endingPage"?: string | undefined;
|
|
1224
|
-
"arxiv:announce_type"?: string | undefined;
|
|
1225
|
-
category?: string | string[] | undefined;
|
|
1226
|
-
}, {
|
|
1227
|
-
title: string;
|
|
1228
|
-
link?: string | undefined;
|
|
1229
|
-
description?: string | undefined;
|
|
1230
|
-
pubDate?: string | undefined;
|
|
1231
|
-
guid?: string | z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1232
|
-
"content:encoded"?: string | undefined;
|
|
1233
|
-
"dc:creator"?: string | string[] | undefined;
|
|
1234
|
-
"dc:date"?: string | undefined;
|
|
1235
|
-
"dc:title"?: string | undefined;
|
|
1236
|
-
"dc:subject"?: string | undefined;
|
|
1237
|
-
"dc:publisher"?: string | undefined;
|
|
1238
|
-
"dc:identifier"?: string | string[] | undefined;
|
|
1239
|
-
"dc:rights"?: string | undefined;
|
|
1240
|
-
"dc:source"?: string | undefined;
|
|
1241
|
-
"prism:publicationDate"?: string | undefined;
|
|
1242
|
-
"prism:section"?: string | undefined;
|
|
1243
|
-
"prism:volume"?: string | undefined;
|
|
1244
|
-
"prism:number"?: string | undefined;
|
|
1245
|
-
"prism:startingPage"?: string | undefined;
|
|
1246
|
-
"prism:endingPage"?: string | undefined;
|
|
1247
|
-
"arxiv:announce_type"?: string | undefined;
|
|
1248
|
-
category?: string | string[] | undefined;
|
|
1249
|
-
}>, "many">>;
|
|
1250
|
-
}, "strip", z.ZodTypeAny, {
|
|
1251
|
-
item: {
|
|
1252
|
-
title: string;
|
|
1253
|
-
link?: string | undefined;
|
|
1254
|
-
description?: string | undefined;
|
|
1255
|
-
pubDate?: string | undefined;
|
|
1256
|
-
guid?: string | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1257
|
-
"content:encoded"?: string | undefined;
|
|
1258
|
-
"dc:creator"?: string | string[] | undefined;
|
|
1259
|
-
"dc:date"?: string | undefined;
|
|
1260
|
-
"dc:title"?: string | undefined;
|
|
1261
|
-
"dc:subject"?: string | undefined;
|
|
1262
|
-
"dc:publisher"?: string | undefined;
|
|
1263
|
-
"dc:identifier"?: string | string[] | undefined;
|
|
1264
|
-
"dc:rights"?: string | undefined;
|
|
1265
|
-
"dc:source"?: string | undefined;
|
|
1266
|
-
"prism:publicationDate"?: string | undefined;
|
|
1267
|
-
"prism:section"?: string | undefined;
|
|
1268
|
-
"prism:volume"?: string | undefined;
|
|
1269
|
-
"prism:number"?: string | undefined;
|
|
1270
|
-
"prism:startingPage"?: string | undefined;
|
|
1271
|
-
"prism:endingPage"?: string | undefined;
|
|
1272
|
-
"arxiv:announce_type"?: string | undefined;
|
|
1273
|
-
category?: string | string[] | undefined;
|
|
1274
|
-
}[];
|
|
1275
|
-
link?: string | undefined;
|
|
1276
|
-
title?: string | undefined;
|
|
1277
|
-
description?: string | undefined;
|
|
1278
|
-
pubDate?: string | undefined;
|
|
1279
|
-
lastBuildDate?: string | undefined;
|
|
1280
|
-
language?: string | undefined;
|
|
1281
|
-
}, {
|
|
1282
|
-
link?: string | undefined;
|
|
1283
|
-
title?: string | undefined;
|
|
1284
|
-
description?: string | undefined;
|
|
1285
|
-
pubDate?: string | undefined;
|
|
1286
|
-
lastBuildDate?: string | undefined;
|
|
1287
|
-
language?: string | undefined;
|
|
1288
|
-
item?: any;
|
|
1289
|
-
}>;
|
|
1290
|
-
}, "strip", z.ZodTypeAny, {
|
|
1291
|
-
channel: {
|
|
1292
|
-
item: {
|
|
1293
|
-
title: string;
|
|
1294
|
-
link?: string | undefined;
|
|
1295
|
-
description?: string | undefined;
|
|
1296
|
-
pubDate?: string | undefined;
|
|
1297
|
-
guid?: string | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1298
|
-
"content:encoded"?: string | undefined;
|
|
1299
|
-
"dc:creator"?: string | string[] | undefined;
|
|
1300
|
-
"dc:date"?: string | undefined;
|
|
1301
|
-
"dc:title"?: string | undefined;
|
|
1302
|
-
"dc:subject"?: string | undefined;
|
|
1303
|
-
"dc:publisher"?: string | undefined;
|
|
1304
|
-
"dc:identifier"?: string | string[] | undefined;
|
|
1305
|
-
"dc:rights"?: string | undefined;
|
|
1306
|
-
"dc:source"?: string | undefined;
|
|
1307
|
-
"prism:publicationDate"?: string | undefined;
|
|
1308
|
-
"prism:section"?: string | undefined;
|
|
1309
|
-
"prism:volume"?: string | undefined;
|
|
1310
|
-
"prism:number"?: string | undefined;
|
|
1311
|
-
"prism:startingPage"?: string | undefined;
|
|
1312
|
-
"prism:endingPage"?: string | undefined;
|
|
1313
|
-
"arxiv:announce_type"?: string | undefined;
|
|
1314
|
-
category?: string | string[] | undefined;
|
|
1315
|
-
}[];
|
|
1316
|
-
link?: string | undefined;
|
|
1317
|
-
title?: string | undefined;
|
|
1318
|
-
description?: string | undefined;
|
|
1319
|
-
pubDate?: string | undefined;
|
|
1320
|
-
lastBuildDate?: string | undefined;
|
|
1321
|
-
language?: string | undefined;
|
|
1322
|
-
};
|
|
1323
|
-
}, {
|
|
1324
|
-
channel: {
|
|
1325
|
-
link?: string | undefined;
|
|
1326
|
-
title?: string | undefined;
|
|
1327
|
-
description?: string | undefined;
|
|
1328
|
-
pubDate?: string | undefined;
|
|
1329
|
-
lastBuildDate?: string | undefined;
|
|
1330
|
-
language?: string | undefined;
|
|
1331
|
-
item?: any;
|
|
1332
|
-
};
|
|
1333
|
-
}>>;
|
|
1334
|
-
rdf: z.ZodOptional<z.ZodObject<{
|
|
1335
|
-
channel: z.ZodOptional<z.ZodObject<{
|
|
1336
|
-
title: z.ZodOptional<z.ZodString>;
|
|
1337
|
-
link: z.ZodOptional<z.ZodString>;
|
|
1338
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1339
|
-
items: z.ZodOptional<z.ZodObject<{
|
|
1340
|
-
"rdf:Seq": z.ZodOptional<z.ZodObject<{
|
|
1341
|
-
"rdf:li": z.ZodOptional<z.ZodAny>;
|
|
1342
|
-
}, "strip", z.ZodTypeAny, {
|
|
1343
|
-
"rdf:li"?: any;
|
|
1344
|
-
}, {
|
|
1345
|
-
"rdf:li"?: any;
|
|
1346
|
-
}>>;
|
|
1347
|
-
}, "strip", z.ZodTypeAny, {
|
|
1348
|
-
"rdf:Seq"?: {
|
|
1349
|
-
"rdf:li"?: any;
|
|
1350
|
-
} | undefined;
|
|
1351
|
-
}, {
|
|
1352
|
-
"rdf:Seq"?: {
|
|
1353
|
-
"rdf:li"?: any;
|
|
1354
|
-
} | undefined;
|
|
1355
|
-
}>>;
|
|
1356
|
-
item: z.ZodOptional<z.ZodPipeline<z.ZodEffects<z.ZodAny, any[], any>, z.ZodArray<z.ZodObject<{
|
|
1357
|
-
title: z.ZodString;
|
|
1358
|
-
link: z.ZodOptional<z.ZodString>;
|
|
1359
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1360
|
-
"dc:creator": z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1361
|
-
"dc:date": z.ZodOptional<z.ZodString>;
|
|
1362
|
-
"dc:title": z.ZodOptional<z.ZodString>;
|
|
1363
|
-
"dc:subject": z.ZodOptional<z.ZodString>;
|
|
1364
|
-
"dc:publisher": z.ZodOptional<z.ZodString>;
|
|
1365
|
-
"dc:identifier": z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1366
|
-
"dc:rights": z.ZodOptional<z.ZodString>;
|
|
1367
|
-
"dc:source": z.ZodOptional<z.ZodString>;
|
|
1368
|
-
"prism:publicationDate": z.ZodOptional<z.ZodString>;
|
|
1369
|
-
"prism:section": z.ZodOptional<z.ZodString>;
|
|
1370
|
-
"prism:volume": z.ZodOptional<z.ZodString>;
|
|
1371
|
-
"prism:number": z.ZodOptional<z.ZodString>;
|
|
1372
|
-
"prism:startingPage": z.ZodOptional<z.ZodString>;
|
|
1373
|
-
"prism:endingPage": z.ZodOptional<z.ZodString>;
|
|
1374
|
-
category: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1375
|
-
}, "strip", z.ZodTypeAny, {
|
|
1376
|
-
title: string;
|
|
1377
|
-
link?: string | undefined;
|
|
1378
|
-
description?: string | undefined;
|
|
1379
|
-
"dc:creator"?: string | string[] | undefined;
|
|
1380
|
-
"dc:date"?: string | undefined;
|
|
1381
|
-
"dc:title"?: string | undefined;
|
|
1382
|
-
"dc:subject"?: string | undefined;
|
|
1383
|
-
"dc:publisher"?: string | undefined;
|
|
1384
|
-
"dc:identifier"?: string | string[] | undefined;
|
|
1385
|
-
"dc:rights"?: string | undefined;
|
|
1386
|
-
"dc:source"?: string | undefined;
|
|
1387
|
-
"prism:publicationDate"?: string | undefined;
|
|
1388
|
-
"prism:section"?: string | undefined;
|
|
1389
|
-
"prism:volume"?: string | undefined;
|
|
1390
|
-
"prism:number"?: string | undefined;
|
|
1391
|
-
"prism:startingPage"?: string | undefined;
|
|
1392
|
-
"prism:endingPage"?: string | undefined;
|
|
1393
|
-
category?: string | string[] | undefined;
|
|
1394
|
-
}, {
|
|
1395
|
-
title: string;
|
|
1396
|
-
link?: string | undefined;
|
|
1397
|
-
description?: string | undefined;
|
|
1398
|
-
"dc:creator"?: string | string[] | undefined;
|
|
1399
|
-
"dc:date"?: string | undefined;
|
|
1400
|
-
"dc:title"?: string | undefined;
|
|
1401
|
-
"dc:subject"?: string | undefined;
|
|
1402
|
-
"dc:publisher"?: string | undefined;
|
|
1403
|
-
"dc:identifier"?: string | string[] | undefined;
|
|
1404
|
-
"dc:rights"?: string | undefined;
|
|
1405
|
-
"dc:source"?: string | undefined;
|
|
1406
|
-
"prism:publicationDate"?: string | undefined;
|
|
1407
|
-
"prism:section"?: string | undefined;
|
|
1408
|
-
"prism:volume"?: string | undefined;
|
|
1409
|
-
"prism:number"?: string | undefined;
|
|
1410
|
-
"prism:startingPage"?: string | undefined;
|
|
1411
|
-
"prism:endingPage"?: string | undefined;
|
|
1412
|
-
category?: string | string[] | undefined;
|
|
1413
|
-
}>, "many">>>;
|
|
1414
|
-
}, "strip", z.ZodTypeAny, {
|
|
1415
|
-
link?: string | undefined;
|
|
1416
|
-
title?: string | undefined;
|
|
1417
|
-
description?: string | undefined;
|
|
1418
|
-
item?: {
|
|
1419
|
-
title: string;
|
|
1420
|
-
link?: string | undefined;
|
|
1421
|
-
description?: string | undefined;
|
|
1422
|
-
"dc:creator"?: string | string[] | undefined;
|
|
1423
|
-
"dc:date"?: string | undefined;
|
|
1424
|
-
"dc:title"?: string | undefined;
|
|
1425
|
-
"dc:subject"?: string | undefined;
|
|
1426
|
-
"dc:publisher"?: string | undefined;
|
|
1427
|
-
"dc:identifier"?: string | string[] | undefined;
|
|
1428
|
-
"dc:rights"?: string | undefined;
|
|
1429
|
-
"dc:source"?: string | undefined;
|
|
1430
|
-
"prism:publicationDate"?: string | undefined;
|
|
1431
|
-
"prism:section"?: string | undefined;
|
|
1432
|
-
"prism:volume"?: string | undefined;
|
|
1433
|
-
"prism:number"?: string | undefined;
|
|
1434
|
-
"prism:startingPage"?: string | undefined;
|
|
1435
|
-
"prism:endingPage"?: string | undefined;
|
|
1436
|
-
category?: string | string[] | undefined;
|
|
1437
|
-
}[] | undefined;
|
|
1438
|
-
items?: {
|
|
1439
|
-
"rdf:Seq"?: {
|
|
1440
|
-
"rdf:li"?: any;
|
|
1441
|
-
} | undefined;
|
|
1442
|
-
} | undefined;
|
|
1443
|
-
}, {
|
|
1444
|
-
link?: string | undefined;
|
|
1445
|
-
title?: string | undefined;
|
|
1446
|
-
description?: string | undefined;
|
|
1447
|
-
item?: any;
|
|
1448
|
-
items?: {
|
|
1449
|
-
"rdf:Seq"?: {
|
|
1450
|
-
"rdf:li"?: any;
|
|
1451
|
-
} | undefined;
|
|
1452
|
-
} | undefined;
|
|
1453
|
-
}>>;
|
|
1454
|
-
}, "strip", z.ZodTypeAny, {
|
|
1455
|
-
channel?: {
|
|
1456
|
-
link?: string | undefined;
|
|
1457
|
-
title?: string | undefined;
|
|
1458
|
-
description?: string | undefined;
|
|
1459
|
-
item?: {
|
|
1460
|
-
title: string;
|
|
1461
|
-
link?: string | undefined;
|
|
1462
|
-
description?: string | undefined;
|
|
1463
|
-
"dc:creator"?: string | string[] | undefined;
|
|
1464
|
-
"dc:date"?: string | undefined;
|
|
1465
|
-
"dc:title"?: string | undefined;
|
|
1466
|
-
"dc:subject"?: string | undefined;
|
|
1467
|
-
"dc:publisher"?: string | undefined;
|
|
1468
|
-
"dc:identifier"?: string | string[] | undefined;
|
|
1469
|
-
"dc:rights"?: string | undefined;
|
|
1470
|
-
"dc:source"?: string | undefined;
|
|
1471
|
-
"prism:publicationDate"?: string | undefined;
|
|
1472
|
-
"prism:section"?: string | undefined;
|
|
1473
|
-
"prism:volume"?: string | undefined;
|
|
1474
|
-
"prism:number"?: string | undefined;
|
|
1475
|
-
"prism:startingPage"?: string | undefined;
|
|
1476
|
-
"prism:endingPage"?: string | undefined;
|
|
1477
|
-
category?: string | string[] | undefined;
|
|
1478
|
-
}[] | undefined;
|
|
1479
|
-
items?: {
|
|
1480
|
-
"rdf:Seq"?: {
|
|
1481
|
-
"rdf:li"?: any;
|
|
1482
|
-
} | undefined;
|
|
1483
|
-
} | undefined;
|
|
1484
|
-
} | undefined;
|
|
1485
|
-
}, {
|
|
1486
|
-
channel?: {
|
|
1487
|
-
link?: string | undefined;
|
|
1488
|
-
title?: string | undefined;
|
|
1489
|
-
description?: string | undefined;
|
|
1490
|
-
item?: any;
|
|
1491
|
-
items?: {
|
|
1492
|
-
"rdf:Seq"?: {
|
|
1493
|
-
"rdf:li"?: any;
|
|
1494
|
-
} | undefined;
|
|
1495
|
-
} | undefined;
|
|
1496
|
-
} | undefined;
|
|
1497
|
-
}>>;
|
|
1498
|
-
feed: z.ZodOptional<z.ZodObject<{
|
|
1499
|
-
title: z.ZodOptional<z.ZodString>;
|
|
1500
|
-
link: z.ZodOptional<z.ZodString>;
|
|
1501
|
-
entry: z.ZodPipeline<z.ZodEffects<z.ZodAny, any[], any>, z.ZodArray<z.ZodObject<{
|
|
1502
|
-
title: z.ZodString;
|
|
1503
|
-
link: z.ZodOptional<z.ZodString>;
|
|
1504
|
-
summary: z.ZodOptional<z.ZodString>;
|
|
1505
|
-
content: z.ZodOptional<z.ZodString>;
|
|
1506
|
-
author: z.ZodOptional<z.ZodString>;
|
|
1507
|
-
published: z.ZodOptional<z.ZodString>;
|
|
1508
|
-
id: z.ZodOptional<z.ZodString>;
|
|
1509
|
-
}, "strip", z.ZodTypeAny, {
|
|
1510
|
-
title: string;
|
|
1511
|
-
content?: string | undefined;
|
|
1512
|
-
id?: string | undefined;
|
|
1513
|
-
link?: string | undefined;
|
|
1514
|
-
summary?: string | undefined;
|
|
1515
|
-
author?: string | undefined;
|
|
1516
|
-
published?: string | undefined;
|
|
1517
|
-
}, {
|
|
1518
|
-
title: string;
|
|
1519
|
-
content?: string | undefined;
|
|
1520
|
-
id?: string | undefined;
|
|
1521
|
-
link?: string | undefined;
|
|
1522
|
-
summary?: string | undefined;
|
|
1523
|
-
author?: string | undefined;
|
|
1524
|
-
published?: string | undefined;
|
|
1525
|
-
}>, "many">>;
|
|
1526
|
-
}, "strip", z.ZodTypeAny, {
|
|
1527
|
-
entry: {
|
|
1528
|
-
title: string;
|
|
1529
|
-
content?: string | undefined;
|
|
1530
|
-
id?: string | undefined;
|
|
1531
|
-
link?: string | undefined;
|
|
1532
|
-
summary?: string | undefined;
|
|
1533
|
-
author?: string | undefined;
|
|
1534
|
-
published?: string | undefined;
|
|
1535
|
-
}[];
|
|
1536
|
-
link?: string | undefined;
|
|
1537
|
-
title?: string | undefined;
|
|
1538
|
-
}, {
|
|
1539
|
-
link?: string | undefined;
|
|
1540
|
-
title?: string | undefined;
|
|
1541
|
-
entry?: any;
|
|
1542
|
-
}>>;
|
|
1543
|
-
}, "strip", z.ZodTypeAny, {
|
|
1544
|
-
rss?: {
|
|
1545
|
-
channel: {
|
|
1546
|
-
item: {
|
|
1547
|
-
title: string;
|
|
1548
|
-
link?: string | undefined;
|
|
1549
|
-
description?: string | undefined;
|
|
1550
|
-
pubDate?: string | undefined;
|
|
1551
|
-
guid?: string | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1552
|
-
"content:encoded"?: string | undefined;
|
|
1553
|
-
"dc:creator"?: string | string[] | undefined;
|
|
1554
|
-
"dc:date"?: string | undefined;
|
|
1555
|
-
"dc:title"?: string | undefined;
|
|
1556
|
-
"dc:subject"?: string | undefined;
|
|
1557
|
-
"dc:publisher"?: string | undefined;
|
|
1558
|
-
"dc:identifier"?: string | string[] | undefined;
|
|
1559
|
-
"dc:rights"?: string | undefined;
|
|
1560
|
-
"dc:source"?: string | undefined;
|
|
1561
|
-
"prism:publicationDate"?: string | undefined;
|
|
1562
|
-
"prism:section"?: string | undefined;
|
|
1563
|
-
"prism:volume"?: string | undefined;
|
|
1564
|
-
"prism:number"?: string | undefined;
|
|
1565
|
-
"prism:startingPage"?: string | undefined;
|
|
1566
|
-
"prism:endingPage"?: string | undefined;
|
|
1567
|
-
"arxiv:announce_type"?: string | undefined;
|
|
1568
|
-
category?: string | string[] | undefined;
|
|
1569
|
-
}[];
|
|
1570
|
-
link?: string | undefined;
|
|
1571
|
-
title?: string | undefined;
|
|
1572
|
-
description?: string | undefined;
|
|
1573
|
-
pubDate?: string | undefined;
|
|
1574
|
-
lastBuildDate?: string | undefined;
|
|
1575
|
-
language?: string | undefined;
|
|
1576
|
-
};
|
|
1577
|
-
} | undefined;
|
|
1578
|
-
rdf?: {
|
|
1579
|
-
channel?: {
|
|
1580
|
-
link?: string | undefined;
|
|
1581
|
-
title?: string | undefined;
|
|
1582
|
-
description?: string | undefined;
|
|
1583
|
-
item?: {
|
|
1584
|
-
title: string;
|
|
1585
|
-
link?: string | undefined;
|
|
1586
|
-
description?: string | undefined;
|
|
1587
|
-
"dc:creator"?: string | string[] | undefined;
|
|
1588
|
-
"dc:date"?: string | undefined;
|
|
1589
|
-
"dc:title"?: string | undefined;
|
|
1590
|
-
"dc:subject"?: string | undefined;
|
|
1591
|
-
"dc:publisher"?: string | undefined;
|
|
1592
|
-
"dc:identifier"?: string | string[] | undefined;
|
|
1593
|
-
"dc:rights"?: string | undefined;
|
|
1594
|
-
"dc:source"?: string | undefined;
|
|
1595
|
-
"prism:publicationDate"?: string | undefined;
|
|
1596
|
-
"prism:section"?: string | undefined;
|
|
1597
|
-
"prism:volume"?: string | undefined;
|
|
1598
|
-
"prism:number"?: string | undefined;
|
|
1599
|
-
"prism:startingPage"?: string | undefined;
|
|
1600
|
-
"prism:endingPage"?: string | undefined;
|
|
1601
|
-
category?: string | string[] | undefined;
|
|
1602
|
-
}[] | undefined;
|
|
1603
|
-
items?: {
|
|
1604
|
-
"rdf:Seq"?: {
|
|
1605
|
-
"rdf:li"?: any;
|
|
1606
|
-
} | undefined;
|
|
1607
|
-
} | undefined;
|
|
1608
|
-
} | undefined;
|
|
1609
|
-
} | undefined;
|
|
1610
|
-
feed?: {
|
|
1611
|
-
entry: {
|
|
1612
|
-
title: string;
|
|
1613
|
-
content?: string | undefined;
|
|
1614
|
-
id?: string | undefined;
|
|
1615
|
-
link?: string | undefined;
|
|
1616
|
-
summary?: string | undefined;
|
|
1617
|
-
author?: string | undefined;
|
|
1618
|
-
published?: string | undefined;
|
|
1619
|
-
}[];
|
|
1620
|
-
link?: string | undefined;
|
|
1621
|
-
title?: string | undefined;
|
|
1622
|
-
} | undefined;
|
|
1623
|
-
}, {
|
|
1624
|
-
rss?: {
|
|
1625
|
-
channel: {
|
|
1626
|
-
link?: string | undefined;
|
|
1627
|
-
title?: string | undefined;
|
|
1628
|
-
description?: string | undefined;
|
|
1629
|
-
pubDate?: string | undefined;
|
|
1630
|
-
lastBuildDate?: string | undefined;
|
|
1631
|
-
language?: string | undefined;
|
|
1632
|
-
item?: any;
|
|
1633
|
-
};
|
|
1634
|
-
} | undefined;
|
|
1635
|
-
rdf?: {
|
|
1636
|
-
channel?: {
|
|
1637
|
-
link?: string | undefined;
|
|
1638
|
-
title?: string | undefined;
|
|
1639
|
-
description?: string | undefined;
|
|
1640
|
-
item?: any;
|
|
1641
|
-
items?: {
|
|
1642
|
-
"rdf:Seq"?: {
|
|
1643
|
-
"rdf:li"?: any;
|
|
1644
|
-
} | undefined;
|
|
1645
|
-
} | undefined;
|
|
1646
|
-
} | undefined;
|
|
1647
|
-
} | undefined;
|
|
1648
|
-
feed?: {
|
|
1649
|
-
link?: string | undefined;
|
|
1650
|
-
title?: string | undefined;
|
|
1651
|
-
entry?: any;
|
|
1652
|
-
} | undefined;
|
|
1653
|
-
}>;
|
|
1654
|
-
collect(url: string): Promise<SimpleGeneralRSSCollectedData>;
|
|
1655
|
-
/**
|
|
1656
|
-
* Extracts GUID value from either a string or object
|
|
1657
|
-
*/
|
|
1658
|
-
private extractGuidValue;
|
|
1659
|
-
/**
|
|
1660
|
-
* Dynamically searches for items in any XML structure
|
|
1661
|
-
*/
|
|
1662
|
-
private findItemsDynamically;
|
|
1663
|
-
/**
|
|
1664
|
-
* Fallback method using regex to find items when standard parsing fails
|
|
1665
|
-
*/
|
|
1666
|
-
private findItemsWithRegex;
|
|
1667
|
-
/**
|
|
1668
|
-
* Dynamically searches for channel title in any XML structure
|
|
1669
|
-
*/
|
|
1670
|
-
private findChannelTitle;
|
|
1671
|
-
/**
|
|
1672
|
-
* Find channel title using regex
|
|
1673
|
-
*/
|
|
1674
|
-
private findChannelTitleWithRegex;
|
|
1675
|
-
/**
|
|
1676
|
-
* Intelligently extracts the main text content from an RSS item.
|
|
1677
|
-
* Finds the element with the most text and appends other text-rich elements.
|
|
1678
|
-
* Returns cleaned, combined text content.
|
|
1679
|
-
*/
|
|
1680
|
-
private extractMainText;
|
|
1681
|
-
/**
|
|
1682
|
-
* Checks if two text contents are substantially similar to avoid duplication
|
|
1683
|
-
*/
|
|
1684
|
-
private isDuplicateContent;
|
|
1685
|
-
/**
|
|
1686
|
-
* Cleans text of HTML tags, special characters, and formatting.
|
|
1687
|
-
* Preserves readable text while removing markup.
|
|
1688
|
-
*/
|
|
1689
|
-
private cleanText;
|
|
1690
|
-
/**
|
|
1691
|
-
* Extracts structured metadata from RSS item fields.
|
|
1692
|
-
*/
|
|
1693
|
-
private extractMetadata;
|
|
1694
|
-
/**
|
|
1695
|
-
* Extracts tags from the item and combines with feed-level tags.
|
|
1696
|
-
*/
|
|
1697
|
-
private extractTags;
|
|
1698
|
-
}
|
|
1699
|
-
type SimpleGeneralRSSCollectedData = {
|
|
1700
|
-
title: string;
|
|
1701
|
-
link?: string;
|
|
1702
|
-
mainText: string;
|
|
1703
|
-
rawXml: any;
|
|
1704
|
-
metadata: Record<string, any>;
|
|
1705
|
-
tags: string[];
|
|
1706
|
-
pubDate?: string;
|
|
1707
|
-
guid?: string;
|
|
1708
|
-
}[];
|
|
16
|
+
declare function parseResponseAsJSON<T>(response: string): T | undefined;
|
|
1709
17
|
|
|
1710
18
|
/**
|
|
1711
|
-
*
|
|
1712
|
-
* Useful for basic string processing or when you need to pass through string data.
|
|
19
|
+
* Converts the given byte array to a string
|
|
1713
20
|
*/
|
|
1714
|
-
declare
|
|
1715
|
-
readonly identifier = "string";
|
|
1716
|
-
collect(source: unknown): Promise<string | undefined>;
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
declare class ForwardError extends Error {
|
|
1720
|
-
startedAt: Date;
|
|
1721
|
-
code?: string;
|
|
1722
|
-
constructor(message: string, options?: ErrorOptions & {
|
|
1723
|
-
startedAt: Date;
|
|
1724
|
-
code?: string;
|
|
1725
|
-
});
|
|
1726
|
-
}
|
|
1727
|
-
|
|
1728
|
-
declare class InvalidDataError extends Error {
|
|
1729
|
-
constructor(message?: string);
|
|
1730
|
-
}
|
|
1731
|
-
declare class ParserIsNotCompatibleError extends InvalidDataError {
|
|
1732
|
-
constructor();
|
|
1733
|
-
}
|
|
1734
|
-
|
|
1735
|
-
declare const PEERBENCH_ERROR_CODES: {
|
|
1736
|
-
readonly PROVIDER_FORWARD_FAILED: "PROVIDER_FORWARD_FAILED";
|
|
1737
|
-
readonly PROVIDER_UNAUTHORIZED: "PROVIDER_UNAUTHORIZED";
|
|
1738
|
-
readonly PROVIDER_MAX_RETRIES_REACHED: "PROVIDER_MAX_RETRIES_REACHED";
|
|
1739
|
-
};
|
|
1740
|
-
type PeerBenchErrorCode = (typeof PEERBENCH_ERROR_CODES)[keyof typeof PEERBENCH_ERROR_CODES];
|
|
1741
|
-
|
|
21
|
+
declare function bufferToString(buffer: Uint8Array, encoding?: BufferEncoding): string;
|
|
1742
22
|
/**
|
|
1743
|
-
*
|
|
23
|
+
* Converts the given string to a byte array
|
|
1744
24
|
*/
|
|
1745
|
-
declare
|
|
1746
|
-
abstract readonly identifier: string;
|
|
1747
|
-
abstract inputSchema: z.ZodSchema<unknown>;
|
|
1748
|
-
/**
|
|
1749
|
-
* Generate prompt from the collected source data
|
|
1750
|
-
* @param input - Raw input data that will be validated against inputSchema
|
|
1751
|
-
* @param options - Optional configuration options
|
|
1752
|
-
* @returns Promise resolving to an array of prompts
|
|
1753
|
-
*/
|
|
1754
|
-
generate(input: unknown, options?: Parameters<this["generatePrompts"]>[1]): Promise<Prompt[]>;
|
|
1755
|
-
/**
|
|
1756
|
-
* Abstract method that implementors MUST override.
|
|
1757
|
-
* This method receives already validated input data.
|
|
1758
|
-
*
|
|
1759
|
-
* NOTE: Callers must use `generate()` method
|
|
1760
|
-
*/
|
|
1761
|
-
abstract generatePrompts(input: z.infer<(typeof this)["inputSchema"]>, options?: Record<string, any>): Promise<Prompt[]>;
|
|
1762
|
-
/**
|
|
1763
|
-
* Checks whether the generator can handle the given input
|
|
1764
|
-
*/
|
|
1765
|
-
canHandle(input: any): MaybePromise<boolean>;
|
|
1766
|
-
/**
|
|
1767
|
-
* Initializes the generator (depends on the implementation)
|
|
1768
|
-
*/
|
|
1769
|
-
initialize(...args: any[]): Promise<void>;
|
|
1770
|
-
buildPrompt(params: {
|
|
1771
|
-
/**
|
|
1772
|
-
* Base question
|
|
1773
|
-
*/
|
|
1774
|
-
question: string;
|
|
1775
|
-
/**
|
|
1776
|
-
* For multiple choice prompts, includes each option as letter-answer pairs
|
|
1777
|
-
*/
|
|
1778
|
-
options?: Record<string, string>;
|
|
1779
|
-
/**
|
|
1780
|
-
* Correct answer that is expected. For multiple choice prompts,
|
|
1781
|
-
* this is the letter of the correct answer.
|
|
1782
|
-
*/
|
|
1783
|
-
correctAnswer: string;
|
|
1784
|
-
/**
|
|
1785
|
-
* The full Prompt text that will be sent.
|
|
1786
|
-
*/
|
|
1787
|
-
fullPrompt: string;
|
|
1788
|
-
/**
|
|
1789
|
-
* Prompt type
|
|
1790
|
-
*/
|
|
1791
|
-
type: PromptType;
|
|
1792
|
-
/**
|
|
1793
|
-
* Metadata
|
|
1794
|
-
*/
|
|
1795
|
-
metadata?: Record<string, any>;
|
|
1796
|
-
/**
|
|
1797
|
-
* Expected Scorers that can be used to
|
|
1798
|
-
* score the Responses for this Prompt
|
|
1799
|
-
*/
|
|
1800
|
-
scorers?: string[];
|
|
1801
|
-
}): Promise<Prompt>;
|
|
1802
|
-
}
|
|
25
|
+
declare function stringToBuffer(str: string): Uint8Array;
|
|
1803
26
|
|
|
1804
|
-
declare
|
|
1805
|
-
identifier: string;
|
|
1806
|
-
inputSchema: z.ZodArray<z.ZodObject<{
|
|
1807
|
-
pmid: z.ZodString;
|
|
1808
|
-
title: z.ZodString;
|
|
1809
|
-
paragraphs: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
1810
|
-
tags: z.ZodArray<z.ZodString, "many">;
|
|
1811
|
-
}, "strip", z.ZodTypeAny, {
|
|
1812
|
-
title: string;
|
|
1813
|
-
pmid: string;
|
|
1814
|
-
paragraphs: Record<string, string>;
|
|
1815
|
-
tags: string[];
|
|
1816
|
-
}, {
|
|
1817
|
-
title: string;
|
|
1818
|
-
pmid: string;
|
|
1819
|
-
paragraphs: Record<string, string>;
|
|
1820
|
-
tags: string[];
|
|
1821
|
-
}>, "many">;
|
|
1822
|
-
optionsSchema: z.ZodObject<{
|
|
1823
|
-
openRouterApiKey: z.ZodString;
|
|
1824
|
-
paragraphMergeStrategy: z.ZodDefault<z.ZodEffects<z.ZodString, NonNullable<"without-titles" | "with-titles-as-sentences" | "titles-within-sentences">, string>>;
|
|
1825
|
-
model: z.ZodString;
|
|
1826
|
-
placeholder: z.ZodDefault<z.ZodString>;
|
|
1827
|
-
nerPrompt: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1828
|
-
}, "strip", z.ZodTypeAny, {
|
|
1829
|
-
model: string;
|
|
1830
|
-
openRouterApiKey: string;
|
|
1831
|
-
paragraphMergeStrategy: NonNullable<"without-titles" | "with-titles-as-sentences" | "titles-within-sentences">;
|
|
1832
|
-
placeholder: string;
|
|
1833
|
-
nerPrompt: string;
|
|
1834
|
-
}, {
|
|
1835
|
-
model: string;
|
|
1836
|
-
openRouterApiKey: string;
|
|
1837
|
-
paragraphMergeStrategy?: string | undefined;
|
|
1838
|
-
placeholder?: string | undefined;
|
|
1839
|
-
nerPrompt?: string | undefined;
|
|
1840
|
-
}>;
|
|
1841
|
-
generatePrompts(input: TypeOf<this["inputSchema"]>, options?: z.input<(typeof this)["optionsSchema"]>): Promise<{
|
|
1842
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
1843
|
-
did: string;
|
|
1844
|
-
question: {
|
|
1845
|
-
sha256: string;
|
|
1846
|
-
data: string;
|
|
1847
|
-
cid: string;
|
|
1848
|
-
};
|
|
1849
|
-
fullPrompt: {
|
|
1850
|
-
sha256: string;
|
|
1851
|
-
data: string;
|
|
1852
|
-
cid: string;
|
|
1853
|
-
};
|
|
1854
|
-
answer?: string | undefined;
|
|
1855
|
-
metadata?: Record<string, any> | undefined;
|
|
1856
|
-
options?: Record<string, string> | undefined;
|
|
1857
|
-
answerKey?: string | undefined;
|
|
1858
|
-
scorers?: string[] | undefined;
|
|
1859
|
-
}[]>;
|
|
1860
|
-
private generatePromptFromArticle;
|
|
1861
|
-
private doNER;
|
|
1862
|
-
}
|
|
27
|
+
declare const idGeneratorUUIDv7: IdGenerator;
|
|
1863
28
|
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
/**
|
|
1873
|
-
* Unique identifier of the Provider.
|
|
1874
|
-
*/
|
|
1875
|
-
abstract readonly identifier: string;
|
|
1876
|
-
/**
|
|
1877
|
-
* Forwards the given input to the Provider and returns the response.
|
|
1878
|
-
*
|
|
1879
|
-
* @example
|
|
1880
|
-
* ```ts
|
|
1881
|
-
* const provider = new ImageGenerationProvider();
|
|
1882
|
-
*
|
|
1883
|
-
* // Input and the options are provider specific.
|
|
1884
|
-
* // In this example we are using a Provider that generates images from text inputs.
|
|
1885
|
-
* const response = await provider.forward("A beautiful sunset over a calm ocean", {
|
|
1886
|
-
* width: 1024,
|
|
1887
|
-
* height: 1024,
|
|
1888
|
-
* });
|
|
1889
|
-
*
|
|
1890
|
-
* // Write the generated image to a file
|
|
1891
|
-
* await fs.writeFile("response.png", response.data);
|
|
1892
|
-
* ```
|
|
1893
|
-
*/
|
|
1894
|
-
abstract forward(input: TInput, options?: any): Promise<ProviderResponse<TOutput>>;
|
|
1895
|
-
}
|
|
1896
|
-
/**
|
|
1897
|
-
* Type of the response returned by the Provider.
|
|
1898
|
-
*/
|
|
1899
|
-
type ProviderResponse<TData = Uint8Array> = {
|
|
1900
|
-
/**
|
|
1901
|
-
* The date and time when the response was started.
|
|
1902
|
-
*/
|
|
1903
|
-
startedAt: Date;
|
|
1904
|
-
/**
|
|
1905
|
-
* The date and time when the response was completed.
|
|
1906
|
-
*/
|
|
1907
|
-
completedAt: Date;
|
|
1908
|
-
/**
|
|
1909
|
-
* The response data.
|
|
1910
|
-
*/
|
|
1911
|
-
data: TData;
|
|
1912
|
-
};
|
|
1913
|
-
|
|
1914
|
-
/**
|
|
1915
|
-
* Base class for LLM based Providers. It uses OpenAI's API client to forward the
|
|
1916
|
-
* inputs to the underlying LLM and returns the response as a string. Also implements
|
|
1917
|
-
* rate limiting and timeout features for parallel execution.
|
|
1918
|
-
*/
|
|
1919
|
-
declare abstract class BaseLLMProvider extends AbstractProvider<string, string> {
|
|
1920
|
-
protected timestamps: number[];
|
|
1921
|
-
timeout: number;
|
|
1922
|
-
rateLimit: number;
|
|
1923
|
-
rateLimitTimeWindow: number;
|
|
1924
|
-
client: OpenAI;
|
|
1925
|
-
maxRetries: number;
|
|
1926
|
-
/**
|
|
1927
|
-
* Initialize a new LLM provider
|
|
1928
|
-
* @param options Options for the provider
|
|
1929
|
-
*/
|
|
1930
|
-
constructor(options: BaseLLMProviderOptions);
|
|
1931
|
-
enforceRateLimit(): Promise<void>;
|
|
1932
|
-
/**
|
|
1933
|
-
* Fetch all supported models from the provider
|
|
1934
|
-
* @returns Array of model information
|
|
1935
|
-
*/
|
|
1936
|
-
getSupportedModels(): Promise<ModelInfo[]>;
|
|
1937
|
-
forward(input: string | ChatCompletionMessageParam[], options: BaseLLMProviderForwardOptions): Promise<ForwardResponse>;
|
|
1938
|
-
/**
|
|
1939
|
-
* Parses the given model ID that includes the model name, owner, and sub-provider (if any).
|
|
1940
|
-
* @param id Model ID that has the format `<sub provider name if any>/<model owner>/<model name>`
|
|
1941
|
-
* @deprecated
|
|
1942
|
-
*/
|
|
1943
|
-
abstract parseModelInfo(modelOrId: OpenAI.Models.Model | string): MaybePromise<ModelInfo | undefined>;
|
|
1944
|
-
}
|
|
1945
|
-
type ForwardResponse = {
|
|
1946
|
-
data: string;
|
|
1947
|
-
startedAt: Date;
|
|
1948
|
-
completedAt: Date;
|
|
1949
|
-
inputTokensUsed?: number;
|
|
1950
|
-
inputCost?: string;
|
|
1951
|
-
outputTokensUsed?: number;
|
|
1952
|
-
outputCost?: string;
|
|
1953
|
-
};
|
|
1954
|
-
type BaseLLMProviderOptions = {
|
|
1955
|
-
/**
|
|
1956
|
-
* API key for the provider
|
|
1957
|
-
*/
|
|
1958
|
-
apiKey: string;
|
|
1959
|
-
/**
|
|
1960
|
-
* Base URL for the provider
|
|
1961
|
-
*/
|
|
1962
|
-
baseURL?: string;
|
|
1963
|
-
/**
|
|
1964
|
-
* Maximum number of retries for the provider
|
|
1965
|
-
*/
|
|
1966
|
-
maxRetries?: number;
|
|
1967
|
-
/**
|
|
1968
|
-
* Timeout for the provider
|
|
1969
|
-
*/
|
|
1970
|
-
timeout?: number;
|
|
1971
|
-
/**
|
|
1972
|
-
* Rate limit for the provider
|
|
1973
|
-
*/
|
|
1974
|
-
rateLimit?: number;
|
|
1975
|
-
/**
|
|
1976
|
-
* Rate limit time window for the provider
|
|
1977
|
-
*/
|
|
1978
|
-
rateLimitTimeWindow?: number;
|
|
1979
|
-
};
|
|
1980
|
-
type BaseLLMProviderForwardOptions = {
|
|
1981
|
-
model: string;
|
|
1982
|
-
system?: string;
|
|
1983
|
-
abortSignal?: AbortSignal;
|
|
1984
|
-
temperature?: number;
|
|
1985
|
-
};
|
|
1986
|
-
/**
|
|
1987
|
-
* Parsed information about the model.
|
|
1988
|
-
*/
|
|
1989
|
-
type ModelInfo = {
|
|
1990
|
-
/**
|
|
1991
|
-
* Original ID of the model that can be used in the requests
|
|
1992
|
-
*/
|
|
1993
|
-
id: string;
|
|
1994
|
-
/**
|
|
1995
|
-
* Unified name of the model
|
|
1996
|
-
*/
|
|
1997
|
-
name: LargeLanguageModelType;
|
|
1998
|
-
/**
|
|
1999
|
-
* Unified owner of the model
|
|
2000
|
-
*/
|
|
2001
|
-
owner: LargeLanguageModelOwnerType;
|
|
2002
|
-
/**
|
|
2003
|
-
* Provider name of the model
|
|
2004
|
-
* TODO: This field might be redundant
|
|
2005
|
-
*/
|
|
2006
|
-
provider: string;
|
|
2007
|
-
/**
|
|
2008
|
-
* The entity that responsible for hosting the model
|
|
2009
|
-
*/
|
|
2010
|
-
host?: string;
|
|
2011
|
-
/**
|
|
2012
|
-
* The tier of the model (e.g free, max)
|
|
2013
|
-
*/
|
|
2014
|
-
tier?: string;
|
|
2015
|
-
/**
|
|
2016
|
-
* Additional metadata (warning: not might be available always)
|
|
2017
|
-
*/
|
|
2018
|
-
metadata?: Record<string, unknown>;
|
|
2019
|
-
};
|
|
2020
|
-
/**
|
|
2021
|
-
* Known LLM owners
|
|
2022
|
-
*/
|
|
2023
|
-
declare const LargeLanguageModelOwner: {
|
|
2024
|
-
readonly Meta: "meta";
|
|
2025
|
-
readonly OpenAI: "openai";
|
|
2026
|
-
readonly Deepseek: "deepseek";
|
|
2027
|
-
readonly Qwen: "qwen";
|
|
2028
|
-
readonly Google: "google";
|
|
2029
|
-
readonly XAI: "x-ai";
|
|
2030
|
-
readonly Anthropic: "anthropic";
|
|
2031
|
-
readonly Mistral: "mistral";
|
|
2032
|
-
};
|
|
2033
|
-
type LargeLanguageModelOwnerType = (typeof LargeLanguageModelOwner)[keyof typeof LargeLanguageModelOwner];
|
|
2034
|
-
/**
|
|
2035
|
-
* Known models of Meta
|
|
2036
|
-
*/
|
|
2037
|
-
declare const MetaModels: {
|
|
2038
|
-
readonly Llama_4_Maverick: "llama-4-maverick";
|
|
2039
|
-
readonly Llama_4_Scout: "llama-4-scout";
|
|
2040
|
-
readonly Llama_3_3_70b_Instruct: "llama-3.3-70b-instruct";
|
|
2041
|
-
readonly Llama_3_1_8b_Instruct: "llama-3.1-8b-instruct";
|
|
2042
|
-
readonly Llama_3_1_70b_Instruct: "llama-3.1-70b-instruct";
|
|
2043
|
-
};
|
|
2044
|
-
/**
|
|
2045
|
-
* Known models of Qwen
|
|
2046
|
-
*/
|
|
2047
|
-
declare const QwenModels: {
|
|
2048
|
-
readonly QwQ_32b: "qwq-32b";
|
|
2049
|
-
};
|
|
2050
|
-
/**
|
|
2051
|
-
* Known models of DeepSeek
|
|
2052
|
-
*/
|
|
2053
|
-
declare const DeepSeekModels: {
|
|
2054
|
-
readonly V3: "deepseek-v3";
|
|
2055
|
-
readonly V3_0324: "deepseek-v3-0324";
|
|
2056
|
-
};
|
|
2057
|
-
/**
|
|
2058
|
-
* Known models of XAI
|
|
2059
|
-
*/
|
|
2060
|
-
declare const XAIModels: {
|
|
2061
|
-
readonly Grok3_Beta: "grok-3-beta";
|
|
2062
|
-
readonly Grok4: "grok-4";
|
|
2063
|
-
};
|
|
2064
|
-
/**
|
|
2065
|
-
* Known models of Google
|
|
2066
|
-
*/
|
|
2067
|
-
declare const GoogleModels: {
|
|
2068
|
-
readonly Gemini_2_0_Flash: "gemini-2.0-flash";
|
|
2069
|
-
readonly Gemini_2_5_Flash_Lite: "gemini-2.5-flash-lite";
|
|
2070
|
-
readonly Gemini_2_5_Pro: "gemini-2.5-pro";
|
|
2071
|
-
};
|
|
2072
|
-
/**
|
|
2073
|
-
* Known models of Anthropic
|
|
2074
|
-
*/
|
|
2075
|
-
declare const AnthropicModels: {
|
|
2076
|
-
readonly Claude_3_7_Sonnet: "claude-3.7-sonnet";
|
|
2077
|
-
readonly Claude_Sonnet_4_5: "claude-sonnet-4.5";
|
|
2078
|
-
};
|
|
2079
|
-
/**
|
|
2080
|
-
* Known models of OpenAI
|
|
2081
|
-
*/
|
|
2082
|
-
declare const OpenAIModels: {
|
|
2083
|
-
readonly ChatGPT_4o: "chatgpt-4o-latest";
|
|
2084
|
-
readonly GPT_4o: "gpt-4o";
|
|
2085
|
-
readonly GPT_4o_Mini: "gpt-4o-mini";
|
|
2086
|
-
readonly GPT_5: "gpt-5";
|
|
2087
|
-
};
|
|
2088
|
-
declare const MistralModels: {
|
|
2089
|
-
readonly Ministral_8B: "ministral-8b";
|
|
2090
|
-
};
|
|
2091
|
-
/**
|
|
2092
|
-
* Known models of all providers
|
|
2093
|
-
*/
|
|
2094
|
-
declare const LargeLanguageModel: {
|
|
2095
|
-
readonly meta: {
|
|
2096
|
-
readonly Llama_4_Maverick: "llama-4-maverick";
|
|
2097
|
-
readonly Llama_4_Scout: "llama-4-scout";
|
|
2098
|
-
readonly Llama_3_3_70b_Instruct: "llama-3.3-70b-instruct";
|
|
2099
|
-
readonly Llama_3_1_8b_Instruct: "llama-3.1-8b-instruct";
|
|
2100
|
-
readonly Llama_3_1_70b_Instruct: "llama-3.1-70b-instruct";
|
|
2101
|
-
};
|
|
2102
|
-
readonly deepseek: {
|
|
2103
|
-
readonly V3: "deepseek-v3";
|
|
2104
|
-
readonly V3_0324: "deepseek-v3-0324";
|
|
2105
|
-
};
|
|
2106
|
-
readonly qwen: {
|
|
2107
|
-
readonly QwQ_32b: "qwq-32b";
|
|
29
|
+
type Runner<TTestCase extends z__default.ZodObject, TResponse extends z__default.ZodObject, TScore extends z__default.ZodObject, TProvider extends AbstractProvider, TScorer extends AbstractScorer, TRunConfig extends Record<string, unknown>> = (params: {
|
|
30
|
+
testCase: z__default.infer<TTestCase>;
|
|
31
|
+
provider: TProvider;
|
|
32
|
+
scorer?: TScorer;
|
|
33
|
+
runConfig: TRunConfig;
|
|
34
|
+
idGenerators?: {
|
|
35
|
+
response?: IdGenerator;
|
|
36
|
+
score?: IdGenerator;
|
|
2108
37
|
};
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
readonly "x-ai": {
|
|
2115
|
-
readonly Grok3_Beta: "grok-3-beta";
|
|
2116
|
-
readonly Grok4: "grok-4";
|
|
2117
|
-
};
|
|
2118
|
-
readonly openai: {
|
|
2119
|
-
readonly ChatGPT_4o: "chatgpt-4o-latest";
|
|
2120
|
-
readonly GPT_4o: "gpt-4o";
|
|
2121
|
-
readonly GPT_4o_Mini: "gpt-4o-mini";
|
|
2122
|
-
readonly GPT_5: "gpt-5";
|
|
2123
|
-
};
|
|
2124
|
-
readonly anthropic: {
|
|
2125
|
-
readonly Claude_3_7_Sonnet: "claude-3.7-sonnet";
|
|
2126
|
-
readonly Claude_Sonnet_4_5: "claude-sonnet-4.5";
|
|
2127
|
-
};
|
|
2128
|
-
readonly mistral: {
|
|
2129
|
-
readonly Ministral_8B: "ministral-8b";
|
|
2130
|
-
};
|
|
2131
|
-
};
|
|
2132
|
-
type LargeLanguageModelType = (typeof MetaModels)[keyof typeof MetaModels] | (typeof DeepSeekModels)[keyof typeof DeepSeekModels] | (typeof QwenModels)[keyof typeof QwenModels] | (typeof GoogleModels)[keyof typeof GoogleModels] | (typeof XAIModels)[keyof typeof XAIModels] | (typeof AnthropicModels)[keyof typeof AnthropicModels] | (typeof OpenAIModels)[keyof typeof OpenAIModels] | (typeof MistralModels)[keyof typeof MistralModels];
|
|
2133
|
-
|
|
2134
|
-
declare class OpenRouterProvider extends BaseLLMProvider {
|
|
2135
|
-
private models;
|
|
2136
|
-
private modelsCachePromise;
|
|
2137
|
-
private modelsUpdatedAt;
|
|
2138
|
-
readonly identifier = "openrouter.ai";
|
|
2139
|
-
constructor(options: OpenRouterProviderOptions);
|
|
2140
|
-
/**
|
|
2141
|
-
* Updates the cache that holds information about OpenRouter models
|
|
2142
|
-
* including pricing information. It will be valid for 24 hours as
|
|
2143
|
-
* long as the instance of this Provider object is alive.
|
|
2144
|
-
*/
|
|
2145
|
-
private updateModelsCache;
|
|
2146
|
-
/**
|
|
2147
|
-
* Returns the detailed information about
|
|
2148
|
-
* the models that are available on OpenRouter.
|
|
2149
|
-
*/
|
|
2150
|
-
getModelDetails(): Promise<ModelsResponse["data"] | undefined>;
|
|
2151
|
-
getModelDetails(modelId: string): Promise<ModelsResponse["data"][number] | undefined>;
|
|
2152
|
-
/**
|
|
2153
|
-
* Returns the credits that the account has on openrouter.ai
|
|
2154
|
-
*/
|
|
2155
|
-
getCredits(): Promise<any>;
|
|
2156
|
-
/**
|
|
2157
|
-
* Makes a request to a protected endpoint to validate the API key.
|
|
2158
|
-
*/
|
|
2159
|
-
validateApiKey(): Promise<boolean>;
|
|
2160
|
-
forward(input: string | ChatCompletionMessageParam$1[], options: BaseLLMProviderForwardOptions): Promise<ForwardResponse>;
|
|
2161
|
-
parseModelInfo(modelOrId: OpenAI.Models.Model | string): ModelInfo | undefined;
|
|
2162
|
-
}
|
|
2163
|
-
type OpenRouterProviderOptions = Omit<BaseLLMProviderOptions, "baseURL">;
|
|
2164
|
-
type PutModality = "text" | "image" | "file" | "audio";
|
|
2165
|
-
type Modality = "text->text" | "text+image->text" | "text+image->text+image";
|
|
2166
|
-
type ModelsResponse = {
|
|
2167
|
-
data: {
|
|
2168
|
-
readonly id: string;
|
|
2169
|
-
readonly canonical_slug: string;
|
|
2170
|
-
readonly hugging_face_id: null | string;
|
|
2171
|
-
readonly name: string;
|
|
2172
|
-
readonly created: number;
|
|
2173
|
-
readonly description: string;
|
|
2174
|
-
readonly context_length: number;
|
|
2175
|
-
readonly architecture: {
|
|
2176
|
-
readonly modality: Modality;
|
|
2177
|
-
readonly input_modalities: PutModality[];
|
|
2178
|
-
readonly output_modalities: PutModality[];
|
|
2179
|
-
readonly instruct_type: null | string;
|
|
2180
|
-
};
|
|
2181
|
-
readonly pricing: {
|
|
2182
|
-
readonly prompt: string;
|
|
2183
|
-
readonly completion: string;
|
|
2184
|
-
readonly request?: string;
|
|
2185
|
-
readonly image?: string;
|
|
2186
|
-
readonly web_search?: string;
|
|
2187
|
-
readonly internal_reasoning?: string;
|
|
2188
|
-
readonly input_cache_read?: string;
|
|
2189
|
-
readonly input_cache_write?: string;
|
|
2190
|
-
readonly audio?: string;
|
|
2191
|
-
};
|
|
2192
|
-
}[];
|
|
2193
|
-
};
|
|
2194
|
-
|
|
2195
|
-
declare class NearAIProvider extends BaseLLMProvider {
|
|
2196
|
-
readonly identifier = "near.ai";
|
|
2197
|
-
constructor(options: NearAIProviderOptions);
|
|
2198
|
-
parseModelInfo(modelOrId: OpenAI.Models.Model | string): ModelInfo | undefined;
|
|
2199
|
-
}
|
|
2200
|
-
type NearAIProviderOptions = Omit<BaseLLMProviderOptions, "baseURL">;
|
|
2201
|
-
|
|
2202
|
-
/**
|
|
2203
|
-
* Generic Multiple Choice Question Generator using an LLM model
|
|
2204
|
-
*/
|
|
2205
|
-
declare class MCQGenerator extends AbstractGenerator {
|
|
2206
|
-
readonly identifier = "mcq";
|
|
2207
|
-
inputSchema: z.ZodArray<z.ZodAny, "many">;
|
|
2208
|
-
optionsSchema: z.ZodEffects<z.ZodObject<{
|
|
2209
|
-
/**
|
|
2210
|
-
* The API key for the OpenRouter provider. Won't be used if `provider` is given.
|
|
2211
|
-
*/
|
|
2212
|
-
openRouterApiKey: z.ZodOptional<z.ZodString>;
|
|
2213
|
-
/**
|
|
2214
|
-
* The Provider that is going to be used to generate the Prompts.
|
|
2215
|
-
*/
|
|
2216
|
-
provider: z.ZodOptional<z.ZodType<BaseLLMProvider, z.ZodTypeDef, BaseLLMProvider>>;
|
|
2217
|
-
/**
|
|
2218
|
-
* The model that is going to be used to generate the prompts
|
|
2219
|
-
*/
|
|
2220
|
-
model: z.ZodString;
|
|
2221
|
-
systemPromptPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
2222
|
-
/**
|
|
2223
|
-
* Additional rules that will be appended to the system prompt.
|
|
2224
|
-
*/
|
|
2225
|
-
systemPromptRules: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
2226
|
-
systemPrompt: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
2227
|
-
systemPromptSuffix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
2228
|
-
/**
|
|
2229
|
-
* The main function that parses the input value to a string.
|
|
2230
|
-
*/
|
|
2231
|
-
parseInput: z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodString>;
|
|
2232
|
-
/**
|
|
2233
|
-
* Whether to include the original data as a field inside the metadata.
|
|
2234
|
-
*/
|
|
2235
|
-
includeOriginalInputAsMetadata: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
2236
|
-
/**
|
|
2237
|
-
* Additional metadata that is going to be added to the each Prompt.
|
|
2238
|
-
* If a function is given then that function takes an argument which
|
|
2239
|
-
* is the input value for each item and generates the additional metadata.
|
|
2240
|
-
*/
|
|
2241
|
-
additionalMetadata: z.ZodOptional<z.ZodUnion<[z.ZodFunction<z.ZodTuple<[z.ZodAny, z.ZodObject<{
|
|
2242
|
-
systemPrompt: z.ZodString;
|
|
2243
|
-
}, "strip", z.ZodTypeAny, {
|
|
2244
|
-
systemPrompt: string;
|
|
2245
|
-
}, {
|
|
2246
|
-
systemPrompt: string;
|
|
2247
|
-
}>], z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodAny>>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
|
|
2248
|
-
}, "strip", z.ZodTypeAny, {
|
|
2249
|
-
model: string;
|
|
2250
|
-
systemPrompt: string;
|
|
2251
|
-
systemPromptPrefix: string;
|
|
2252
|
-
systemPromptRules: string[];
|
|
2253
|
-
systemPromptSuffix: string;
|
|
2254
|
-
parseInput: (args_0: any, ...args: unknown[]) => string;
|
|
2255
|
-
includeOriginalInputAsMetadata: boolean;
|
|
2256
|
-
provider?: BaseLLMProvider | undefined;
|
|
2257
|
-
openRouterApiKey?: string | undefined;
|
|
2258
|
-
additionalMetadata?: Record<string, any> | ((args_0: any, args_1: {
|
|
2259
|
-
systemPrompt: string;
|
|
2260
|
-
}, ...args: unknown[]) => Record<string, any>) | undefined;
|
|
2261
|
-
}, {
|
|
2262
|
-
model: string;
|
|
2263
|
-
parseInput: (args_0: any, ...args: unknown[]) => string;
|
|
2264
|
-
provider?: BaseLLMProvider | undefined;
|
|
2265
|
-
openRouterApiKey?: string | undefined;
|
|
2266
|
-
systemPrompt?: string | undefined;
|
|
2267
|
-
systemPromptPrefix?: string | undefined;
|
|
2268
|
-
systemPromptRules?: string[] | undefined;
|
|
2269
|
-
systemPromptSuffix?: string | undefined;
|
|
2270
|
-
includeOriginalInputAsMetadata?: boolean | undefined;
|
|
2271
|
-
additionalMetadata?: Record<string, any> | ((args_0: any, args_1: {
|
|
2272
|
-
systemPrompt: string;
|
|
2273
|
-
}, ...args: unknown[]) => Record<string, any>) | undefined;
|
|
2274
|
-
}>, {
|
|
2275
|
-
model: string;
|
|
2276
|
-
systemPrompt: string;
|
|
2277
|
-
systemPromptPrefix: string;
|
|
2278
|
-
systemPromptRules: string[];
|
|
2279
|
-
systemPromptSuffix: string;
|
|
2280
|
-
parseInput: (args_0: any, ...args: unknown[]) => string;
|
|
2281
|
-
includeOriginalInputAsMetadata: boolean;
|
|
2282
|
-
provider?: BaseLLMProvider | undefined;
|
|
2283
|
-
openRouterApiKey?: string | undefined;
|
|
2284
|
-
additionalMetadata?: Record<string, any> | ((args_0: any, args_1: {
|
|
2285
|
-
systemPrompt: string;
|
|
2286
|
-
}, ...args: unknown[]) => Record<string, any>) | undefined;
|
|
2287
|
-
}, {
|
|
2288
|
-
model: string;
|
|
2289
|
-
parseInput: (args_0: any, ...args: unknown[]) => string;
|
|
2290
|
-
provider?: BaseLLMProvider | undefined;
|
|
2291
|
-
openRouterApiKey?: string | undefined;
|
|
2292
|
-
systemPrompt?: string | undefined;
|
|
2293
|
-
systemPromptPrefix?: string | undefined;
|
|
2294
|
-
systemPromptRules?: string[] | undefined;
|
|
2295
|
-
systemPromptSuffix?: string | undefined;
|
|
2296
|
-
includeOriginalInputAsMetadata?: boolean | undefined;
|
|
2297
|
-
additionalMetadata?: Record<string, any> | ((args_0: any, args_1: {
|
|
2298
|
-
systemPrompt: string;
|
|
2299
|
-
}, ...args: unknown[]) => Record<string, any>) | undefined;
|
|
2300
|
-
}>;
|
|
2301
|
-
generatePrompts(input: z.input<this["inputSchema"]>, options?: z.input<this["optionsSchema"]>): Promise<{
|
|
2302
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
2303
|
-
did: string;
|
|
2304
|
-
question: {
|
|
2305
|
-
sha256: string;
|
|
2306
|
-
data: string;
|
|
2307
|
-
cid: string;
|
|
2308
|
-
};
|
|
2309
|
-
fullPrompt: {
|
|
2310
|
-
sha256: string;
|
|
2311
|
-
data: string;
|
|
2312
|
-
cid: string;
|
|
2313
|
-
};
|
|
2314
|
-
answer?: string | undefined;
|
|
2315
|
-
metadata?: Record<string, any> | undefined;
|
|
2316
|
-
options?: Record<string, string> | undefined;
|
|
2317
|
-
answerKey?: string | undefined;
|
|
2318
|
-
scorers?: string[] | undefined;
|
|
2319
|
-
}[]>;
|
|
2320
|
-
private generateFromInput;
|
|
2321
|
-
}
|
|
2322
|
-
|
|
2323
|
-
declare class OpenEndedGenerator extends AbstractGenerator {
|
|
2324
|
-
readonly identifier = "open-ended";
|
|
2325
|
-
inputSchema: z.ZodArray<z.ZodAny, "many">;
|
|
2326
|
-
optionsSchema: z.ZodEffects<z.ZodObject<{
|
|
2327
|
-
/**
|
|
2328
|
-
* The API key for the OpenRouter provider. Won't be used if `provider` is given.
|
|
2329
|
-
*/
|
|
2330
|
-
openRouterApiKey: z.ZodOptional<z.ZodString>;
|
|
2331
|
-
/**
|
|
2332
|
-
* The Provider that is going to be used to generate the Prompts.
|
|
2333
|
-
*/
|
|
2334
|
-
provider: z.ZodOptional<z.ZodType<BaseLLMProvider, z.ZodTypeDef, BaseLLMProvider>>;
|
|
2335
|
-
/**
|
|
2336
|
-
* The model that is going to be used to generate the prompts
|
|
2337
|
-
*/
|
|
2338
|
-
model: z.ZodString;
|
|
2339
|
-
/**
|
|
2340
|
-
* Adds an additional clue to the end of the question such as "Answer with a positive number"
|
|
2341
|
-
* which is relevant with the answer type expected.
|
|
2342
|
-
*/
|
|
2343
|
-
addClueToQuestion: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
2344
|
-
/**
|
|
2345
|
-
* Additional rules that will be appended to the system prompt.
|
|
2346
|
-
*/
|
|
2347
|
-
systemPromptRules: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
2348
|
-
systemPromptPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
2349
|
-
systemPrompt: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
2350
|
-
systemPromptSuffix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
2351
|
-
/**
|
|
2352
|
-
* The main function that parses the input value to a string.
|
|
2353
|
-
*/
|
|
2354
|
-
parseInput: z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodString>;
|
|
2355
|
-
/**
|
|
2356
|
-
* Whether to include the original as a field inside the metadata.
|
|
2357
|
-
*/
|
|
2358
|
-
includeOriginalInputAsMetadata: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
2359
|
-
/**
|
|
2360
|
-
* Additional metadata that is going to be added to the each Prompt.
|
|
2361
|
-
* If a function is given then that function takes an argument which
|
|
2362
|
-
* is the input value for each item and generates the additional metadata.
|
|
2363
|
-
*/
|
|
2364
|
-
additionalMetadata: z.ZodOptional<z.ZodUnion<[z.ZodFunction<z.ZodTuple<[z.ZodAny, z.ZodObject<{
|
|
2365
|
-
systemPrompt: z.ZodString;
|
|
2366
|
-
}, "strip", z.ZodTypeAny, {
|
|
2367
|
-
systemPrompt: string;
|
|
2368
|
-
}, {
|
|
2369
|
-
systemPrompt: string;
|
|
2370
|
-
}>], z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodAny>>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
|
|
2371
|
-
}, "strip", z.ZodTypeAny, {
|
|
2372
|
-
model: string;
|
|
2373
|
-
systemPrompt: string;
|
|
2374
|
-
systemPromptPrefix: string;
|
|
2375
|
-
systemPromptRules: string[];
|
|
2376
|
-
systemPromptSuffix: string;
|
|
2377
|
-
parseInput: (args_0: any, ...args: unknown[]) => string;
|
|
2378
|
-
includeOriginalInputAsMetadata: boolean;
|
|
2379
|
-
addClueToQuestion: boolean;
|
|
2380
|
-
provider?: BaseLLMProvider | undefined;
|
|
2381
|
-
openRouterApiKey?: string | undefined;
|
|
2382
|
-
additionalMetadata?: Record<string, any> | ((args_0: any, args_1: {
|
|
2383
|
-
systemPrompt: string;
|
|
2384
|
-
}, ...args: unknown[]) => Record<string, any>) | undefined;
|
|
2385
|
-
}, {
|
|
2386
|
-
model: string;
|
|
2387
|
-
parseInput: (args_0: any, ...args: unknown[]) => string;
|
|
2388
|
-
provider?: BaseLLMProvider | undefined;
|
|
2389
|
-
openRouterApiKey?: string | undefined;
|
|
2390
|
-
systemPrompt?: string | undefined;
|
|
2391
|
-
systemPromptPrefix?: string | undefined;
|
|
2392
|
-
systemPromptRules?: string[] | undefined;
|
|
2393
|
-
systemPromptSuffix?: string | undefined;
|
|
2394
|
-
includeOriginalInputAsMetadata?: boolean | undefined;
|
|
2395
|
-
additionalMetadata?: Record<string, any> | ((args_0: any, args_1: {
|
|
2396
|
-
systemPrompt: string;
|
|
2397
|
-
}, ...args: unknown[]) => Record<string, any>) | undefined;
|
|
2398
|
-
addClueToQuestion?: boolean | undefined;
|
|
2399
|
-
}>, {
|
|
2400
|
-
model: string;
|
|
2401
|
-
systemPrompt: string;
|
|
2402
|
-
systemPromptPrefix: string;
|
|
2403
|
-
systemPromptRules: string[];
|
|
2404
|
-
systemPromptSuffix: string;
|
|
2405
|
-
parseInput: (args_0: any, ...args: unknown[]) => string;
|
|
2406
|
-
includeOriginalInputAsMetadata: boolean;
|
|
2407
|
-
addClueToQuestion: boolean;
|
|
2408
|
-
provider?: BaseLLMProvider | undefined;
|
|
2409
|
-
openRouterApiKey?: string | undefined;
|
|
2410
|
-
additionalMetadata?: Record<string, any> | ((args_0: any, args_1: {
|
|
2411
|
-
systemPrompt: string;
|
|
2412
|
-
}, ...args: unknown[]) => Record<string, any>) | undefined;
|
|
2413
|
-
}, {
|
|
2414
|
-
model: string;
|
|
2415
|
-
parseInput: (args_0: any, ...args: unknown[]) => string;
|
|
2416
|
-
provider?: BaseLLMProvider | undefined;
|
|
2417
|
-
openRouterApiKey?: string | undefined;
|
|
2418
|
-
systemPrompt?: string | undefined;
|
|
2419
|
-
systemPromptPrefix?: string | undefined;
|
|
2420
|
-
systemPromptRules?: string[] | undefined;
|
|
2421
|
-
systemPromptSuffix?: string | undefined;
|
|
2422
|
-
includeOriginalInputAsMetadata?: boolean | undefined;
|
|
2423
|
-
additionalMetadata?: Record<string, any> | ((args_0: any, args_1: {
|
|
2424
|
-
systemPrompt: string;
|
|
2425
|
-
}, ...args: unknown[]) => Record<string, any>) | undefined;
|
|
2426
|
-
addClueToQuestion?: boolean | undefined;
|
|
2427
|
-
}>;
|
|
2428
|
-
generatePrompts(input: TypeOf<this["inputSchema"]>, options?: z.input<(typeof this)["optionsSchema"]>): Promise<{
|
|
2429
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
2430
|
-
did: string;
|
|
2431
|
-
question: {
|
|
2432
|
-
sha256: string;
|
|
2433
|
-
data: string;
|
|
2434
|
-
cid: string;
|
|
2435
|
-
};
|
|
2436
|
-
fullPrompt: {
|
|
2437
|
-
sha256: string;
|
|
2438
|
-
data: string;
|
|
2439
|
-
cid: string;
|
|
2440
|
-
};
|
|
2441
|
-
answer?: string | undefined;
|
|
2442
|
-
metadata?: Record<string, any> | undefined;
|
|
2443
|
-
options?: Record<string, string> | undefined;
|
|
2444
|
-
answerKey?: string | undefined;
|
|
2445
|
-
scorers?: string[] | undefined;
|
|
2446
|
-
}[]>;
|
|
2447
|
-
private generateFromInput;
|
|
2448
|
-
}
|
|
2449
|
-
|
|
2450
|
-
/**
|
|
2451
|
-
* Merges the paragraphs of a Pubmed article into a single string.
|
|
2452
|
-
*/
|
|
2453
|
-
declare function paragraphMerge(paragraphs: Record<string, string>, strategy: ParagraphMergeStrategyType): string;
|
|
2454
|
-
declare const ParagraphMergeStrategy: {
|
|
2455
|
-
readonly WithoutTitles: "without-titles";
|
|
2456
|
-
readonly TitlesAsSentences: "with-titles-as-sentences";
|
|
2457
|
-
readonly TitlesWithinSentences: "titles-within-sentences";
|
|
2458
|
-
};
|
|
2459
|
-
type ParagraphMergeStrategyType = (typeof ParagraphMergeStrategy)[keyof typeof ParagraphMergeStrategy];
|
|
2460
|
-
|
|
2461
|
-
/**
|
|
2462
|
-
* Abstract Registry class
|
|
2463
|
-
*
|
|
2464
|
-
* A Registry implementation is responsible from sending, receiving and doing
|
|
2465
|
-
* other operations with an external service such as a remote server.
|
|
2466
|
-
*/
|
|
2467
|
-
declare abstract class AbstractRegistry {
|
|
2468
|
-
/**
|
|
2469
|
-
* The unique identifier of the Registry.
|
|
2470
|
-
*/
|
|
2471
|
-
abstract readonly identifier: string;
|
|
2472
|
-
/**
|
|
2473
|
-
* Uploads the given prompts to the Registry.
|
|
2474
|
-
*
|
|
2475
|
-
* @returns the number of prompts uploaded
|
|
2476
|
-
*/
|
|
2477
|
-
abstract uploadPrompts(prompts: Prompt[], options?: Record<string, any>): MaybePromise<number>;
|
|
2478
|
-
/**
|
|
2479
|
-
* Uploads the given responses to the Registry.
|
|
2480
|
-
*
|
|
2481
|
-
* @returns the number of responses uploaded
|
|
2482
|
-
*/
|
|
2483
|
-
abstract uploadResponses(responses: PromptResponse[], options?: Record<string, any>): MaybePromise<number>;
|
|
2484
|
-
/**
|
|
2485
|
-
* Uploads the given scores to the Registry.
|
|
2486
|
-
*
|
|
2487
|
-
* @returns the number of scores uploaded
|
|
2488
|
-
*/
|
|
2489
|
-
abstract uploadScores(scores: PromptScore[], options?: Record<string, any> & {
|
|
2490
|
-
/**
|
|
2491
|
-
* Whether to include the response and prompt data in the scores
|
|
2492
|
-
*/
|
|
2493
|
-
includeData?: boolean;
|
|
2494
|
-
}): MaybePromise<number>;
|
|
2495
|
-
}
|
|
2496
|
-
|
|
2497
|
-
/**
|
|
2498
|
-
* Registry implementation for peerBench server
|
|
2499
|
-
*/
|
|
2500
|
-
declare class PeerBenchRegistry extends AbstractRegistry {
|
|
2501
|
-
static readonly identifier = "peerbench";
|
|
2502
|
-
readonly identifier = "peerbench";
|
|
2503
|
-
private token?;
|
|
2504
|
-
private supabaseClient?;
|
|
2505
|
-
private apiURL;
|
|
2506
|
-
private session;
|
|
2507
|
-
private readonly email?;
|
|
2508
|
-
private readonly password?;
|
|
2509
|
-
private readonly authMethod?;
|
|
2510
|
-
private refreshTokenInterval?;
|
|
2511
|
-
private isRefreshingToken;
|
|
2512
|
-
private isClosed;
|
|
2513
|
-
private isInitialized;
|
|
2514
|
-
private tokenRefresher;
|
|
2515
|
-
constructor(options: PeerBenchRegistryOptions);
|
|
2516
|
-
uploadPrompts(prompts: Prompt[], options: UploadPromptsOptions): Promise<number>;
|
|
2517
|
-
uploadResponses(responses: PromptResponse[], options?: UploadResponsesOptions): Promise<number>;
|
|
2518
|
-
uploadScores(scores: PromptScore[], options?: UploadScoresOptions): Promise<number>;
|
|
2519
|
-
/**
|
|
2520
|
-
* Clears the interval execution for refreshing the token.
|
|
2521
|
-
*/
|
|
2522
|
-
clearRefreshInterval(): Promise<void>;
|
|
2523
|
-
private init;
|
|
2524
|
-
/**
|
|
2525
|
-
* Refreshes the token if it is about to expire.
|
|
2526
|
-
*/
|
|
2527
|
-
private refreshToken;
|
|
2528
|
-
private login;
|
|
2529
|
-
}
|
|
2530
|
-
type PeerBenchRegistryOptionsBase = {
|
|
2531
|
-
peerbenchApiURL: string;
|
|
2532
|
-
/**
|
|
2533
|
-
* If you are using this instance in a browser environment, you can
|
|
2534
|
-
* use `cookie` approach to authenticate requests. In this case the
|
|
2535
|
-
* user must be logged in via Supabase auth.
|
|
2536
|
-
* @default "token"
|
|
2537
|
-
*/
|
|
2538
|
-
authMethod?: "token" | "cookie";
|
|
2539
|
-
/**
|
|
2540
|
-
* Supabase tokens must be refreshed periodically.
|
|
2541
|
-
* But if the class usage is short-lived, it's not necessary to start
|
|
2542
|
-
* a background interval for refreshing the token.
|
|
2543
|
-
* @default false
|
|
2544
|
-
*/
|
|
2545
|
-
tokenRefresher?: boolean;
|
|
2546
|
-
peerbenchSupabaseURL?: string;
|
|
2547
|
-
peerbenchSupabaseAnonKey?: string;
|
|
2548
|
-
email?: string;
|
|
2549
|
-
password?: string;
|
|
2550
|
-
};
|
|
2551
|
-
type PeerBenchRegistryOptions = (PeerBenchRegistryOptionsBase & {
|
|
2552
|
-
authMethod?: "token";
|
|
2553
|
-
tokenRefresher?: boolean;
|
|
2554
|
-
peerbenchSupabaseURL: string;
|
|
2555
|
-
peerbenchSupabaseAnonKey: string;
|
|
2556
|
-
email: string;
|
|
2557
|
-
password: string;
|
|
2558
|
-
}) | (PeerBenchRegistryOptionsBase & {
|
|
2559
|
-
authMethod: "cookie";
|
|
2560
|
-
tokenRefresher?: never;
|
|
2561
|
-
peerbenchSupabaseURL?: never;
|
|
2562
|
-
peerbenchSupabaseAnonKey?: never;
|
|
2563
|
-
email?: never;
|
|
2564
|
-
password?: never;
|
|
2565
|
-
});
|
|
2566
|
-
/**
|
|
2567
|
-
* Options for uploading prompts
|
|
2568
|
-
*/
|
|
2569
|
-
type UploadPromptsOptions = {
|
|
2570
|
-
promptSetId: number;
|
|
2571
|
-
account?: Account;
|
|
2572
|
-
};
|
|
2573
|
-
/**
|
|
2574
|
-
* Options for uploading responses
|
|
2575
|
-
*/
|
|
2576
|
-
type UploadResponsesOptions = {
|
|
2577
|
-
account?: Account;
|
|
2578
|
-
};
|
|
2579
|
-
/**
|
|
2580
|
-
* Options for uploading scores
|
|
2581
|
-
*/
|
|
2582
|
-
type UploadScoresOptions = {
|
|
2583
|
-
account?: Account;
|
|
2584
|
-
};
|
|
2585
|
-
|
|
2586
|
-
/**
|
|
2587
|
-
* Abstract base class for scorers
|
|
2588
|
-
*/
|
|
2589
|
-
declare abstract class AbstractScorer {
|
|
2590
|
-
/**
|
|
2591
|
-
* Unique identifier for the scorer
|
|
2592
|
-
*/
|
|
2593
|
-
abstract readonly identifier: string;
|
|
2594
|
-
/**
|
|
2595
|
-
* Score a single response
|
|
2596
|
-
* @param response The response to score
|
|
2597
|
-
* @param options Additional options for scoring
|
|
2598
|
-
* @returns PromptScore object including the given Response, Prompt and the calculated Score
|
|
2599
|
-
*/
|
|
2600
|
-
abstract scoreOne(response: PromptResponse, options?: Record<string, any>): MaybePromise<PromptScore | undefined>;
|
|
2601
|
-
/**
|
|
2602
|
-
* Checks whether the scorer is eligible to score the given response
|
|
2603
|
-
*/
|
|
2604
|
-
abstract canScore(response: PromptResponse): MaybePromise<boolean>;
|
|
2605
|
-
}
|
|
2606
|
-
|
|
2607
|
-
/**
|
|
2608
|
-
* Scorer implementation for multiple choice questions. Parses the answer letter
|
|
2609
|
-
* from the response text by looking for patterns like `answer is <letter>` or
|
|
2610
|
-
* `<letter>:` and compares it with the `answerKey` of the prompt.
|
|
2611
|
-
*/
|
|
2612
|
-
declare class MultipleChoiceScorer extends AbstractScorer {
|
|
2613
|
-
readonly identifier = "multiple-choice";
|
|
2614
|
-
private readonly EXPLANATION_TEXT;
|
|
2615
|
-
/**
|
|
2616
|
-
* Score a multiple choice response
|
|
2617
|
-
*/
|
|
2618
|
-
scoreOne(response: PromptResponse): Promise<{
|
|
2619
|
-
sha256: string;
|
|
2620
|
-
startedAt: number;
|
|
2621
|
-
modelName: string;
|
|
2622
|
-
did: string;
|
|
2623
|
-
cid: string;
|
|
2624
|
-
provider: string;
|
|
2625
|
-
modelId: string;
|
|
2626
|
-
modelOwner: string;
|
|
2627
|
-
modelHost: string;
|
|
2628
|
-
finishedAt: number;
|
|
2629
|
-
runId: string;
|
|
2630
|
-
scoreDID: string;
|
|
2631
|
-
score: number;
|
|
2632
|
-
method: "human" | "ai" | "algo";
|
|
2633
|
-
metadata?: Record<string, any> | undefined;
|
|
2634
|
-
inputTokensUsed?: number | undefined;
|
|
2635
|
-
outputTokensUsed?: number | undefined;
|
|
2636
|
-
data?: string | undefined;
|
|
2637
|
-
inputCost?: string | undefined;
|
|
2638
|
-
outputCost?: string | undefined;
|
|
2639
|
-
prompt?: {
|
|
2640
|
-
did: string;
|
|
2641
|
-
question: {
|
|
2642
|
-
sha256: string;
|
|
2643
|
-
cid: string;
|
|
2644
|
-
data?: string | undefined;
|
|
2645
|
-
};
|
|
2646
|
-
fullPrompt: {
|
|
2647
|
-
sha256: string;
|
|
2648
|
-
cid: string;
|
|
2649
|
-
data?: string | undefined;
|
|
2650
|
-
};
|
|
2651
|
-
answer?: string | undefined;
|
|
2652
|
-
metadata?: Record<string, any> | undefined;
|
|
2653
|
-
options?: Record<string, string> | undefined;
|
|
2654
|
-
type?: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs" | undefined;
|
|
2655
|
-
answerKey?: string | undefined;
|
|
2656
|
-
scorers?: string[] | undefined;
|
|
2657
|
-
} | undefined;
|
|
2658
|
-
scoreMetadata?: Record<string, any> | undefined;
|
|
2659
|
-
explanation?: string | undefined;
|
|
2660
|
-
scorerAI?: {
|
|
2661
|
-
modelName: string;
|
|
2662
|
-
provider: string;
|
|
2663
|
-
modelId: string;
|
|
2664
|
-
modelOwner: string;
|
|
2665
|
-
modelHost: string;
|
|
2666
|
-
inputTokensUsed?: number | undefined;
|
|
2667
|
-
outputTokensUsed?: number | undefined;
|
|
2668
|
-
inputCost?: string | undefined;
|
|
2669
|
-
outputCost?: string | undefined;
|
|
2670
|
-
} | undefined;
|
|
2671
|
-
} | undefined>;
|
|
2672
|
-
canScore(response: PromptResponse): Promise<boolean>;
|
|
2673
|
-
/**
|
|
2674
|
-
* Extracts answer from Response text using regex patterns
|
|
2675
|
-
*/
|
|
2676
|
-
private lookForAnswer;
|
|
2677
|
-
private escapeRegex;
|
|
2678
|
-
}
|
|
2679
|
-
|
|
2680
|
-
/**
|
|
2681
|
-
* It can be used both for multiple choice and free form questions.
|
|
2682
|
-
* If the Prompt includes options (aka it is multiple choice question) then
|
|
2683
|
-
* compares the `answerKey` field with the response and checks if they are the same.
|
|
2684
|
-
* Otherwise uses `answer` field for the same thing.
|
|
2685
|
-
*/
|
|
2686
|
-
declare class ExactMatchScorer extends AbstractScorer {
|
|
2687
|
-
readonly identifier = "exact-match";
|
|
2688
|
-
scoreOne(response: PromptResponse): Promise<{
|
|
2689
|
-
sha256: string;
|
|
2690
|
-
startedAt: number;
|
|
2691
|
-
modelName: string;
|
|
2692
|
-
did: string;
|
|
2693
|
-
cid: string;
|
|
2694
|
-
provider: string;
|
|
2695
|
-
modelId: string;
|
|
2696
|
-
modelOwner: string;
|
|
2697
|
-
modelHost: string;
|
|
2698
|
-
finishedAt: number;
|
|
2699
|
-
runId: string;
|
|
2700
|
-
scoreDID: string;
|
|
2701
|
-
score: number;
|
|
2702
|
-
method: "human" | "ai" | "algo";
|
|
2703
|
-
metadata?: Record<string, any> | undefined;
|
|
2704
|
-
inputTokensUsed?: number | undefined;
|
|
2705
|
-
outputTokensUsed?: number | undefined;
|
|
2706
|
-
data?: string | undefined;
|
|
2707
|
-
inputCost?: string | undefined;
|
|
2708
|
-
outputCost?: string | undefined;
|
|
2709
|
-
prompt?: {
|
|
2710
|
-
did: string;
|
|
2711
|
-
question: {
|
|
2712
|
-
sha256: string;
|
|
2713
|
-
cid: string;
|
|
2714
|
-
data?: string | undefined;
|
|
2715
|
-
};
|
|
2716
|
-
fullPrompt: {
|
|
2717
|
-
sha256: string;
|
|
2718
|
-
cid: string;
|
|
2719
|
-
data?: string | undefined;
|
|
2720
|
-
};
|
|
2721
|
-
answer?: string | undefined;
|
|
2722
|
-
metadata?: Record<string, any> | undefined;
|
|
2723
|
-
options?: Record<string, string> | undefined;
|
|
2724
|
-
type?: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs" | undefined;
|
|
2725
|
-
answerKey?: string | undefined;
|
|
2726
|
-
scorers?: string[] | undefined;
|
|
2727
|
-
} | undefined;
|
|
2728
|
-
scoreMetadata?: Record<string, any> | undefined;
|
|
2729
|
-
explanation?: string | undefined;
|
|
2730
|
-
scorerAI?: {
|
|
2731
|
-
modelName: string;
|
|
2732
|
-
provider: string;
|
|
2733
|
-
modelId: string;
|
|
2734
|
-
modelOwner: string;
|
|
2735
|
-
modelHost: string;
|
|
2736
|
-
inputTokensUsed?: number | undefined;
|
|
2737
|
-
outputTokensUsed?: number | undefined;
|
|
2738
|
-
inputCost?: string | undefined;
|
|
2739
|
-
outputCost?: string | undefined;
|
|
2740
|
-
} | undefined;
|
|
2741
|
-
} | undefined>;
|
|
2742
|
-
canScore(response: PromptResponse): Promise<boolean>;
|
|
2743
|
-
}
|
|
2744
|
-
|
|
2745
|
-
/**
|
|
2746
|
-
* A Scorer which uses an LLM model to judge the response against the correct answer.
|
|
2747
|
-
*/
|
|
2748
|
-
declare class RefAnswerEqualityLLMJudgeScorer extends AbstractScorer {
|
|
2749
|
-
readonly identifier = "ref-answer-equality-llm-judge-scorer";
|
|
2750
|
-
optionsSchema: z.ZodEffects<z.ZodObject<{
|
|
2751
|
-
openRouterApiKey: z.ZodOptional<z.ZodString>;
|
|
2752
|
-
provider: z.ZodOptional<z.ZodType<BaseLLMProvider, z.ZodTypeDef, BaseLLMProvider>>;
|
|
2753
|
-
model: z.ZodString;
|
|
2754
|
-
prompt: z.ZodDefault<z.ZodString>;
|
|
2755
|
-
promptSuffix: z.ZodDefault<z.ZodString>;
|
|
2756
|
-
promptPrefix: z.ZodDefault<z.ZodString>;
|
|
2757
|
-
}, "strip", z.ZodTypeAny, {
|
|
2758
|
-
model: string;
|
|
2759
|
-
prompt: string;
|
|
2760
|
-
promptSuffix: string;
|
|
2761
|
-
promptPrefix: string;
|
|
2762
|
-
provider?: BaseLLMProvider | undefined;
|
|
2763
|
-
openRouterApiKey?: string | undefined;
|
|
2764
|
-
}, {
|
|
2765
|
-
model: string;
|
|
2766
|
-
provider?: BaseLLMProvider | undefined;
|
|
2767
|
-
prompt?: string | undefined;
|
|
2768
|
-
openRouterApiKey?: string | undefined;
|
|
2769
|
-
promptSuffix?: string | undefined;
|
|
2770
|
-
promptPrefix?: string | undefined;
|
|
2771
|
-
}>, {
|
|
2772
|
-
model: string;
|
|
2773
|
-
prompt: string;
|
|
2774
|
-
promptSuffix: string;
|
|
2775
|
-
promptPrefix: string;
|
|
2776
|
-
provider?: BaseLLMProvider | undefined;
|
|
2777
|
-
openRouterApiKey?: string | undefined;
|
|
2778
|
-
}, {
|
|
2779
|
-
model: string;
|
|
2780
|
-
provider?: BaseLLMProvider | undefined;
|
|
2781
|
-
prompt?: string | undefined;
|
|
2782
|
-
openRouterApiKey?: string | undefined;
|
|
2783
|
-
promptSuffix?: string | undefined;
|
|
2784
|
-
promptPrefix?: string | undefined;
|
|
2785
|
-
}>;
|
|
2786
|
-
scoreOne(response: PromptResponse, options: z.input<typeof this.optionsSchema>): Promise<{
|
|
2787
|
-
sha256: string;
|
|
2788
|
-
startedAt: number;
|
|
2789
|
-
modelName: string;
|
|
2790
|
-
did: string;
|
|
2791
|
-
cid: string;
|
|
2792
|
-
provider: string;
|
|
2793
|
-
modelId: string;
|
|
2794
|
-
modelOwner: string;
|
|
2795
|
-
modelHost: string;
|
|
2796
|
-
finishedAt: number;
|
|
2797
|
-
runId: string;
|
|
2798
|
-
scoreDID: string;
|
|
2799
|
-
score: number;
|
|
2800
|
-
method: "human" | "ai" | "algo";
|
|
2801
|
-
metadata?: Record<string, any> | undefined;
|
|
2802
|
-
inputTokensUsed?: number | undefined;
|
|
2803
|
-
outputTokensUsed?: number | undefined;
|
|
2804
|
-
data?: string | undefined;
|
|
2805
|
-
inputCost?: string | undefined;
|
|
2806
|
-
outputCost?: string | undefined;
|
|
2807
|
-
prompt?: {
|
|
2808
|
-
did: string;
|
|
2809
|
-
question: {
|
|
2810
|
-
sha256: string;
|
|
2811
|
-
cid: string;
|
|
2812
|
-
data?: string | undefined;
|
|
2813
|
-
};
|
|
2814
|
-
fullPrompt: {
|
|
2815
|
-
sha256: string;
|
|
2816
|
-
cid: string;
|
|
2817
|
-
data?: string | undefined;
|
|
2818
|
-
};
|
|
2819
|
-
answer?: string | undefined;
|
|
2820
|
-
metadata?: Record<string, any> | undefined;
|
|
2821
|
-
options?: Record<string, string> | undefined;
|
|
2822
|
-
type?: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs" | undefined;
|
|
2823
|
-
answerKey?: string | undefined;
|
|
2824
|
-
scorers?: string[] | undefined;
|
|
2825
|
-
} | undefined;
|
|
2826
|
-
scoreMetadata?: Record<string, any> | undefined;
|
|
2827
|
-
explanation?: string | undefined;
|
|
2828
|
-
scorerAI?: {
|
|
2829
|
-
modelName: string;
|
|
2830
|
-
provider: string;
|
|
2831
|
-
modelId: string;
|
|
2832
|
-
modelOwner: string;
|
|
2833
|
-
modelHost: string;
|
|
2834
|
-
inputTokensUsed?: number | undefined;
|
|
2835
|
-
outputTokensUsed?: number | undefined;
|
|
2836
|
-
inputCost?: string | undefined;
|
|
2837
|
-
outputCost?: string | undefined;
|
|
2838
|
-
} | undefined;
|
|
2839
|
-
} | undefined>;
|
|
2840
|
-
canScore(response: PromptResponse): Promise<boolean>;
|
|
2841
|
-
}
|
|
2842
|
-
|
|
2843
|
-
/**
|
|
2844
|
-
* This Scorer splits the given Response and the answer into sentences and checks the similarity between them.
|
|
2845
|
-
* For each sentence that is placed correctly in the Response (same position as in the answer) it counts one score.
|
|
2846
|
-
* The final score is the ratio of the number of sentences that are placed correctly in the Response to the total number of sentences in the answer.
|
|
2847
|
-
* Simply `correctly_placed_sentences / total_sentence_count`. It uses `sbd` library to split the text into sentences.
|
|
2848
|
-
*/
|
|
2849
|
-
declare class SimilarityScorer extends AbstractScorer {
|
|
2850
|
-
readonly identifier = "similarity";
|
|
2851
|
-
scoreOne(response: PromptResponse, options?: {
|
|
2852
|
-
ignoreCase?: boolean;
|
|
2853
|
-
}): Promise<{
|
|
2854
|
-
sha256: string;
|
|
2855
|
-
startedAt: number;
|
|
2856
|
-
modelName: string;
|
|
2857
|
-
did: string;
|
|
2858
|
-
cid: string;
|
|
2859
|
-
provider: string;
|
|
2860
|
-
modelId: string;
|
|
2861
|
-
modelOwner: string;
|
|
2862
|
-
modelHost: string;
|
|
2863
|
-
finishedAt: number;
|
|
2864
|
-
runId: string;
|
|
2865
|
-
scoreDID: string;
|
|
2866
|
-
score: number;
|
|
2867
|
-
method: "human" | "ai" | "algo";
|
|
2868
|
-
metadata?: Record<string, any> | undefined;
|
|
2869
|
-
inputTokensUsed?: number | undefined;
|
|
2870
|
-
outputTokensUsed?: number | undefined;
|
|
2871
|
-
data?: string | undefined;
|
|
2872
|
-
inputCost?: string | undefined;
|
|
2873
|
-
outputCost?: string | undefined;
|
|
2874
|
-
prompt?: {
|
|
2875
|
-
did: string;
|
|
2876
|
-
question: {
|
|
2877
|
-
sha256: string;
|
|
2878
|
-
cid: string;
|
|
2879
|
-
data?: string | undefined;
|
|
2880
|
-
};
|
|
2881
|
-
fullPrompt: {
|
|
2882
|
-
sha256: string;
|
|
2883
|
-
cid: string;
|
|
2884
|
-
data?: string | undefined;
|
|
2885
|
-
};
|
|
2886
|
-
answer?: string | undefined;
|
|
2887
|
-
metadata?: Record<string, any> | undefined;
|
|
2888
|
-
options?: Record<string, string> | undefined;
|
|
2889
|
-
type?: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs" | undefined;
|
|
2890
|
-
answerKey?: string | undefined;
|
|
2891
|
-
scorers?: string[] | undefined;
|
|
2892
|
-
} | undefined;
|
|
2893
|
-
scoreMetadata?: Record<string, any> | undefined;
|
|
2894
|
-
explanation?: string | undefined;
|
|
2895
|
-
scorerAI?: {
|
|
2896
|
-
modelName: string;
|
|
2897
|
-
provider: string;
|
|
2898
|
-
modelId: string;
|
|
2899
|
-
modelOwner: string;
|
|
2900
|
-
modelHost: string;
|
|
2901
|
-
inputTokensUsed?: number | undefined;
|
|
2902
|
-
outputTokensUsed?: number | undefined;
|
|
2903
|
-
inputCost?: string | undefined;
|
|
2904
|
-
outputCost?: string | undefined;
|
|
2905
|
-
} | undefined;
|
|
2906
|
-
} | undefined>;
|
|
2907
|
-
canScore(response: PromptResponse): Promise<boolean>;
|
|
2908
|
-
}
|
|
2909
|
-
|
|
2910
|
-
/**
|
|
2911
|
-
* LLM Judge Scorer that supports both pointwise and pairwise evaluation modes
|
|
2912
|
-
*/
|
|
2913
|
-
declare class LLMJudgeScorer extends AbstractScorer {
|
|
2914
|
-
readonly identifier = "llm-judge";
|
|
2915
|
-
optionsSchema: z.ZodEffects<z.ZodObject<{
|
|
2916
|
-
openRouterApiKey: z.ZodOptional<z.ZodString>;
|
|
2917
|
-
provider: z.ZodOptional<z.ZodType<BaseLLMProvider, z.ZodTypeDef, BaseLLMProvider>>;
|
|
2918
|
-
model: z.ZodDefault<z.ZodString>;
|
|
2919
|
-
mode: z.ZodDefault<z.ZodEnum<["pointwise", "pairwise"]>>;
|
|
2920
|
-
criteria: z.ZodArray<z.ZodObject<{
|
|
2921
|
-
id: z.ZodString;
|
|
2922
|
-
description: z.ZodString;
|
|
2923
|
-
weight: z.ZodDefault<z.ZodNumber>;
|
|
2924
|
-
scale: z.ZodDefault<z.ZodObject<{
|
|
2925
|
-
min: z.ZodDefault<z.ZodNumber>;
|
|
2926
|
-
max: z.ZodDefault<z.ZodNumber>;
|
|
2927
|
-
}, "strip", z.ZodTypeAny, {
|
|
2928
|
-
min: number;
|
|
2929
|
-
max: number;
|
|
2930
|
-
}, {
|
|
2931
|
-
min?: number | undefined;
|
|
2932
|
-
max?: number | undefined;
|
|
2933
|
-
}>>;
|
|
2934
|
-
}, "strip", z.ZodTypeAny, {
|
|
2935
|
-
id: string;
|
|
2936
|
-
description: string;
|
|
2937
|
-
weight: number;
|
|
2938
|
-
scale: {
|
|
2939
|
-
min: number;
|
|
2940
|
-
max: number;
|
|
2941
|
-
};
|
|
2942
|
-
}, {
|
|
2943
|
-
id: string;
|
|
2944
|
-
description: string;
|
|
2945
|
-
weight?: number | undefined;
|
|
2946
|
-
scale?: {
|
|
2947
|
-
min?: number | undefined;
|
|
2948
|
-
max?: number | undefined;
|
|
2949
|
-
} | undefined;
|
|
2950
|
-
}>, "many">;
|
|
2951
|
-
meta: z.ZodOptional<z.ZodRecord<z.ZodAny, z.ZodAny>>;
|
|
2952
|
-
temperature: z.ZodDefault<z.ZodNumber>;
|
|
2953
|
-
promptPrefix: z.ZodDefault<z.ZodString>;
|
|
2954
|
-
promptSuffix: z.ZodDefault<z.ZodString>;
|
|
2955
|
-
responseB: z.ZodOptional<z.ZodObject<{
|
|
2956
|
-
did: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodType<string, z.ZodTypeDef, string>>;
|
|
2957
|
-
provider: z.ZodString;
|
|
2958
|
-
modelId: z.ZodString;
|
|
2959
|
-
modelName: z.ZodString;
|
|
2960
|
-
modelOwner: z.ZodString;
|
|
2961
|
-
modelHost: z.ZodString;
|
|
2962
|
-
prompt: z.ZodEffects<z.ZodObject<{
|
|
2963
|
-
did: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodType<string, z.ZodTypeDef, string>>;
|
|
2964
|
-
question: z.ZodObject<{
|
|
2965
|
-
data: z.ZodString;
|
|
2966
|
-
cid: z.ZodString;
|
|
2967
|
-
sha256: z.ZodString;
|
|
2968
|
-
}, "strip", z.ZodTypeAny, {
|
|
2969
|
-
sha256: string;
|
|
2970
|
-
data: string;
|
|
2971
|
-
cid: string;
|
|
2972
|
-
}, {
|
|
2973
|
-
sha256: string;
|
|
2974
|
-
data: string;
|
|
2975
|
-
cid: string;
|
|
2976
|
-
}>;
|
|
2977
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2978
|
-
fullPrompt: z.ZodObject<{
|
|
2979
|
-
data: z.ZodString;
|
|
2980
|
-
cid: z.ZodString;
|
|
2981
|
-
sha256: z.ZodString;
|
|
2982
|
-
}, "strip", z.ZodTypeAny, {
|
|
2983
|
-
sha256: string;
|
|
2984
|
-
data: string;
|
|
2985
|
-
cid: string;
|
|
2986
|
-
}, {
|
|
2987
|
-
sha256: string;
|
|
2988
|
-
data: string;
|
|
2989
|
-
cid: string;
|
|
2990
|
-
}>;
|
|
2991
|
-
type: z.ZodNativeEnum<{
|
|
2992
|
-
readonly MultipleChoice: "multiple-choice";
|
|
2993
|
-
readonly OrderSentences: "order-sentences";
|
|
2994
|
-
readonly TextReplacement: "text-replacement";
|
|
2995
|
-
readonly Typo: "typo";
|
|
2996
|
-
readonly OpenEnded: "open-ended";
|
|
2997
|
-
readonly OpenEndedWithDocs: "open-ended-with-docs";
|
|
2998
|
-
}>;
|
|
2999
|
-
answer: z.ZodOptional<z.ZodString>;
|
|
3000
|
-
answerKey: z.ZodOptional<z.ZodString>;
|
|
3001
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
3002
|
-
scorers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3003
|
-
}, "strip", z.ZodTypeAny, {
|
|
3004
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3005
|
-
did: string;
|
|
3006
|
-
question: {
|
|
3007
|
-
sha256: string;
|
|
3008
|
-
data: string;
|
|
3009
|
-
cid: string;
|
|
3010
|
-
};
|
|
3011
|
-
fullPrompt: {
|
|
3012
|
-
sha256: string;
|
|
3013
|
-
data: string;
|
|
3014
|
-
cid: string;
|
|
3015
|
-
};
|
|
3016
|
-
answer?: string | undefined;
|
|
3017
|
-
metadata?: Record<string, any> | undefined;
|
|
3018
|
-
options?: Record<string, string> | undefined;
|
|
3019
|
-
answerKey?: string | undefined;
|
|
3020
|
-
scorers?: string[] | undefined;
|
|
3021
|
-
}, {
|
|
3022
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3023
|
-
did: string;
|
|
3024
|
-
question: {
|
|
3025
|
-
sha256: string;
|
|
3026
|
-
data: string;
|
|
3027
|
-
cid: string;
|
|
3028
|
-
};
|
|
3029
|
-
fullPrompt: {
|
|
3030
|
-
sha256: string;
|
|
3031
|
-
data: string;
|
|
3032
|
-
cid: string;
|
|
3033
|
-
};
|
|
3034
|
-
answer?: string | undefined;
|
|
3035
|
-
metadata?: Record<string, any> | undefined;
|
|
3036
|
-
options?: Record<string, string> | undefined;
|
|
3037
|
-
answerKey?: string | undefined;
|
|
3038
|
-
scorers?: string[] | undefined;
|
|
3039
|
-
}>, {
|
|
3040
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3041
|
-
did: string;
|
|
3042
|
-
question: {
|
|
3043
|
-
sha256: string;
|
|
3044
|
-
data: string;
|
|
3045
|
-
cid: string;
|
|
3046
|
-
};
|
|
3047
|
-
fullPrompt: {
|
|
3048
|
-
sha256: string;
|
|
3049
|
-
data: string;
|
|
3050
|
-
cid: string;
|
|
3051
|
-
};
|
|
3052
|
-
answer?: string | undefined;
|
|
3053
|
-
metadata?: Record<string, any> | undefined;
|
|
3054
|
-
options?: Record<string, string> | undefined;
|
|
3055
|
-
answerKey?: string | undefined;
|
|
3056
|
-
scorers?: string[] | undefined;
|
|
3057
|
-
}, {
|
|
3058
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3059
|
-
did: string;
|
|
3060
|
-
question: {
|
|
3061
|
-
sha256: string;
|
|
3062
|
-
data: string;
|
|
3063
|
-
cid: string;
|
|
3064
|
-
};
|
|
3065
|
-
fullPrompt: {
|
|
3066
|
-
sha256: string;
|
|
3067
|
-
data: string;
|
|
3068
|
-
cid: string;
|
|
3069
|
-
};
|
|
3070
|
-
answer?: string | undefined;
|
|
3071
|
-
metadata?: Record<string, any> | undefined;
|
|
3072
|
-
options?: Record<string, string> | undefined;
|
|
3073
|
-
answerKey?: string | undefined;
|
|
3074
|
-
scorers?: string[] | undefined;
|
|
3075
|
-
}>;
|
|
3076
|
-
cid: z.ZodString;
|
|
3077
|
-
sha256: z.ZodString;
|
|
3078
|
-
data: z.ZodString;
|
|
3079
|
-
startedAt: z.ZodNumber;
|
|
3080
|
-
finishedAt: z.ZodNumber;
|
|
3081
|
-
runId: z.ZodString;
|
|
3082
|
-
inputTokensUsed: z.ZodOptional<z.ZodNumber>;
|
|
3083
|
-
outputTokensUsed: z.ZodOptional<z.ZodNumber>;
|
|
3084
|
-
inputCost: z.ZodOptional<z.ZodString>;
|
|
3085
|
-
outputCost: z.ZodOptional<z.ZodString>;
|
|
3086
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
3087
|
-
}, "strip", z.ZodTypeAny, {
|
|
3088
|
-
sha256: string;
|
|
3089
|
-
startedAt: number;
|
|
3090
|
-
data: string;
|
|
3091
|
-
modelName: string;
|
|
3092
|
-
did: string;
|
|
3093
|
-
cid: string;
|
|
3094
|
-
provider: string;
|
|
3095
|
-
modelId: string;
|
|
3096
|
-
modelOwner: string;
|
|
3097
|
-
modelHost: string;
|
|
3098
|
-
prompt: {
|
|
3099
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3100
|
-
did: string;
|
|
3101
|
-
question: {
|
|
3102
|
-
sha256: string;
|
|
3103
|
-
data: string;
|
|
3104
|
-
cid: string;
|
|
3105
|
-
};
|
|
3106
|
-
fullPrompt: {
|
|
3107
|
-
sha256: string;
|
|
3108
|
-
data: string;
|
|
3109
|
-
cid: string;
|
|
3110
|
-
};
|
|
3111
|
-
answer?: string | undefined;
|
|
3112
|
-
metadata?: Record<string, any> | undefined;
|
|
3113
|
-
options?: Record<string, string> | undefined;
|
|
3114
|
-
answerKey?: string | undefined;
|
|
3115
|
-
scorers?: string[] | undefined;
|
|
3116
|
-
};
|
|
3117
|
-
finishedAt: number;
|
|
3118
|
-
runId: string;
|
|
3119
|
-
metadata?: Record<string, any> | undefined;
|
|
3120
|
-
inputTokensUsed?: number | undefined;
|
|
3121
|
-
outputTokensUsed?: number | undefined;
|
|
3122
|
-
inputCost?: string | undefined;
|
|
3123
|
-
outputCost?: string | undefined;
|
|
3124
|
-
}, {
|
|
3125
|
-
sha256: string;
|
|
3126
|
-
startedAt: number;
|
|
3127
|
-
data: string;
|
|
3128
|
-
modelName: string;
|
|
3129
|
-
did: string;
|
|
3130
|
-
cid: string;
|
|
3131
|
-
provider: string;
|
|
3132
|
-
modelId: string;
|
|
3133
|
-
modelOwner: string;
|
|
3134
|
-
modelHost: string;
|
|
3135
|
-
prompt: {
|
|
3136
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3137
|
-
did: string;
|
|
3138
|
-
question: {
|
|
3139
|
-
sha256: string;
|
|
3140
|
-
data: string;
|
|
3141
|
-
cid: string;
|
|
3142
|
-
};
|
|
3143
|
-
fullPrompt: {
|
|
3144
|
-
sha256: string;
|
|
3145
|
-
data: string;
|
|
3146
|
-
cid: string;
|
|
3147
|
-
};
|
|
3148
|
-
answer?: string | undefined;
|
|
3149
|
-
metadata?: Record<string, any> | undefined;
|
|
3150
|
-
options?: Record<string, string> | undefined;
|
|
3151
|
-
answerKey?: string | undefined;
|
|
3152
|
-
scorers?: string[] | undefined;
|
|
3153
|
-
};
|
|
3154
|
-
finishedAt: number;
|
|
3155
|
-
runId: string;
|
|
3156
|
-
metadata?: Record<string, any> | undefined;
|
|
3157
|
-
inputTokensUsed?: number | undefined;
|
|
3158
|
-
outputTokensUsed?: number | undefined;
|
|
3159
|
-
inputCost?: string | undefined;
|
|
3160
|
-
outputCost?: string | undefined;
|
|
3161
|
-
}>>;
|
|
3162
|
-
}, "strip", z.ZodTypeAny, {
|
|
3163
|
-
model: string;
|
|
3164
|
-
promptSuffix: string;
|
|
3165
|
-
promptPrefix: string;
|
|
3166
|
-
mode: "pointwise" | "pairwise";
|
|
3167
|
-
criteria: {
|
|
3168
|
-
id: string;
|
|
3169
|
-
description: string;
|
|
3170
|
-
weight: number;
|
|
3171
|
-
scale: {
|
|
3172
|
-
min: number;
|
|
3173
|
-
max: number;
|
|
3174
|
-
};
|
|
3175
|
-
}[];
|
|
3176
|
-
temperature: number;
|
|
3177
|
-
meta?: Record<any, any> | undefined;
|
|
3178
|
-
provider?: BaseLLMProvider | undefined;
|
|
3179
|
-
openRouterApiKey?: string | undefined;
|
|
3180
|
-
responseB?: {
|
|
3181
|
-
sha256: string;
|
|
3182
|
-
startedAt: number;
|
|
3183
|
-
data: string;
|
|
3184
|
-
modelName: string;
|
|
3185
|
-
did: string;
|
|
3186
|
-
cid: string;
|
|
3187
|
-
provider: string;
|
|
3188
|
-
modelId: string;
|
|
3189
|
-
modelOwner: string;
|
|
3190
|
-
modelHost: string;
|
|
3191
|
-
prompt: {
|
|
3192
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3193
|
-
did: string;
|
|
3194
|
-
question: {
|
|
3195
|
-
sha256: string;
|
|
3196
|
-
data: string;
|
|
3197
|
-
cid: string;
|
|
3198
|
-
};
|
|
3199
|
-
fullPrompt: {
|
|
3200
|
-
sha256: string;
|
|
3201
|
-
data: string;
|
|
3202
|
-
cid: string;
|
|
3203
|
-
};
|
|
3204
|
-
answer?: string | undefined;
|
|
3205
|
-
metadata?: Record<string, any> | undefined;
|
|
3206
|
-
options?: Record<string, string> | undefined;
|
|
3207
|
-
answerKey?: string | undefined;
|
|
3208
|
-
scorers?: string[] | undefined;
|
|
3209
|
-
};
|
|
3210
|
-
finishedAt: number;
|
|
3211
|
-
runId: string;
|
|
3212
|
-
metadata?: Record<string, any> | undefined;
|
|
3213
|
-
inputTokensUsed?: number | undefined;
|
|
3214
|
-
outputTokensUsed?: number | undefined;
|
|
3215
|
-
inputCost?: string | undefined;
|
|
3216
|
-
outputCost?: string | undefined;
|
|
3217
|
-
} | undefined;
|
|
3218
|
-
}, {
|
|
3219
|
-
criteria: {
|
|
3220
|
-
id: string;
|
|
3221
|
-
description: string;
|
|
3222
|
-
weight?: number | undefined;
|
|
3223
|
-
scale?: {
|
|
3224
|
-
min?: number | undefined;
|
|
3225
|
-
max?: number | undefined;
|
|
3226
|
-
} | undefined;
|
|
3227
|
-
}[];
|
|
3228
|
-
meta?: Record<any, any> | undefined;
|
|
3229
|
-
model?: string | undefined;
|
|
3230
|
-
provider?: BaseLLMProvider | undefined;
|
|
3231
|
-
openRouterApiKey?: string | undefined;
|
|
3232
|
-
promptSuffix?: string | undefined;
|
|
3233
|
-
promptPrefix?: string | undefined;
|
|
3234
|
-
mode?: "pointwise" | "pairwise" | undefined;
|
|
3235
|
-
temperature?: number | undefined;
|
|
3236
|
-
responseB?: {
|
|
3237
|
-
sha256: string;
|
|
3238
|
-
startedAt: number;
|
|
3239
|
-
data: string;
|
|
3240
|
-
modelName: string;
|
|
3241
|
-
did: string;
|
|
3242
|
-
cid: string;
|
|
3243
|
-
provider: string;
|
|
3244
|
-
modelId: string;
|
|
3245
|
-
modelOwner: string;
|
|
3246
|
-
modelHost: string;
|
|
3247
|
-
prompt: {
|
|
3248
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3249
|
-
did: string;
|
|
3250
|
-
question: {
|
|
3251
|
-
sha256: string;
|
|
3252
|
-
data: string;
|
|
3253
|
-
cid: string;
|
|
3254
|
-
};
|
|
3255
|
-
fullPrompt: {
|
|
3256
|
-
sha256: string;
|
|
3257
|
-
data: string;
|
|
3258
|
-
cid: string;
|
|
3259
|
-
};
|
|
3260
|
-
answer?: string | undefined;
|
|
3261
|
-
metadata?: Record<string, any> | undefined;
|
|
3262
|
-
options?: Record<string, string> | undefined;
|
|
3263
|
-
answerKey?: string | undefined;
|
|
3264
|
-
scorers?: string[] | undefined;
|
|
3265
|
-
};
|
|
3266
|
-
finishedAt: number;
|
|
3267
|
-
runId: string;
|
|
3268
|
-
metadata?: Record<string, any> | undefined;
|
|
3269
|
-
inputTokensUsed?: number | undefined;
|
|
3270
|
-
outputTokensUsed?: number | undefined;
|
|
3271
|
-
inputCost?: string | undefined;
|
|
3272
|
-
outputCost?: string | undefined;
|
|
3273
|
-
} | undefined;
|
|
3274
|
-
}>, {
|
|
3275
|
-
model: string;
|
|
3276
|
-
promptSuffix: string;
|
|
3277
|
-
promptPrefix: string;
|
|
3278
|
-
mode: "pointwise" | "pairwise";
|
|
3279
|
-
criteria: {
|
|
3280
|
-
id: string;
|
|
3281
|
-
description: string;
|
|
3282
|
-
weight: number;
|
|
3283
|
-
scale: {
|
|
3284
|
-
min: number;
|
|
3285
|
-
max: number;
|
|
3286
|
-
};
|
|
3287
|
-
}[];
|
|
3288
|
-
temperature: number;
|
|
3289
|
-
meta?: Record<any, any> | undefined;
|
|
3290
|
-
provider?: BaseLLMProvider | undefined;
|
|
3291
|
-
openRouterApiKey?: string | undefined;
|
|
3292
|
-
responseB?: {
|
|
3293
|
-
sha256: string;
|
|
3294
|
-
startedAt: number;
|
|
3295
|
-
data: string;
|
|
3296
|
-
modelName: string;
|
|
3297
|
-
did: string;
|
|
3298
|
-
cid: string;
|
|
3299
|
-
provider: string;
|
|
3300
|
-
modelId: string;
|
|
3301
|
-
modelOwner: string;
|
|
3302
|
-
modelHost: string;
|
|
3303
|
-
prompt: {
|
|
3304
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3305
|
-
did: string;
|
|
3306
|
-
question: {
|
|
3307
|
-
sha256: string;
|
|
3308
|
-
data: string;
|
|
3309
|
-
cid: string;
|
|
3310
|
-
};
|
|
3311
|
-
fullPrompt: {
|
|
3312
|
-
sha256: string;
|
|
3313
|
-
data: string;
|
|
3314
|
-
cid: string;
|
|
3315
|
-
};
|
|
3316
|
-
answer?: string | undefined;
|
|
3317
|
-
metadata?: Record<string, any> | undefined;
|
|
3318
|
-
options?: Record<string, string> | undefined;
|
|
3319
|
-
answerKey?: string | undefined;
|
|
3320
|
-
scorers?: string[] | undefined;
|
|
3321
|
-
};
|
|
3322
|
-
finishedAt: number;
|
|
3323
|
-
runId: string;
|
|
3324
|
-
metadata?: Record<string, any> | undefined;
|
|
3325
|
-
inputTokensUsed?: number | undefined;
|
|
3326
|
-
outputTokensUsed?: number | undefined;
|
|
3327
|
-
inputCost?: string | undefined;
|
|
3328
|
-
outputCost?: string | undefined;
|
|
3329
|
-
} | undefined;
|
|
3330
|
-
}, {
|
|
3331
|
-
criteria: {
|
|
3332
|
-
id: string;
|
|
3333
|
-
description: string;
|
|
3334
|
-
weight?: number | undefined;
|
|
3335
|
-
scale?: {
|
|
3336
|
-
min?: number | undefined;
|
|
3337
|
-
max?: number | undefined;
|
|
3338
|
-
} | undefined;
|
|
3339
|
-
}[];
|
|
3340
|
-
meta?: Record<any, any> | undefined;
|
|
3341
|
-
model?: string | undefined;
|
|
3342
|
-
provider?: BaseLLMProvider | undefined;
|
|
3343
|
-
openRouterApiKey?: string | undefined;
|
|
3344
|
-
promptSuffix?: string | undefined;
|
|
3345
|
-
promptPrefix?: string | undefined;
|
|
3346
|
-
mode?: "pointwise" | "pairwise" | undefined;
|
|
3347
|
-
temperature?: number | undefined;
|
|
3348
|
-
responseB?: {
|
|
3349
|
-
sha256: string;
|
|
3350
|
-
startedAt: number;
|
|
3351
|
-
data: string;
|
|
3352
|
-
modelName: string;
|
|
3353
|
-
did: string;
|
|
3354
|
-
cid: string;
|
|
3355
|
-
provider: string;
|
|
3356
|
-
modelId: string;
|
|
3357
|
-
modelOwner: string;
|
|
3358
|
-
modelHost: string;
|
|
3359
|
-
prompt: {
|
|
3360
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3361
|
-
did: string;
|
|
3362
|
-
question: {
|
|
3363
|
-
sha256: string;
|
|
3364
|
-
data: string;
|
|
3365
|
-
cid: string;
|
|
3366
|
-
};
|
|
3367
|
-
fullPrompt: {
|
|
3368
|
-
sha256: string;
|
|
3369
|
-
data: string;
|
|
3370
|
-
cid: string;
|
|
3371
|
-
};
|
|
3372
|
-
answer?: string | undefined;
|
|
3373
|
-
metadata?: Record<string, any> | undefined;
|
|
3374
|
-
options?: Record<string, string> | undefined;
|
|
3375
|
-
answerKey?: string | undefined;
|
|
3376
|
-
scorers?: string[] | undefined;
|
|
3377
|
-
};
|
|
3378
|
-
finishedAt: number;
|
|
3379
|
-
runId: string;
|
|
3380
|
-
metadata?: Record<string, any> | undefined;
|
|
3381
|
-
inputTokensUsed?: number | undefined;
|
|
3382
|
-
outputTokensUsed?: number | undefined;
|
|
3383
|
-
inputCost?: string | undefined;
|
|
3384
|
-
outputCost?: string | undefined;
|
|
3385
|
-
} | undefined;
|
|
3386
|
-
}>;
|
|
3387
|
-
scoreOne(response: PromptResponse, options: z.input<typeof this.optionsSchema>): Promise<{
|
|
3388
|
-
sha256: string;
|
|
3389
|
-
startedAt: number;
|
|
3390
|
-
modelName: string;
|
|
3391
|
-
did: string;
|
|
3392
|
-
cid: string;
|
|
3393
|
-
provider: string;
|
|
3394
|
-
modelId: string;
|
|
3395
|
-
modelOwner: string;
|
|
3396
|
-
modelHost: string;
|
|
3397
|
-
finishedAt: number;
|
|
3398
|
-
runId: string;
|
|
3399
|
-
scoreDID: string;
|
|
3400
|
-
score: number;
|
|
3401
|
-
method: "human" | "ai" | "algo";
|
|
3402
|
-
metadata?: Record<string, any> | undefined;
|
|
3403
|
-
inputTokensUsed?: number | undefined;
|
|
3404
|
-
outputTokensUsed?: number | undefined;
|
|
3405
|
-
data?: string | undefined;
|
|
3406
|
-
inputCost?: string | undefined;
|
|
3407
|
-
outputCost?: string | undefined;
|
|
3408
|
-
prompt?: {
|
|
3409
|
-
did: string;
|
|
3410
|
-
question: {
|
|
3411
|
-
sha256: string;
|
|
3412
|
-
cid: string;
|
|
3413
|
-
data?: string | undefined;
|
|
3414
|
-
};
|
|
3415
|
-
fullPrompt: {
|
|
3416
|
-
sha256: string;
|
|
3417
|
-
cid: string;
|
|
3418
|
-
data?: string | undefined;
|
|
3419
|
-
};
|
|
3420
|
-
answer?: string | undefined;
|
|
3421
|
-
metadata?: Record<string, any> | undefined;
|
|
3422
|
-
options?: Record<string, string> | undefined;
|
|
3423
|
-
type?: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs" | undefined;
|
|
3424
|
-
answerKey?: string | undefined;
|
|
3425
|
-
scorers?: string[] | undefined;
|
|
3426
|
-
} | undefined;
|
|
3427
|
-
scoreMetadata?: Record<string, any> | undefined;
|
|
3428
|
-
explanation?: string | undefined;
|
|
3429
|
-
scorerAI?: {
|
|
3430
|
-
modelName: string;
|
|
3431
|
-
provider: string;
|
|
3432
|
-
modelId: string;
|
|
3433
|
-
modelOwner: string;
|
|
3434
|
-
modelHost: string;
|
|
3435
|
-
inputTokensUsed?: number | undefined;
|
|
3436
|
-
outputTokensUsed?: number | undefined;
|
|
3437
|
-
inputCost?: string | undefined;
|
|
3438
|
-
outputCost?: string | undefined;
|
|
3439
|
-
} | undefined;
|
|
3440
|
-
} | undefined>;
|
|
3441
|
-
private systemPrompt;
|
|
3442
|
-
private scorePointwise;
|
|
3443
|
-
private scorePairwise;
|
|
3444
|
-
/**
|
|
3445
|
-
* Build the pairwise evaluation prompt
|
|
3446
|
-
*/
|
|
3447
|
-
private buildPairwisePrompt;
|
|
3448
|
-
/**
|
|
3449
|
-
* Normalize criterion weights to sum to 1
|
|
3450
|
-
*/
|
|
3451
|
-
private normalizeWeights;
|
|
3452
|
-
/**
|
|
3453
|
-
* Render criteria as a formatted string
|
|
3454
|
-
*/
|
|
3455
|
-
private renderCriteria;
|
|
3456
|
-
/**
|
|
3457
|
-
* Compute overall score from per-criterion scores
|
|
3458
|
-
*/
|
|
3459
|
-
private computeOverallScore;
|
|
3460
|
-
/**
|
|
3461
|
-
* Extract criteria IDs from prompt text (fallback)
|
|
3462
|
-
*/
|
|
3463
|
-
private extractCriteria;
|
|
3464
|
-
canScore(response: PromptResponse, options?: Record<string, any>): Promise<boolean>;
|
|
3465
|
-
}
|
|
3466
|
-
|
|
3467
|
-
declare abstract class AbstractParser {
|
|
3468
|
-
/**
|
|
3469
|
-
* String identifier of the parser. Must be
|
|
3470
|
-
* set to distunguish the parser from the others.
|
|
3471
|
-
*/
|
|
3472
|
-
static readonly identifier: string;
|
|
3473
|
-
/**
|
|
3474
|
-
* Parses the given file
|
|
3475
|
-
*/
|
|
3476
|
-
abstract parseFile(path: string): MaybePromise<ParseResult>;
|
|
3477
|
-
/**
|
|
3478
|
-
* Parses the given buffer or string
|
|
3479
|
-
*/
|
|
3480
|
-
abstract parseContent(content: string | Uint8Array): MaybePromise<ParseResult>;
|
|
3481
|
-
/**
|
|
3482
|
-
* Returns the identifier of the parser.
|
|
3483
|
-
*/
|
|
3484
|
-
getIdentifier(): string | undefined;
|
|
3485
|
-
}
|
|
3486
|
-
type ParseResult = {
|
|
3487
|
-
prompts: Prompt[];
|
|
3488
|
-
responses: PromptResponse[];
|
|
3489
|
-
scores: PromptScore[];
|
|
3490
|
-
};
|
|
38
|
+
}) => Promise<{
|
|
39
|
+
response: z__default.infer<TResponse>;
|
|
40
|
+
score?: z__default.infer<TScore>;
|
|
41
|
+
}>;
|
|
42
|
+
type InferRunConfig<TRunConfigSchema extends z__default.ZodRawShape> = z__default.infer<z__default.ZodObject<TRunConfigSchema>>;
|
|
3491
43
|
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
* and Score objects for the each object from the data that is parsed from the file/content.
|
|
3497
|
-
*
|
|
3498
|
-
* It also prevents having same Prompts with different IDs using the
|
|
3499
|
-
* `fullPrompt` CID calculation of the produced Prompt objects.
|
|
3500
|
-
*/
|
|
3501
|
-
declare class GenericArrayParser extends AbstractParser {
|
|
3502
|
-
static readonly identifier: string;
|
|
3503
|
-
private promptBuilder;
|
|
3504
|
-
private responseBuilder?;
|
|
3505
|
-
private scoreBuilder?;
|
|
3506
|
-
constructor(options: {
|
|
3507
|
-
promptBuilder: GenericArrayParserPromptBuilder;
|
|
3508
|
-
responseBuilder?: GenericArrayParserResponseBuilder;
|
|
3509
|
-
scoreBuilder?: GenericArrayParserScoreBuilder;
|
|
44
|
+
declare class PeerbenchError extends Error {
|
|
45
|
+
code: number;
|
|
46
|
+
constructor(message?: string, options?: ErrorOptions & {
|
|
47
|
+
code: number;
|
|
3510
48
|
});
|
|
3511
|
-
parseFile(path: string): Promise<ParseResult>;
|
|
3512
|
-
parseContent(content: string | Uint8Array): Promise<ParseResult>;
|
|
3513
|
-
}
|
|
3514
|
-
type GenericArrayParserPromptBuilder = (data: any, context: {
|
|
3515
|
-
result: ParseResult;
|
|
3516
|
-
}) => MaybePromise<Prompt | undefined>;
|
|
3517
|
-
type GenericArrayParserResponseBuilder = (data: any, context: {
|
|
3518
|
-
result: ParseResult;
|
|
3519
|
-
/**
|
|
3520
|
-
* The generated Prompt object for the current item if there is one.
|
|
3521
|
-
*/
|
|
3522
|
-
prompt?: Prompt;
|
|
3523
|
-
}) => MaybePromise<PromptResponse | undefined>;
|
|
3524
|
-
type GenericArrayParserScoreBuilder = (data: any, context: {
|
|
3525
|
-
result: ParseResult;
|
|
3526
|
-
/**
|
|
3527
|
-
* The generated Prompt object for the current item if there is one.
|
|
3528
|
-
*/
|
|
3529
|
-
prompt?: Prompt;
|
|
3530
|
-
/**
|
|
3531
|
-
* The generated Response object for the current item if there is one.
|
|
3532
|
-
*/
|
|
3533
|
-
response?: PromptResponse;
|
|
3534
|
-
}) => MaybePromise<PromptScore | undefined>;
|
|
3535
|
-
|
|
3536
|
-
declare class MedQAParser extends AbstractParser {
|
|
3537
|
-
static readonly identifier = "medqa";
|
|
3538
|
-
parseFile(path: string): Promise<ParseResult>;
|
|
3539
|
-
parseContent(content: string | Uint8Array): Promise<ParseResult>;
|
|
3540
|
-
}
|
|
3541
|
-
|
|
3542
|
-
declare class MMLUProParser extends AbstractParser {
|
|
3543
|
-
static readonly identifier = "mmlu-pro";
|
|
3544
|
-
parseFile(path: string): Promise<ParseResult>;
|
|
3545
|
-
parseContent(content: string | Uint8Array): Promise<ParseResult>;
|
|
3546
49
|
}
|
|
3547
50
|
|
|
3548
|
-
|
|
3549
|
-
* Parser for the standard PeerBench format.
|
|
3550
|
-
*
|
|
3551
|
-
* The given data must be formatted as JSON or JSONL array of objects.
|
|
3552
|
-
*
|
|
3553
|
-
* Each object can be one of the following:
|
|
3554
|
-
* - Prompt,
|
|
3555
|
-
* - Response,
|
|
3556
|
-
* - Score
|
|
3557
|
-
*
|
|
3558
|
-
* Prompts that are included within the Response or Score objects are counted as Prompts in the result (deduplicated).
|
|
3559
|
-
*/
|
|
3560
|
-
declare class PBParser extends GenericArrayParser {
|
|
3561
|
-
static readonly identifier: string;
|
|
3562
|
-
constructor();
|
|
3563
|
-
}
|
|
51
|
+
declare function captureStackTrace(error: Error, constructor: Function): void;
|
|
3564
52
|
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
declare class DataParser {
|
|
3570
|
-
static parsers: Map<string, AbstractParser>;
|
|
3571
|
-
/**
|
|
3572
|
-
* Tries to parse data from a file path with one of the available parsers.
|
|
3573
|
-
* @example
|
|
3574
|
-
* ```typescript
|
|
3575
|
-
* const { result, parser } = await DataParser.parseFile("path/to/file.json");
|
|
3576
|
-
* ```
|
|
3577
|
-
*/
|
|
3578
|
-
static parseFile(path: string): Promise<{
|
|
3579
|
-
result: ParseResult;
|
|
3580
|
-
parser: AbstractParser;
|
|
3581
|
-
}>;
|
|
3582
|
-
/**
|
|
3583
|
-
* Tries to parse data from a string or ArrayBuffer content with one of the available parsers.
|
|
3584
|
-
* @example
|
|
3585
|
-
* ```typescript
|
|
3586
|
-
* // With string content
|
|
3587
|
-
* const { result, parser } = await DataParser.parseContent('{"question": "What is...", ...}');
|
|
3588
|
-
*
|
|
3589
|
-
* // With file upload in browser
|
|
3590
|
-
* const file = event.target.files[0];
|
|
3591
|
-
* const content = await file.arrayBuffer();
|
|
3592
|
-
* const { result, parser } = await DataParser.parseContent(content);
|
|
3593
|
-
* ```
|
|
3594
|
-
*/
|
|
3595
|
-
static parseContent(content: string | Uint8Array): Promise<{
|
|
3596
|
-
result: ParseResult;
|
|
3597
|
-
parser: AbstractParser;
|
|
3598
|
-
}>;
|
|
3599
|
-
}
|
|
3600
|
-
|
|
3601
|
-
/**
|
|
3602
|
-
* Parses JSONL formatted string into an array
|
|
3603
|
-
* @returns An array of parsed JSON lines
|
|
3604
|
-
*/
|
|
3605
|
-
declare function parseJSONL<T>(str: string, options?: {
|
|
3606
|
-
errorOnInvalid?: boolean;
|
|
3607
|
-
}): T[];
|
|
3608
|
-
/**
|
|
3609
|
-
* Tries to parse the given string as JSON.
|
|
3610
|
-
* Returns `undefined` if it is not a valid JSON entity.
|
|
3611
|
-
*/
|
|
3612
|
-
declare function tryParseJson<T = any>(content: string): T | undefined;
|
|
3613
|
-
/**
|
|
3614
|
-
* Stringifies the given JSON value using `safe-stable-stringify` in a stable manner.
|
|
3615
|
-
* This stable method generates the same string output for the same input value (including objects).
|
|
3616
|
-
*/
|
|
3617
|
-
declare function stableStringify(value: any): string | undefined;
|
|
3618
|
-
|
|
3619
|
-
/**
|
|
3620
|
-
* Calculates the CID of the given data
|
|
3621
|
-
*/
|
|
3622
|
-
declare function calculateCID(data: unknown): Promise<CID<unknown, 512, 18, 1>>;
|
|
3623
|
-
|
|
3624
|
-
declare function sleep(ms: number): Promise<void>;
|
|
3625
|
-
|
|
3626
|
-
/**
|
|
3627
|
-
* Reads the file and returns the content as a string.
|
|
3628
|
-
* @param path - The path to the file.
|
|
3629
|
-
* @returns The content of the file as a string.
|
|
3630
|
-
*/
|
|
3631
|
-
declare function readFile(path: string): Promise<Uint8Array>;
|
|
3632
|
-
|
|
3633
|
-
/**
|
|
3634
|
-
* Prepares the full Prompt that is going to be sent to the model
|
|
3635
|
-
*/
|
|
3636
|
-
declare function preparePrompt(question: string, options?: PromptOptions): string;
|
|
3637
|
-
|
|
3638
|
-
/**
|
|
3639
|
-
* Calculates the SHA-256 hash of the given text or byte array.
|
|
3640
|
-
* @param input - The text or byte array to calculate the hash of.
|
|
3641
|
-
* @returns The SHA-256 hash of the given input.
|
|
3642
|
-
*/
|
|
3643
|
-
declare function calculateSHA256(input: string | Uint8Array): Promise<string>;
|
|
3644
|
-
|
|
3645
|
-
/**
|
|
3646
|
-
* Removes the `did:<entity type>:` prefix from the given string and returns the rest.
|
|
3647
|
-
*/
|
|
3648
|
-
declare function removeDIDPrefix(did: string): string;
|
|
53
|
+
declare const PEERBENCH_NAMESPACE: "peerbench.ai";
|
|
54
|
+
declare const CATEGORIES: {
|
|
55
|
+
LLM: string;
|
|
56
|
+
};
|
|
3649
57
|
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
/**
|
|
3656
|
-
* When true, includes all time units (days, hours, minutes, seconds, ms) in the output
|
|
3657
|
-
*/
|
|
3658
|
-
full?: boolean;
|
|
58
|
+
declare function defineRunner<const TProviders extends ProviderCtor[], const TScorers extends ScorerCtor[], const TSchemaSets extends SchemaSetDefinition[], const TRunConfigSchema extends z__default.ZodRawShape = {}>(config: {
|
|
59
|
+
schemaSets: TSchemaSets;
|
|
60
|
+
providers: TProviders;
|
|
61
|
+
scorers: TScorers;
|
|
62
|
+
runConfigSchema?: TRunConfigSchema;
|
|
3659
63
|
/**
|
|
3660
|
-
*
|
|
64
|
+
* @default true
|
|
3661
65
|
*/
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
* @returns The string representation of the byte array
|
|
3668
|
-
*/
|
|
3669
|
-
declare function bufferToString(buffer: Uint8Array): string;
|
|
3670
|
-
/**
|
|
3671
|
-
* Converts a string to a byte array using the TextEncoder
|
|
3672
|
-
* @param str - The string to convert
|
|
3673
|
-
* @returns The byte array representation of the string
|
|
3674
|
-
*/
|
|
3675
|
-
declare function stringToBuffer(str: string): Uint8Array;
|
|
3676
|
-
/**
|
|
3677
|
-
* Python like string formatter. Replaces the `{key}` with the value from the `values` object.
|
|
3678
|
-
*/
|
|
3679
|
-
declare function formatString(str: string, values: Record<string, string>): string;
|
|
3680
|
-
|
|
3681
|
-
/**
|
|
3682
|
-
* Tries to repair and parse LLM response as a JSON object. LLM must
|
|
3683
|
-
* be configured to return a JSON object. This function only helps to
|
|
3684
|
-
* get rid out of some additional formatting (e.g. ```json).
|
|
3685
|
-
*/
|
|
3686
|
-
declare function parseResponseAsJSON<T>(response: string): T | undefined;
|
|
3687
|
-
/**
|
|
3688
|
-
* Extracts the first JSON formatted part from the response
|
|
3689
|
-
*/
|
|
3690
|
-
declare function extractJSONFromResponse(response: string): string | undefined;
|
|
3691
|
-
|
|
3692
|
-
/**
|
|
3693
|
-
* Extracts the first error message (if there is any)
|
|
3694
|
-
* from a Zod safe parse result and format it.
|
|
3695
|
-
* @param safeParseReturn
|
|
3696
|
-
* @param path Path of the parsing object. It will be used to indicate the invalid field if the info is not available in the validation error.
|
|
3697
|
-
*/
|
|
3698
|
-
declare function parseValidationError<T, K>(safeParseReturn: z.SafeParseReturnType<T, K>, path?: string): string | undefined;
|
|
3699
|
-
/**
|
|
3700
|
-
* Checks the error state of the given Zod safe parse result
|
|
3701
|
-
* and throws an error if there is any.
|
|
3702
|
-
* @param safeParseReturn
|
|
3703
|
-
* @param path Path of the parsing object. It will be used to indicate the invalid field if the info is not available in the validation error.
|
|
3704
|
-
*/
|
|
3705
|
-
declare function checkValidationError<T, K>(safeParseReturn: z.SafeParseReturnType<T, K>, path?: string): K;
|
|
3706
|
-
|
|
3707
|
-
/**
|
|
3708
|
-
* Builds a valid Prompt object from the given parameters.
|
|
3709
|
-
*/
|
|
3710
|
-
declare function buildPrompt(params: {
|
|
3711
|
-
did?: string;
|
|
3712
|
-
question: string;
|
|
3713
|
-
fullPrompt?: string;
|
|
3714
|
-
options?: Record<string, string>;
|
|
3715
|
-
answer?: string;
|
|
3716
|
-
answerKey?: string;
|
|
3717
|
-
type: PromptType;
|
|
3718
|
-
metadata?: Record<string, any>;
|
|
3719
|
-
scorers?: string[];
|
|
3720
|
-
}): Promise<{
|
|
3721
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3722
|
-
did: string;
|
|
3723
|
-
question: {
|
|
3724
|
-
sha256: string;
|
|
3725
|
-
data: string;
|
|
3726
|
-
cid: string;
|
|
66
|
+
parseRunConfig?: boolean;
|
|
67
|
+
defaults?: {
|
|
68
|
+
scorer?: InstanceType<TScorers[number]>;
|
|
69
|
+
responseIdGenerator?: IdGenerator;
|
|
70
|
+
scoreIdGenerator?: IdGenerator;
|
|
3727
71
|
};
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
cid: string;
|
|
3732
|
-
};
|
|
3733
|
-
answer?: string | undefined;
|
|
3734
|
-
metadata?: Record<string, any> | undefined;
|
|
3735
|
-
options?: Record<string, string> | undefined;
|
|
3736
|
-
answerKey?: string | undefined;
|
|
3737
|
-
scorers?: string[] | undefined;
|
|
72
|
+
}, fn: Runner<TSchemaSets[number]["testCase"], TSchemaSets[number]["response"], TSchemaSets[number]["score"], InstanceType<TProviders[number]>, InstanceType<TScorers[number]>, InferRunConfig<TRunConfigSchema>>): (params: Parameters<typeof fn>[0]) => Promise<{
|
|
73
|
+
response: z__default.core.output<TSchemaSets[number]["response"]>;
|
|
74
|
+
score?: z__default.core.output<TSchemaSets[number]["score"]> | undefined;
|
|
3738
75
|
}>;
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
forwardResponse: ForwardResponse;
|
|
3745
|
-
provider: string;
|
|
3746
|
-
modelId: string;
|
|
3747
|
-
did?: string;
|
|
3748
|
-
modelName?: string;
|
|
3749
|
-
modelOwner?: string;
|
|
3750
|
-
modelHost?: string;
|
|
3751
|
-
runId?: string;
|
|
3752
|
-
metadata?: Record<string, any>;
|
|
3753
|
-
}): Promise<{
|
|
3754
|
-
sha256: string;
|
|
3755
|
-
startedAt: number;
|
|
3756
|
-
data: string;
|
|
3757
|
-
modelName: string;
|
|
3758
|
-
did: string;
|
|
3759
|
-
cid: string;
|
|
3760
|
-
provider: string;
|
|
3761
|
-
modelId: string;
|
|
3762
|
-
modelOwner: string;
|
|
3763
|
-
modelHost: string;
|
|
3764
|
-
prompt: {
|
|
3765
|
-
type: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs";
|
|
3766
|
-
did: string;
|
|
3767
|
-
question: {
|
|
3768
|
-
sha256: string;
|
|
3769
|
-
data: string;
|
|
3770
|
-
cid: string;
|
|
3771
|
-
};
|
|
3772
|
-
fullPrompt: {
|
|
3773
|
-
sha256: string;
|
|
3774
|
-
data: string;
|
|
3775
|
-
cid: string;
|
|
3776
|
-
};
|
|
3777
|
-
answer?: string | undefined;
|
|
3778
|
-
metadata?: Record<string, any> | undefined;
|
|
3779
|
-
options?: Record<string, string> | undefined;
|
|
3780
|
-
answerKey?: string | undefined;
|
|
3781
|
-
scorers?: string[] | undefined;
|
|
3782
|
-
};
|
|
3783
|
-
finishedAt: number;
|
|
3784
|
-
runId: string;
|
|
3785
|
-
metadata?: Record<string, any> | undefined;
|
|
3786
|
-
inputTokensUsed?: number | undefined;
|
|
3787
|
-
outputTokensUsed?: number | undefined;
|
|
3788
|
-
inputCost?: string | undefined;
|
|
3789
|
-
outputCost?: string | undefined;
|
|
3790
|
-
}>;
|
|
3791
|
-
/**
|
|
3792
|
-
* Builds a valid PromptScore object from the given parameters.
|
|
3793
|
-
*/
|
|
3794
|
-
declare function buildScore(params: Omit<z.input<typeof PromptScoreSchema>, "scoreDID"> & {
|
|
3795
|
-
scoreDID?: string;
|
|
3796
|
-
}): Promise<{
|
|
3797
|
-
sha256: string;
|
|
3798
|
-
startedAt: number;
|
|
3799
|
-
modelName: string;
|
|
3800
|
-
did: string;
|
|
3801
|
-
cid: string;
|
|
3802
|
-
provider: string;
|
|
3803
|
-
modelId: string;
|
|
3804
|
-
modelOwner: string;
|
|
3805
|
-
modelHost: string;
|
|
3806
|
-
finishedAt: number;
|
|
3807
|
-
runId: string;
|
|
3808
|
-
scoreDID: string;
|
|
3809
|
-
score: number;
|
|
3810
|
-
method: "human" | "ai" | "algo";
|
|
3811
|
-
metadata?: Record<string, any> | undefined;
|
|
3812
|
-
inputTokensUsed?: number | undefined;
|
|
3813
|
-
outputTokensUsed?: number | undefined;
|
|
3814
|
-
data?: string | undefined;
|
|
3815
|
-
inputCost?: string | undefined;
|
|
3816
|
-
outputCost?: string | undefined;
|
|
3817
|
-
prompt?: {
|
|
3818
|
-
did: string;
|
|
3819
|
-
question: {
|
|
3820
|
-
sha256: string;
|
|
3821
|
-
cid: string;
|
|
3822
|
-
data?: string | undefined;
|
|
3823
|
-
};
|
|
3824
|
-
fullPrompt: {
|
|
3825
|
-
sha256: string;
|
|
3826
|
-
cid: string;
|
|
3827
|
-
data?: string | undefined;
|
|
3828
|
-
};
|
|
3829
|
-
answer?: string | undefined;
|
|
3830
|
-
metadata?: Record<string, any> | undefined;
|
|
3831
|
-
options?: Record<string, string> | undefined;
|
|
3832
|
-
type?: "multiple-choice" | "order-sentences" | "text-replacement" | "typo" | "open-ended" | "open-ended-with-docs" | undefined;
|
|
3833
|
-
answerKey?: string | undefined;
|
|
3834
|
-
scorers?: string[] | undefined;
|
|
3835
|
-
} | undefined;
|
|
3836
|
-
scoreMetadata?: Record<string, any> | undefined;
|
|
3837
|
-
explanation?: string | undefined;
|
|
3838
|
-
scorerAI?: {
|
|
3839
|
-
modelName: string;
|
|
3840
|
-
provider: string;
|
|
3841
|
-
modelId: string;
|
|
3842
|
-
modelOwner: string;
|
|
3843
|
-
modelHost: string;
|
|
3844
|
-
inputTokensUsed?: number | undefined;
|
|
3845
|
-
outputTokensUsed?: number | undefined;
|
|
3846
|
-
inputCost?: string | undefined;
|
|
3847
|
-
outputCost?: string | undefined;
|
|
3848
|
-
} | undefined;
|
|
3849
|
-
}>;
|
|
3850
|
-
|
|
3851
|
-
/**
|
|
3852
|
-
* Parses the given string as an enum value based on either
|
|
3853
|
-
* the keys or values of the given enum.
|
|
3854
|
-
* @param lookFor - Whether to look for the key or value
|
|
3855
|
-
*/
|
|
3856
|
-
declare function EnumSchema<T>(_enum: Record<string, T>, lookFor?: "key" | "value"): z.ZodEffects<z.ZodString, NonNullable<T>, string>;
|
|
3857
|
-
|
|
3858
|
-
declare const MULTIPLE_CHOICE_SYSTEM_PROMPT = "Your explanation can't be longer than 400 tokens. The last sentence must be formatted as one of the following:\n- The answer is <answer letter>\n- The answer is **<answer letter>**\n- <answer letter>: ...\n- <answer letter>) ...\nReplace <answer letter> with the letter of your chosen answer.\n\nUse the following string as your last sentence if you are not capable of answering the question:\n<!NO ANSWER!>";
|
|
3859
|
-
declare const SENTENCE_REORDER_SYSTEM_PROMPT = "Your task is ordering the given sentences (each line is a sentence) in a correct order. Your output must be formatted as the input but with the sentences in the correct order. Markdown formatting is forbidden.";
|
|
3860
|
-
declare const TEXT_REPLACEMENT_SYSTEM_PROMPT = "Your task is placing all the entities that are provided in the ENTITIES section to the input text in a correct order. Your output only and only includes the modified text, nothing else. It is forbidden to modify anything else from the input text. Markdown formatting is forbidden too.";
|
|
3861
|
-
declare const TYPO_SYSTEM_PROMPT = "Your task is to find all the typos in the given text. Your output must include the corrected text, nothing else.";
|
|
3862
|
-
declare const OPEN_ENDED_SYSTEM_PROMPT = "You are a knowledgeable expert. Please provide a clear, accurate, short and well-reasoned answer to the following question. Be concise but comprehensive in your response. Your answer must be short and clear with less than 20 words";
|
|
76
|
+
type SchemaSetDefinition<TTestCase extends z__default.ZodObject = z__default.ZodObject, TResponse extends z__default.ZodObject = z__default.ZodObject, TScore extends z__default.ZodObject = z__default.ZodObject> = {
|
|
77
|
+
testCase: TTestCase;
|
|
78
|
+
response: TResponse;
|
|
79
|
+
score: TScore;
|
|
80
|
+
};
|
|
3863
81
|
|
|
3864
|
-
export {
|
|
82
|
+
export { CATEGORIES, IdGenerator, type InferRunConfig, PEERBENCH_NAMESPACE, PeerbenchError, ProviderCtor, type Runner, ScorerCtor, bufferToString, captureStackTrace, defineRunner, idGeneratorUUIDv7, parseResponseAsJSON, sleep, stringToBuffer };
|