qualifire 1.0.1 → 1.1.1
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 +72 -26
- package/lib/index.d.ts +27 -5
- package/lib/index.js +61 -40
- package/lib/types.d.ts +472 -0
- package/lib/types.js +65 -0
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -1,49 +1,95 @@
|
|
|
1
|
-
|
|
1
|
+
Qualifire
|
|
2
2
|
|
|
3
|
-
[](https://github.com/qualifire-dev/qualifire-typescript-sdk/actions/workflows/codeql-analysis.yml)
|
|
4
|
+
[](https://github.com/qualifire-dev/qualifire-typescript-sdk/actions/workflows/release.yml)
|
|
5
5
|
[![Issues][issues-img]][issues-url]
|
|
6
6
|
[![Code Coverage][codecov-img]][codecov-url]
|
|
7
7
|
[![Commitizen Friendly][commitizen-img]][commitizen-url]
|
|
8
8
|
[![Semantic Release][semantic-release-img]][semantic-release-url]
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
# Qualifire SDK
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
This is the official SDK for interacting with the Qualifire API.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
13
15
|
|
|
14
16
|
```bash
|
|
15
|
-
npm install
|
|
17
|
+
npm install qualifire
|
|
16
18
|
```
|
|
17
19
|
|
|
18
|
-
##
|
|
20
|
+
## usage
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
import * as qualifire from 'qualifire';
|
|
22
|
+
First, import the `Qualifire` class from the SDK:
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
```javascript
|
|
25
|
+
import { Qualifire } from 'qualifire-sdk';
|
|
26
|
+
```
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
'isMyAwesomeFeatureEnabled',
|
|
27
|
-
{
|
|
28
|
-
var1: 'val1',
|
|
29
|
-
var2: 'val2',
|
|
30
|
-
}
|
|
31
|
-
);
|
|
28
|
+
Then, create a new instance of the Qualifire class, passing your API key and the base URL of the Qualifire API:
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
```javascript
|
|
31
|
+
const qualifire = new Qualifire({
|
|
32
|
+
apiKey: 'your-api-key',
|
|
36
33
|
});
|
|
37
34
|
```
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
ℹ️ There are default environment variables if you prefer to set it that way `QUALIFIRE_API_KEY`
|
|
37
|
+
|
|
38
|
+
You can now use the `evaluate` method to evaluate input and output data:
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
const input = {
|
|
42
|
+
model: 'gpt-3.5-turbo',
|
|
43
|
+
messages: [
|
|
44
|
+
{
|
|
45
|
+
role: 'user',
|
|
46
|
+
content: 'this is my awesome request',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const output = await openai.chat.completions.create(input);
|
|
52
|
+
|
|
53
|
+
const evaluationResponse = await qualifire.evaluate(input, output); // This will block until the evaluation is done
|
|
54
|
+
console.log(evaluationResponse);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Non-blocking execution
|
|
58
|
+
|
|
59
|
+
In case you want to trigger a completely async evaluation (to view in qualifire's UI) simply add the `{async: true}` option to your call.
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
const input = {
|
|
63
|
+
model: 'gpt-3.5-turbo',
|
|
64
|
+
messages: [
|
|
65
|
+
{
|
|
66
|
+
role: 'user',
|
|
67
|
+
content: 'this is my awesome request',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const output = await openai.chat.completions.create(input);
|
|
73
|
+
|
|
74
|
+
const evaluationResponse = await qualifire.evaluate(input, output, {
|
|
75
|
+
async: true,
|
|
76
|
+
}); // This will block until the evaluation is done
|
|
77
|
+
console.log(evaluationResponse);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Evaluates the input and output using the Qualifire API. Returns a promise that resolves to the evaluation response, or undefined if async is true.
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
[build-img]: https://github.com/qualifire-dev/develop/qualifire-typescript-sdk/actions/workflows/release.yml/badge.svg
|
|
86
|
+
[build-url]: https://github.com/qualifire-dev/qualifire-typescript-sdk/actions/workflows/release.yml
|
|
41
87
|
[downloads-img]: https://img.shields.io/npm/dt/main/qualifire
|
|
42
88
|
[npm-url]: https://www.npmjs.com/package/qualifire
|
|
43
|
-
[issues-img]: https://img.shields.io/github/issues/
|
|
44
|
-
[issues-url]: https://github.com/
|
|
45
|
-
[codecov-img]: https://codecov.io/gh/
|
|
46
|
-
[codecov-url]: https://codecov.io/gh/
|
|
89
|
+
[issues-img]: https://img.shields.io/github/issues/qualifire-dev/develop/qualifire-typescript-sdk
|
|
90
|
+
[issues-url]: https://github.com/qualifire-dev/qualifire-typescript-sdk/issues
|
|
91
|
+
[codecov-img]: https://codecov.io/gh/qualifire-dev/develop/qualifire-typescript-sdk/branch/main/graph/badge.svg
|
|
92
|
+
[codecov-url]: https://codecov.io/gh/qualifire-dev/develop/qualifire-typescript-sdk
|
|
47
93
|
[semantic-release-img]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
|
|
48
94
|
[semantic-release-url]: https://github.com/semantic-release/semantic-release
|
|
49
95
|
[commitizen-img]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { EvaluationResponse, Input, Output } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the Qualifire SDK.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The Qualifire class represents the Qualifire SDK.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Qualifire {
|
|
3
9
|
sdkKey: string;
|
|
4
10
|
baseUrl: string;
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
/**
|
|
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.
|
|
15
|
+
*/
|
|
16
|
+
constructor({ apiKey, baseUrl }: {
|
|
17
|
+
apiKey: string;
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Evaluates the input and output using the Qualifire API.
|
|
22
|
+
* @param input - The input data for evaluation.
|
|
23
|
+
* @param output - The expected output data for evaluation.
|
|
24
|
+
* @param options - Additional options for evaluation.
|
|
25
|
+
* @returns A promise that resolves to the evaluation response.
|
|
26
|
+
*/
|
|
27
|
+
evaluate: (input: Input, output: Output, { async, }: {
|
|
28
|
+
async?: boolean | undefined;
|
|
29
|
+
}) => Promise<EvaluationResponse | undefined>;
|
|
7
30
|
}
|
|
8
|
-
export {};
|
package/lib/index.js
CHANGED
|
@@ -1,46 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
3
|
+
exports.Qualifire = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
/**
|
|
6
|
+
* Represents the Qualifire SDK.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The Qualifire class represents the Qualifire SDK.
|
|
10
|
+
*/
|
|
11
|
+
class Qualifire {
|
|
12
|
+
/**
|
|
13
|
+
* 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.
|
|
16
|
+
*/
|
|
17
|
+
constructor({ apiKey, baseUrl }) {
|
|
18
|
+
/**
|
|
19
|
+
* Evaluates the input and output using the Qualifire API.
|
|
20
|
+
* @param input - The input data for evaluation.
|
|
21
|
+
* @param output - The expected output data for evaluation.
|
|
22
|
+
* @param options - Additional options for evaluation.
|
|
23
|
+
* @returns A promise that resolves to the evaluation response.
|
|
24
|
+
*/
|
|
25
|
+
this.evaluate = async (input, output, { async = false, }) => {
|
|
26
|
+
const url = `${this.baseUrl}/api/evaluate/v1`;
|
|
27
|
+
const body = JSON.stringify({ async, input, output });
|
|
28
|
+
const headers = {
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
'X-qualifire-key': this.sdkKey,
|
|
31
|
+
};
|
|
32
|
+
if (async) {
|
|
33
|
+
void fetch(url, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers,
|
|
36
|
+
body,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const response = await fetch(url, {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
headers,
|
|
43
|
+
body,
|
|
44
|
+
});
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
throw new Error(`Qualifire API error: ${response.statusText}`);
|
|
47
|
+
}
|
|
48
|
+
const jsonResponse = await response.json();
|
|
49
|
+
const parsed = types_1.evaluationResponseSchema.safeParse(jsonResponse);
|
|
50
|
+
if (!parsed.success) {
|
|
51
|
+
throw new Error('Qualifire API error: Evaluation failed');
|
|
52
|
+
}
|
|
53
|
+
return parsed.data;
|
|
41
54
|
}
|
|
42
|
-
|
|
55
|
+
};
|
|
56
|
+
const key = apiKey || process.env.QUALIFIRE_API_KEY;
|
|
57
|
+
const qualifireBaseUrl = baseUrl ||
|
|
58
|
+
process.env.QUALIFIRE_BASE_URL ||
|
|
59
|
+
'https://gateway.qualifire.ai';
|
|
60
|
+
if (!key) {
|
|
61
|
+
throw new Error('Missing SDK key, please provide an arg or add the QUALIFIRE_API_KEY environment variable.');
|
|
43
62
|
}
|
|
44
|
-
|
|
63
|
+
this.sdkKey = key;
|
|
64
|
+
this.baseUrl = qualifireBaseUrl;
|
|
45
65
|
}
|
|
46
66
|
}
|
|
67
|
+
exports.Qualifire = Qualifire;
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const messageSchema: z.ZodObject<{
|
|
3
|
+
role: z.ZodString;
|
|
4
|
+
content: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
role: string;
|
|
7
|
+
content: string;
|
|
8
|
+
}, {
|
|
9
|
+
role: string;
|
|
10
|
+
content: string;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const choiceSchema: z.ZodObject<{
|
|
13
|
+
index: z.ZodNumber;
|
|
14
|
+
message: z.ZodObject<{
|
|
15
|
+
role: z.ZodString;
|
|
16
|
+
content: z.ZodString;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
role: string;
|
|
19
|
+
content: string;
|
|
20
|
+
}, {
|
|
21
|
+
role: string;
|
|
22
|
+
content: string;
|
|
23
|
+
}>;
|
|
24
|
+
finish_reason: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
message: {
|
|
27
|
+
role: string;
|
|
28
|
+
content: string;
|
|
29
|
+
};
|
|
30
|
+
index: number;
|
|
31
|
+
finish_reason?: string | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
message: {
|
|
34
|
+
role: string;
|
|
35
|
+
content: string;
|
|
36
|
+
};
|
|
37
|
+
index: number;
|
|
38
|
+
finish_reason?: string | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const usageSchema: z.ZodObject<{
|
|
41
|
+
prompt_tokens: z.ZodNumber;
|
|
42
|
+
completion_tokens: z.ZodNumber;
|
|
43
|
+
total_tokens: z.ZodNumber;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
prompt_tokens: number;
|
|
46
|
+
completion_tokens: number;
|
|
47
|
+
total_tokens: number;
|
|
48
|
+
}, {
|
|
49
|
+
prompt_tokens: number;
|
|
50
|
+
completion_tokens: number;
|
|
51
|
+
total_tokens: number;
|
|
52
|
+
}>;
|
|
53
|
+
export declare const inputSchema: z.ZodObject<{
|
|
54
|
+
model: z.ZodString;
|
|
55
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
56
|
+
role: z.ZodString;
|
|
57
|
+
content: z.ZodString;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
role: string;
|
|
60
|
+
content: string;
|
|
61
|
+
}, {
|
|
62
|
+
role: string;
|
|
63
|
+
content: string;
|
|
64
|
+
}>, "many">;
|
|
65
|
+
caller: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
model: string;
|
|
68
|
+
messages: {
|
|
69
|
+
role: string;
|
|
70
|
+
content: string;
|
|
71
|
+
}[];
|
|
72
|
+
caller?: string | undefined;
|
|
73
|
+
}, {
|
|
74
|
+
model: string;
|
|
75
|
+
messages: {
|
|
76
|
+
role: string;
|
|
77
|
+
content: string;
|
|
78
|
+
}[];
|
|
79
|
+
caller?: string | undefined;
|
|
80
|
+
}>;
|
|
81
|
+
export type Input = z.infer<typeof inputSchema>;
|
|
82
|
+
export declare const outputSchema: z.ZodObject<{
|
|
83
|
+
id: z.ZodString;
|
|
84
|
+
created: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
model: z.ZodString;
|
|
86
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
87
|
+
index: z.ZodNumber;
|
|
88
|
+
message: z.ZodObject<{
|
|
89
|
+
role: z.ZodString;
|
|
90
|
+
content: z.ZodString;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
role: string;
|
|
93
|
+
content: string;
|
|
94
|
+
}, {
|
|
95
|
+
role: string;
|
|
96
|
+
content: string;
|
|
97
|
+
}>;
|
|
98
|
+
finish_reason: z.ZodOptional<z.ZodString>;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
message: {
|
|
101
|
+
role: string;
|
|
102
|
+
content: string;
|
|
103
|
+
};
|
|
104
|
+
index: number;
|
|
105
|
+
finish_reason?: string | undefined;
|
|
106
|
+
}, {
|
|
107
|
+
message: {
|
|
108
|
+
role: string;
|
|
109
|
+
content: string;
|
|
110
|
+
};
|
|
111
|
+
index: number;
|
|
112
|
+
finish_reason?: string | undefined;
|
|
113
|
+
}>, "many">;
|
|
114
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
115
|
+
prompt_tokens: z.ZodNumber;
|
|
116
|
+
completion_tokens: z.ZodNumber;
|
|
117
|
+
total_tokens: z.ZodNumber;
|
|
118
|
+
}, "strip", z.ZodTypeAny, {
|
|
119
|
+
prompt_tokens: number;
|
|
120
|
+
completion_tokens: number;
|
|
121
|
+
total_tokens: number;
|
|
122
|
+
}, {
|
|
123
|
+
prompt_tokens: number;
|
|
124
|
+
completion_tokens: number;
|
|
125
|
+
total_tokens: number;
|
|
126
|
+
}>>;
|
|
127
|
+
system_fingerprint: z.ZodOptional<z.ZodString>;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
model: string;
|
|
130
|
+
id: string;
|
|
131
|
+
choices: {
|
|
132
|
+
message: {
|
|
133
|
+
role: string;
|
|
134
|
+
content: string;
|
|
135
|
+
};
|
|
136
|
+
index: number;
|
|
137
|
+
finish_reason?: string | undefined;
|
|
138
|
+
}[];
|
|
139
|
+
created?: number | undefined;
|
|
140
|
+
usage?: {
|
|
141
|
+
prompt_tokens: number;
|
|
142
|
+
completion_tokens: number;
|
|
143
|
+
total_tokens: number;
|
|
144
|
+
} | undefined;
|
|
145
|
+
system_fingerprint?: string | undefined;
|
|
146
|
+
}, {
|
|
147
|
+
model: string;
|
|
148
|
+
id: string;
|
|
149
|
+
choices: {
|
|
150
|
+
message: {
|
|
151
|
+
role: string;
|
|
152
|
+
content: string;
|
|
153
|
+
};
|
|
154
|
+
index: number;
|
|
155
|
+
finish_reason?: string | undefined;
|
|
156
|
+
}[];
|
|
157
|
+
created?: number | undefined;
|
|
158
|
+
usage?: {
|
|
159
|
+
prompt_tokens: number;
|
|
160
|
+
completion_tokens: number;
|
|
161
|
+
total_tokens: number;
|
|
162
|
+
} | undefined;
|
|
163
|
+
system_fingerprint?: string | undefined;
|
|
164
|
+
}>;
|
|
165
|
+
export type Output = z.infer<typeof outputSchema>;
|
|
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.ZodString;
|
|
173
|
+
}, "strip", z.ZodTypeAny, {
|
|
174
|
+
role: string;
|
|
175
|
+
content: string;
|
|
176
|
+
}, {
|
|
177
|
+
role: string;
|
|
178
|
+
content: string;
|
|
179
|
+
}>, "many">;
|
|
180
|
+
caller: z.ZodOptional<z.ZodString>;
|
|
181
|
+
}, "strip", z.ZodTypeAny, {
|
|
182
|
+
model: string;
|
|
183
|
+
messages: {
|
|
184
|
+
role: string;
|
|
185
|
+
content: string;
|
|
186
|
+
}[];
|
|
187
|
+
caller?: string | undefined;
|
|
188
|
+
}, {
|
|
189
|
+
model: string;
|
|
190
|
+
messages: {
|
|
191
|
+
role: string;
|
|
192
|
+
content: string;
|
|
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.ZodString;
|
|
205
|
+
}, "strip", z.ZodTypeAny, {
|
|
206
|
+
role: string;
|
|
207
|
+
content: string;
|
|
208
|
+
}, {
|
|
209
|
+
role: string;
|
|
210
|
+
content: string;
|
|
211
|
+
}>;
|
|
212
|
+
finish_reason: z.ZodOptional<z.ZodString>;
|
|
213
|
+
}, "strip", z.ZodTypeAny, {
|
|
214
|
+
message: {
|
|
215
|
+
role: string;
|
|
216
|
+
content: string;
|
|
217
|
+
};
|
|
218
|
+
index: number;
|
|
219
|
+
finish_reason?: string | undefined;
|
|
220
|
+
}, {
|
|
221
|
+
message: {
|
|
222
|
+
role: string;
|
|
223
|
+
content: string;
|
|
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>;
|
|
242
|
+
}, "strip", z.ZodTypeAny, {
|
|
243
|
+
model: string;
|
|
244
|
+
id: string;
|
|
245
|
+
choices: {
|
|
246
|
+
message: {
|
|
247
|
+
role: string;
|
|
248
|
+
content: string;
|
|
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;
|
|
260
|
+
}, {
|
|
261
|
+
model: string;
|
|
262
|
+
id: string;
|
|
263
|
+
choices: {
|
|
264
|
+
message: {
|
|
265
|
+
role: string;
|
|
266
|
+
content: string;
|
|
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
|
+
}>;
|
|
279
|
+
}, "strip", z.ZodTypeAny, {
|
|
280
|
+
async: boolean;
|
|
281
|
+
input: {
|
|
282
|
+
model: string;
|
|
283
|
+
messages: {
|
|
284
|
+
role: string;
|
|
285
|
+
content: string;
|
|
286
|
+
}[];
|
|
287
|
+
caller?: string | undefined;
|
|
288
|
+
};
|
|
289
|
+
output: {
|
|
290
|
+
model: string;
|
|
291
|
+
id: string;
|
|
292
|
+
choices: {
|
|
293
|
+
message: {
|
|
294
|
+
role: string;
|
|
295
|
+
content: string;
|
|
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
|
+
};
|
|
308
|
+
}, {
|
|
309
|
+
async: boolean;
|
|
310
|
+
input: {
|
|
311
|
+
model: string;
|
|
312
|
+
messages: {
|
|
313
|
+
role: string;
|
|
314
|
+
content: string;
|
|
315
|
+
}[];
|
|
316
|
+
caller?: string | undefined;
|
|
317
|
+
};
|
|
318
|
+
output: {
|
|
319
|
+
model: string;
|
|
320
|
+
id: string;
|
|
321
|
+
choices: {
|
|
322
|
+
message: {
|
|
323
|
+
role: string;
|
|
324
|
+
content: string;
|
|
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
|
+
};
|
|
337
|
+
}>;
|
|
338
|
+
export declare const evaluationResponseSchema: z.ZodObject<{
|
|
339
|
+
success: z.ZodBoolean;
|
|
340
|
+
evaluationResults: z.ZodArray<z.ZodObject<{
|
|
341
|
+
type: z.ZodString;
|
|
342
|
+
results: z.ZodArray<z.ZodObject<{
|
|
343
|
+
claim: z.ZodString;
|
|
344
|
+
contradiction: z.ZodBoolean;
|
|
345
|
+
passed: z.ZodBoolean;
|
|
346
|
+
matchScore: z.ZodNumber;
|
|
347
|
+
reason: z.ZodString;
|
|
348
|
+
quote: z.ZodString;
|
|
349
|
+
includedInContent: z.ZodBoolean;
|
|
350
|
+
monitorId: z.ZodString;
|
|
351
|
+
createdAt: z.ZodString;
|
|
352
|
+
organizationId: z.ZodString;
|
|
353
|
+
callId: z.ZodString;
|
|
354
|
+
}, "strip", z.ZodTypeAny, {
|
|
355
|
+
claim: string;
|
|
356
|
+
contradiction: boolean;
|
|
357
|
+
passed: boolean;
|
|
358
|
+
matchScore: number;
|
|
359
|
+
reason: string;
|
|
360
|
+
quote: string;
|
|
361
|
+
includedInContent: boolean;
|
|
362
|
+
monitorId: string;
|
|
363
|
+
createdAt: string;
|
|
364
|
+
organizationId: string;
|
|
365
|
+
callId: string;
|
|
366
|
+
}, {
|
|
367
|
+
claim: string;
|
|
368
|
+
contradiction: boolean;
|
|
369
|
+
passed: boolean;
|
|
370
|
+
matchScore: number;
|
|
371
|
+
reason: string;
|
|
372
|
+
quote: string;
|
|
373
|
+
includedInContent: boolean;
|
|
374
|
+
monitorId: string;
|
|
375
|
+
createdAt: string;
|
|
376
|
+
organizationId: string;
|
|
377
|
+
callId: string;
|
|
378
|
+
}>, "many">;
|
|
379
|
+
}, "strip", z.ZodTypeAny, {
|
|
380
|
+
type: string;
|
|
381
|
+
results: {
|
|
382
|
+
claim: string;
|
|
383
|
+
contradiction: boolean;
|
|
384
|
+
passed: boolean;
|
|
385
|
+
matchScore: number;
|
|
386
|
+
reason: string;
|
|
387
|
+
quote: string;
|
|
388
|
+
includedInContent: boolean;
|
|
389
|
+
monitorId: string;
|
|
390
|
+
createdAt: string;
|
|
391
|
+
organizationId: string;
|
|
392
|
+
callId: string;
|
|
393
|
+
}[];
|
|
394
|
+
}, {
|
|
395
|
+
type: string;
|
|
396
|
+
results: {
|
|
397
|
+
claim: string;
|
|
398
|
+
contradiction: boolean;
|
|
399
|
+
passed: boolean;
|
|
400
|
+
matchScore: number;
|
|
401
|
+
reason: string;
|
|
402
|
+
quote: string;
|
|
403
|
+
includedInContent: boolean;
|
|
404
|
+
monitorId: string;
|
|
405
|
+
createdAt: string;
|
|
406
|
+
organizationId: string;
|
|
407
|
+
callId: string;
|
|
408
|
+
}[];
|
|
409
|
+
}>, "many">;
|
|
410
|
+
score: z.ZodNumber;
|
|
411
|
+
status: z.ZodString;
|
|
412
|
+
scoreBreakdown: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
413
|
+
length: z.ZodNumber;
|
|
414
|
+
scoreSum: z.ZodNumber;
|
|
415
|
+
}, "strip", z.ZodTypeAny, {
|
|
416
|
+
length: number;
|
|
417
|
+
scoreSum: number;
|
|
418
|
+
}, {
|
|
419
|
+
length: number;
|
|
420
|
+
scoreSum: number;
|
|
421
|
+
}>>;
|
|
422
|
+
}, "strip", z.ZodTypeAny, {
|
|
423
|
+
status: string;
|
|
424
|
+
success: boolean;
|
|
425
|
+
evaluationResults: {
|
|
426
|
+
type: string;
|
|
427
|
+
results: {
|
|
428
|
+
claim: string;
|
|
429
|
+
contradiction: boolean;
|
|
430
|
+
passed: boolean;
|
|
431
|
+
matchScore: number;
|
|
432
|
+
reason: string;
|
|
433
|
+
quote: string;
|
|
434
|
+
includedInContent: boolean;
|
|
435
|
+
monitorId: string;
|
|
436
|
+
createdAt: string;
|
|
437
|
+
organizationId: string;
|
|
438
|
+
callId: string;
|
|
439
|
+
}[];
|
|
440
|
+
}[];
|
|
441
|
+
score: number;
|
|
442
|
+
scoreBreakdown: Record<string, {
|
|
443
|
+
length: number;
|
|
444
|
+
scoreSum: number;
|
|
445
|
+
}>;
|
|
446
|
+
}, {
|
|
447
|
+
status: string;
|
|
448
|
+
success: boolean;
|
|
449
|
+
evaluationResults: {
|
|
450
|
+
type: string;
|
|
451
|
+
results: {
|
|
452
|
+
claim: string;
|
|
453
|
+
contradiction: boolean;
|
|
454
|
+
passed: boolean;
|
|
455
|
+
matchScore: number;
|
|
456
|
+
reason: string;
|
|
457
|
+
quote: string;
|
|
458
|
+
includedInContent: boolean;
|
|
459
|
+
monitorId: string;
|
|
460
|
+
createdAt: string;
|
|
461
|
+
organizationId: string;
|
|
462
|
+
callId: string;
|
|
463
|
+
}[];
|
|
464
|
+
}[];
|
|
465
|
+
score: number;
|
|
466
|
+
scoreBreakdown: Record<string, {
|
|
467
|
+
length: number;
|
|
468
|
+
scoreSum: number;
|
|
469
|
+
}>;
|
|
470
|
+
}>;
|
|
471
|
+
export type Evaluation = z.infer<typeof evaluationSchema>;
|
|
472
|
+
export type EvaluationResponse = z.infer<typeof evaluationResponseSchema>;
|
package/lib/types.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evaluationResponseSchema = exports.evaluationSchema = exports.outputSchema = exports.inputSchema = exports.usageSchema = exports.choiceSchema = exports.messageSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.messageSchema = zod_1.z.object({
|
|
6
|
+
role: zod_1.z.string(),
|
|
7
|
+
content: zod_1.z.string(),
|
|
8
|
+
});
|
|
9
|
+
exports.choiceSchema = zod_1.z.object({
|
|
10
|
+
index: zod_1.z.number(),
|
|
11
|
+
message: exports.messageSchema,
|
|
12
|
+
finish_reason: zod_1.z.string().optional(),
|
|
13
|
+
});
|
|
14
|
+
exports.usageSchema = zod_1.z.object({
|
|
15
|
+
prompt_tokens: zod_1.z.number(),
|
|
16
|
+
completion_tokens: zod_1.z.number(),
|
|
17
|
+
total_tokens: zod_1.z.number(),
|
|
18
|
+
});
|
|
19
|
+
exports.inputSchema = zod_1.z.object({
|
|
20
|
+
model: zod_1.z.string(),
|
|
21
|
+
messages: zod_1.z.array(exports.messageSchema),
|
|
22
|
+
caller: zod_1.z.string().optional(),
|
|
23
|
+
});
|
|
24
|
+
exports.outputSchema = zod_1.z.object({
|
|
25
|
+
id: zod_1.z.string(),
|
|
26
|
+
created: zod_1.z.number().optional(),
|
|
27
|
+
model: zod_1.z.string(),
|
|
28
|
+
choices: zod_1.z.array(exports.choiceSchema),
|
|
29
|
+
usage: exports.usageSchema.optional(),
|
|
30
|
+
system_fingerprint: zod_1.z.string().optional(),
|
|
31
|
+
});
|
|
32
|
+
exports.evaluationSchema = zod_1.z.object({
|
|
33
|
+
async: zod_1.z.boolean(),
|
|
34
|
+
input: exports.inputSchema,
|
|
35
|
+
output: exports.outputSchema,
|
|
36
|
+
});
|
|
37
|
+
const resultSchema = zod_1.z.object({
|
|
38
|
+
claim: zod_1.z.string(),
|
|
39
|
+
contradiction: zod_1.z.boolean(),
|
|
40
|
+
passed: zod_1.z.boolean(),
|
|
41
|
+
matchScore: zod_1.z.number(),
|
|
42
|
+
reason: zod_1.z.string(),
|
|
43
|
+
quote: zod_1.z.string(),
|
|
44
|
+
includedInContent: zod_1.z.boolean(),
|
|
45
|
+
monitorId: zod_1.z.string(),
|
|
46
|
+
createdAt: zod_1.z.string(),
|
|
47
|
+
organizationId: zod_1.z.string(),
|
|
48
|
+
callId: zod_1.z.string(),
|
|
49
|
+
});
|
|
50
|
+
const evaluationResultSchema = zod_1.z.object({
|
|
51
|
+
type: zod_1.z.string(),
|
|
52
|
+
results: zod_1.z.array(resultSchema),
|
|
53
|
+
});
|
|
54
|
+
const scoreBreakdownItemSchema = zod_1.z.object({
|
|
55
|
+
length: zod_1.z.number(),
|
|
56
|
+
scoreSum: zod_1.z.number(),
|
|
57
|
+
});
|
|
58
|
+
const scoreBreakdownSchema = zod_1.z.record(scoreBreakdownItemSchema);
|
|
59
|
+
exports.evaluationResponseSchema = zod_1.z.object({
|
|
60
|
+
success: zod_1.z.boolean(),
|
|
61
|
+
evaluationResults: zod_1.z.array(evaluationResultSchema),
|
|
62
|
+
score: zod_1.z.number(),
|
|
63
|
+
status: zod_1.z.string(),
|
|
64
|
+
scoreBreakdown: scoreBreakdownSchema,
|
|
65
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qualifire",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Qualifire client SDK",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/
|
|
22
|
+
"url": "https://github.com/qualifire-dev/qualifire-typescript-sdk.git"
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"author": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"llmops"
|
|
37
37
|
],
|
|
38
38
|
"bugs": {
|
|
39
|
-
"url": "https://github.com/
|
|
39
|
+
"url": "https://github.com/qualifire-dev/qualifire-typescript-sdk/issues"
|
|
40
40
|
},
|
|
41
|
-
"homepage": "https://github.com/
|
|
41
|
+
"homepage": "https://github.com/qualifire-dev/qualifire-typescript-sdk#readme",
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@ryansonshine/commitizen": "^4.2.8",
|
|
44
44
|
"@ryansonshine/cz-conventional-changelog": "^3.3.4",
|
|
@@ -112,5 +112,8 @@
|
|
|
112
112
|
"@semantic-release/npm",
|
|
113
113
|
"@semantic-release/github"
|
|
114
114
|
]
|
|
115
|
+
},
|
|
116
|
+
"dependencies": {
|
|
117
|
+
"zod": "^3.22.4"
|
|
115
118
|
}
|
|
116
119
|
}
|