qualifire 1.1.8 → 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 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
- evaluate: (input: Input, output: Output, { async, }?: {
21
- async?: boolean | undefined;
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
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Qualifire = void 0;
4
- const types_1 = require("./types");
5
4
  /**
6
5
  * Represents the Qualifire SDK.
7
6
  */
@@ -11,45 +10,115 @@ const types_1 = require("./types");
11
10
  class Qualifire {
12
11
  /**
13
12
  * Creates an instance of the Qualifire class.
14
- * @param apiKey - The API key for the Qualifire SDK.
15
- * @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.
16
14
  */
17
15
  constructor({ apiKey, baseUrl }) {
18
- this.evaluate = async (input, output, { async, } = {}) => {
19
- const url = `${this.baseUrl}/api/evaluation/v1`;
20
- const body = JSON.stringify({ async, input, output });
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
+ });
21
65
  const headers = {
22
66
  'Content-Type': 'application/json',
23
- 'X-qualifire-key': this.sdkKey,
67
+ 'X-Qualifire-API-Key': this.sdkKey,
24
68
  };
25
- if (async) {
26
- void fetch(url, {
27
- method: 'POST',
28
- headers,
29
- body,
30
- });
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}`);
31
76
  }
32
- else {
33
- const response = await fetch(url, {
34
- method: 'POST',
35
- headers,
36
- body,
37
- });
38
- if (!response.ok) {
39
- throw new Error(`Qualifire API error: ${response.statusText}`);
40
- }
41
- const jsonResponse = await response.json();
42
- const parsed = types_1.evaluationResponseSchema.safeParse(jsonResponse);
43
- if (!parsed.success) {
44
- throw new Error('Qualifire API error: Evaluation failed');
45
- }
46
- return parsed.data;
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}`);
47
116
  }
117
+ const jsonResponse = await response.json();
118
+ return jsonResponse;
48
119
  };
49
120
  const key = apiKey || process.env.QUALIFIRE_API_KEY;
50
- const qualifireBaseUrl = baseUrl ||
51
- process.env.QUALIFIRE_BASE_URL ||
52
- 'https://gateway.qualifire.ai';
121
+ const qualifireBaseUrl = baseUrl || process.env.QUALIFIRE_BASE_URL || 'https://proxy.qualifire.ai';
53
122
  if (!key) {
54
123
  throw new Error('Missing SDK key, please provide an arg or add the QUALIFIRE_API_KEY environment variable.');
55
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
- export declare const evaluationSchema: z.ZodObject<{
167
- async: z.ZodBoolean;
168
- input: z.ZodObject<{
169
- model: z.ZodString;
170
- messages: z.ZodArray<z.ZodObject<{
171
- role: z.ZodString;
172
- content: z.ZodNullable<z.ZodString>;
173
- }, "strip", z.ZodTypeAny, {
174
- role: string;
175
- content: string | null;
176
- }, {
177
- role: string;
178
- content: string | null;
179
- }>, "many">;
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
- model: string;
244
- id: string;
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
- model: string;
262
- id: string;
263
- choices: {
264
- message: {
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
- async: boolean;
281
- input: {
282
- model: string;
283
- messages: {
284
- role: string;
285
- content: string | null;
286
- }[];
287
- caller?: string | undefined;
288
- };
289
- output: {
290
- model: string;
291
- id: string;
292
- choices: {
293
- message: {
294
- role: string;
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
- async: boolean;
310
- input: {
311
- model: string;
312
- messages: {
313
- role: string;
314
- content: string | null;
315
- }[];
316
- caller?: string | undefined;
317
- };
318
- output: {
319
- model: string;
320
- id: string;
321
- choices: {
322
- message: {
323
- role: string;
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
- export declare const evaluationResponseSchema: z.ZodObject<{
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.ZodOptional<z.ZodString>;
344
- contradiction: z.ZodOptional<z.ZodBoolean>;
345
- passed: z.ZodOptional<z.ZodBoolean>;
346
- matchScore: z.ZodOptional<z.ZodNumber>;
347
- reason: z.ZodOptional<z.ZodString>;
348
- quote: z.ZodOptional<z.ZodString>;
349
- includedInContent: z.ZodOptional<z.ZodBoolean>;
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?: string | undefined;
357
- contradiction?: boolean | undefined;
358
- passed?: boolean | undefined;
359
- matchScore?: number | undefined;
360
- reason?: string | undefined;
361
- quote?: string | undefined;
362
- includedInContent?: boolean | undefined;
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?: string | undefined;
370
- contradiction?: boolean | undefined;
371
- passed?: boolean | undefined;
372
- matchScore?: number | undefined;
373
- reason?: string | undefined;
374
- quote?: string | undefined;
375
- includedInContent?: boolean | undefined;
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?: string | undefined;
386
- contradiction?: boolean | undefined;
387
- passed?: boolean | undefined;
388
- matchScore?: number | undefined;
389
- reason?: string | undefined;
390
- quote?: string | undefined;
391
- includedInContent?: boolean | undefined;
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?: string | undefined;
402
- contradiction?: boolean | undefined;
403
- passed?: boolean | undefined;
404
- matchScore?: number | undefined;
405
- reason?: string | undefined;
406
- quote?: string | undefined;
407
- includedInContent?: boolean | undefined;
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
- success: boolean;
276
+ score: number;
430
277
  evaluationResults: {
431
278
  type: string;
432
279
  results: {
433
- claim?: string | undefined;
434
- contradiction?: boolean | undefined;
435
- passed?: boolean | undefined;
436
- matchScore?: number | undefined;
437
- reason?: string | undefined;
438
- quote?: string | undefined;
439
- includedInContent?: boolean | undefined;
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
- success: boolean;
291
+ score: number;
455
292
  evaluationResults: {
456
293
  type: string;
457
294
  results: {
458
- claim?: string | undefined;
459
- contradiction?: boolean | undefined;
460
- passed?: boolean | undefined;
461
- matchScore?: number | undefined;
462
- reason?: string | undefined;
463
- quote?: string | undefined;
464
- includedInContent?: boolean | undefined;
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 Evaluation = z.infer<typeof evaluationSchema>;
479
- export type EvaluationResponse = z.infer<typeof evaluationResponseSchema>;
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.evaluationResponseSchema = exports.evaluationSchema = exports.outputSchema = exports.inputSchema = exports.usageSchema = exports.choiceSchema = exports.messageSchema = void 0;
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
- exports.evaluationSchema = zod_1.z.object({
33
- async: zod_1.z.boolean(),
34
- input: exports.inputSchema,
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 resultSchema = zod_1.z.object({
38
- claim: zod_1.z.string().optional(),
39
- contradiction: zod_1.z.boolean().optional(),
40
- passed: zod_1.z.boolean().optional(),
41
- matchScore: zod_1.z.number().optional(),
42
- reason: zod_1.z.string().optional(),
43
- quote: zod_1.z.string().optional(),
44
- includedInContent: zod_1.z.boolean().optional(),
45
- monitorId: zod_1.z.string().optional(),
46
- createdAt: zod_1.z.string().optional(),
47
- organizationId: zod_1.z.string().optional(),
48
- callId: zod_1.z.string().optional(),
49
- label: zod_1.z.string().optional(),
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 evaluationResultSchema = zod_1.z.object({
52
- type: zod_1.z.string(),
53
- results: zod_1.z.array(resultSchema),
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 scoreBreakdownItemSchema = zod_1.z.object({
56
- length: zod_1.z.number(),
57
- scoreSum: zod_1.z.number(),
59
+ const EvaluationResultItemSchema = zod_1.z.object({
60
+ results: zod_1.z.array(EvaluationResultSchema),
61
+ type: zod_1.z.string(),
58
62
  });
59
- const scoreBreakdownSchema = zod_1.z.record(scoreBreakdownItemSchema);
60
- exports.evaluationResponseSchema = zod_1.z.object({
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qualifire",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "description": "Qualifire client SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [