scorecard-ai 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +52 -24
  3. package/client.d.mts +13 -13
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +13 -13
  6. package/client.d.ts.map +1 -1
  7. package/client.js +26 -22
  8. package/client.js.map +1 -1
  9. package/client.mjs +15 -11
  10. package/client.mjs.map +1 -1
  11. package/core/resource.d.mts +1 -1
  12. package/core/resource.d.mts.map +1 -1
  13. package/core/resource.d.ts +1 -1
  14. package/core/resource.d.ts.map +1 -1
  15. package/core/resource.js.map +1 -1
  16. package/core/resource.mjs.map +1 -1
  17. package/internal/headers.d.mts.map +1 -1
  18. package/internal/headers.d.ts.map +1 -1
  19. package/internal/headers.js +4 -4
  20. package/internal/headers.js.map +1 -1
  21. package/internal/headers.mjs +4 -4
  22. package/internal/headers.mjs.map +1 -1
  23. package/internal/request-options.d.mts +1 -0
  24. package/internal/request-options.d.mts.map +1 -1
  25. package/internal/request-options.d.ts +1 -0
  26. package/internal/request-options.d.ts.map +1 -1
  27. package/internal/request-options.js.map +1 -1
  28. package/internal/request-options.mjs.map +1 -1
  29. package/internal/uploads.js +1 -1
  30. package/internal/uploads.js.map +1 -1
  31. package/internal/uploads.mjs +1 -1
  32. package/internal/uploads.mjs.map +1 -1
  33. package/internal/utils/log.js +1 -1
  34. package/internal/utils/log.js.map +1 -1
  35. package/internal/utils/log.mjs +1 -1
  36. package/internal/utils/log.mjs.map +1 -1
  37. package/internal/utils/path.d.mts.map +1 -1
  38. package/internal/utils/path.d.ts.map +1 -1
  39. package/internal/utils/path.js.map +1 -1
  40. package/internal/utils/path.mjs +1 -1
  41. package/internal/utils/path.mjs.map +1 -1
  42. package/internal/utils/values.d.mts +2 -0
  43. package/internal/utils/values.d.mts.map +1 -1
  44. package/internal/utils/values.d.ts +2 -0
  45. package/internal/utils/values.d.ts.map +1 -1
  46. package/internal/utils/values.js +4 -1
  47. package/internal/utils/values.js.map +1 -1
  48. package/internal/utils/values.mjs +2 -0
  49. package/internal/utils/values.mjs.map +1 -1
  50. package/package.json +1 -1
  51. package/resources/index.d.mts +1 -1
  52. package/resources/index.d.mts.map +1 -1
  53. package/resources/index.d.ts +1 -1
  54. package/resources/index.d.ts.map +1 -1
  55. package/resources/index.js.map +1 -1
  56. package/resources/index.mjs.map +1 -1
  57. package/resources/metrics.d.mts +192 -2
  58. package/resources/metrics.d.mts.map +1 -1
  59. package/resources/metrics.d.ts +192 -2
  60. package/resources/metrics.d.ts.map +1 -1
  61. package/resources/metrics.js +20 -1
  62. package/resources/metrics.js.map +1 -1
  63. package/resources/metrics.mjs +20 -1
  64. package/resources/metrics.mjs.map +1 -1
  65. package/resources/records.d.mts +18 -7
  66. package/resources/records.d.mts.map +1 -1
  67. package/resources/records.d.ts +18 -7
  68. package/resources/records.d.ts.map +1 -1
  69. package/resources/records.js.map +1 -1
  70. package/resources/records.mjs.map +1 -1
  71. package/resources/scores.d.mts +6 -2
  72. package/resources/scores.d.mts.map +1 -1
  73. package/resources/scores.d.ts +6 -2
  74. package/resources/scores.d.ts.map +1 -1
  75. package/resources/shared.d.mts +3 -1
  76. package/resources/shared.d.mts.map +1 -1
  77. package/resources/shared.d.ts +3 -1
  78. package/resources/shared.d.ts.map +1 -1
  79. package/resources/systems/systems.d.mts +27 -9
  80. package/resources/systems/systems.d.mts.map +1 -1
  81. package/resources/systems/systems.d.ts +27 -9
  82. package/resources/systems/systems.d.ts.map +1 -1
  83. package/resources/systems/versions.d.mts +6 -2
  84. package/resources/systems/versions.d.mts.map +1 -1
  85. package/resources/systems/versions.d.ts +6 -2
  86. package/resources/systems/versions.d.ts.map +1 -1
  87. package/resources/testcases.d.mts +15 -5
  88. package/resources/testcases.d.mts.map +1 -1
  89. package/resources/testcases.d.ts +15 -5
  90. package/resources/testcases.d.ts.map +1 -1
  91. package/resources/testsets.d.mts +9 -3
  92. package/resources/testsets.d.mts.map +1 -1
  93. package/resources/testsets.d.ts +9 -3
  94. package/resources/testsets.d.ts.map +1 -1
  95. package/src/client.ts +42 -23
  96. package/src/core/resource.ts +1 -1
  97. package/src/internal/headers.ts +5 -5
  98. package/src/internal/request-options.ts +1 -0
  99. package/src/internal/uploads.ts +1 -1
  100. package/src/internal/utils/log.ts +1 -1
  101. package/src/internal/utils/path.ts +1 -1
  102. package/src/internal/utils/values.ts +3 -0
  103. package/src/resources/index.ts +1 -1
  104. package/src/resources/metrics.ts +245 -2
  105. package/src/resources/records.ts +6 -7
  106. package/src/resources/scores.ts +2 -2
  107. package/src/resources/shared.ts +1 -1
  108. package/src/resources/systems/systems.ts +9 -9
  109. package/src/resources/systems/versions.ts +2 -2
  110. package/src/resources/testcases.ts +5 -5
  111. package/src/resources/testsets.ts +3 -3
  112. package/src/version.ts +1 -1
  113. package/version.d.mts +1 -1
  114. package/version.d.ts +1 -1
  115. package/version.js +1 -1
  116. package/version.mjs +1 -1
@@ -7,7 +7,8 @@ import { path } from '../internal/utils/path';
7
7
 
8
8
  export class Metrics extends APIResource {
9
9
  /**
10
- * Create a new Metric for evaluating system outputs.
10
+ * Create a new Metric for evaluating system outputs. The structure of a metric
11
+ * depends on the evalType and outputType of the metric.
11
12
  *
12
13
  * @example
13
14
  * ```ts
@@ -29,6 +30,25 @@ export class Metrics extends APIResource {
29
30
  create(projectID: string, body: MetricCreateParams, options?: RequestOptions): APIPromise<Metric> {
30
31
  return this._client.post(path`/projects/${projectID}/metrics`, { body, ...options });
31
32
  }
33
+
34
+ /**
35
+ * Update an existing Metric. You must specify the evalType and outputType of the
36
+ * metric. The structure of a metric depends on the evalType and outputType of the
37
+ * metric.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const metric = await client.metrics.update('321', {
42
+ * evalType: 'ai',
43
+ * outputType: 'boolean',
44
+ * promptTemplate:
45
+ * 'Using the following guidelines, evaluate the response: {{ guidelines }}\n\nResponse: {{ outputs.response }}\n\nIdeal answer: {{ expected.idealResponse }}',
46
+ * });
47
+ * ```
48
+ */
49
+ update(metricID: string, body: MetricUpdateParams, options?: RequestOptions): APIPromise<Metric> {
50
+ return this._client.patch(path`/metrics/${metricID}`, { body, ...options });
51
+ }
32
52
  }
33
53
 
34
54
  /**
@@ -520,6 +540,229 @@ export declare namespace MetricCreateParams {
520
540
  }
521
541
  }
522
542
 
543
+ export type MetricUpdateParams =
544
+ | MetricUpdateParams.AIIntMetric
545
+ | MetricUpdateParams.HumanIntMetric
546
+ | MetricUpdateParams.HeuristicIntMetric
547
+ | MetricUpdateParams.AIBooleanMetric
548
+ | MetricUpdateParams.HumanBooleanMetric
549
+ | MetricUpdateParams.HeuristicBooleanMetric;
550
+
551
+ export declare namespace MetricUpdateParams {
552
+ export interface AIIntMetric {
553
+ /**
554
+ * AI-based evaluation type.
555
+ */
556
+ evalType: 'ai';
557
+
558
+ /**
559
+ * Integer output type.
560
+ */
561
+ outputType: 'int';
562
+
563
+ /**
564
+ * The description of the Metric.
565
+ */
566
+ description?: string | null;
567
+
568
+ /**
569
+ * The AI model to use for evaluation.
570
+ */
571
+ evalModelName?: string;
572
+
573
+ /**
574
+ * Guidelines for AI evaluation on how to score the metric.
575
+ */
576
+ guidelines?: string | null;
577
+
578
+ /**
579
+ * The name of the Metric.
580
+ */
581
+ name?: string;
582
+
583
+ /**
584
+ * The threshold for determining pass/fail from integer scores (1-5).
585
+ */
586
+ passingThreshold?: number;
587
+
588
+ /**
589
+ * The complete prompt template for AI evaluation. Should include placeholders for
590
+ * dynamic content.
591
+ */
592
+ promptTemplate?: string;
593
+
594
+ /**
595
+ * The temperature for AI evaluation (0-2).
596
+ */
597
+ temperature?: number;
598
+ }
599
+
600
+ export interface HumanIntMetric {
601
+ /**
602
+ * Human-based evaluation type.
603
+ */
604
+ evalType: 'human';
605
+
606
+ /**
607
+ * Integer output type.
608
+ */
609
+ outputType: 'int';
610
+
611
+ /**
612
+ * The description of the Metric.
613
+ */
614
+ description?: string | null;
615
+
616
+ /**
617
+ * Guidelines for human evaluators.
618
+ */
619
+ guidelines?: string;
620
+
621
+ /**
622
+ * The name of the Metric.
623
+ */
624
+ name?: string;
625
+
626
+ /**
627
+ * The threshold for determining pass/fail from integer scores (1-5).
628
+ */
629
+ passingThreshold?: number;
630
+ }
631
+
632
+ export interface HeuristicIntMetric {
633
+ /**
634
+ * Heuristic-based evaluation type.
635
+ */
636
+ evalType: 'heuristic';
637
+
638
+ /**
639
+ * Integer output type.
640
+ */
641
+ outputType: 'int';
642
+
643
+ /**
644
+ * The description of the Metric.
645
+ */
646
+ description?: string | null;
647
+
648
+ /**
649
+ * Optional guidelines for heuristic evaluation logic.
650
+ */
651
+ guidelines?: string;
652
+
653
+ /**
654
+ * The name of the Metric.
655
+ */
656
+ name?: string;
657
+
658
+ /**
659
+ * The threshold for determining pass/fail from integer scores (1-5).
660
+ */
661
+ passingThreshold?: number;
662
+ }
663
+
664
+ export interface AIBooleanMetric {
665
+ /**
666
+ * AI-based evaluation type.
667
+ */
668
+ evalType: 'ai';
669
+
670
+ /**
671
+ * Boolean output type.
672
+ */
673
+ outputType: 'boolean';
674
+
675
+ /**
676
+ * The description of the Metric.
677
+ */
678
+ description?: string | null;
679
+
680
+ /**
681
+ * The AI model to use for evaluation.
682
+ */
683
+ evalModelName?: string;
684
+
685
+ /**
686
+ * Guidelines for AI evaluation on how to score the metric.
687
+ */
688
+ guidelines?: string | null;
689
+
690
+ /**
691
+ * The name of the Metric.
692
+ */
693
+ name?: string;
694
+
695
+ /**
696
+ * The complete prompt template for AI evaluation. Should include placeholders for
697
+ * dynamic content.
698
+ */
699
+ promptTemplate?: string;
700
+
701
+ /**
702
+ * The temperature for AI evaluation (0-2).
703
+ */
704
+ temperature?: number;
705
+ }
706
+
707
+ export interface HumanBooleanMetric {
708
+ /**
709
+ * Human-based evaluation type.
710
+ */
711
+ evalType: 'human';
712
+
713
+ /**
714
+ * Boolean output type.
715
+ */
716
+ outputType: 'boolean';
717
+
718
+ /**
719
+ * The description of the Metric.
720
+ */
721
+ description?: string | null;
722
+
723
+ /**
724
+ * Guidelines for human evaluators.
725
+ */
726
+ guidelines?: string;
727
+
728
+ /**
729
+ * The name of the Metric.
730
+ */
731
+ name?: string;
732
+ }
733
+
734
+ export interface HeuristicBooleanMetric {
735
+ /**
736
+ * Heuristic-based evaluation type.
737
+ */
738
+ evalType: 'heuristic';
739
+
740
+ /**
741
+ * Boolean output type.
742
+ */
743
+ outputType: 'boolean';
744
+
745
+ /**
746
+ * The description of the Metric.
747
+ */
748
+ description?: string | null;
749
+
750
+ /**
751
+ * Optional guidelines for heuristic evaluation logic.
752
+ */
753
+ guidelines?: string;
754
+
755
+ /**
756
+ * The name of the Metric.
757
+ */
758
+ name?: string;
759
+ }
760
+ }
761
+
523
762
  export declare namespace Metrics {
524
- export { type Metric as Metric, type MetricCreateParams as MetricCreateParams };
763
+ export {
764
+ type Metric as Metric,
765
+ type MetricCreateParams as MetricCreateParams,
766
+ type MetricUpdateParams as MetricUpdateParams,
767
+ };
525
768
  }
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
- import { type Record as BuiltinRecord } from '../internal/builtin-types';
6
5
  import { RequestOptions } from '../internal/request-options';
7
6
  import { path } from '../internal/utils/path';
8
7
 
@@ -39,18 +38,18 @@ export interface Record {
39
38
  /**
40
39
  * The expected outputs for the Testcase.
41
40
  */
42
- expected: BuiltinRecord<string, unknown>;
41
+ expected: { [key: string]: unknown };
43
42
 
44
43
  /**
45
44
  * The actual inputs sent to the system, which should match the system's input
46
45
  * schema.
47
46
  */
48
- inputs: BuiltinRecord<string, unknown>;
47
+ inputs: { [key: string]: unknown };
49
48
 
50
49
  /**
51
50
  * The actual outputs from the system.
52
51
  */
53
- outputs: BuiltinRecord<string, unknown>;
52
+ outputs: { [key: string]: unknown };
54
53
 
55
54
  /**
56
55
  * The ID of the Run containing this Record.
@@ -67,18 +66,18 @@ export interface RecordCreateParams {
67
66
  /**
68
67
  * The expected outputs for the Testcase.
69
68
  */
70
- expected: BuiltinRecord<string, unknown>;
69
+ expected: { [key: string]: unknown };
71
70
 
72
71
  /**
73
72
  * The actual inputs sent to the system, which should match the system's input
74
73
  * schema.
75
74
  */
76
- inputs: BuiltinRecord<string, unknown>;
75
+ inputs: { [key: string]: unknown };
77
76
 
78
77
  /**
79
78
  * The actual outputs from the system.
80
79
  */
81
- outputs: BuiltinRecord<string, unknown>;
80
+ outputs: { [key: string]: unknown };
82
81
 
83
82
  /**
84
83
  * The ID of the Testcase.
@@ -56,7 +56,7 @@ export interface Score {
56
56
  * the output schema defined by the associated MetricConfig. If it doesn't,
57
57
  * validation errors will be captured in the `validationErrors` field.
58
58
  */
59
- score: Record<string, unknown>;
59
+ score: { [key: string]: unknown };
60
60
 
61
61
  /**
62
62
  * Validation errors found in the Score data. If present, the Score doesn't fully
@@ -90,7 +90,7 @@ export interface ScoreUpsertParams {
90
90
  * conform to the output schema defined by the associated MetricConfig. If it
91
91
  * doesn't, validation errors will be captured in the `validationErrors` field.
92
92
  */
93
- score: Record<string, unknown>;
93
+ score: { [key: string]: unknown };
94
94
  }
95
95
 
96
96
  export declare namespace Scores {
@@ -6,7 +6,7 @@
6
6
  export interface APIError {
7
7
  code: string;
8
8
 
9
- details: Record<string, unknown>;
9
+ details: { [key: string]: unknown };
10
10
 
11
11
  message: string;
12
12
  }
@@ -191,7 +191,7 @@ export interface System {
191
191
  /**
192
192
  * The schema of the system's configuration.
193
193
  */
194
- configSchema: Record<string, unknown>;
194
+ configSchema: { [key: string]: unknown };
195
195
 
196
196
  /**
197
197
  * The description of the system.
@@ -201,7 +201,7 @@ export interface System {
201
201
  /**
202
202
  * The schema of the system's inputs.
203
203
  */
204
- inputSchema: Record<string, unknown>;
204
+ inputSchema: { [key: string]: unknown };
205
205
 
206
206
  /**
207
207
  * The name of the system.
@@ -211,7 +211,7 @@ export interface System {
211
211
  /**
212
212
  * The schema of the system's outputs.
213
213
  */
214
- outputSchema: Record<string, unknown>;
214
+ outputSchema: { [key: string]: unknown };
215
215
  }
216
216
 
217
217
  export interface SystemDeleteResponse {
@@ -225,7 +225,7 @@ export interface SystemCreateParams {
225
225
  /**
226
226
  * The schema of the system's configuration.
227
227
  */
228
- configSchema: Record<string, unknown>;
228
+ configSchema: { [key: string]: unknown };
229
229
 
230
230
  /**
231
231
  * The description of the system.
@@ -235,7 +235,7 @@ export interface SystemCreateParams {
235
235
  /**
236
236
  * The schema of the system's inputs.
237
237
  */
238
- inputSchema: Record<string, unknown>;
238
+ inputSchema: { [key: string]: unknown };
239
239
 
240
240
  /**
241
241
  * The name of the system.
@@ -245,14 +245,14 @@ export interface SystemCreateParams {
245
245
  /**
246
246
  * The schema of the system's outputs.
247
247
  */
248
- outputSchema: Record<string, unknown>;
248
+ outputSchema: { [key: string]: unknown };
249
249
  }
250
250
 
251
251
  export interface SystemUpdateParams {
252
252
  /**
253
253
  * The schema of the system's configuration.
254
254
  */
255
- configSchema?: Record<string, unknown>;
255
+ configSchema?: { [key: string]: unknown };
256
256
 
257
257
  /**
258
258
  * The description of the system.
@@ -262,7 +262,7 @@ export interface SystemUpdateParams {
262
262
  /**
263
263
  * The schema of the system's inputs.
264
264
  */
265
- inputSchema?: Record<string, unknown>;
265
+ inputSchema?: { [key: string]: unknown };
266
266
 
267
267
  /**
268
268
  * The name of the system.
@@ -272,7 +272,7 @@ export interface SystemUpdateParams {
272
272
  /**
273
273
  * The schema of the system's outputs.
274
274
  */
275
- outputSchema?: Record<string, unknown>;
275
+ outputSchema?: { [key: string]: unknown };
276
276
  }
277
277
 
278
278
  export interface SystemListParams extends PaginatedResponseParams {}
@@ -109,7 +109,7 @@ export interface SystemVersion {
109
109
  /**
110
110
  * The configuration of the system version.
111
111
  */
112
- config: Record<string, unknown>;
112
+ config: { [key: string]: unknown };
113
113
 
114
114
  /**
115
115
  * The name of the system version.
@@ -146,7 +146,7 @@ export interface VersionCreateParams {
146
146
  /**
147
147
  * The configuration of the system version.
148
148
  */
149
- config: Record<string, unknown>;
149
+ config: { [key: string]: unknown };
150
150
 
151
151
  /**
152
152
  * The name of the system version.
@@ -136,18 +136,18 @@ export interface Testcase {
136
136
  * Derived from data based on the Testset's fieldMapping. Contains all fields
137
137
  * marked as expected outputs, including those with validation errors.
138
138
  */
139
- expected: Record<string, unknown>;
139
+ expected: { [key: string]: unknown };
140
140
 
141
141
  /**
142
142
  * Derived from data based on the Testset's fieldMapping. Contains all fields
143
143
  * marked as inputs, including those with validation errors.
144
144
  */
145
- inputs: Record<string, unknown>;
145
+ inputs: { [key: string]: unknown };
146
146
 
147
147
  /**
148
148
  * The JSON data of the Testcase, which is validated against the Testset's schema.
149
149
  */
150
- jsonData: Record<string, unknown>;
150
+ jsonData: { [key: string]: unknown };
151
151
 
152
152
  /**
153
153
  * The ID of the Testset this Testcase belongs to.
@@ -198,7 +198,7 @@ export namespace TestcaseCreateParams {
198
198
  /**
199
199
  * The JSON data of the Testcase, which is validated against the Testset's schema.
200
200
  */
201
- jsonData: Record<string, unknown>;
201
+ jsonData: { [key: string]: unknown };
202
202
  }
203
203
  }
204
204
 
@@ -206,7 +206,7 @@ export interface TestcaseUpdateParams {
206
206
  /**
207
207
  * The JSON data of the Testcase, which is validated against the Testset's schema.
208
208
  */
209
- jsonData: Record<string, unknown>;
209
+ jsonData: { [key: string]: unknown };
210
210
  }
211
211
 
212
212
  export interface TestcaseListParams extends PaginatedResponseParams {}
@@ -162,7 +162,7 @@ export interface Testset {
162
162
  /**
163
163
  * The JSON schema for each Testcase in the Testset.
164
164
  */
165
- jsonSchema: Record<string, unknown>;
165
+ jsonSchema: { [key: string]: unknown };
166
166
 
167
167
  /**
168
168
  * The name of the Testset.
@@ -215,7 +215,7 @@ export interface TestsetCreateParams {
215
215
  /**
216
216
  * The JSON schema for each Testcase in the Testset.
217
217
  */
218
- jsonSchema: Record<string, unknown>;
218
+ jsonSchema: { [key: string]: unknown };
219
219
 
220
220
  /**
221
221
  * The name of the Testset.
@@ -261,7 +261,7 @@ export interface TestsetUpdateParams {
261
261
  /**
262
262
  * The JSON schema for each Testcase in the Testset.
263
263
  */
264
- jsonSchema?: Record<string, unknown>;
264
+ jsonSchema?: { [key: string]: unknown };
265
265
 
266
266
  /**
267
267
  * The name of the Testset.
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.0.0'; // x-release-please-version
1
+ export const VERSION = '1.2.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.0.0";
1
+ export declare const VERSION = "1.2.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.0.0";
1
+ export declare const VERSION = "1.2.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '1.0.0'; // x-release-please-version
4
+ exports.VERSION = '1.2.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.0.0'; // x-release-please-version
1
+ export const VERSION = '1.2.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map