scorecard-ai 1.0.0-alpha.5 → 1.0.0-alpha.7
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/CHANGELOG.md +41 -0
- package/README.md +17 -7
- package/client.d.mts +13 -6
- package/client.d.mts.map +1 -1
- package/client.d.ts +13 -6
- package/client.d.ts.map +1 -1
- package/client.js +27 -7
- package/client.js.map +1 -1
- package/client.mjs +27 -7
- package/client.mjs.map +1 -1
- package/internal/headers.js +1 -1
- package/internal/headers.js.map +1 -1
- package/internal/headers.mjs +1 -1
- package/internal/headers.mjs.map +1 -1
- package/internal/to-file.d.mts +0 -1
- package/internal/to-file.d.mts.map +1 -1
- package/internal/to-file.d.ts +0 -1
- package/internal/to-file.d.ts.map +1 -1
- package/internal/to-file.js +3 -2
- package/internal/to-file.js.map +1 -1
- package/internal/to-file.mjs +3 -2
- package/internal/to-file.mjs.map +1 -1
- package/internal/uploads.d.mts +1 -1
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +1 -1
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js +14 -4
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +12 -3
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/uuid.d.mts +1 -1
- package/internal/utils/uuid.d.mts.map +1 -1
- package/internal/utils/uuid.d.ts +1 -1
- package/internal/utils/uuid.d.ts.map +1 -1
- package/internal/utils/uuid.js +1 -2
- package/internal/utils/uuid.js.map +1 -1
- package/internal/utils/uuid.mjs +1 -2
- package/internal/utils/uuid.mjs.map +1 -1
- package/package.json +1 -5
- package/resources/index.d.mts +2 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +2 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/projects.d.mts +39 -4
- package/resources/projects.d.mts.map +1 -1
- package/resources/projects.d.ts +39 -4
- package/resources/projects.d.ts.map +1 -1
- package/resources/projects.js +23 -4
- package/resources/projects.js.map +1 -1
- package/resources/projects.mjs +23 -4
- package/resources/projects.mjs.map +1 -1
- package/resources/records.d.mts +10 -0
- package/resources/records.d.mts.map +1 -1
- package/resources/records.d.ts +10 -0
- package/resources/records.d.ts.map +1 -1
- package/resources/records.js +10 -0
- package/resources/records.js.map +1 -1
- package/resources/records.mjs +10 -0
- package/resources/records.mjs.map +1 -1
- package/resources/runs.d.mts +16 -0
- package/resources/runs.d.mts.map +1 -1
- package/resources/runs.d.ts +16 -0
- package/resources/runs.d.ts.map +1 -1
- package/resources/runs.js +16 -0
- package/resources/runs.js.map +1 -1
- package/resources/runs.mjs +16 -0
- package/resources/runs.mjs.map +1 -1
- package/resources/scores.d.mts +83 -0
- package/resources/scores.d.mts.map +1 -0
- package/resources/scores.d.ts +83 -0
- package/resources/scores.d.ts.map +1 -0
- package/resources/scores.js +35 -0
- package/resources/scores.js.map +1 -0
- package/resources/scores.mjs +31 -0
- package/resources/scores.mjs.map +1 -0
- package/resources/system-configs.d.mts +33 -0
- package/resources/system-configs.d.mts.map +1 -1
- package/resources/system-configs.d.ts +33 -0
- package/resources/system-configs.d.ts.map +1 -1
- package/resources/system-configs.js +33 -0
- package/resources/system-configs.js.map +1 -1
- package/resources/system-configs.mjs +33 -0
- package/resources/system-configs.mjs.map +1 -1
- package/resources/systems.d.mts +73 -0
- package/resources/systems.d.mts.map +1 -1
- package/resources/systems.d.ts +73 -0
- package/resources/systems.d.ts.map +1 -1
- package/resources/systems.js +73 -0
- package/resources/systems.js.map +1 -1
- package/resources/systems.mjs +73 -0
- package/resources/systems.mjs.map +1 -1
- package/resources/testcases.d.mts +62 -0
- package/resources/testcases.d.mts.map +1 -1
- package/resources/testcases.d.ts +62 -0
- package/resources/testcases.d.ts.map +1 -1
- package/resources/testcases.js +62 -0
- package/resources/testcases.js.map +1 -1
- package/resources/testcases.mjs +62 -0
- package/resources/testcases.mjs.map +1 -1
- package/resources/testsets.d.mts +48 -0
- package/resources/testsets.d.mts.map +1 -1
- package/resources/testsets.d.ts +48 -0
- package/resources/testsets.d.ts.map +1 -1
- package/resources/testsets.js +48 -0
- package/resources/testsets.js.map +1 -1
- package/resources/testsets.mjs +48 -0
- package/resources/testsets.mjs.map +1 -1
- package/src/client.ts +38 -13
- package/src/internal/headers.ts +1 -1
- package/src/internal/to-file.ts +4 -2
- package/src/internal/uploads.ts +16 -4
- package/src/internal/utils/uuid.ts +1 -3
- package/src/resources/index.ts +4 -2
- package/src/resources/projects.ts +48 -9
- package/src/resources/records.ts +10 -0
- package/src/resources/runs.ts +16 -0
- package/src/resources/scores.ts +98 -0
- package/src/resources/system-configs.ts +33 -0
- package/src/resources/systems.ts +73 -0
- package/src/resources/testcases.ts +62 -0
- package/src/resources/testsets.ts +48 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/internal/shims/crypto.d.mts +0 -13
- package/internal/shims/crypto.d.mts.map +0 -1
- package/internal/shims/crypto.d.ts +0 -13
- package/internal/shims/crypto.d.ts.map +0 -1
- package/internal/shims/crypto.js +0 -13
- package/internal/shims/crypto.js.map +0 -1
- package/internal/shims/crypto.mjs +0 -9
- package/internal/shims/crypto.mjs.map +0 -1
- package/internal/shims/file.d.mts +0 -22
- package/internal/shims/file.d.mts.map +0 -1
- package/internal/shims/file.d.ts +0 -22
- package/internal/shims/file.d.ts.map +0 -1
- package/internal/shims/file.js +0 -16
- package/internal/shims/file.js.map +0 -1
- package/internal/shims/file.mjs +0 -12
- package/internal/shims/file.mjs.map +0 -1
- package/internal/shims/getBuiltinModule.d.mts +0 -11
- package/internal/shims/getBuiltinModule.d.mts.map +0 -1
- package/internal/shims/getBuiltinModule.d.ts +0 -11
- package/internal/shims/getBuiltinModule.d.ts.map +0 -1
- package/internal/shims/getBuiltinModule.js +0 -71
- package/internal/shims/getBuiltinModule.js.map +0 -1
- package/internal/shims/getBuiltinModule.mjs +0 -67
- package/internal/shims/getBuiltinModule.mjs.map +0 -1
- package/internal/shims/nullGetBuiltinModule.d.mts +0 -2
- package/internal/shims/nullGetBuiltinModule.d.mts.map +0 -1
- package/internal/shims/nullGetBuiltinModule.d.ts +0 -2
- package/internal/shims/nullGetBuiltinModule.d.ts.map +0 -1
- package/internal/shims/nullGetBuiltinModule.js +0 -5
- package/internal/shims/nullGetBuiltinModule.js.map +0 -1
- package/internal/shims/nullGetBuiltinModule.mjs +0 -2
- package/internal/shims/nullGetBuiltinModule.mjs.map +0 -1
- package/src/internal/shims/crypto.ts +0 -18
- package/src/internal/shims/file.ts +0 -32
- package/src/internal/shims/getBuiltinModule.ts +0 -66
- package/src/internal/shims/nullGetBuiltinModule.ts +0 -1
package/resources/testsets.d.mts
CHANGED
|
@@ -6,6 +6,28 @@ export declare class Testsets extends APIResource {
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a new Testset for a Project. The Testset will be created in the Project
|
|
8
8
|
* specified in the path.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const testset = await client.testsets.create('314', {
|
|
13
|
+
* description: 'Testset for long context Q&A chatbot.',
|
|
14
|
+
* fieldMapping: {
|
|
15
|
+
* inputs: ['question'],
|
|
16
|
+
* labels: ['idealAnswer'],
|
|
17
|
+
* metadata: [],
|
|
18
|
+
* },
|
|
19
|
+
* jsonSchema: {
|
|
20
|
+
* type: 'object',
|
|
21
|
+
* properties: {
|
|
22
|
+
* question: { type: 'string' },
|
|
23
|
+
* idealAnswer: { type: 'string' },
|
|
24
|
+
* provenance: { type: 'string' },
|
|
25
|
+
* geo: { type: 'string' },
|
|
26
|
+
* },
|
|
27
|
+
* },
|
|
28
|
+
* name: 'Long Context Q&A',
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
9
31
|
*/
|
|
10
32
|
create(projectID: string, body: TestsetCreateParams, options?: RequestOptions): APIPromise<Testset>;
|
|
11
33
|
/**
|
|
@@ -21,18 +43,44 @@ export declare class Testsets extends APIResource {
|
|
|
21
43
|
* updated schema
|
|
22
44
|
* - For complete control, provide both schema and fieldMapping when updating the
|
|
23
45
|
* schema
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const testset = await client.testsets.update('246', {
|
|
50
|
+
* description: 'Updated description for the Q&A Testset.',
|
|
51
|
+
* name: 'Updated Q&A Testset',
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
24
54
|
*/
|
|
25
55
|
update(testsetID: string, body?: TestsetUpdateParams | null | undefined, options?: RequestOptions): APIPromise<Testset>;
|
|
26
56
|
/**
|
|
27
57
|
* Retrieve a paginated list of Testsets belonging to a Project.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // Automatically fetches more pages as needed.
|
|
62
|
+
* for await (const testset of client.testsets.list('314')) {
|
|
63
|
+
* // ...
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
28
66
|
*/
|
|
29
67
|
list(projectID: string, query?: TestsetListParams | null | undefined, options?: RequestOptions): PagePromise<TestsetsPaginatedResponse, Testset>;
|
|
30
68
|
/**
|
|
31
69
|
* Delete Testset
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const testset = await client.testsets.delete('246');
|
|
74
|
+
* ```
|
|
32
75
|
*/
|
|
33
76
|
delete(testsetID: string, options?: RequestOptions): APIPromise<TestsetDeleteResponse>;
|
|
34
77
|
/**
|
|
35
78
|
* Get Testset by ID
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const testset = await client.testsets.get('246');
|
|
83
|
+
* ```
|
|
36
84
|
*/
|
|
37
85
|
get(testsetID: string, options?: RequestOptions): APIPromise<Testset>;
|
|
38
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testsets.d.mts","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
|
|
1
|
+
{"version":3,"file":"testsets.d.mts","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;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAInG;;;;;;;;;;;;;;;;;;;;;OAqBG;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;;;;;;;;;;OAUG;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;;;;;;;OAOG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,qBAAqB,CAAC;IAItF;;;;;;;OAOG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;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AED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC,YAAY,CAAC;IAEhD;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAErC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,yBAAiB,mBAAmB,CAAC;IACnC;;;OAGG;IACH,UAAiB,YAAY;QAC3B;;WAEG;QACH,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAEtB;;WAEG;QACH,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAEtB;;WAEG;QACH,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KACzB;CACF;AAED,MAAM,WAAW,iBAAkB,SAAQ,uBAAuB;CAAG;AAErE,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EACL,KAAK,OAAO,IAAI,OAAO,EACvB,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,iBAAiB,IAAI,iBAAiB,GAC5C,CAAC;CACH"}
|
package/resources/testsets.d.ts
CHANGED
|
@@ -6,6 +6,28 @@ export declare class Testsets extends APIResource {
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a new Testset for a Project. The Testset will be created in the Project
|
|
8
8
|
* specified in the path.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const testset = await client.testsets.create('314', {
|
|
13
|
+
* description: 'Testset for long context Q&A chatbot.',
|
|
14
|
+
* fieldMapping: {
|
|
15
|
+
* inputs: ['question'],
|
|
16
|
+
* labels: ['idealAnswer'],
|
|
17
|
+
* metadata: [],
|
|
18
|
+
* },
|
|
19
|
+
* jsonSchema: {
|
|
20
|
+
* type: 'object',
|
|
21
|
+
* properties: {
|
|
22
|
+
* question: { type: 'string' },
|
|
23
|
+
* idealAnswer: { type: 'string' },
|
|
24
|
+
* provenance: { type: 'string' },
|
|
25
|
+
* geo: { type: 'string' },
|
|
26
|
+
* },
|
|
27
|
+
* },
|
|
28
|
+
* name: 'Long Context Q&A',
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
9
31
|
*/
|
|
10
32
|
create(projectID: string, body: TestsetCreateParams, options?: RequestOptions): APIPromise<Testset>;
|
|
11
33
|
/**
|
|
@@ -21,18 +43,44 @@ export declare class Testsets extends APIResource {
|
|
|
21
43
|
* updated schema
|
|
22
44
|
* - For complete control, provide both schema and fieldMapping when updating the
|
|
23
45
|
* schema
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const testset = await client.testsets.update('246', {
|
|
50
|
+
* description: 'Updated description for the Q&A Testset.',
|
|
51
|
+
* name: 'Updated Q&A Testset',
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
24
54
|
*/
|
|
25
55
|
update(testsetID: string, body?: TestsetUpdateParams | null | undefined, options?: RequestOptions): APIPromise<Testset>;
|
|
26
56
|
/**
|
|
27
57
|
* Retrieve a paginated list of Testsets belonging to a Project.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // Automatically fetches more pages as needed.
|
|
62
|
+
* for await (const testset of client.testsets.list('314')) {
|
|
63
|
+
* // ...
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
28
66
|
*/
|
|
29
67
|
list(projectID: string, query?: TestsetListParams | null | undefined, options?: RequestOptions): PagePromise<TestsetsPaginatedResponse, Testset>;
|
|
30
68
|
/**
|
|
31
69
|
* Delete Testset
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const testset = await client.testsets.delete('246');
|
|
74
|
+
* ```
|
|
32
75
|
*/
|
|
33
76
|
delete(testsetID: string, options?: RequestOptions): APIPromise<TestsetDeleteResponse>;
|
|
34
77
|
/**
|
|
35
78
|
* Get Testset by ID
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const testset = await client.testsets.get('246');
|
|
83
|
+
* ```
|
|
36
84
|
*/
|
|
37
85
|
get(testsetID: string, options?: RequestOptions): APIPromise<Testset>;
|
|
38
86
|
}
|
|
@@ -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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAInG;;;;;;;;;;;;;;;;;;;;;OAqBG;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;;;;;;;;;;OAUG;IACH,IAAI,CACF,SAAS,EAAE,MAAM,EACjB,K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 -9,6 +9,28 @@ class Testsets extends resource_1.APIResource {
|
|
|
9
9
|
/**
|
|
10
10
|
* Create a new Testset for a Project. The Testset will be created in the Project
|
|
11
11
|
* specified in the path.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const testset = await client.testsets.create('314', {
|
|
16
|
+
* description: 'Testset for long context Q&A chatbot.',
|
|
17
|
+
* fieldMapping: {
|
|
18
|
+
* inputs: ['question'],
|
|
19
|
+
* labels: ['idealAnswer'],
|
|
20
|
+
* metadata: [],
|
|
21
|
+
* },
|
|
22
|
+
* jsonSchema: {
|
|
23
|
+
* type: 'object',
|
|
24
|
+
* properties: {
|
|
25
|
+
* question: { type: 'string' },
|
|
26
|
+
* idealAnswer: { type: 'string' },
|
|
27
|
+
* provenance: { type: 'string' },
|
|
28
|
+
* geo: { type: 'string' },
|
|
29
|
+
* },
|
|
30
|
+
* },
|
|
31
|
+
* name: 'Long Context Q&A',
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
12
34
|
*/
|
|
13
35
|
create(projectID, body, options) {
|
|
14
36
|
return this._client.post((0, path_1.path) `/projects/${projectID}/testsets`, { body, ...options });
|
|
@@ -26,12 +48,28 @@ class Testsets extends resource_1.APIResource {
|
|
|
26
48
|
* updated schema
|
|
27
49
|
* - For complete control, provide both schema and fieldMapping when updating the
|
|
28
50
|
* schema
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const testset = await client.testsets.update('246', {
|
|
55
|
+
* description: 'Updated description for the Q&A Testset.',
|
|
56
|
+
* name: 'Updated Q&A Testset',
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
29
59
|
*/
|
|
30
60
|
update(testsetID, body = {}, options) {
|
|
31
61
|
return this._client.patch((0, path_1.path) `/testsets/${testsetID}`, { body, ...options });
|
|
32
62
|
}
|
|
33
63
|
/**
|
|
34
64
|
* Retrieve a paginated list of Testsets belonging to a Project.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* // Automatically fetches more pages as needed.
|
|
69
|
+
* for await (const testset of client.testsets.list('314')) {
|
|
70
|
+
* // ...
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
35
73
|
*/
|
|
36
74
|
list(projectID, query = {}, options) {
|
|
37
75
|
return this._client.getAPIList((0, path_1.path) `/projects/${projectID}/testsets`, (pagination_1.PaginatedResponse), {
|
|
@@ -41,12 +79,22 @@ class Testsets extends resource_1.APIResource {
|
|
|
41
79
|
}
|
|
42
80
|
/**
|
|
43
81
|
* Delete Testset
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const testset = await client.testsets.delete('246');
|
|
86
|
+
* ```
|
|
44
87
|
*/
|
|
45
88
|
delete(testsetID, options) {
|
|
46
89
|
return this._client.delete((0, path_1.path) `/testsets/${testsetID}`, options);
|
|
47
90
|
}
|
|
48
91
|
/**
|
|
49
92
|
* Get Testset by ID
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const testset = await client.testsets.get('246');
|
|
97
|
+
* ```
|
|
50
98
|
*/
|
|
51
99
|
get(testsetID, options) {
|
|
52
100
|
return this._client.get((0, path_1.path) `/testsets/${testsetID}`, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testsets.js","sourceRoot":"","sources":["../src/resources/testsets.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAE/C,sDAAkG;AAElG,oDAA8C;AAE9C,MAAa,QAAS,SAAQ,sBAAW;IACvC
|
|
1
|
+
{"version":3,"file":"testsets.js","sourceRoot":"","sources":["../src/resources/testsets.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAE/C,sDAAkG;AAElG,oDAA8C;AAE9C,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,SAAiB,EAAE,IAAyB,EAAE,OAAwB;QAC3E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,aAAa,SAAS,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACxF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CACJ,SAAiB,EACjB,OAA+C,EAAE,EACjD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAA,WAAI,EAAA,aAAa,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,CACF,SAAiB,EACjB,QAA8C,EAAE,EAChD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAA,WAAI,EAAA,aAAa,SAAS,WAAW,EAAE,CAAA,8BAA0B,CAAA,EAAE;YAChG,KAAK;YACL,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,SAAiB,EAAE,OAAwB;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAA,WAAI,EAAA,aAAa,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,SAAiB,EAAE,OAAwB;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,aAAa,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;CACF;AA1GD,4BA0GC"}
|
package/resources/testsets.mjs
CHANGED
|
@@ -6,6 +6,28 @@ export class Testsets extends APIResource {
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a new Testset for a Project. The Testset will be created in the Project
|
|
8
8
|
* specified in the path.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const testset = await client.testsets.create('314', {
|
|
13
|
+
* description: 'Testset for long context Q&A chatbot.',
|
|
14
|
+
* fieldMapping: {
|
|
15
|
+
* inputs: ['question'],
|
|
16
|
+
* labels: ['idealAnswer'],
|
|
17
|
+
* metadata: [],
|
|
18
|
+
* },
|
|
19
|
+
* jsonSchema: {
|
|
20
|
+
* type: 'object',
|
|
21
|
+
* properties: {
|
|
22
|
+
* question: { type: 'string' },
|
|
23
|
+
* idealAnswer: { type: 'string' },
|
|
24
|
+
* provenance: { type: 'string' },
|
|
25
|
+
* geo: { type: 'string' },
|
|
26
|
+
* },
|
|
27
|
+
* },
|
|
28
|
+
* name: 'Long Context Q&A',
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
9
31
|
*/
|
|
10
32
|
create(projectID, body, options) {
|
|
11
33
|
return this._client.post(path `/projects/${projectID}/testsets`, { body, ...options });
|
|
@@ -23,12 +45,28 @@ export class Testsets extends APIResource {
|
|
|
23
45
|
* updated schema
|
|
24
46
|
* - For complete control, provide both schema and fieldMapping when updating the
|
|
25
47
|
* schema
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const testset = await client.testsets.update('246', {
|
|
52
|
+
* description: 'Updated description for the Q&A Testset.',
|
|
53
|
+
* name: 'Updated Q&A Testset',
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
26
56
|
*/
|
|
27
57
|
update(testsetID, body = {}, options) {
|
|
28
58
|
return this._client.patch(path `/testsets/${testsetID}`, { body, ...options });
|
|
29
59
|
}
|
|
30
60
|
/**
|
|
31
61
|
* Retrieve a paginated list of Testsets belonging to a Project.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* // Automatically fetches more pages as needed.
|
|
66
|
+
* for await (const testset of client.testsets.list('314')) {
|
|
67
|
+
* // ...
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
32
70
|
*/
|
|
33
71
|
list(projectID, query = {}, options) {
|
|
34
72
|
return this._client.getAPIList(path `/projects/${projectID}/testsets`, (PaginatedResponse), {
|
|
@@ -38,12 +76,22 @@ export class Testsets extends APIResource {
|
|
|
38
76
|
}
|
|
39
77
|
/**
|
|
40
78
|
* Delete Testset
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const testset = await client.testsets.delete('246');
|
|
83
|
+
* ```
|
|
41
84
|
*/
|
|
42
85
|
delete(testsetID, options) {
|
|
43
86
|
return this._client.delete(path `/testsets/${testsetID}`, options);
|
|
44
87
|
}
|
|
45
88
|
/**
|
|
46
89
|
* Get Testset by ID
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const testset = await client.testsets.get('246');
|
|
94
|
+
* ```
|
|
47
95
|
*/
|
|
48
96
|
get(testsetID, options) {
|
|
49
97
|
return this._client.get(path `/testsets/${testsetID}`, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testsets.mjs","sourceRoot":"","sources":["../src/resources/testsets.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAEf,EAAe,iBAAiB,EAAgC;OAEhE,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC
|
|
1
|
+
{"version":3,"file":"testsets.mjs","sourceRoot":"","sources":["../src/resources/testsets.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAEf,EAAe,iBAAiB,EAAgC;OAEhE,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,SAAiB,EAAE,IAAyB,EAAE,OAAwB;QAC3E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,aAAa,SAAS,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACxF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CACJ,SAAiB,EACjB,OAA+C,EAAE,EACjD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA,aAAa,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,CACF,SAAiB,EACjB,QAA8C,EAAE,EAChD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAA,aAAa,SAAS,WAAW,EAAE,CAAA,iBAA0B,CAAA,EAAE;YAChG,KAAK;YACL,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,SAAiB,EAAE,OAAwB;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,aAAa,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,SAAiB,EAAE,OAAwB;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,aAAa,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;CACF"}
|
package/src/client.ts
CHANGED
|
@@ -23,13 +23,15 @@ 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
25
|
import {
|
|
26
|
+
Project,
|
|
27
|
+
ProjectCreateParams,
|
|
26
28
|
ProjectListParams,
|
|
27
|
-
ProjectListResponse,
|
|
28
|
-
ProjectListResponsesPaginatedResponse,
|
|
29
29
|
Projects,
|
|
30
|
+
ProjectsPaginatedResponse,
|
|
30
31
|
} from './resources/projects';
|
|
31
32
|
import { Record as RecordsAPIRecord, RecordCreateParams, Records } from './resources/records';
|
|
32
33
|
import { Run, RunCreateParams, RunUpdateParams, RunUpdateResponse, Runs } from './resources/runs';
|
|
34
|
+
import { Score, ScoreUpsertParams, Scores } from './resources/scores';
|
|
33
35
|
import {
|
|
34
36
|
SystemConfig,
|
|
35
37
|
SystemConfigCreateParams,
|
|
@@ -82,7 +84,7 @@ export interface ClientOptions {
|
|
|
82
84
|
/**
|
|
83
85
|
* Defaults to process.env['SCORECARD_API_KEY'].
|
|
84
86
|
*/
|
|
85
|
-
|
|
87
|
+
apiKey?: string | undefined;
|
|
86
88
|
|
|
87
89
|
/**
|
|
88
90
|
* Specifies the environment to use for the API.
|
|
@@ -165,7 +167,7 @@ export interface ClientOptions {
|
|
|
165
167
|
* API Client for interfacing with the Scorecard API.
|
|
166
168
|
*/
|
|
167
169
|
export class Scorecard {
|
|
168
|
-
|
|
170
|
+
apiKey: string;
|
|
169
171
|
|
|
170
172
|
baseURL: string;
|
|
171
173
|
maxRetries: number;
|
|
@@ -182,7 +184,7 @@ export class Scorecard {
|
|
|
182
184
|
/**
|
|
183
185
|
* API Client for interfacing with the Scorecard API.
|
|
184
186
|
*
|
|
185
|
-
* @param {string | undefined} [opts.
|
|
187
|
+
* @param {string | undefined} [opts.apiKey=process.env['SCORECARD_API_KEY'] ?? undefined]
|
|
186
188
|
* @param {Environment} [opts.environment=production] - Specifies the environment URL to use for the API.
|
|
187
189
|
* @param {string} [opts.baseURL=process.env['SCORECARD_BASE_URL'] ?? https://api2.scorecard.io/api/v2] - Override the default base URL for the API.
|
|
188
190
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
@@ -194,17 +196,17 @@ export class Scorecard {
|
|
|
194
196
|
*/
|
|
195
197
|
constructor({
|
|
196
198
|
baseURL = readEnv('SCORECARD_BASE_URL'),
|
|
197
|
-
|
|
199
|
+
apiKey = readEnv('SCORECARD_API_KEY'),
|
|
198
200
|
...opts
|
|
199
201
|
}: ClientOptions = {}) {
|
|
200
|
-
if (
|
|
202
|
+
if (apiKey === undefined) {
|
|
201
203
|
throw new Errors.ScorecardError(
|
|
202
|
-
"The SCORECARD_API_KEY environment variable is missing or empty; either provide it, or instantiate the Scorecard client with an
|
|
204
|
+
"The SCORECARD_API_KEY environment variable is missing or empty; either provide it, or instantiate the Scorecard client with an apiKey option, like new Scorecard({ apiKey: 'My API Key' }).",
|
|
203
205
|
);
|
|
204
206
|
}
|
|
205
207
|
|
|
206
208
|
const options: ClientOptions = {
|
|
207
|
-
|
|
209
|
+
apiKey,
|
|
208
210
|
...opts,
|
|
209
211
|
baseURL,
|
|
210
212
|
environment: opts.environment ?? 'production',
|
|
@@ -233,7 +235,25 @@ export class Scorecard {
|
|
|
233
235
|
|
|
234
236
|
this._options = options;
|
|
235
237
|
|
|
236
|
-
this.
|
|
238
|
+
this.apiKey = apiKey;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
243
|
+
*/
|
|
244
|
+
withOptions(options: Partial<ClientOptions>): this {
|
|
245
|
+
return new (this.constructor as any as new (props: ClientOptions) => typeof this)({
|
|
246
|
+
...this._options,
|
|
247
|
+
environment: options.environment ? options.environment : undefined,
|
|
248
|
+
baseURL: options.environment ? undefined : this.baseURL,
|
|
249
|
+
maxRetries: this.maxRetries,
|
|
250
|
+
timeout: this.timeout,
|
|
251
|
+
logger: this.logger,
|
|
252
|
+
logLevel: this.logLevel,
|
|
253
|
+
fetchOptions: this.fetchOptions,
|
|
254
|
+
apiKey: this.apiKey,
|
|
255
|
+
...options,
|
|
256
|
+
});
|
|
237
257
|
}
|
|
238
258
|
|
|
239
259
|
protected defaultQuery(): Record<string, string | undefined> | undefined {
|
|
@@ -245,7 +265,7 @@ export class Scorecard {
|
|
|
245
265
|
}
|
|
246
266
|
|
|
247
267
|
protected authHeaders(opts: FinalRequestOptions): NullableHeaders | undefined {
|
|
248
|
-
return buildHeaders([{ Authorization: `Bearer ${this.
|
|
268
|
+
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
|
|
249
269
|
}
|
|
250
270
|
|
|
251
271
|
/**
|
|
@@ -769,6 +789,7 @@ export class Scorecard {
|
|
|
769
789
|
testcases: API.Testcases = new API.Testcases(this);
|
|
770
790
|
runs: API.Runs = new API.Runs(this);
|
|
771
791
|
records: API.Records = new API.Records(this);
|
|
792
|
+
scores: API.Scores = new API.Scores(this);
|
|
772
793
|
systems: API.Systems = new API.Systems(this);
|
|
773
794
|
systemConfigs: API.SystemConfigs = new API.SystemConfigs(this);
|
|
774
795
|
}
|
|
@@ -777,6 +798,7 @@ Scorecard.Testsets = Testsets;
|
|
|
777
798
|
Scorecard.Testcases = Testcases;
|
|
778
799
|
Scorecard.Runs = Runs;
|
|
779
800
|
Scorecard.Records = Records;
|
|
801
|
+
Scorecard.Scores = Scores;
|
|
780
802
|
Scorecard.Systems = Systems;
|
|
781
803
|
Scorecard.SystemConfigs = SystemConfigs;
|
|
782
804
|
export declare namespace Scorecard {
|
|
@@ -790,8 +812,9 @@ export declare namespace Scorecard {
|
|
|
790
812
|
|
|
791
813
|
export {
|
|
792
814
|
Projects as Projects,
|
|
793
|
-
type
|
|
794
|
-
type
|
|
815
|
+
type Project as Project,
|
|
816
|
+
type ProjectsPaginatedResponse as ProjectsPaginatedResponse,
|
|
817
|
+
type ProjectCreateParams as ProjectCreateParams,
|
|
795
818
|
type ProjectListParams as ProjectListParams,
|
|
796
819
|
};
|
|
797
820
|
|
|
@@ -831,6 +854,8 @@ export declare namespace Scorecard {
|
|
|
831
854
|
type RecordCreateParams as RecordCreateParams,
|
|
832
855
|
};
|
|
833
856
|
|
|
857
|
+
export { Scores as Scores, type Score as Score, type ScoreUpsertParams as ScoreUpsertParams };
|
|
858
|
+
|
|
834
859
|
export {
|
|
835
860
|
Systems as Systems,
|
|
836
861
|
type System as System,
|
package/src/internal/headers.ts
CHANGED
|
@@ -71,8 +71,8 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
|
|
|
71
71
|
export const buildHeaders = (newHeaders: HeadersLike[]): NullableHeaders => {
|
|
72
72
|
const targetHeaders = new Headers();
|
|
73
73
|
const nullHeaders = new Set<string>();
|
|
74
|
-
const seenHeaders = new Set<string>();
|
|
75
74
|
for (const headers of newHeaders) {
|
|
75
|
+
const seenHeaders = new Set<string>();
|
|
76
76
|
for (const [name, value] of iterateHeaders(headers)) {
|
|
77
77
|
const lowerName = name.toLowerCase();
|
|
78
78
|
if (!seenHeaders.has(lowerName)) {
|
package/src/internal/to-file.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type File, getFile } from './shims/file';
|
|
2
1
|
import { BlobPart, getName, makeFile, isAsyncIterable } from './uploads';
|
|
3
2
|
import type { FilePropertyBag } from './builtin-types';
|
|
3
|
+
import { checkFileSupport } from './uploads';
|
|
4
4
|
|
|
5
5
|
type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | DataView;
|
|
6
6
|
|
|
@@ -85,12 +85,14 @@ export async function toFile(
|
|
|
85
85
|
name?: string | null | undefined,
|
|
86
86
|
options?: FilePropertyBag | undefined,
|
|
87
87
|
): Promise<File> {
|
|
88
|
+
checkFileSupport();
|
|
89
|
+
|
|
88
90
|
// If it's a promise, resolve it.
|
|
89
91
|
value = await value;
|
|
90
92
|
|
|
91
93
|
// If we've been given a `File` we don't need to do anything
|
|
92
94
|
if (isFileLike(value)) {
|
|
93
|
-
if (value instanceof
|
|
95
|
+
if (value instanceof File) {
|
|
94
96
|
return value;
|
|
95
97
|
}
|
|
96
98
|
return makeFile([await value.arrayBuffer()], value.name);
|
package/src/internal/uploads.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type RequestOptions } from './request-options';
|
|
2
2
|
import type { FilePropertyBag, Fetch } from './builtin-types';
|
|
3
3
|
import type { Scorecard } from '../client';
|
|
4
|
-
import { type File, getFile } from './shims/file';
|
|
5
4
|
import { ReadableStreamFrom } from './shims';
|
|
6
5
|
|
|
7
6
|
export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | DataView;
|
|
@@ -12,6 +11,20 @@ interface BunFile extends Blob {
|
|
|
12
11
|
readonly name?: string | undefined;
|
|
13
12
|
}
|
|
14
13
|
|
|
14
|
+
export const checkFileSupport = () => {
|
|
15
|
+
if (typeof File === 'undefined') {
|
|
16
|
+
const { process } = globalThis as any;
|
|
17
|
+
const isOldNode =
|
|
18
|
+
typeof process?.versions?.node === 'string' && parseInt(process.versions.node.split('.')) < 20;
|
|
19
|
+
throw new Error(
|
|
20
|
+
'`File` is not defined as a global, which is required for file uploads.' +
|
|
21
|
+
(isOldNode ?
|
|
22
|
+
" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`."
|
|
23
|
+
: ''),
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
15
28
|
/**
|
|
16
29
|
* Typically, this is a native "File" class.
|
|
17
30
|
*
|
|
@@ -32,7 +45,7 @@ export function makeFile(
|
|
|
32
45
|
fileName: string | undefined,
|
|
33
46
|
options?: FilePropertyBag,
|
|
34
47
|
): File {
|
|
35
|
-
|
|
48
|
+
checkFileSupport();
|
|
36
49
|
return new File(fileBits as any, fileName ?? 'unknown_file', options);
|
|
37
50
|
}
|
|
38
51
|
|
|
@@ -125,8 +138,7 @@ export const createForm = async <T = Record<string, unknown>>(
|
|
|
125
138
|
|
|
126
139
|
// We check for Blob not File because Bun.File doesn't inherit from File,
|
|
127
140
|
// but they both inherit from Blob and have a `name` property at runtime.
|
|
128
|
-
const isNamedBlob = (value: object) =>
|
|
129
|
-
value instanceof getFile() || (value instanceof Blob && 'name' in value);
|
|
141
|
+
const isNamedBlob = (value: object) => value instanceof Blob && 'name' in value;
|
|
130
142
|
|
|
131
143
|
const isUploadable = (value: unknown) =>
|
|
132
144
|
typeof value === 'object' &&
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { getCrypto } from '../shims/crypto';
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* https://stackoverflow.com/a/2117523
|
|
7
5
|
*/
|
|
8
6
|
export let uuid4 = function () {
|
|
9
|
-
const crypto =
|
|
7
|
+
const { crypto } = globalThis as any;
|
|
10
8
|
if (crypto?.randomUUID) {
|
|
11
9
|
uuid4 = crypto.randomUUID.bind(crypto);
|
|
12
10
|
return crypto.randomUUID();
|
package/src/resources/index.ts
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
export * from './shared';
|
|
4
4
|
export {
|
|
5
5
|
Projects,
|
|
6
|
-
type
|
|
6
|
+
type Project,
|
|
7
|
+
type ProjectCreateParams,
|
|
7
8
|
type ProjectListParams,
|
|
8
|
-
type
|
|
9
|
+
type ProjectsPaginatedResponse,
|
|
9
10
|
} from './projects';
|
|
10
11
|
export { Records, type Record, type RecordCreateParams } from './records';
|
|
11
12
|
export { Runs, type Run, type RunUpdateResponse, type RunCreateParams, type RunUpdateParams } from './runs';
|
|
13
|
+
export { Scores, type Score, type ScoreUpsertParams } from './scores';
|
|
12
14
|
export {
|
|
13
15
|
SystemConfigs,
|
|
14
16
|
type SystemConfig,
|