scorecard-ai 1.0.0-alpha.2 → 1.0.0-alpha.4

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 (107) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +10 -12
  3. package/client.d.mts +3 -3
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +3 -3
  6. package/client.d.ts.map +1 -1
  7. package/client.js +9 -7
  8. package/client.js.map +1 -1
  9. package/client.mjs +9 -7
  10. package/client.mjs.map +1 -1
  11. package/internal/headers.d.mts +1 -1
  12. package/internal/headers.d.mts.map +1 -1
  13. package/internal/headers.d.ts +1 -1
  14. package/internal/headers.d.ts.map +1 -1
  15. package/internal/headers.js +2 -0
  16. package/internal/headers.js.map +1 -1
  17. package/internal/headers.mjs +2 -0
  18. package/internal/headers.mjs.map +1 -1
  19. package/internal/utils/base64.d.mts.map +1 -1
  20. package/internal/utils/base64.d.ts.map +1 -1
  21. package/internal/utils/base64.js +4 -3
  22. package/internal/utils/base64.js.map +1 -1
  23. package/internal/utils/base64.mjs +4 -3
  24. package/internal/utils/base64.mjs.map +1 -1
  25. package/internal/utils/bytes.d.mts +4 -0
  26. package/internal/utils/bytes.d.mts.map +1 -0
  27. package/internal/utils/bytes.d.ts +4 -0
  28. package/internal/utils/bytes.d.ts.map +1 -0
  29. package/internal/utils/bytes.js +32 -0
  30. package/internal/utils/bytes.js.map +1 -0
  31. package/internal/utils/bytes.mjs +26 -0
  32. package/internal/utils/bytes.mjs.map +1 -0
  33. package/lib/runAndEvaluate.d.mts +19 -0
  34. package/lib/runAndEvaluate.d.mts.map +1 -0
  35. package/lib/runAndEvaluate.d.ts +19 -0
  36. package/lib/runAndEvaluate.d.ts.map +1 -0
  37. package/lib/runAndEvaluate.js +40 -0
  38. package/lib/runAndEvaluate.js.map +1 -0
  39. package/lib/runAndEvaluate.mjs +36 -0
  40. package/lib/runAndEvaluate.mjs.map +1 -0
  41. package/package.json +12 -2
  42. package/resources/index.d.mts +1 -1
  43. package/resources/index.d.mts.map +1 -1
  44. package/resources/index.d.ts +1 -1
  45. package/resources/index.d.ts.map +1 -1
  46. package/resources/index.js +3 -3
  47. package/resources/index.js.map +1 -1
  48. package/resources/index.mjs +1 -1
  49. package/resources/index.mjs.map +1 -1
  50. package/resources/projects.d.mts +5 -5
  51. package/resources/projects.d.ts +5 -5
  52. package/resources/projects.js +2 -2
  53. package/resources/projects.mjs +2 -2
  54. package/resources/records.d.mts +63 -0
  55. package/resources/records.d.mts.map +1 -0
  56. package/resources/records.d.ts +63 -0
  57. package/resources/records.d.ts.map +1 -0
  58. package/resources/{execution-records.js → records.js} +6 -6
  59. package/resources/records.js.map +1 -0
  60. package/resources/{execution-records.mjs → records.mjs} +4 -4
  61. package/resources/records.mjs.map +1 -0
  62. package/resources/runs.d.mts +13 -13
  63. package/resources/runs.d.ts +13 -13
  64. package/resources/runs.js +2 -2
  65. package/resources/runs.mjs +2 -2
  66. package/resources/shared.d.mts +1 -1
  67. package/resources/shared.d.ts +1 -1
  68. package/resources/system-configs.d.mts +11 -11
  69. package/resources/system-configs.d.ts +11 -11
  70. package/resources/systems.d.mts +20 -20
  71. package/resources/systems.d.ts +20 -20
  72. package/resources/testcases.d.mts +23 -23
  73. package/resources/testcases.d.ts +23 -23
  74. package/resources/testcases.js +5 -5
  75. package/resources/testcases.mjs +5 -5
  76. package/resources/testsets.d.mts +43 -42
  77. package/resources/testsets.d.mts.map +1 -1
  78. package/resources/testsets.d.ts +43 -42
  79. package/resources/testsets.d.ts.map +1 -1
  80. package/resources/testsets.js +5 -5
  81. package/resources/testsets.mjs +5 -5
  82. package/src/client.ts +11 -15
  83. package/src/internal/headers.ts +3 -2
  84. package/src/internal/utils/base64.ts +5 -4
  85. package/src/internal/utils/bytes.ts +32 -0
  86. package/src/lib/runAndEvaluate.ts +54 -0
  87. package/src/resources/index.ts +1 -5
  88. package/src/resources/projects.ts +5 -5
  89. package/src/resources/records.ts +79 -0
  90. package/src/resources/runs.ts +13 -13
  91. package/src/resources/shared.ts +1 -1
  92. package/src/resources/system-configs.ts +11 -11
  93. package/src/resources/systems.ts +20 -20
  94. package/src/resources/testcases.ts +23 -23
  95. package/src/resources/testsets.ts +43 -42
  96. package/src/version.ts +1 -1
  97. package/version.d.mts +1 -1
  98. package/version.d.ts +1 -1
  99. package/version.js +1 -1
  100. package/version.mjs +1 -1
  101. package/resources/execution-records.d.mts +0 -62
  102. package/resources/execution-records.d.mts.map +0 -1
  103. package/resources/execution-records.d.ts +0 -62
  104. package/resources/execution-records.d.ts.map +0 -1
  105. package/resources/execution-records.js.map +0 -1
  106. package/resources/execution-records.mjs.map +0 -1
  107. package/src/resources/execution-records.ts +0 -85
@@ -4,12 +4,12 @@ import { PagePromise, PaginatedResponse, type PaginatedResponseParams } from "..
4
4
  import { RequestOptions } from "../internal/request-options.js";
5
5
  export declare class Testsets extends APIResource {
6
6
  /**
7
- * Create a new testset for a project. The testset will be created in the project
7
+ * Create a new Testset for a Project. The Testset will be created in the Project
8
8
  * specified in the path.
9
9
  */
10
10
  create(projectID: string, body: TestsetCreateParams, options?: RequestOptions): APIPromise<Testset>;
11
11
  /**
12
- * Update a testset. Only the fields provided in the request body will be updated.
12
+ * Update a Testset. Only the fields provided in the request body will be updated.
13
13
  * If a field is provided, the new content will replace the existing content. If a
14
14
  * field is not provided, the existing content will remain unchanged.
15
15
  *
@@ -24,167 +24,168 @@ export declare class Testsets extends APIResource {
24
24
  */
25
25
  update(testsetID: string, body?: TestsetUpdateParams | null | undefined, options?: RequestOptions): APIPromise<Testset>;
26
26
  /**
27
- * Retrieve a paginated list of testsets belonging to a project.
27
+ * Retrieve a paginated list of Testsets belonging to a Project.
28
28
  */
29
29
  list(projectID: string, query?: TestsetListParams | null | undefined, options?: RequestOptions): PagePromise<TestsetsPaginatedResponse, Testset>;
30
30
  /**
31
- * Delete testset
31
+ * Delete Testset
32
32
  */
33
33
  delete(testsetID: string, options?: RequestOptions): APIPromise<TestsetDeleteResponse>;
34
34
  /**
35
- * Get testset by ID
35
+ * Get Testset by ID
36
36
  */
37
37
  get(testsetID: string, options?: RequestOptions): APIPromise<Testset>;
38
38
  }
39
39
  export type TestsetsPaginatedResponse = PaginatedResponse<Testset>;
40
40
  /**
41
- * A collection of test cases that share the same schema. Each testset defines the
42
- * structure of its test cases through a JSON schema. The `fieldMapping` object
43
- * maps top-level keys of the testcase schema to their roles (input/label). Fields
44
- * not mentioned in the `fieldMapping` during creation or update are treated as
41
+ * A collection of Testcases that share the same schema. Each Testset defines the
42
+ * structure of its Testcases through a JSON schema. The `fieldMapping` object maps
43
+ * top-level keys of the Testcase schema to their roles (input/label). Fields not
44
+ * mentioned in the `fieldMapping` during creation or update are treated as
45
45
  * metadata.
46
46
  *
47
47
  * ## JSON Schema validation constraints supported:
48
48
  *
49
49
  * - **Required fields** - Fields listed in the schema's `required` array must be
50
- * present in testcases
50
+ * present in Testcases.
51
51
  * - **Type validation** - Values must match the specified type (string, number,
52
- * boolean, null, integer, object, array)
52
+ * boolean, null, integer, object, array).
53
53
  * - **Enum validation** - Values must be one of the options specified in the
54
- * `enum` array
54
+ * `enum` array.
55
55
  * - **Object property validation** - Properties of objects must conform to their
56
- * defined schemas
57
- * - **Array item validation** - Items in arrays must conform to the `items` schema
56
+ * defined schemas.
57
+ * - **Array item validation** - Items in arrays must conform to the `items`
58
+ * schema.
58
59
  * - **Logical composition** - Values must conform to at least one schema in the
59
- * `anyOf` array
60
+ * `anyOf` array.
60
61
  *
61
62
  * Testcases that fail validation will still be stored, but will include
62
- * `validationErrors` detailing the issues. Extra fields in the testcase data that
63
+ * `validationErrors` detailing the issues. Extra fields in the Testcase data that
63
64
  * are not in the schema will be stored but are ignored during validation.
64
65
  */
65
66
  export interface Testset {
66
67
  /**
67
- * The ID of the testset
68
+ * The ID of the Testset.
68
69
  */
69
70
  id: string;
70
71
  /**
71
- * The description of the testset
72
+ * The description of the Testset.
72
73
  */
73
74
  description: string;
74
75
  /**
75
- * Maps top-level keys of the testcase schema to their roles (input/label).
76
+ * Maps top-level keys of the Testcase schema to their roles (input/label).
76
77
  * Unmapped fields are treated as metadata.
77
78
  */
78
79
  fieldMapping: Testset.FieldMapping;
79
80
  /**
80
- * The JSON schema for each testcase in the testset
81
+ * The JSON schema for each Testcase in the Testset.
81
82
  */
82
83
  jsonSchema: Record<string, unknown>;
83
84
  /**
84
- * The name of the testset
85
+ * The name of the Testset.
85
86
  */
86
87
  name: string;
87
88
  }
88
89
  export declare namespace Testset {
89
90
  /**
90
- * Maps top-level keys of the testcase schema to their roles (input/label).
91
+ * Maps top-level keys of the Testcase schema to their roles (input/label).
91
92
  * Unmapped fields are treated as metadata.
92
93
  */
93
94
  interface FieldMapping {
94
95
  /**
95
- * Fields that represent inputs to the AI system
96
+ * Fields that represent inputs to the AI system.
96
97
  */
97
98
  inputs: Array<string>;
98
99
  /**
99
- * Fields that represent expected outputs/labels
100
+ * Fields that represent expected outputs/labels.
100
101
  */
101
102
  labels: Array<string>;
102
103
  /**
103
- * Fields that are not inputs or labels
104
+ * Fields that are not inputs or labels.
104
105
  */
105
106
  metadata: Array<string>;
106
107
  }
107
108
  }
108
109
  export interface TestsetDeleteResponse {
109
110
  /**
110
- * Whether the deletion was successful
111
+ * Whether the deletion was successful.
111
112
  */
112
113
  success: boolean;
113
114
  }
114
115
  export interface TestsetCreateParams {
115
116
  /**
116
- * The description of the testset
117
+ * The description of the Testset.
117
118
  */
118
119
  description: string;
119
120
  /**
120
- * Maps top-level keys of the testcase schema to their roles (input/label).
121
+ * Maps top-level keys of the Testcase schema to their roles (input/label).
121
122
  * Unmapped fields are treated as metadata.
122
123
  */
123
124
  fieldMapping: TestsetCreateParams.FieldMapping;
124
125
  /**
125
- * The JSON schema for each testcase in the testset
126
+ * The JSON schema for each Testcase in the Testset.
126
127
  */
127
128
  jsonSchema: Record<string, unknown>;
128
129
  /**
129
- * The name of the testset
130
+ * The name of the Testset.
130
131
  */
131
132
  name: string;
132
133
  }
133
134
  export declare namespace TestsetCreateParams {
134
135
  /**
135
- * Maps top-level keys of the testcase schema to their roles (input/label).
136
+ * Maps top-level keys of the Testcase schema to their roles (input/label).
136
137
  * Unmapped fields are treated as metadata.
137
138
  */
138
139
  interface FieldMapping {
139
140
  /**
140
- * Fields that represent inputs to the AI system
141
+ * Fields that represent inputs to the AI system.
141
142
  */
142
143
  inputs: Array<string>;
143
144
  /**
144
- * Fields that represent expected outputs/labels
145
+ * Fields that represent expected outputs/labels.
145
146
  */
146
147
  labels: Array<string>;
147
148
  /**
148
- * Fields that are not inputs or labels
149
+ * Fields that are not inputs or labels.
149
150
  */
150
151
  metadata: Array<string>;
151
152
  }
152
153
  }
153
154
  export interface TestsetUpdateParams {
154
155
  /**
155
- * The description of the testset
156
+ * The description of the Testset.
156
157
  */
157
158
  description?: string;
158
159
  /**
159
- * Maps top-level keys of the testcase schema to their roles (input/label).
160
+ * Maps top-level keys of the Testcase schema to their roles (input/label).
160
161
  * Unmapped fields are treated as metadata.
161
162
  */
162
163
  fieldMapping?: TestsetUpdateParams.FieldMapping;
163
164
  /**
164
- * The JSON schema for each testcase in the testset
165
+ * The JSON schema for each Testcase in the Testset.
165
166
  */
166
167
  jsonSchema?: Record<string, unknown>;
167
168
  /**
168
- * The name of the testset
169
+ * The name of the Testset.
169
170
  */
170
171
  name?: string;
171
172
  }
172
173
  export declare namespace TestsetUpdateParams {
173
174
  /**
174
- * Maps top-level keys of the testcase schema to their roles (input/label).
175
+ * Maps top-level keys of the Testcase schema to their roles (input/label).
175
176
  * Unmapped fields are treated as metadata.
176
177
  */
177
178
  interface FieldMapping {
178
179
  /**
179
- * Fields that represent inputs to the AI system
180
+ * Fields that represent inputs to the AI system.
180
181
  */
181
182
  inputs: Array<string>;
182
183
  /**
183
- * Fields that represent expected outputs/labels
184
+ * Fields that represent expected outputs/labels.
184
185
  */
185
186
  labels: Array<string>;
186
187
  /**
187
- * Fields that are not inputs or labels
188
+ * Fields that are not inputs or labels.
188
189
  */
189
190
  metadata: Array<string>;
190
191
  }
@@ -1 +1 @@
1
- {"version":3,"file":"testsets.d.ts","sourceRoot":"","sources":["../src/resources/testsets.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,WAAW,EAAE,iBAAiB,EAAE,KAAK,uBAAuB,EAAE;OAChE,EAAE,cAAc,EAAE;AAGzB,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAInG;;;;;;;;;;;;;OAaG;IACH,MAAM,CACJ,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,mBAAmB,GAAG,IAAI,GAAG,SAAc,EACjD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC;IAItB;;OAEG;IACH,IAAI,CACF,SAAS,EAAE,MAAM,EACjB,KAAK,GAAE,iBAAiB,GAAG,IAAI,GAAG,SAAc,EAChD,OAAO,CAAC,EAAE,cAAc,GACvB,WAAW,CAAC,yBAAyB,EAAE,OAAO,CAAC;IAOlD;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,qBAAqB,CAAC;IAItF;;OAEG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;CAGtE;AAED,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,YAAY,EAAE,OAAO,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class Testsets extends resource_1.APIResource {
9
9
  /**
10
- * Create a new testset for a project. The testset will be created in the project
10
+ * Create a new Testset for a Project. The Testset will be created in the Project
11
11
  * specified in the path.
12
12
  */
13
13
  create(projectID, body, options) {
14
14
  return this._client.post((0, path_1.path) `/projects/${projectID}/testsets`, { body, ...options });
15
15
  }
16
16
  /**
17
- * Update a testset. Only the fields provided in the request body will be updated.
17
+ * Update a Testset. Only the fields provided in the request body will be updated.
18
18
  * If a field is provided, the new content will replace the existing content. If a
19
19
  * field is not provided, the existing content will remain unchanged.
20
20
  *
@@ -31,7 +31,7 @@ class Testsets extends resource_1.APIResource {
31
31
  return this._client.patch((0, path_1.path) `/testsets/${testsetID}`, { body, ...options });
32
32
  }
33
33
  /**
34
- * Retrieve a paginated list of testsets belonging to a project.
34
+ * Retrieve a paginated list of Testsets belonging to a Project.
35
35
  */
36
36
  list(projectID, query = {}, options) {
37
37
  return this._client.getAPIList((0, path_1.path) `/projects/${projectID}/testsets`, (pagination_1.PaginatedResponse), {
@@ -40,13 +40,13 @@ class Testsets extends resource_1.APIResource {
40
40
  });
41
41
  }
42
42
  /**
43
- * Delete testset
43
+ * Delete Testset
44
44
  */
45
45
  delete(testsetID, options) {
46
46
  return this._client.delete((0, path_1.path) `/testsets/${testsetID}`, options);
47
47
  }
48
48
  /**
49
- * Get testset by ID
49
+ * Get Testset by ID
50
50
  */
51
51
  get(testsetID, options) {
52
52
  return this._client.get((0, path_1.path) `/testsets/${testsetID}`, options);
@@ -4,14 +4,14 @@ import { PaginatedResponse } from "../core/pagination.mjs";
4
4
  import { path } from "../internal/utils/path.mjs";
5
5
  export class Testsets extends APIResource {
6
6
  /**
7
- * Create a new testset for a project. The testset will be created in the project
7
+ * Create a new Testset for a Project. The Testset will be created in the Project
8
8
  * specified in the path.
9
9
  */
10
10
  create(projectID, body, options) {
11
11
  return this._client.post(path `/projects/${projectID}/testsets`, { body, ...options });
12
12
  }
13
13
  /**
14
- * Update a testset. Only the fields provided in the request body will be updated.
14
+ * Update a Testset. Only the fields provided in the request body will be updated.
15
15
  * If a field is provided, the new content will replace the existing content. If a
16
16
  * field is not provided, the existing content will remain unchanged.
17
17
  *
@@ -28,7 +28,7 @@ export class Testsets extends APIResource {
28
28
  return this._client.patch(path `/testsets/${testsetID}`, { body, ...options });
29
29
  }
30
30
  /**
31
- * Retrieve a paginated list of testsets belonging to a project.
31
+ * Retrieve a paginated list of Testsets belonging to a Project.
32
32
  */
33
33
  list(projectID, query = {}, options) {
34
34
  return this._client.getAPIList(path `/projects/${projectID}/testsets`, (PaginatedResponse), {
@@ -37,13 +37,13 @@ export class Testsets extends APIResource {
37
37
  });
38
38
  }
39
39
  /**
40
- * Delete testset
40
+ * Delete Testset
41
41
  */
42
42
  delete(testsetID, options) {
43
43
  return this._client.delete(path `/testsets/${testsetID}`, options);
44
44
  }
45
45
  /**
46
- * Get testset by ID
46
+ * Get Testset by ID
47
47
  */
48
48
  get(testsetID, options) {
49
49
  return this._client.get(path `/testsets/${testsetID}`, options);
package/src/client.ts CHANGED
@@ -22,17 +22,13 @@ import { APIPromise } from './core/api-promise';
22
22
  import { type Fetch } from './internal/builtin-types';
23
23
  import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
24
24
  import { FinalRequestOptions, RequestOptions } from './internal/request-options';
25
- import {
26
- ExecutionRecord,
27
- ExecutionRecordCreateParams,
28
- ExecutionRecords,
29
- } from './resources/execution-records';
30
25
  import {
31
26
  ProjectListParams,
32
27
  ProjectListResponse,
33
28
  ProjectListResponsesPaginatedResponse,
34
29
  Projects,
35
30
  } from './resources/projects';
31
+ import { Record as RecordsAPIRecord, RecordCreateParams, Records } from './resources/records';
36
32
  import { Run, RunCreateParams, RunUpdateParams, RunUpdateResponse, Runs } from './resources/runs';
37
33
  import {
38
34
  SystemConfig,
@@ -563,12 +559,12 @@ export class Scorecard {
563
559
  fetchOptions.method = method.toUpperCase();
564
560
  }
565
561
 
566
- return (
562
+ try {
567
563
  // use undefined this binding; fetch errors if bound to something else in browser/cloudflare
568
- this.fetch.call(undefined, url, fetchOptions).finally(() => {
569
- clearTimeout(timeout);
570
- })
571
- );
564
+ return await this.fetch.call(undefined, url, fetchOptions);
565
+ } finally {
566
+ clearTimeout(timeout);
567
+ }
572
568
  }
573
569
 
574
570
  private shouldRetry(response: Response): boolean {
@@ -772,7 +768,7 @@ export class Scorecard {
772
768
  testsets: API.Testsets = new API.Testsets(this);
773
769
  testcases: API.Testcases = new API.Testcases(this);
774
770
  runs: API.Runs = new API.Runs(this);
775
- executionRecords: API.ExecutionRecords = new API.ExecutionRecords(this);
771
+ records: API.Records = new API.Records(this);
776
772
  systems: API.Systems = new API.Systems(this);
777
773
  systemConfigs: API.SystemConfigs = new API.SystemConfigs(this);
778
774
  }
@@ -780,7 +776,7 @@ Scorecard.Projects = Projects;
780
776
  Scorecard.Testsets = Testsets;
781
777
  Scorecard.Testcases = Testcases;
782
778
  Scorecard.Runs = Runs;
783
- Scorecard.ExecutionRecords = ExecutionRecords;
779
+ Scorecard.Records = Records;
784
780
  Scorecard.Systems = Systems;
785
781
  Scorecard.SystemConfigs = SystemConfigs;
786
782
  export declare namespace Scorecard {
@@ -830,9 +826,9 @@ export declare namespace Scorecard {
830
826
  };
831
827
 
832
828
  export {
833
- ExecutionRecords as ExecutionRecords,
834
- type ExecutionRecord as ExecutionRecord,
835
- type ExecutionRecordCreateParams as ExecutionRecordCreateParams,
829
+ Records as Records,
830
+ type RecordsAPIRecord as Record,
831
+ type RecordCreateParams as RecordCreateParams,
836
832
  };
837
833
 
838
834
  export {
@@ -3,7 +3,7 @@
3
3
  type HeaderValue = string | undefined | null;
4
4
  export type HeadersLike =
5
5
  | Headers
6
- | readonly [string, HeaderValue][]
6
+ | readonly HeaderValue[][]
7
7
  | Record<string, HeaderValue | readonly HeaderValue[]>
8
8
  | undefined
9
9
  | null
@@ -40,7 +40,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
40
40
  }
41
41
 
42
42
  let shouldClear = false;
43
- let iter: Iterable<readonly [string, HeaderValue | readonly HeaderValue[]]>;
43
+ let iter: Iterable<readonly (HeaderValue | readonly HeaderValue[])[]>;
44
44
  if (headers instanceof Headers) {
45
45
  iter = headers.entries();
46
46
  } else if (isArray(headers)) {
@@ -51,6 +51,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
51
51
  }
52
52
  for (let row of iter) {
53
53
  const name = row[0];
54
+ if (typeof name !== 'string') throw new TypeError('expected header name to be a string');
54
55
  const values = isArray(row[1]) ? row[1] : [row[1]];
55
56
  let didClear = false;
56
57
  for (const value of values) {
@@ -1,18 +1,19 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { ScorecardError } from '../../core/error';
4
+ import { encodeUTF8 } from './bytes';
4
5
 
5
6
  export const toBase64 = (data: string | Uint8Array | null | undefined): string => {
6
7
  if (!data) return '';
7
8
 
8
- if (typeof data === 'string') {
9
- data = new (globalThis as any).TextEncoder().encode(data);
10
- }
11
-
12
9
  if (typeof (globalThis as any).Buffer !== 'undefined') {
13
10
  return (globalThis as any).Buffer.from(data).toString('base64');
14
11
  }
15
12
 
13
+ if (typeof data === 'string') {
14
+ data = encodeUTF8(data);
15
+ }
16
+
16
17
  if (typeof btoa !== 'undefined') {
17
18
  return btoa(String.fromCharCode.apply(null, data as any));
18
19
  }
@@ -0,0 +1,32 @@
1
+ export function concatBytes(buffers: Uint8Array[]): Uint8Array {
2
+ let length = 0;
3
+ for (const buffer of buffers) {
4
+ length += buffer.length;
5
+ }
6
+ const output = new Uint8Array(length);
7
+ let index = 0;
8
+ for (const buffer of buffers) {
9
+ output.set(buffer, index);
10
+ index += buffer.length;
11
+ }
12
+
13
+ return output;
14
+ }
15
+
16
+ let encodeUTF8_: (str: string) => Uint8Array;
17
+ export function encodeUTF8(str: string) {
18
+ let encoder;
19
+ return (
20
+ encodeUTF8_ ??
21
+ ((encoder = new (globalThis as any).TextEncoder()), (encodeUTF8_ = encoder.encode.bind(encoder)))
22
+ )(str);
23
+ }
24
+
25
+ let decodeUTF8_: (bytes: Uint8Array) => string;
26
+ export function decodeUTF8(bytes: Uint8Array) {
27
+ let decoder;
28
+ return (
29
+ decodeUTF8_ ??
30
+ ((decoder = new (globalThis as any).TextDecoder()), (decodeUTF8_ = decoder.decode.bind(decoder)))
31
+ )(bytes);
32
+ }
@@ -0,0 +1,54 @@
1
+ import { Scorecard } from '../client';
2
+
3
+ /**
4
+ * Runs a system on a Testset and records the results in Scorecard.
5
+ *
6
+ * @param scorecard The Scorecard client
7
+ * @param projectId The ID of the Project to run the system on.
8
+ * @param testsetId The ID of the Testset to run the system on.
9
+ * @param metricIds The IDs of the Metrics to use for evaluation.
10
+ * @param system The system to run on the Testset.
11
+ */
12
+ export async function runAndEvaluate<SystemInput extends Object, SystemOutput extends Object>(
13
+ scorecard: Scorecard,
14
+ {
15
+ projectId,
16
+ testsetId,
17
+ metricIds,
18
+ system,
19
+ }: {
20
+ projectId: string;
21
+ testsetId: string;
22
+ metricIds: Array<string>;
23
+ system: (testcaseInput: SystemInput) => Promise<SystemOutput>;
24
+ },
25
+ ): Promise<Pick<Scorecard.Runs.Run, 'id'> & { url: string }> {
26
+ const run = await scorecard.runs.create(projectId, {
27
+ testsetId,
28
+ metricIds,
29
+ });
30
+
31
+ // Run each Testcase sequentially
32
+ const recordPromises: Array<Promise<any>> = [];
33
+ for await (const testcase of scorecard.testcases.list(run.testsetId)) {
34
+ const modelResponse = await system(testcase.inputs as SystemInput);
35
+ const promise = scorecard.records.create(run.id, {
36
+ testcaseId: testcase.id,
37
+ inputs: testcase.inputs,
38
+ labels: testcase.labels,
39
+ outputs: modelResponse as Record<string, unknown>,
40
+ });
41
+ recordPromises.push(promise);
42
+ }
43
+ // Wait until all the Records are created
44
+ await Promise.all(recordPromises);
45
+
46
+ // Mark the Run as done with execution and ready for scoring.
47
+ await scorecard.runs.update(run.id, {
48
+ status: 'awaiting_scoring',
49
+ });
50
+
51
+ const runUrl = `https://app.getscorecard.ai/projects/${projectId}/runs/grades/${run.id}`;
52
+
53
+ return { id: run.id, url: runUrl };
54
+ }
@@ -1,17 +1,13 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  export * from './shared';
4
- export {
5
- ExecutionRecords,
6
- type ExecutionRecord,
7
- type ExecutionRecordCreateParams,
8
- } from './execution-records';
9
4
  export {
10
5
  Projects,
11
6
  type ProjectListResponse,
12
7
  type ProjectListParams,
13
8
  type ProjectListResponsesPaginatedResponse,
14
9
  } from './projects';
10
+ export { Records, type Record, type RecordCreateParams } from './records';
15
11
  export { Runs, type Run, type RunUpdateResponse, type RunCreateParams, type RunUpdateParams } from './runs';
16
12
  export {
17
13
  SystemConfigs,
@@ -6,8 +6,8 @@ import { RequestOptions } from '../internal/request-options';
6
6
 
7
7
  export class Projects extends APIResource {
8
8
  /**
9
- * Retrieve a paginated list of all projects. Projects are ordered by creation
10
- * date, with oldest projects first.
9
+ * Retrieve a paginated list of all Projects. Projects are ordered by creation
10
+ * date, with oldest Projects first.
11
11
  */
12
12
  list(
13
13
  query: ProjectListParams | null | undefined = {},
@@ -23,16 +23,16 @@ export class Projects extends APIResource {
23
23
  export type ProjectListResponsesPaginatedResponse = PaginatedResponse<ProjectListResponse>;
24
24
 
25
25
  /**
26
- * A project in the Scorecard system.
26
+ * A Project in the Scorecard system.
27
27
  */
28
28
  export interface ProjectListResponse {
29
29
  /**
30
- * The ID of the project
30
+ * The ID of the Project.
31
31
  */
32
32
  id: string;
33
33
 
34
34
  /**
35
- * The name of the project
35
+ * The name of the Project.
36
36
  */
37
37
  name: string | null;
38
38
  }
@@ -0,0 +1,79 @@
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 { type Record as BuiltinRecord } from '../internal/builtin-types';
6
+ import { RequestOptions } from '../internal/request-options';
7
+ import { path } from '../internal/utils/path';
8
+
9
+ export class Records extends APIResource {
10
+ /**
11
+ * Create a new Record in a Run.
12
+ */
13
+ create(runID: string, body: RecordCreateParams, options?: RequestOptions): APIPromise<Record> {
14
+ return this._client.post(path`/runs/${runID}/records`, { body, ...options });
15
+ }
16
+ }
17
+
18
+ /**
19
+ * A record of a system execution in the Scorecard system.
20
+ */
21
+ export interface Record {
22
+ /**
23
+ * The ID of the Record.
24
+ */
25
+ id: string;
26
+
27
+ /**
28
+ * The actual inputs sent to the system, which should match the system's input
29
+ * schema.
30
+ */
31
+ inputs: BuiltinRecord<string, unknown>;
32
+
33
+ /**
34
+ * The expected outputs for the Testcase.
35
+ */
36
+ labels: BuiltinRecord<string, unknown>;
37
+
38
+ /**
39
+ * The actual outputs from the system.
40
+ */
41
+ outputs: BuiltinRecord<string, unknown>;
42
+
43
+ /**
44
+ * The ID of the Run containing this Record.
45
+ */
46
+ runId: string;
47
+
48
+ /**
49
+ * The ID of the Testcase.
50
+ */
51
+ testcaseId?: string;
52
+ }
53
+
54
+ export interface RecordCreateParams {
55
+ /**
56
+ * The actual inputs sent to the system, which should match the system's input
57
+ * schema.
58
+ */
59
+ inputs: BuiltinRecord<string, unknown>;
60
+
61
+ /**
62
+ * The expected outputs for the Testcase.
63
+ */
64
+ labels: BuiltinRecord<string, unknown>;
65
+
66
+ /**
67
+ * The actual outputs from the system.
68
+ */
69
+ outputs: BuiltinRecord<string, unknown>;
70
+
71
+ /**
72
+ * The ID of the Testcase.
73
+ */
74
+ testcaseId?: string;
75
+ }
76
+
77
+ export declare namespace Records {
78
+ export { type Record as Record, type RecordCreateParams as RecordCreateParams };
79
+ }