scorecard-ai 1.0.0-alpha.8 → 1.0.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.
Files changed (143) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +25 -37
  3. package/client.d.mts +5 -4
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +5 -4
  6. package/client.d.ts.map +1 -1
  7. package/client.js +19 -4
  8. package/client.js.map +1 -1
  9. package/client.mjs +19 -4
  10. package/client.mjs.map +1 -1
  11. package/core/pagination.d.mts +1 -1
  12. package/core/pagination.d.mts.map +1 -1
  13. package/core/pagination.d.ts +1 -1
  14. package/core/pagination.d.ts.map +1 -1
  15. package/index.d.mts +1 -0
  16. package/index.d.mts.map +1 -1
  17. package/index.d.ts +1 -0
  18. package/index.d.ts.map +1 -1
  19. package/index.js +3 -1
  20. package/index.js.map +1 -1
  21. package/index.mjs +1 -0
  22. package/index.mjs.map +1 -1
  23. package/internal/detect-platform.js +3 -3
  24. package/internal/detect-platform.js.map +1 -1
  25. package/internal/detect-platform.mjs +3 -3
  26. package/internal/detect-platform.mjs.map +1 -1
  27. package/internal/shim-types.d.mts +11 -22
  28. package/internal/shim-types.d.mts.map +1 -0
  29. package/internal/shim-types.d.ts +11 -22
  30. package/internal/shim-types.d.ts.map +1 -0
  31. package/internal/shim-types.js +4 -0
  32. package/internal/shim-types.js.map +1 -0
  33. package/internal/shim-types.mjs +3 -0
  34. package/internal/shim-types.mjs.map +1 -0
  35. package/internal/shims.d.mts +2 -2
  36. package/internal/shims.d.mts.map +1 -1
  37. package/internal/shims.d.ts +2 -2
  38. package/internal/shims.d.ts.map +1 -1
  39. package/internal/tslib.js +6 -6
  40. package/internal/uploads.js.map +1 -1
  41. package/internal/uploads.mjs.map +1 -1
  42. package/lib/runAndEvaluate.d.mts +62 -10
  43. package/lib/runAndEvaluate.d.mts.map +1 -1
  44. package/lib/runAndEvaluate.d.ts +62 -10
  45. package/lib/runAndEvaluate.d.ts.map +1 -1
  46. package/lib/runAndEvaluate.js +72 -19
  47. package/lib/runAndEvaluate.js.map +1 -1
  48. package/lib/runAndEvaluate.mjs +72 -19
  49. package/lib/runAndEvaluate.mjs.map +1 -1
  50. package/package.json +1 -4
  51. package/resources/index.d.mts +2 -2
  52. package/resources/index.d.mts.map +1 -1
  53. package/resources/index.d.ts +2 -2
  54. package/resources/index.d.ts.map +1 -1
  55. package/resources/index.js +4 -4
  56. package/resources/index.js.map +1 -1
  57. package/resources/index.mjs +2 -2
  58. package/resources/index.mjs.map +1 -1
  59. package/resources/metrics.d.mts +421 -0
  60. package/resources/metrics.d.mts.map +1 -0
  61. package/resources/metrics.d.ts +421 -0
  62. package/resources/metrics.d.ts.map +1 -0
  63. package/resources/metrics.js +33 -0
  64. package/resources/metrics.js.map +1 -0
  65. package/resources/metrics.mjs +29 -0
  66. package/resources/metrics.mjs.map +1 -0
  67. package/resources/runs.d.mts +8 -8
  68. package/resources/runs.d.mts.map +1 -1
  69. package/resources/runs.d.ts +8 -8
  70. package/resources/runs.d.ts.map +1 -1
  71. package/resources/runs.js +1 -1
  72. package/resources/runs.mjs +1 -1
  73. package/resources/systems/index.d.mts +3 -0
  74. package/resources/systems/index.d.mts.map +1 -0
  75. package/resources/systems/index.d.ts +3 -0
  76. package/resources/systems/index.d.ts.map +1 -0
  77. package/resources/systems/index.js +9 -0
  78. package/resources/systems/index.js.map +1 -0
  79. package/resources/systems/index.mjs +4 -0
  80. package/resources/systems/index.mjs.map +1 -0
  81. package/resources/systems/systems.d.mts +229 -0
  82. package/resources/systems/systems.d.mts.map +1 -0
  83. package/resources/systems/systems.d.ts +229 -0
  84. package/resources/systems/systems.d.ts.map +1 -0
  85. package/resources/systems/systems.js +151 -0
  86. package/resources/systems/systems.js.map +1 -0
  87. package/resources/systems/systems.mjs +146 -0
  88. package/resources/systems/systems.mjs.map +1 -0
  89. package/resources/systems/versions.d.mts +132 -0
  90. package/resources/systems/versions.d.mts.map +1 -0
  91. package/resources/systems/versions.d.ts +132 -0
  92. package/resources/systems/versions.d.ts.map +1 -0
  93. package/resources/systems/versions.js +82 -0
  94. package/resources/systems/versions.js.map +1 -0
  95. package/resources/systems/versions.mjs +78 -0
  96. package/resources/systems/versions.mjs.map +1 -0
  97. package/resources/systems.d.mts +1 -224
  98. package/resources/systems.d.mts.map +1 -1
  99. package/resources/systems.d.ts +1 -224
  100. package/resources/systems.d.ts.map +1 -1
  101. package/resources/systems.js +2 -139
  102. package/resources/systems.js.map +1 -1
  103. package/resources/systems.mjs +1 -137
  104. package/resources/systems.mjs.map +1 -1
  105. package/resources/testsets.d.mts +1 -1
  106. package/resources/testsets.d.ts +1 -1
  107. package/resources/testsets.js +1 -1
  108. package/resources/testsets.mjs +1 -1
  109. package/src/client.ts +28 -28
  110. package/src/core/pagination.ts +1 -1
  111. package/src/index.ts +2 -0
  112. package/src/internal/detect-platform.ts +3 -3
  113. package/src/internal/shim-types.ts +26 -0
  114. package/src/internal/shims.ts +2 -2
  115. package/src/internal/uploads.ts +1 -1
  116. package/src/lib/runAndEvaluate.ts +159 -31
  117. package/src/resources/index.ts +2 -9
  118. package/src/resources/metrics.ts +525 -0
  119. package/src/resources/runs.ts +8 -8
  120. package/src/resources/systems/index.ts +18 -0
  121. package/src/resources/systems/systems.ts +299 -0
  122. package/src/resources/systems/versions.ts +166 -0
  123. package/src/resources/systems.ts +1 -277
  124. package/src/resources/testsets.ts +1 -1
  125. package/src/version.ts +1 -1
  126. package/version.d.mts +1 -1
  127. package/version.d.mts.map +1 -1
  128. package/version.d.ts +1 -1
  129. package/version.d.ts.map +1 -1
  130. package/version.js +1 -1
  131. package/version.js.map +1 -1
  132. package/version.mjs +1 -1
  133. package/version.mjs.map +1 -1
  134. package/resources/system-configs.d.mts +0 -155
  135. package/resources/system-configs.d.mts.map +0 -1
  136. package/resources/system-configs.d.ts +0 -155
  137. package/resources/system-configs.d.ts.map +0 -1
  138. package/resources/system-configs.js +0 -83
  139. package/resources/system-configs.js.map +0 -1
  140. package/resources/system-configs.mjs +0 -79
  141. package/resources/system-configs.mjs.map +0 -1
  142. package/src/internal/shim-types.d.ts +0 -28
  143. package/src/resources/system-configs.ts +0 -203
@@ -0,0 +1,299 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as VersionsAPI from './versions';
5
+ import {
6
+ SystemVersion,
7
+ SystemVersionsPaginatedResponse,
8
+ VersionCreateParams,
9
+ VersionListParams,
10
+ Versions,
11
+ } from './versions';
12
+ import { APIPromise } from '../../core/api-promise';
13
+ import { PagePromise, PaginatedResponse, type PaginatedResponseParams } from '../../core/pagination';
14
+ import { RequestOptions } from '../../internal/request-options';
15
+ import { path } from '../../internal/utils/path';
16
+
17
+ export class Systems extends APIResource {
18
+ versions: VersionsAPI.Versions = new VersionsAPI.Versions(this._client);
19
+
20
+ /**
21
+ * Create a new system definition that specifies the interface contracts for a
22
+ * component you want to evaluate.
23
+ *
24
+ * A system acts as a template that defines three key contracts through JSON
25
+ * Schemas:
26
+ *
27
+ * 1. Input Schema: What data your system accepts (e.g., user queries, context
28
+ * documents)
29
+ * 2. Output Schema: What data your system produces (e.g., responses, confidence
30
+ * scores)
31
+ * 3. Config Schema: What parameters can be adjusted (e.g., model selection,
32
+ * temperature)
33
+ *
34
+ * This separation lets you evaluate any system as a black box, focusing on its
35
+ * interface rather than implementation details.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const system = await client.systems.create('314', {
40
+ * configSchema: {
41
+ * type: 'object',
42
+ * properties: {
43
+ * temperature: { type: 'number' },
44
+ * maxTokens: { type: 'integer' },
45
+ * model: { type: 'string', enum: ['gpt-4', 'gpt-4-turbo'] },
46
+ * },
47
+ * required: ['model'],
48
+ * },
49
+ * description: 'Production chatbot powered by GPT-4',
50
+ * inputSchema: {
51
+ * type: 'object',
52
+ * properties: {
53
+ * messages: {
54
+ * type: 'array',
55
+ * items: {
56
+ * type: 'object',
57
+ * properties: {
58
+ * role: { type: 'string', enum: ['system', 'user', 'assistant'] },
59
+ * content: { type: 'string' },
60
+ * },
61
+ * required: ['role', 'content'],
62
+ * },
63
+ * },
64
+ * },
65
+ * required: ['messages'],
66
+ * },
67
+ * name: 'GPT-4 Chatbot',
68
+ * outputSchema: {
69
+ * type: 'object',
70
+ * properties: { response: { type: 'string' } },
71
+ * required: ['response'],
72
+ * },
73
+ * });
74
+ * ```
75
+ */
76
+ create(projectID: string, body: SystemCreateParams, options?: RequestOptions): APIPromise<System> {
77
+ return this._client.post(path`/projects/${projectID}/systems`, { body, ...options });
78
+ }
79
+
80
+ /**
81
+ * Update an existing system definition. Only the fields provided in the request
82
+ * body will be updated. If a field is provided, the new content will replace the
83
+ * existing content. If a field is not provided, the existing content will remain
84
+ * unchanged.
85
+ *
86
+ * When updating schemas:
87
+ *
88
+ * - The system will accept your changes regardless of compatibility with existing
89
+ * configurations
90
+ * - Schema updates won't invalidate existing evaluations or configurations
91
+ * - For significant redesigns, creating a new system definition provides a cleaner
92
+ * separation
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const system = await client.systems.update(
97
+ * '12345678-0a8b-4f66-b6f3-2ddcfa097257',
98
+ * {
99
+ * description:
100
+ * 'Updated production chatbot powered by GPT-4 Turbo',
101
+ * name: 'GPT-4 Turbo Chatbot',
102
+ * },
103
+ * );
104
+ * ```
105
+ */
106
+ update(
107
+ systemID: string,
108
+ body: SystemUpdateParams | null | undefined = {},
109
+ options?: RequestOptions,
110
+ ): APIPromise<System> {
111
+ return this._client.patch(path`/systems/${systemID}`, { body, ...options });
112
+ }
113
+
114
+ /**
115
+ * Retrieve a paginated list of all systems. Systems are ordered by creation date.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * // Automatically fetches more pages as needed.
120
+ * for await (const system of client.systems.list('314')) {
121
+ * // ...
122
+ * }
123
+ * ```
124
+ */
125
+ list(
126
+ projectID: string,
127
+ query: SystemListParams | null | undefined = {},
128
+ options?: RequestOptions,
129
+ ): PagePromise<SystemsPaginatedResponse, System> {
130
+ return this._client.getAPIList(path`/projects/${projectID}/systems`, PaginatedResponse<System>, {
131
+ query,
132
+ ...options,
133
+ });
134
+ }
135
+
136
+ /**
137
+ * Delete a system definition by ID. This will not delete associated system
138
+ * versions.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * const system = await client.systems.delete(
143
+ * '12345678-0a8b-4f66-b6f3-2ddcfa097257',
144
+ * );
145
+ * ```
146
+ */
147
+ delete(systemID: string, options?: RequestOptions): APIPromise<SystemDeleteResponse> {
148
+ return this._client.delete(path`/systems/${systemID}`, options);
149
+ }
150
+
151
+ /**
152
+ * Retrieve a specific system by ID.
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * const system = await client.systems.get(
157
+ * '12345678-0a8b-4f66-b6f3-2ddcfa097257',
158
+ * );
159
+ * ```
160
+ */
161
+ get(systemID: string, options?: RequestOptions): APIPromise<System> {
162
+ return this._client.get(path`/systems/${systemID}`, options);
163
+ }
164
+ }
165
+
166
+ export type SystemsPaginatedResponse = PaginatedResponse<System>;
167
+
168
+ /**
169
+ * A System Under Test (SUT) defines the interface to a component or service you
170
+ * want to evaluate.
171
+ *
172
+ * It specifies three contracts through schemas:
173
+ *
174
+ * - inputSchema: The structure of data the system accepts.
175
+ * - outputSchema: The structure of data the system produces.
176
+ * - configSchema: The parameters that modify system behavior.
177
+ *
178
+ * This abstraction lets you evaluate any system as a black box, focusing on its
179
+ * interface rather than implementation details. It's particularly useful for
180
+ * systems with variable outputs or complex internal state.
181
+ *
182
+ * Systems are templates - to run evaluations, pair them with a SystemVersion that
183
+ * provides specific parameter values.
184
+ */
185
+ export interface System {
186
+ /**
187
+ * The ID of the system.
188
+ */
189
+ id: string;
190
+
191
+ /**
192
+ * The schema of the system's configuration.
193
+ */
194
+ configSchema: Record<string, unknown>;
195
+
196
+ /**
197
+ * The description of the system.
198
+ */
199
+ description: string;
200
+
201
+ /**
202
+ * The schema of the system's inputs.
203
+ */
204
+ inputSchema: Record<string, unknown>;
205
+
206
+ /**
207
+ * The name of the system.
208
+ */
209
+ name: string;
210
+
211
+ /**
212
+ * The schema of the system's outputs.
213
+ */
214
+ outputSchema: Record<string, unknown>;
215
+ }
216
+
217
+ export interface SystemDeleteResponse {
218
+ /**
219
+ * Whether the deletion was successful.
220
+ */
221
+ success: boolean;
222
+ }
223
+
224
+ export interface SystemCreateParams {
225
+ /**
226
+ * The schema of the system's configuration.
227
+ */
228
+ configSchema: Record<string, unknown>;
229
+
230
+ /**
231
+ * The description of the system.
232
+ */
233
+ description: string;
234
+
235
+ /**
236
+ * The schema of the system's inputs.
237
+ */
238
+ inputSchema: Record<string, unknown>;
239
+
240
+ /**
241
+ * The name of the system.
242
+ */
243
+ name: string;
244
+
245
+ /**
246
+ * The schema of the system's outputs.
247
+ */
248
+ outputSchema: Record<string, unknown>;
249
+ }
250
+
251
+ export interface SystemUpdateParams {
252
+ /**
253
+ * The schema of the system's configuration.
254
+ */
255
+ configSchema?: Record<string, unknown>;
256
+
257
+ /**
258
+ * The description of the system.
259
+ */
260
+ description?: string;
261
+
262
+ /**
263
+ * The schema of the system's inputs.
264
+ */
265
+ inputSchema?: Record<string, unknown>;
266
+
267
+ /**
268
+ * The name of the system.
269
+ */
270
+ name?: string;
271
+
272
+ /**
273
+ * The schema of the system's outputs.
274
+ */
275
+ outputSchema?: Record<string, unknown>;
276
+ }
277
+
278
+ export interface SystemListParams extends PaginatedResponseParams {}
279
+
280
+ Systems.Versions = Versions;
281
+
282
+ export declare namespace Systems {
283
+ export {
284
+ type System as System,
285
+ type SystemDeleteResponse as SystemDeleteResponse,
286
+ type SystemsPaginatedResponse as SystemsPaginatedResponse,
287
+ type SystemCreateParams as SystemCreateParams,
288
+ type SystemUpdateParams as SystemUpdateParams,
289
+ type SystemListParams as SystemListParams,
290
+ };
291
+
292
+ export {
293
+ Versions as Versions,
294
+ type SystemVersion as SystemVersion,
295
+ type SystemVersionsPaginatedResponse as SystemVersionsPaginatedResponse,
296
+ type VersionCreateParams as VersionCreateParams,
297
+ type VersionListParams as VersionListParams,
298
+ };
299
+ }
@@ -0,0 +1,166 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { PagePromise, PaginatedResponse, type PaginatedResponseParams } from '../../core/pagination';
6
+ import { RequestOptions } from '../../internal/request-options';
7
+ import { path } from '../../internal/utils/path';
8
+
9
+ export class Versions extends APIResource {
10
+ /**
11
+ * Create a new version for a system.
12
+ *
13
+ * Each version contains specific parameter values that match the system's
14
+ * `configSchema` - things like model parameters, thresholds, or processing
15
+ * options. Once created, versions cannot be modified, ensuring stable reference
16
+ * points for evaluations.
17
+ *
18
+ * When creating a system version:
19
+ *
20
+ * - The `config` object is validated against the parent system's `configSchema`.
21
+ * - System versions with validation errors are still stored, with errors included
22
+ * in the response.
23
+ * - Validation errors indicate fields that don't match the schema but don't
24
+ * prevent creation.
25
+ * - Having validation errors may affect how some evaluation metrics are
26
+ * calculated.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const systemVersion = await client.systems.versions.create(
31
+ * '12345678-0a8b-4f66-b6f3-2ddcfa097257',
32
+ * {
33
+ * config: {
34
+ * temperature: 0.1,
35
+ * maxTokens: 1024,
36
+ * model: 'gpt-4-turbo',
37
+ * },
38
+ * name: 'Production (Low Temperature)',
39
+ * },
40
+ * );
41
+ * ```
42
+ */
43
+ create(systemID: string, body: VersionCreateParams, options?: RequestOptions): APIPromise<SystemVersion> {
44
+ return this._client.post(path`/systems/${systemID}/configs`, { body, ...options });
45
+ }
46
+
47
+ /**
48
+ * Retrieve a paginated list of system versions for a specific system.
49
+ *
50
+ * System versions provide concrete parameter values for a System Under Test,
51
+ * defining exactly how the system should be configured during an evaluation run.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * // Automatically fetches more pages as needed.
56
+ * for await (const systemVersion of client.systems.versions.list(
57
+ * '12345678-0a8b-4f66-b6f3-2ddcfa097257',
58
+ * )) {
59
+ * // ...
60
+ * }
61
+ * ```
62
+ */
63
+ list(
64
+ systemID: string,
65
+ query: VersionListParams | null | undefined = {},
66
+ options?: RequestOptions,
67
+ ): PagePromise<SystemVersionsPaginatedResponse, SystemVersion> {
68
+ return this._client.getAPIList(path`/systems/${systemID}/configs`, PaginatedResponse<SystemVersion>, {
69
+ query,
70
+ ...options,
71
+ });
72
+ }
73
+
74
+ /**
75
+ * Retrieve a specific system version by ID.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * const systemVersion = await client.systems.versions.get(
80
+ * '87654321-4d3b-4ae4-8c7a-4b6e2a19ccf0',
81
+ * );
82
+ * ```
83
+ */
84
+ get(systemVersionID: string, options?: RequestOptions): APIPromise<SystemVersion> {
85
+ return this._client.get(path`/systems/configs/${systemVersionID}`, options);
86
+ }
87
+ }
88
+
89
+ export type SystemVersionsPaginatedResponse = PaginatedResponse<SystemVersion>;
90
+
91
+ /**
92
+ * A SystemVersion defines the specific settings for a System Under Test.
93
+ *
94
+ * System versions contain parameter values that determine system behavior during
95
+ * evaluation. They are immutable snapshots - once created, they never change.
96
+ *
97
+ * When running evaluations, you reference a specific systemVersionId to establish
98
+ * which system version to test.
99
+ *
100
+ * System versions will be validated against the system's configSchema, with
101
+ * non-conforming values generating warnings.
102
+ */
103
+ export interface SystemVersion {
104
+ /**
105
+ * The ID of the system version.
106
+ */
107
+ id: string;
108
+
109
+ /**
110
+ * The configuration of the system version.
111
+ */
112
+ config: Record<string, unknown>;
113
+
114
+ /**
115
+ * The name of the system version.
116
+ */
117
+ name: string;
118
+
119
+ /**
120
+ * The ID of the system the system version belongs to.
121
+ */
122
+ systemId: string;
123
+
124
+ /**
125
+ * Validation errors found in the system version. If present, the system version
126
+ * doesn't fully conform to its system's configSchema.
127
+ */
128
+ validationErrors?: Array<SystemVersion.ValidationError>;
129
+ }
130
+
131
+ export namespace SystemVersion {
132
+ export interface ValidationError {
133
+ /**
134
+ * Human-readable error description.
135
+ */
136
+ message: string;
137
+
138
+ /**
139
+ * JSON Pointer to the field with the validation error.
140
+ */
141
+ path: string;
142
+ }
143
+ }
144
+
145
+ export interface VersionCreateParams {
146
+ /**
147
+ * The configuration of the system version.
148
+ */
149
+ config: Record<string, unknown>;
150
+
151
+ /**
152
+ * The name of the system version.
153
+ */
154
+ name: string;
155
+ }
156
+
157
+ export interface VersionListParams extends PaginatedResponseParams {}
158
+
159
+ export declare namespace Versions {
160
+ export {
161
+ type SystemVersion as SystemVersion,
162
+ type SystemVersionsPaginatedResponse as SystemVersionsPaginatedResponse,
163
+ type VersionCreateParams as VersionCreateParams,
164
+ type VersionListParams as VersionListParams,
165
+ };
166
+ }