qualifire 1.1.9 → 1.2.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/lib/index.d.ts +71 -5
- package/lib/index.js +100 -30
- package/lib/types.d.ts +106 -278
- package/lib/types.js +30 -29
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EvaluationResponse, Input, Output } from './types';
|
|
1
|
+
import type { EvaluationResponse, Input, Output } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Represents the Qualifire SDK.
|
|
4
4
|
*/
|
|
@@ -10,14 +10,80 @@ export declare class Qualifire {
|
|
|
10
10
|
baseUrl: string;
|
|
11
11
|
/**
|
|
12
12
|
* Creates an instance of the Qualifire class.
|
|
13
|
-
* @param apiKey - The API key for the Qualifire SDK.
|
|
14
|
-
* @param baseUrl - The base URL for the Qualifire API.
|
|
13
|
+
* @param apiKey - The API key for the Qualifire SDK. * @param baseUrl - The base URL for the Qualifire API.
|
|
15
14
|
*/
|
|
16
15
|
constructor({ apiKey, baseUrl }: {
|
|
17
16
|
apiKey?: string;
|
|
18
17
|
baseUrl?: string;
|
|
19
18
|
});
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Evaluates the output of a model against a set of criteria.
|
|
21
|
+
*
|
|
22
|
+
* @param input - The input to the model.
|
|
23
|
+
* @param output - The output of the model.
|
|
24
|
+
* @param assertions - An array of assertions to check.
|
|
25
|
+
* @param consistencyCheck - Whether to check for consistency.
|
|
26
|
+
* @param dangerousContentCheck - Whether to check for dangerous content.
|
|
27
|
+
* @param hallucinationsCheck - Whether to check for hallucinations.
|
|
28
|
+
* @param harassmentCheck - Whether to check for harassment.
|
|
29
|
+
* @param hateSpeechCheck - Whether to check for hate speech.
|
|
30
|
+
* @param piiCheck - Whether to check for personally identifiable information.
|
|
31
|
+
* @param promptInjections - Whether to check for prompt injections.
|
|
32
|
+
* @param sexualContentCheck - Whether to check for sexual content.
|
|
33
|
+
* @returns An object containing the evaluation results.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const qualifire = new Qualifire();
|
|
38
|
+
* const response = await qualifire.evaluate({
|
|
39
|
+
* input: 'What is the capital of France?',
|
|
40
|
+
* output: 'Paris',
|
|
41
|
+
* assertions: ['capital'],
|
|
42
|
+
* consistencyCheck: true,
|
|
43
|
+
* dangerousContentCheck: true,
|
|
44
|
+
* hallucinationsCheck: true,
|
|
45
|
+
* harassmentCheck: true,
|
|
46
|
+
* hateSpeechCheck: true,
|
|
47
|
+
* piiCheck: true,
|
|
48
|
+
* promptInjections: true,
|
|
49
|
+
* sexualContentCheck: true,
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
evaluate: ({ input, output, assertions, consistencyCheck, dangerousContentCheck, hallucinationsCheck, harassmentCheck, hateSpeechCheck, piiCheck, promptInjections, sexualContentCheck, }: {
|
|
54
|
+
input: Input;
|
|
55
|
+
output: Output;
|
|
56
|
+
assertions: string[];
|
|
57
|
+
consistencyCheck: boolean;
|
|
58
|
+
dangerousContentCheck: boolean;
|
|
59
|
+
hallucinationsCheck: boolean;
|
|
60
|
+
harassmentCheck: boolean;
|
|
61
|
+
hateSpeechCheck: boolean;
|
|
62
|
+
piiCheck: boolean;
|
|
63
|
+
promptInjections: boolean;
|
|
64
|
+
sexualContentCheck: boolean;
|
|
65
|
+
}) => Promise<EvaluationResponse | undefined>;
|
|
66
|
+
/**
|
|
67
|
+
* Invokes an evaluation for a given evaluation ID.
|
|
68
|
+
*
|
|
69
|
+
* @param input - The input to the model.
|
|
70
|
+
* @param output - The output of the model.
|
|
71
|
+
* @param evaluationId - The ID of the evaluation to invoke.
|
|
72
|
+
* @returns An object containing the evaluation results.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const qualifire = new Qualifire();
|
|
77
|
+
* const response = await qualifire.invokeEvaluation({
|
|
78
|
+
* input: 'What is the capital of France?',
|
|
79
|
+
* output: 'Paris',
|
|
80
|
+
* evaluationId: '1234567890',
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
**/
|
|
84
|
+
invokeEvaluation: ({ input, output, evaluationId, }: {
|
|
85
|
+
input: string;
|
|
86
|
+
output: string;
|
|
87
|
+
evaluationId: string;
|
|
22
88
|
}) => Promise<EvaluationResponse | undefined>;
|
|
23
89
|
}
|
package/lib/index.js
CHANGED
|
@@ -10,45 +10,115 @@ exports.Qualifire = void 0;
|
|
|
10
10
|
class Qualifire {
|
|
11
11
|
/**
|
|
12
12
|
* Creates an instance of the Qualifire class.
|
|
13
|
-
* @param apiKey - The API key for the Qualifire SDK.
|
|
14
|
-
* @param baseUrl - The base URL for the Qualifire API.
|
|
13
|
+
* @param apiKey - The API key for the Qualifire SDK. * @param baseUrl - The base URL for the Qualifire API.
|
|
15
14
|
*/
|
|
16
15
|
constructor({ apiKey, baseUrl }) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Evaluates the output of a model against a set of criteria.
|
|
18
|
+
*
|
|
19
|
+
* @param input - The input to the model.
|
|
20
|
+
* @param output - The output of the model.
|
|
21
|
+
* @param assertions - An array of assertions to check.
|
|
22
|
+
* @param consistencyCheck - Whether to check for consistency.
|
|
23
|
+
* @param dangerousContentCheck - Whether to check for dangerous content.
|
|
24
|
+
* @param hallucinationsCheck - Whether to check for hallucinations.
|
|
25
|
+
* @param harassmentCheck - Whether to check for harassment.
|
|
26
|
+
* @param hateSpeechCheck - Whether to check for hate speech.
|
|
27
|
+
* @param piiCheck - Whether to check for personally identifiable information.
|
|
28
|
+
* @param promptInjections - Whether to check for prompt injections.
|
|
29
|
+
* @param sexualContentCheck - Whether to check for sexual content.
|
|
30
|
+
* @returns An object containing the evaluation results.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const qualifire = new Qualifire();
|
|
35
|
+
* const response = await qualifire.evaluate({
|
|
36
|
+
* input: 'What is the capital of France?',
|
|
37
|
+
* output: 'Paris',
|
|
38
|
+
* assertions: ['capital'],
|
|
39
|
+
* consistencyCheck: true,
|
|
40
|
+
* dangerousContentCheck: true,
|
|
41
|
+
* hallucinationsCheck: true,
|
|
42
|
+
* harassmentCheck: true,
|
|
43
|
+
* hateSpeechCheck: true,
|
|
44
|
+
* piiCheck: true,
|
|
45
|
+
* promptInjections: true,
|
|
46
|
+
* sexualContentCheck: true,
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
this.evaluate = async ({ input, output, assertions = [], consistencyCheck = false, dangerousContentCheck = false, hallucinationsCheck = false, harassmentCheck = false, hateSpeechCheck = false, piiCheck = false, promptInjections = false, sexualContentCheck = false, }) => {
|
|
51
|
+
const url = `${this.baseUrl}/api/evaluation/evaluate`;
|
|
52
|
+
const body = JSON.stringify({
|
|
53
|
+
input,
|
|
54
|
+
output,
|
|
55
|
+
assertions,
|
|
56
|
+
consistency_check: consistencyCheck,
|
|
57
|
+
dangerous_content_check: dangerousContentCheck,
|
|
58
|
+
hallucinations_check: hallucinationsCheck,
|
|
59
|
+
harassment_check: harassmentCheck,
|
|
60
|
+
hate_speech_check: hateSpeechCheck,
|
|
61
|
+
pii_check: piiCheck,
|
|
62
|
+
prompt_injections: promptInjections,
|
|
63
|
+
sexual_content_check: sexualContentCheck,
|
|
64
|
+
});
|
|
20
65
|
const headers = {
|
|
21
66
|
'Content-Type': 'application/json',
|
|
22
|
-
'X-
|
|
67
|
+
'X-Qualifire-API-Key': this.sdkKey,
|
|
23
68
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
69
|
+
const response = await fetch(url, {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers,
|
|
72
|
+
body,
|
|
73
|
+
});
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
throw new Error(`Qualifire API error: ${response.statusText}`);
|
|
30
76
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
77
|
+
const jsonResponse = await response.json();
|
|
78
|
+
return jsonResponse;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Invokes an evaluation for a given evaluation ID.
|
|
82
|
+
*
|
|
83
|
+
* @param input - The input to the model.
|
|
84
|
+
* @param output - The output of the model.
|
|
85
|
+
* @param evaluationId - The ID of the evaluation to invoke.
|
|
86
|
+
* @returns An object containing the evaluation results.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* const qualifire = new Qualifire();
|
|
91
|
+
* const response = await qualifire.invokeEvaluation({
|
|
92
|
+
* input: 'What is the capital of France?',
|
|
93
|
+
* output: 'Paris',
|
|
94
|
+
* evaluationId: '1234567890',
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
**/
|
|
98
|
+
this.invokeEvaluation = async ({ input, output, evaluationId, }) => {
|
|
99
|
+
const url = `${this.baseUrl}/api/evaluation/invoke`;
|
|
100
|
+
const body = JSON.stringify({
|
|
101
|
+
input,
|
|
102
|
+
output,
|
|
103
|
+
evaluation_id: evaluationId,
|
|
104
|
+
});
|
|
105
|
+
const headers = {
|
|
106
|
+
'Content-Type': 'application/json',
|
|
107
|
+
'X-Qualifire-API-Key': this.sdkKey,
|
|
108
|
+
};
|
|
109
|
+
const response = await fetch(url, {
|
|
110
|
+
method: 'POST',
|
|
111
|
+
headers,
|
|
112
|
+
body,
|
|
113
|
+
});
|
|
114
|
+
if (!response.ok) {
|
|
115
|
+
throw new Error(`Qualifire API error: ${response.statusText}`);
|
|
46
116
|
}
|
|
117
|
+
const jsonResponse = await response.json();
|
|
118
|
+
return jsonResponse;
|
|
47
119
|
};
|
|
48
120
|
const key = apiKey || process.env.QUALIFIRE_API_KEY;
|
|
49
|
-
const qualifireBaseUrl = baseUrl ||
|
|
50
|
-
process.env.QUALIFIRE_BASE_URL ||
|
|
51
|
-
'https://gateway.qualifire.ai';
|
|
121
|
+
const qualifireBaseUrl = baseUrl || process.env.QUALIFIRE_BASE_URL || 'https://proxy.qualifire.ai';
|
|
52
122
|
if (!key) {
|
|
53
123
|
throw new Error('Missing SDK key, please provide an arg or add the QUALIFIRE_API_KEY environment variable.');
|
|
54
124
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -163,317 +163,145 @@ export declare const outputSchema: z.ZodObject<{
|
|
|
163
163
|
system_fingerprint?: string | undefined;
|
|
164
164
|
}>;
|
|
165
165
|
export type Output = z.infer<typeof outputSchema> | string;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
caller: z.ZodOptional<z.ZodString>;
|
|
181
|
-
}, "strip", z.ZodTypeAny, {
|
|
182
|
-
model: string;
|
|
183
|
-
messages: {
|
|
184
|
-
role: string;
|
|
185
|
-
content: string | null;
|
|
186
|
-
}[];
|
|
187
|
-
caller?: string | undefined;
|
|
188
|
-
}, {
|
|
189
|
-
model: string;
|
|
190
|
-
messages: {
|
|
191
|
-
role: string;
|
|
192
|
-
content: string | null;
|
|
193
|
-
}[];
|
|
194
|
-
caller?: string | undefined;
|
|
195
|
-
}>;
|
|
196
|
-
output: z.ZodObject<{
|
|
197
|
-
id: z.ZodString;
|
|
198
|
-
created: z.ZodOptional<z.ZodNumber>;
|
|
199
|
-
model: z.ZodString;
|
|
200
|
-
choices: z.ZodArray<z.ZodObject<{
|
|
201
|
-
index: z.ZodNumber;
|
|
202
|
-
message: z.ZodObject<{
|
|
203
|
-
role: z.ZodString;
|
|
204
|
-
content: z.ZodNullable<z.ZodString>;
|
|
205
|
-
}, "strip", z.ZodTypeAny, {
|
|
206
|
-
role: string;
|
|
207
|
-
content: string | null;
|
|
208
|
-
}, {
|
|
209
|
-
role: string;
|
|
210
|
-
content: string | null;
|
|
211
|
-
}>;
|
|
212
|
-
finish_reason: z.ZodOptional<z.ZodString>;
|
|
213
|
-
}, "strip", z.ZodTypeAny, {
|
|
214
|
-
message: {
|
|
215
|
-
role: string;
|
|
216
|
-
content: string | null;
|
|
217
|
-
};
|
|
218
|
-
index: number;
|
|
219
|
-
finish_reason?: string | undefined;
|
|
220
|
-
}, {
|
|
221
|
-
message: {
|
|
222
|
-
role: string;
|
|
223
|
-
content: string | null;
|
|
224
|
-
};
|
|
225
|
-
index: number;
|
|
226
|
-
finish_reason?: string | undefined;
|
|
227
|
-
}>, "many">;
|
|
228
|
-
usage: z.ZodOptional<z.ZodObject<{
|
|
229
|
-
prompt_tokens: z.ZodNumber;
|
|
230
|
-
completion_tokens: z.ZodNumber;
|
|
231
|
-
total_tokens: z.ZodNumber;
|
|
232
|
-
}, "strip", z.ZodTypeAny, {
|
|
233
|
-
prompt_tokens: number;
|
|
234
|
-
completion_tokens: number;
|
|
235
|
-
total_tokens: number;
|
|
236
|
-
}, {
|
|
237
|
-
prompt_tokens: number;
|
|
238
|
-
completion_tokens: number;
|
|
239
|
-
total_tokens: number;
|
|
240
|
-
}>>;
|
|
241
|
-
system_fingerprint: z.ZodOptional<z.ZodString>;
|
|
166
|
+
declare const EvaluationRequestSchema: z.ZodObject<{
|
|
167
|
+
input: z.ZodString;
|
|
168
|
+
output: z.ZodString;
|
|
169
|
+
consistency_check: z.ZodBoolean;
|
|
170
|
+
dangerous_content_check: z.ZodBoolean;
|
|
171
|
+
hallucinations_check: z.ZodBoolean;
|
|
172
|
+
harassment_check: z.ZodBoolean;
|
|
173
|
+
hate_speech_check: z.ZodBoolean;
|
|
174
|
+
pii_check: z.ZodBoolean;
|
|
175
|
+
prompt_injections: z.ZodBoolean;
|
|
176
|
+
sexual_content_check: z.ZodBoolean;
|
|
177
|
+
messages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
178
|
+
content: z.ZodString;
|
|
179
|
+
role: z.ZodString;
|
|
242
180
|
}, "strip", z.ZodTypeAny, {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
choices: {
|
|
246
|
-
message: {
|
|
247
|
-
role: string;
|
|
248
|
-
content: string | null;
|
|
249
|
-
};
|
|
250
|
-
index: number;
|
|
251
|
-
finish_reason?: string | undefined;
|
|
252
|
-
}[];
|
|
253
|
-
created?: number | undefined;
|
|
254
|
-
usage?: {
|
|
255
|
-
prompt_tokens: number;
|
|
256
|
-
completion_tokens: number;
|
|
257
|
-
total_tokens: number;
|
|
258
|
-
} | undefined;
|
|
259
|
-
system_fingerprint?: string | undefined;
|
|
181
|
+
role: string;
|
|
182
|
+
content: string;
|
|
260
183
|
}, {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
role: string;
|
|
266
|
-
content: string | null;
|
|
267
|
-
};
|
|
268
|
-
index: number;
|
|
269
|
-
finish_reason?: string | undefined;
|
|
270
|
-
}[];
|
|
271
|
-
created?: number | undefined;
|
|
272
|
-
usage?: {
|
|
273
|
-
prompt_tokens: number;
|
|
274
|
-
completion_tokens: number;
|
|
275
|
-
total_tokens: number;
|
|
276
|
-
} | undefined;
|
|
277
|
-
system_fingerprint?: string | undefined;
|
|
278
|
-
}>;
|
|
184
|
+
role: string;
|
|
185
|
+
content: string;
|
|
186
|
+
}>, "many">>;
|
|
187
|
+
assertions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
279
188
|
}, "strip", z.ZodTypeAny, {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
content: string | null;
|
|
296
|
-
};
|
|
297
|
-
index: number;
|
|
298
|
-
finish_reason?: string | undefined;
|
|
299
|
-
}[];
|
|
300
|
-
created?: number | undefined;
|
|
301
|
-
usage?: {
|
|
302
|
-
prompt_tokens: number;
|
|
303
|
-
completion_tokens: number;
|
|
304
|
-
total_tokens: number;
|
|
305
|
-
} | undefined;
|
|
306
|
-
system_fingerprint?: string | undefined;
|
|
307
|
-
};
|
|
189
|
+
input: string;
|
|
190
|
+
output: string;
|
|
191
|
+
consistency_check: boolean;
|
|
192
|
+
dangerous_content_check: boolean;
|
|
193
|
+
hallucinations_check: boolean;
|
|
194
|
+
harassment_check: boolean;
|
|
195
|
+
hate_speech_check: boolean;
|
|
196
|
+
pii_check: boolean;
|
|
197
|
+
prompt_injections: boolean;
|
|
198
|
+
sexual_content_check: boolean;
|
|
199
|
+
messages?: {
|
|
200
|
+
role: string;
|
|
201
|
+
content: string;
|
|
202
|
+
}[] | undefined;
|
|
203
|
+
assertions?: string[] | undefined;
|
|
308
204
|
}, {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
content: string | null;
|
|
325
|
-
};
|
|
326
|
-
index: number;
|
|
327
|
-
finish_reason?: string | undefined;
|
|
328
|
-
}[];
|
|
329
|
-
created?: number | undefined;
|
|
330
|
-
usage?: {
|
|
331
|
-
prompt_tokens: number;
|
|
332
|
-
completion_tokens: number;
|
|
333
|
-
total_tokens: number;
|
|
334
|
-
} | undefined;
|
|
335
|
-
system_fingerprint?: string | undefined;
|
|
336
|
-
};
|
|
205
|
+
input: string;
|
|
206
|
+
output: string;
|
|
207
|
+
consistency_check: boolean;
|
|
208
|
+
dangerous_content_check: boolean;
|
|
209
|
+
hallucinations_check: boolean;
|
|
210
|
+
harassment_check: boolean;
|
|
211
|
+
hate_speech_check: boolean;
|
|
212
|
+
pii_check: boolean;
|
|
213
|
+
prompt_injections: boolean;
|
|
214
|
+
sexual_content_check: boolean;
|
|
215
|
+
messages?: {
|
|
216
|
+
role: string;
|
|
217
|
+
content: string;
|
|
218
|
+
}[] | undefined;
|
|
219
|
+
assertions?: string[] | undefined;
|
|
337
220
|
}>;
|
|
338
|
-
|
|
339
|
-
success: z.ZodBoolean;
|
|
221
|
+
declare const EvaluationResponseSchema: z.ZodObject<{
|
|
340
222
|
evaluationResults: z.ZodArray<z.ZodObject<{
|
|
341
|
-
type: z.ZodString;
|
|
342
223
|
results: z.ZodArray<z.ZodObject<{
|
|
343
|
-
claim: z.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
monitorId: z.ZodOptional<z.ZodString>;
|
|
351
|
-
createdAt: z.ZodOptional<z.ZodString>;
|
|
352
|
-
organizationId: z.ZodOptional<z.ZodString>;
|
|
353
|
-
callId: z.ZodOptional<z.ZodString>;
|
|
354
|
-
label: z.ZodOptional<z.ZodString>;
|
|
224
|
+
claim: z.ZodString;
|
|
225
|
+
confidence_score: z.ZodNumber;
|
|
226
|
+
label: z.ZodString;
|
|
227
|
+
name: z.ZodString;
|
|
228
|
+
quote: z.ZodString;
|
|
229
|
+
reason: z.ZodString;
|
|
230
|
+
score: z.ZodNumber;
|
|
355
231
|
}, "strip", z.ZodTypeAny, {
|
|
356
|
-
claim
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
monitorId?: string | undefined;
|
|
364
|
-
createdAt?: string | undefined;
|
|
365
|
-
organizationId?: string | undefined;
|
|
366
|
-
callId?: string | undefined;
|
|
367
|
-
label?: string | undefined;
|
|
232
|
+
claim: string;
|
|
233
|
+
confidence_score: number;
|
|
234
|
+
label: string;
|
|
235
|
+
name: string;
|
|
236
|
+
quote: string;
|
|
237
|
+
reason: string;
|
|
238
|
+
score: number;
|
|
368
239
|
}, {
|
|
369
|
-
claim
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
monitorId?: string | undefined;
|
|
377
|
-
createdAt?: string | undefined;
|
|
378
|
-
organizationId?: string | undefined;
|
|
379
|
-
callId?: string | undefined;
|
|
380
|
-
label?: string | undefined;
|
|
240
|
+
claim: string;
|
|
241
|
+
confidence_score: number;
|
|
242
|
+
label: string;
|
|
243
|
+
name: string;
|
|
244
|
+
quote: string;
|
|
245
|
+
reason: string;
|
|
246
|
+
score: number;
|
|
381
247
|
}>, "many">;
|
|
248
|
+
type: z.ZodString;
|
|
382
249
|
}, "strip", z.ZodTypeAny, {
|
|
383
250
|
type: string;
|
|
384
251
|
results: {
|
|
385
|
-
claim
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
monitorId?: string | undefined;
|
|
393
|
-
createdAt?: string | undefined;
|
|
394
|
-
organizationId?: string | undefined;
|
|
395
|
-
callId?: string | undefined;
|
|
396
|
-
label?: string | undefined;
|
|
252
|
+
claim: string;
|
|
253
|
+
confidence_score: number;
|
|
254
|
+
label: string;
|
|
255
|
+
name: string;
|
|
256
|
+
quote: string;
|
|
257
|
+
reason: string;
|
|
258
|
+
score: number;
|
|
397
259
|
}[];
|
|
398
260
|
}, {
|
|
399
261
|
type: string;
|
|
400
262
|
results: {
|
|
401
|
-
claim
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
monitorId?: string | undefined;
|
|
409
|
-
createdAt?: string | undefined;
|
|
410
|
-
organizationId?: string | undefined;
|
|
411
|
-
callId?: string | undefined;
|
|
412
|
-
label?: string | undefined;
|
|
263
|
+
claim: string;
|
|
264
|
+
confidence_score: number;
|
|
265
|
+
label: string;
|
|
266
|
+
name: string;
|
|
267
|
+
quote: string;
|
|
268
|
+
reason: string;
|
|
269
|
+
score: number;
|
|
413
270
|
}[];
|
|
414
271
|
}>, "many">;
|
|
415
272
|
score: z.ZodNumber;
|
|
416
273
|
status: z.ZodString;
|
|
417
|
-
scoreBreakdown: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
418
|
-
length: z.ZodNumber;
|
|
419
|
-
scoreSum: z.ZodNumber;
|
|
420
|
-
}, "strip", z.ZodTypeAny, {
|
|
421
|
-
length: number;
|
|
422
|
-
scoreSum: number;
|
|
423
|
-
}, {
|
|
424
|
-
length: number;
|
|
425
|
-
scoreSum: number;
|
|
426
|
-
}>>;
|
|
427
274
|
}, "strip", z.ZodTypeAny, {
|
|
428
275
|
status: string;
|
|
429
|
-
|
|
276
|
+
score: number;
|
|
430
277
|
evaluationResults: {
|
|
431
278
|
type: string;
|
|
432
279
|
results: {
|
|
433
|
-
claim
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
monitorId?: string | undefined;
|
|
441
|
-
createdAt?: string | undefined;
|
|
442
|
-
organizationId?: string | undefined;
|
|
443
|
-
callId?: string | undefined;
|
|
444
|
-
label?: string | undefined;
|
|
280
|
+
claim: string;
|
|
281
|
+
confidence_score: number;
|
|
282
|
+
label: string;
|
|
283
|
+
name: string;
|
|
284
|
+
quote: string;
|
|
285
|
+
reason: string;
|
|
286
|
+
score: number;
|
|
445
287
|
}[];
|
|
446
288
|
}[];
|
|
447
|
-
score: number;
|
|
448
|
-
scoreBreakdown: Record<string, {
|
|
449
|
-
length: number;
|
|
450
|
-
scoreSum: number;
|
|
451
|
-
}>;
|
|
452
289
|
}, {
|
|
453
290
|
status: string;
|
|
454
|
-
|
|
291
|
+
score: number;
|
|
455
292
|
evaluationResults: {
|
|
456
293
|
type: string;
|
|
457
294
|
results: {
|
|
458
|
-
claim
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
monitorId?: string | undefined;
|
|
466
|
-
createdAt?: string | undefined;
|
|
467
|
-
organizationId?: string | undefined;
|
|
468
|
-
callId?: string | undefined;
|
|
469
|
-
label?: string | undefined;
|
|
295
|
+
claim: string;
|
|
296
|
+
confidence_score: number;
|
|
297
|
+
label: string;
|
|
298
|
+
name: string;
|
|
299
|
+
quote: string;
|
|
300
|
+
reason: string;
|
|
301
|
+
score: number;
|
|
470
302
|
}[];
|
|
471
303
|
}[];
|
|
472
|
-
score: number;
|
|
473
|
-
scoreBreakdown: Record<string, {
|
|
474
|
-
length: number;
|
|
475
|
-
scoreSum: number;
|
|
476
|
-
}>;
|
|
477
304
|
}>;
|
|
478
|
-
export type
|
|
479
|
-
export type
|
|
305
|
+
export type EvaluationResponse = z.infer<typeof EvaluationResponseSchema>;
|
|
306
|
+
export type EvaluationRequestSchema = z.infer<typeof EvaluationRequestSchema>;
|
|
307
|
+
export {};
|
package/lib/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.outputSchema = exports.inputSchema = exports.usageSchema = exports.choiceSchema = exports.messageSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
exports.messageSchema = zod_1.z.object({
|
|
6
6
|
role: zod_1.z.string(),
|
|
@@ -29,38 +29,39 @@ exports.outputSchema = zod_1.z.object({
|
|
|
29
29
|
usage: exports.usageSchema.optional(),
|
|
30
30
|
system_fingerprint: zod_1.z.string().optional(),
|
|
31
31
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
output: exports.outputSchema,
|
|
32
|
+
const LLMMessageSchema = zod_1.z.object({
|
|
33
|
+
content: zod_1.z.string(),
|
|
34
|
+
role: zod_1.z.string(),
|
|
36
35
|
});
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
const EvaluationRequestSchema = zod_1.z.object({
|
|
37
|
+
input: zod_1.z.string(),
|
|
38
|
+
output: zod_1.z.string(),
|
|
39
|
+
consistency_check: zod_1.z.boolean(),
|
|
40
|
+
dangerous_content_check: zod_1.z.boolean(),
|
|
41
|
+
hallucinations_check: zod_1.z.boolean(),
|
|
42
|
+
harassment_check: zod_1.z.boolean(),
|
|
43
|
+
hate_speech_check: zod_1.z.boolean(),
|
|
44
|
+
pii_check: zod_1.z.boolean(),
|
|
45
|
+
prompt_injections: zod_1.z.boolean(),
|
|
46
|
+
sexual_content_check: zod_1.z.boolean(),
|
|
47
|
+
messages: zod_1.z.array(LLMMessageSchema).optional(),
|
|
48
|
+
assertions: zod_1.z.array(zod_1.z.string()).optional(),
|
|
50
49
|
});
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const EvaluationResultSchema = zod_1.z.object({
|
|
51
|
+
claim: zod_1.z.string(),
|
|
52
|
+
confidence_score: zod_1.z.number(),
|
|
53
|
+
label: zod_1.z.string(),
|
|
54
|
+
name: zod_1.z.string(),
|
|
55
|
+
quote: zod_1.z.string(),
|
|
56
|
+
reason: zod_1.z.string(),
|
|
57
|
+
score: zod_1.z.number(),
|
|
54
58
|
});
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
const EvaluationResultItemSchema = zod_1.z.object({
|
|
60
|
+
results: zod_1.z.array(EvaluationResultSchema),
|
|
61
|
+
type: zod_1.z.string(),
|
|
58
62
|
});
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
success: zod_1.z.boolean(),
|
|
62
|
-
evaluationResults: zod_1.z.array(evaluationResultSchema),
|
|
63
|
+
const EvaluationResponseSchema = zod_1.z.object({
|
|
64
|
+
evaluationResults: zod_1.z.array(EvaluationResultItemSchema),
|
|
63
65
|
score: zod_1.z.number(),
|
|
64
66
|
status: zod_1.z.string(),
|
|
65
|
-
scoreBreakdown: scoreBreakdownSchema,
|
|
66
67
|
});
|