scorecard-ai 0.3.0 → 0.5.2

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 (140) hide show
  1. package/Client.d.ts +2 -0
  2. package/api/resources/prompt/client/Client.d.ts +22 -40
  3. package/api/resources/prompt/client/Client.js +50 -205
  4. package/api/resources/prompt/client/requests/PromptCreateParams.d.ts +2 -2
  5. package/api/resources/prompt/client/requests/PromptUpdateParams.d.ts +1 -2
  6. package/api/resources/run/client/Client.d.ts +5 -13
  7. package/api/resources/run/client/Client.js +18 -25
  8. package/api/resources/run/client/requests/RunCreateParams.d.ts +1 -9
  9. package/api/resources/run/client/requests/UpdateStatusParams.d.ts +2 -4
  10. package/api/resources/runMetric/client/Client.d.ts +2 -0
  11. package/api/resources/runMetric/client/Client.js +5 -4
  12. package/api/resources/score/client/Client.d.ts +7 -5
  13. package/api/resources/score/client/Client.js +15 -13
  14. package/api/resources/score/client/requests/ScoreCreateParams.d.ts +1 -0
  15. package/api/resources/testcase/client/Client.d.ts +10 -10
  16. package/api/resources/testcase/client/Client.js +29 -22
  17. package/api/resources/testcase/client/requests/TestcaseCreateParams.d.ts +3 -4
  18. package/api/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.d.ts +1 -1
  19. package/api/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.d.ts +1 -1
  20. package/api/resources/testrecord/client/Client.d.ts +3 -1
  21. package/api/resources/testrecord/client/Client.js +11 -9
  22. package/api/resources/testset/client/Client.d.ts +6 -4
  23. package/api/resources/testset/client/Client.js +29 -24
  24. package/api/resources/testset/client/requests/TestsetGetTestcasesRequest.d.ts +6 -0
  25. package/api/resources/traces/client/Client.d.ts +2 -0
  26. package/api/resources/traces/client/Client.js +5 -4
  27. package/api/types/Grade.d.ts +2 -0
  28. package/api/types/PaginatedTestcaseResponse.d.ts +1 -0
  29. package/api/types/TestCase.d.ts +2 -0
  30. package/api/types/TestCaseCustomInputsValue.d.ts +1 -1
  31. package/api/types/TestCaseCustomLabelsValue.d.ts +1 -1
  32. package/api/types/TestcaseDeletionResponse.d.ts +9 -0
  33. package/api/types/TestcaseDeletionResponse.js +5 -0
  34. package/api/types/Testrecord.d.ts +0 -1
  35. package/api/types/index.d.ts +1 -0
  36. package/api/types/index.js +1 -0
  37. package/core/fetcher/Fetcher.d.ts +1 -0
  38. package/core/fetcher/Fetcher.js +58 -7
  39. package/dist/Client.d.ts +2 -0
  40. package/dist/api/resources/prompt/client/Client.d.ts +22 -40
  41. package/dist/api/resources/prompt/client/Client.js +50 -205
  42. package/dist/api/resources/prompt/client/requests/PromptCreateParams.d.ts +2 -2
  43. package/dist/api/resources/prompt/client/requests/PromptUpdateParams.d.ts +1 -2
  44. package/dist/api/resources/run/client/Client.d.ts +5 -13
  45. package/dist/api/resources/run/client/Client.js +18 -25
  46. package/dist/api/resources/run/client/requests/RunCreateParams.d.ts +1 -9
  47. package/dist/api/resources/run/client/requests/UpdateStatusParams.d.ts +2 -4
  48. package/dist/api/resources/runMetric/client/Client.d.ts +2 -0
  49. package/dist/api/resources/runMetric/client/Client.js +5 -4
  50. package/dist/api/resources/score/client/Client.d.ts +7 -5
  51. package/dist/api/resources/score/client/Client.js +15 -13
  52. package/dist/api/resources/score/client/requests/ScoreCreateParams.d.ts +1 -0
  53. package/dist/api/resources/testcase/client/Client.d.ts +10 -10
  54. package/dist/api/resources/testcase/client/Client.js +29 -22
  55. package/dist/api/resources/testcase/client/requests/TestcaseCreateParams.d.ts +3 -4
  56. package/dist/api/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.d.ts +1 -1
  57. package/dist/api/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.d.ts +1 -1
  58. package/dist/api/resources/testrecord/client/Client.d.ts +3 -1
  59. package/dist/api/resources/testrecord/client/Client.js +11 -9
  60. package/dist/api/resources/testset/client/Client.d.ts +6 -4
  61. package/dist/api/resources/testset/client/Client.js +29 -24
  62. package/dist/api/resources/testset/client/requests/TestsetGetTestcasesRequest.d.ts +6 -0
  63. package/dist/api/resources/traces/client/Client.d.ts +2 -0
  64. package/dist/api/resources/traces/client/Client.js +5 -4
  65. package/dist/api/types/Grade.d.ts +2 -0
  66. package/dist/api/types/PaginatedTestcaseResponse.d.ts +1 -0
  67. package/dist/api/types/TestCase.d.ts +2 -0
  68. package/dist/api/types/TestCaseCustomInputsValue.d.ts +1 -1
  69. package/dist/api/types/TestCaseCustomLabelsValue.d.ts +1 -1
  70. package/dist/api/types/TestcaseDeletionResponse.d.ts +9 -0
  71. package/dist/api/types/TestcaseDeletionResponse.js +5 -0
  72. package/dist/api/types/Testrecord.d.ts +0 -1
  73. package/dist/api/types/index.d.ts +1 -0
  74. package/dist/api/types/index.js +1 -0
  75. package/dist/core/fetcher/Fetcher.d.ts +1 -0
  76. package/dist/core/fetcher/Fetcher.js +58 -7
  77. package/dist/serialization/resources/prompt/client/index.d.ts +0 -3
  78. package/dist/serialization/resources/prompt/client/index.js +0 -16
  79. package/dist/serialization/resources/prompt/client/requests/PromptUpdateParams.d.ts +0 -1
  80. package/dist/serialization/resources/prompt/client/requests/PromptUpdateParams.js +0 -1
  81. package/dist/serialization/resources/run/client/requests/UpdateStatusParams.d.ts +1 -1
  82. package/dist/serialization/resources/run/client/requests/UpdateStatusParams.js +1 -1
  83. package/dist/serialization/resources/testcase/client/requests/TestcaseCreateParams.d.ts +1 -1
  84. package/dist/serialization/resources/testcase/client/requests/TestcaseCreateParams.js +1 -1
  85. package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.d.ts +1 -1
  86. package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.js +4 -1
  87. package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.d.ts +1 -1
  88. package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.js +4 -1
  89. package/dist/serialization/types/TestCaseCustomInputsValue.d.ts +1 -1
  90. package/dist/serialization/types/TestCaseCustomInputsValue.js +4 -1
  91. package/dist/serialization/types/TestCaseCustomLabelsValue.d.ts +1 -1
  92. package/dist/serialization/types/TestCaseCustomLabelsValue.js +4 -1
  93. package/dist/serialization/types/TestcaseDeletionResponse.d.ts +13 -0
  94. package/dist/serialization/{resources/prompt/client/getRoots.js → types/TestcaseDeletionResponse.js} +6 -4
  95. package/dist/serialization/types/Testrecord.d.ts +0 -1
  96. package/dist/serialization/types/Testrecord.js +0 -1
  97. package/dist/serialization/types/index.d.ts +1 -0
  98. package/dist/serialization/types/index.js +1 -0
  99. package/dist/telemetry.d.ts +6 -0
  100. package/dist/telemetry.js +65 -0
  101. package/dist/wrapper/ScorecardClient.d.ts +4 -0
  102. package/dist/wrapper/ScorecardClient.js +4 -6
  103. package/package.json +56 -2
  104. package/reference.md +38 -189
  105. package/serialization/resources/prompt/client/index.d.ts +0 -3
  106. package/serialization/resources/prompt/client/index.js +0 -16
  107. package/serialization/resources/prompt/client/requests/PromptUpdateParams.d.ts +0 -1
  108. package/serialization/resources/prompt/client/requests/PromptUpdateParams.js +0 -1
  109. package/serialization/resources/run/client/requests/UpdateStatusParams.d.ts +1 -1
  110. package/serialization/resources/run/client/requests/UpdateStatusParams.js +1 -1
  111. package/serialization/resources/testcase/client/requests/TestcaseCreateParams.d.ts +1 -1
  112. package/serialization/resources/testcase/client/requests/TestcaseCreateParams.js +1 -1
  113. package/serialization/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.d.ts +1 -1
  114. package/serialization/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.js +4 -1
  115. package/serialization/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.d.ts +1 -1
  116. package/serialization/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.js +4 -1
  117. package/serialization/types/TestCaseCustomInputsValue.d.ts +1 -1
  118. package/serialization/types/TestCaseCustomInputsValue.js +4 -1
  119. package/serialization/types/TestCaseCustomLabelsValue.d.ts +1 -1
  120. package/serialization/types/TestCaseCustomLabelsValue.js +4 -1
  121. package/serialization/types/TestcaseDeletionResponse.d.ts +13 -0
  122. package/{dist/serialization/resources/prompt/client/getGraph.js → serialization/types/TestcaseDeletionResponse.js} +6 -4
  123. package/serialization/types/Testrecord.d.ts +0 -1
  124. package/serialization/types/Testrecord.js +0 -1
  125. package/serialization/types/index.d.ts +1 -0
  126. package/serialization/types/index.js +1 -0
  127. package/telemetry.d.ts +6 -0
  128. package/telemetry.js +65 -0
  129. package/wrapper/ScorecardClient.d.ts +4 -0
  130. package/wrapper/ScorecardClient.js +4 -6
  131. package/dist/serialization/resources/prompt/client/getGraph.d.ts +0 -11
  132. package/dist/serialization/resources/prompt/client/getProds.d.ts +0 -11
  133. package/dist/serialization/resources/prompt/client/getProds.js +0 -32
  134. package/dist/serialization/resources/prompt/client/getRoots.d.ts +0 -11
  135. package/serialization/resources/prompt/client/getGraph.d.ts +0 -11
  136. package/serialization/resources/prompt/client/getGraph.js +0 -32
  137. package/serialization/resources/prompt/client/getProds.d.ts +0 -11
  138. package/serialization/resources/prompt/client/getProds.js +0 -32
  139. package/serialization/resources/prompt/client/getRoots.d.ts +0 -11
  140. package/serialization/resources/prompt/client/getRoots.js +0 -32
package/Client.d.ts CHANGED
@@ -15,10 +15,12 @@ export declare namespace ScorecardClient {
15
15
  interface Options {
16
16
  environment?: core.Supplier<environments.ScorecardEnvironment | string>;
17
17
  apiKey: core.Supplier<string>;
18
+ fetcher?: core.FetchFunction;
18
19
  }
19
20
  interface RequestOptions {
20
21
  timeoutInSeconds?: number;
21
22
  maxRetries?: number;
23
+ abortSignal?: AbortSignal;
22
24
  }
23
25
  }
24
26
  export declare class ScorecardClient {
@@ -8,17 +8,23 @@ export declare namespace Prompt {
8
8
  interface Options {
9
9
  environment?: core.Supplier<environments.ScorecardEnvironment | string>;
10
10
  apiKey: core.Supplier<string>;
11
+ fetcher?: core.FetchFunction;
11
12
  }
12
13
  interface RequestOptions {
13
14
  timeoutInSeconds?: number;
14
15
  maxRetries?: number;
16
+ abortSignal?: AbortSignal;
15
17
  }
16
18
  }
17
19
  export declare class Prompt {
18
20
  protected readonly _options: Prompt.Options;
19
21
  constructor(_options: Prompt.Options);
20
22
  /**
21
- * Create a new prompt
23
+ * Two types of prompts can be created - a root prompt or a child prompt (aka Prompt Version in app).
24
+ *
25
+ * A root prompt can be created by providing the `name` param, and it will always be tagged as prod.
26
+ *
27
+ * A child prompt can be created by providing the `parent_id` param. Note that the `name` param in this case will be ignored as all descendents from a root prompt would share the root's name. `is_prod` can also be provided to configure whether a child should be tagged as prod.
22
28
  *
23
29
  * @param {Scorecard.PromptCreateParams} request
24
30
  * @param {Prompt.RequestOptions} requestOptions - Request-specific configuration.
@@ -30,7 +36,7 @@ export declare class Prompt {
30
36
  *
31
37
  * @example
32
38
  * await scorecard.prompt.create({
33
- * promptTemplate: "You are a virtual assistant",
39
+ * promptTemplate: "<system>\nYou are a helpful assistant. Use the provided context to answer the user's query.\n\nContext: {context}\n</system>\n\n<user>\n{user_query}\n</user>",
34
40
  * name: "Prompt Name",
35
41
  * description: "Description of the prompt",
36
42
  * modelParams: {
@@ -43,7 +49,7 @@ export declare class Prompt {
43
49
  *
44
50
  * @example
45
51
  * await scorecard.prompt.create({
46
- * promptTemplate: "You are a virtual assistant",
52
+ * promptTemplate: "<system>\nYou are a helpful assistant. Use the provided context to answer the user's query.\n\nContext: {context}\n</system>\n\n<user>\n{user_query}\n</user>",
47
53
  * parentId: "7ac3cbd5-3b99-4e72-97f3-9cd2e749cace",
48
54
  * description: "Description of the prompt",
49
55
  * modelParams: {
@@ -57,35 +63,24 @@ export declare class Prompt {
57
63
  */
58
64
  create(request: Scorecard.PromptCreateParams, requestOptions?: Prompt.RequestOptions): Promise<Scorecard.Prompt>;
59
65
  /**
60
- * Retrieve active root prompts for the org
61
- *
62
- * @param {Prompt.RequestOptions} requestOptions - Request-specific configuration.
63
- *
64
- * @throws {@link Scorecard.UnauthorizedError}
65
- * @throws {@link Scorecard.ForbiddenError}
66
- * @throws {@link Scorecard.NotFoundError}
67
- *
68
- * @example
69
- * await scorecard.prompt.getRoots()
70
- */
71
- getRoots(requestOptions?: Prompt.RequestOptions): Promise<Scorecard.Prompt[]>;
72
- /**
73
- * Retrieve prod prompts for the org
66
+ * Retrieve a prompt by id
74
67
  *
68
+ * @param {string} id - The id of the prompt to get.
75
69
  * @param {Prompt.RequestOptions} requestOptions - Request-specific configuration.
76
70
  *
77
71
  * @throws {@link Scorecard.UnauthorizedError}
78
72
  * @throws {@link Scorecard.ForbiddenError}
79
73
  * @throws {@link Scorecard.NotFoundError}
74
+ * @throws {@link Scorecard.UnprocessableEntityError}
80
75
  *
81
76
  * @example
82
- * await scorecard.prompt.getProds()
77
+ * await scorecard.prompt.get("id")
83
78
  */
84
- getProds(requestOptions?: Prompt.RequestOptions): Promise<Scorecard.Prompt[]>;
79
+ get(id: string, requestOptions?: Prompt.RequestOptions): Promise<Scorecard.Prompt>;
85
80
  /**
86
- * Retrieve a prompt by id
81
+ * Delete a root prompt and all of its children.
87
82
  *
88
- * @param {string} id - The id of the prompt to get.
83
+ * @param {string} id - The id of the root prompt to delete.
89
84
  * @param {Prompt.RequestOptions} requestOptions - Request-specific configuration.
90
85
  *
91
86
  * @throws {@link Scorecard.UnauthorizedError}
@@ -94,11 +89,13 @@ export declare class Prompt {
94
89
  * @throws {@link Scorecard.UnprocessableEntityError}
95
90
  *
96
91
  * @example
97
- * await scorecard.prompt.get("id")
92
+ * await scorecard.prompt.delete("id")
98
93
  */
99
- get(id: string, requestOptions?: Prompt.RequestOptions): Promise<Scorecard.Prompt>;
94
+ delete(id: string, requestOptions?: Prompt.RequestOptions): Promise<unknown>;
100
95
  /**
101
- * Update a prompt
96
+ * Update a prompt.
97
+ *
98
+ * `is_prod` tags the provided prompt as the production prompt within the prompt graph.
102
99
  *
103
100
  * @param {string} id - The id of the prompt to update.
104
101
  * @param {Scorecard.PromptUpdateParams} request
@@ -111,7 +108,7 @@ export declare class Prompt {
111
108
  *
112
109
  * @example
113
110
  * await scorecard.prompt.update("id", {
114
- * isArchived: true
111
+ * isProd: true
115
112
  * })
116
113
  */
117
114
  update(id: string, request?: Scorecard.PromptUpdateParams, requestOptions?: Prompt.RequestOptions): Promise<Scorecard.Prompt>;
@@ -130,21 +127,6 @@ export declare class Prompt {
130
127
  * await scorecard.prompt.getByName("name")
131
128
  */
132
129
  getByName(name: string, requestOptions?: Prompt.RequestOptions): Promise<Scorecard.Prompt>;
133
- /**
134
- * Retrieve all nodes within the same graph as the prompt, sorted by created_at desc
135
- *
136
- * @param {string} id - The id of the prompt.
137
- * @param {Prompt.RequestOptions} requestOptions - Request-specific configuration.
138
- *
139
- * @throws {@link Scorecard.UnauthorizedError}
140
- * @throws {@link Scorecard.ForbiddenError}
141
- * @throws {@link Scorecard.NotFoundError}
142
- * @throws {@link Scorecard.UnprocessableEntityError}
143
- *
144
- * @example
145
- * await scorecard.prompt.getGraph("id")
146
- */
147
- getGraph(id: string, requestOptions?: Prompt.RequestOptions): Promise<Scorecard.Prompt[]>;
148
130
  protected _getCustomAuthorizationHeaders(): Promise<{
149
131
  "X-API-Key": string;
150
132
  }>;
@@ -50,7 +50,11 @@ class Prompt {
50
50
  this._options = _options;
51
51
  }
52
52
  /**
53
- * Create a new prompt
53
+ * Two types of prompts can be created - a root prompt or a child prompt (aka Prompt Version in app).
54
+ *
55
+ * A root prompt can be created by providing the `name` param, and it will always be tagged as prod.
56
+ *
57
+ * A child prompt can be created by providing the `parent_id` param. Note that the `name` param in this case will be ignored as all descendents from a root prompt would share the root's name. `is_prod` can also be provided to configure whether a child should be tagged as prod.
54
58
  *
55
59
  * @param {Scorecard.PromptCreateParams} request
56
60
  * @param {Prompt.RequestOptions} requestOptions - Request-specific configuration.
@@ -62,7 +66,7 @@ class Prompt {
62
66
  *
63
67
  * @example
64
68
  * await scorecard.prompt.create({
65
- * promptTemplate: "You are a virtual assistant",
69
+ * promptTemplate: "<system>\nYou are a helpful assistant. Use the provided context to answer the user's query.\n\nContext: {context}\n</system>\n\n<user>\n{user_query}\n</user>",
66
70
  * name: "Prompt Name",
67
71
  * description: "Description of the prompt",
68
72
  * modelParams: {
@@ -75,7 +79,7 @@ class Prompt {
75
79
  *
76
80
  * @example
77
81
  * await scorecard.prompt.create({
78
- * promptTemplate: "You are a virtual assistant",
82
+ * promptTemplate: "<system>\nYou are a helpful assistant. Use the provided context to answer the user's query.\n\nContext: {context}\n</system>\n\n<user>\n{user_query}\n</user>",
79
83
  * parentId: "7ac3cbd5-3b99-4e72-97f3-9cd2e749cace",
80
84
  * description: "Description of the prompt",
81
85
  * modelParams: {
@@ -88,16 +92,17 @@ class Prompt {
88
92
  * })
89
93
  */
90
94
  create(request, requestOptions) {
91
- var _a;
95
+ var _a, _b;
92
96
  return __awaiter(this, void 0, void 0, function* () {
93
- const _response = yield core.fetcher({
94
- url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.ScorecardEnvironment.Default, "v1/prompt"),
97
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
98
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.ScorecardEnvironment.Default, "v1/prompt"),
95
99
  method: "POST",
96
- headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.3.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
100
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.5.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
97
101
  contentType: "application/json",
98
102
  body: yield serializers.PromptCreateParams.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
99
103
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
100
104
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
105
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
101
106
  });
102
107
  if (_response.ok) {
103
108
  return yield serializers.Prompt.parseOrThrow(_response.body, {
@@ -165,30 +170,33 @@ class Prompt {
165
170
  });
166
171
  }
167
172
  /**
168
- * Retrieve active root prompts for the org
173
+ * Retrieve a prompt by id
169
174
  *
175
+ * @param {string} id - The id of the prompt to get.
170
176
  * @param {Prompt.RequestOptions} requestOptions - Request-specific configuration.
171
177
  *
172
178
  * @throws {@link Scorecard.UnauthorizedError}
173
179
  * @throws {@link Scorecard.ForbiddenError}
174
180
  * @throws {@link Scorecard.NotFoundError}
181
+ * @throws {@link Scorecard.UnprocessableEntityError}
175
182
  *
176
183
  * @example
177
- * await scorecard.prompt.getRoots()
184
+ * await scorecard.prompt.get("id")
178
185
  */
179
- getRoots(requestOptions) {
180
- var _a;
186
+ get(id, requestOptions) {
187
+ var _a, _b;
181
188
  return __awaiter(this, void 0, void 0, function* () {
182
- const _response = yield core.fetcher({
183
- url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.ScorecardEnvironment.Default, "v1/prompt/roots"),
189
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
190
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.ScorecardEnvironment.Default, `v1/prompt/${encodeURIComponent(id)}`),
184
191
  method: "GET",
185
- headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.3.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
192
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.5.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
186
193
  contentType: "application/json",
187
194
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
188
195
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
196
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
189
197
  });
190
198
  if (_response.ok) {
191
- return yield serializers.prompt.getRoots.Response.parseOrThrow(_response.body, {
199
+ return yield serializers.Prompt.parseOrThrow(_response.body, {
192
200
  unrecognizedObjectKeys: "passthrough",
193
201
  allowUnrecognizedUnionMembers: true,
194
202
  allowUnrecognizedEnumValues: true,
@@ -222,80 +230,8 @@ class Prompt {
222
230
  skipValidation: true,
223
231
  breadcrumbsPrefix: ["response"],
224
232
  }));
225
- default:
226
- throw new errors.ScorecardError({
227
- statusCode: _response.error.statusCode,
228
- body: _response.error.body,
229
- });
230
- }
231
- }
232
- switch (_response.error.reason) {
233
- case "non-json":
234
- throw new errors.ScorecardError({
235
- statusCode: _response.error.statusCode,
236
- body: _response.error.rawBody,
237
- });
238
- case "timeout":
239
- throw new errors.ScorecardTimeoutError();
240
- case "unknown":
241
- throw new errors.ScorecardError({
242
- message: _response.error.errorMessage,
243
- });
244
- }
245
- });
246
- }
247
- /**
248
- * Retrieve prod prompts for the org
249
- *
250
- * @param {Prompt.RequestOptions} requestOptions - Request-specific configuration.
251
- *
252
- * @throws {@link Scorecard.UnauthorizedError}
253
- * @throws {@link Scorecard.ForbiddenError}
254
- * @throws {@link Scorecard.NotFoundError}
255
- *
256
- * @example
257
- * await scorecard.prompt.getProds()
258
- */
259
- getProds(requestOptions) {
260
- var _a;
261
- return __awaiter(this, void 0, void 0, function* () {
262
- const _response = yield core.fetcher({
263
- url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.ScorecardEnvironment.Default, "v1/prompt/prods"),
264
- method: "GET",
265
- headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.3.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
266
- contentType: "application/json",
267
- timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
268
- maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
269
- });
270
- if (_response.ok) {
271
- return yield serializers.prompt.getProds.Response.parseOrThrow(_response.body, {
272
- unrecognizedObjectKeys: "passthrough",
273
- allowUnrecognizedUnionMembers: true,
274
- allowUnrecognizedEnumValues: true,
275
- skipValidation: true,
276
- breadcrumbsPrefix: ["response"],
277
- });
278
- }
279
- if (_response.error.reason === "status-code") {
280
- switch (_response.error.statusCode) {
281
- case 401:
282
- throw new Scorecard.UnauthorizedError(yield serializers.UnauthenticatedError.parseOrThrow(_response.error.body, {
283
- unrecognizedObjectKeys: "passthrough",
284
- allowUnrecognizedUnionMembers: true,
285
- allowUnrecognizedEnumValues: true,
286
- skipValidation: true,
287
- breadcrumbsPrefix: ["response"],
288
- }));
289
- case 403:
290
- throw new Scorecard.ForbiddenError(yield serializers.UnauthorizedErrorBody.parseOrThrow(_response.error.body, {
291
- unrecognizedObjectKeys: "passthrough",
292
- allowUnrecognizedUnionMembers: true,
293
- allowUnrecognizedEnumValues: true,
294
- skipValidation: true,
295
- breadcrumbsPrefix: ["response"],
296
- }));
297
- case 404:
298
- throw new Scorecard.NotFoundError(yield serializers.NotFoundErrorBody.parseOrThrow(_response.error.body, {
233
+ case 422:
234
+ throw new Scorecard.UnprocessableEntityError(yield serializers.HttpValidationError.parseOrThrow(_response.error.body, {
299
235
  unrecognizedObjectKeys: "passthrough",
300
236
  allowUnrecognizedUnionMembers: true,
301
237
  allowUnrecognizedEnumValues: true,
@@ -325,9 +261,9 @@ class Prompt {
325
261
  });
326
262
  }
327
263
  /**
328
- * Retrieve a prompt by id
264
+ * Delete a root prompt and all of its children.
329
265
  *
330
- * @param {string} id - The id of the prompt to get.
266
+ * @param {string} id - The id of the root prompt to delete.
331
267
  * @param {Prompt.RequestOptions} requestOptions - Request-specific configuration.
332
268
  *
333
269
  * @throws {@link Scorecard.UnauthorizedError}
@@ -336,27 +272,22 @@ class Prompt {
336
272
  * @throws {@link Scorecard.UnprocessableEntityError}
337
273
  *
338
274
  * @example
339
- * await scorecard.prompt.get("id")
275
+ * await scorecard.prompt.delete("id")
340
276
  */
341
- get(id, requestOptions) {
342
- var _a;
277
+ delete(id, requestOptions) {
278
+ var _a, _b;
343
279
  return __awaiter(this, void 0, void 0, function* () {
344
- const _response = yield core.fetcher({
345
- url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.ScorecardEnvironment.Default, `v1/prompt/${encodeURIComponent(id)}`),
346
- method: "GET",
347
- headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.3.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
280
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
281
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.ScorecardEnvironment.Default, `v1/prompt/${encodeURIComponent(id)}`),
282
+ method: "DELETE",
283
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.5.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
348
284
  contentType: "application/json",
349
285
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
350
286
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
287
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
351
288
  });
352
289
  if (_response.ok) {
353
- return yield serializers.Prompt.parseOrThrow(_response.body, {
354
- unrecognizedObjectKeys: "passthrough",
355
- allowUnrecognizedUnionMembers: true,
356
- allowUnrecognizedEnumValues: true,
357
- skipValidation: true,
358
- breadcrumbsPrefix: ["response"],
359
- });
290
+ return _response.body;
360
291
  }
361
292
  if (_response.error.reason === "status-code") {
362
293
  switch (_response.error.statusCode) {
@@ -415,7 +346,9 @@ class Prompt {
415
346
  });
416
347
  }
417
348
  /**
418
- * Update a prompt
349
+ * Update a prompt.
350
+ *
351
+ * `is_prod` tags the provided prompt as the production prompt within the prompt graph.
419
352
  *
420
353
  * @param {string} id - The id of the prompt to update.
421
354
  * @param {Scorecard.PromptUpdateParams} request
@@ -428,20 +361,21 @@ class Prompt {
428
361
  *
429
362
  * @example
430
363
  * await scorecard.prompt.update("id", {
431
- * isArchived: true
364
+ * isProd: true
432
365
  * })
433
366
  */
434
367
  update(id, request = {}, requestOptions) {
435
- var _a;
368
+ var _a, _b;
436
369
  return __awaiter(this, void 0, void 0, function* () {
437
- const _response = yield core.fetcher({
438
- url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.ScorecardEnvironment.Default, `v1/prompt/${encodeURIComponent(id)}`),
370
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
371
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.ScorecardEnvironment.Default, `v1/prompt/${encodeURIComponent(id)}`),
439
372
  method: "PATCH",
440
- headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.3.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
373
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.5.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
441
374
  contentType: "application/json",
442
375
  body: yield serializers.PromptUpdateParams.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
443
376
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
444
377
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
378
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
445
379
  });
446
380
  if (_response.ok) {
447
381
  return yield serializers.Prompt.parseOrThrow(_response.body, {
@@ -523,15 +457,16 @@ class Prompt {
523
457
  * await scorecard.prompt.getByName("name")
524
458
  */
525
459
  getByName(name, requestOptions) {
526
- var _a;
460
+ var _a, _b;
527
461
  return __awaiter(this, void 0, void 0, function* () {
528
- const _response = yield core.fetcher({
529
- url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.ScorecardEnvironment.Default, `v1/prompt/name/${encodeURIComponent(name)}`),
462
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
463
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.ScorecardEnvironment.Default, `v1/prompt/name/${encodeURIComponent(name)}`),
530
464
  method: "GET",
531
- headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.3.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
465
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.5.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
532
466
  contentType: "application/json",
533
467
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
534
468
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
469
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
535
470
  });
536
471
  if (_response.ok) {
537
472
  return yield serializers.Prompt.parseOrThrow(_response.body, {
@@ -598,96 +533,6 @@ class Prompt {
598
533
  }
599
534
  });
600
535
  }
601
- /**
602
- * Retrieve all nodes within the same graph as the prompt, sorted by created_at desc
603
- *
604
- * @param {string} id - The id of the prompt.
605
- * @param {Prompt.RequestOptions} requestOptions - Request-specific configuration.
606
- *
607
- * @throws {@link Scorecard.UnauthorizedError}
608
- * @throws {@link Scorecard.ForbiddenError}
609
- * @throws {@link Scorecard.NotFoundError}
610
- * @throws {@link Scorecard.UnprocessableEntityError}
611
- *
612
- * @example
613
- * await scorecard.prompt.getGraph("id")
614
- */
615
- getGraph(id, requestOptions) {
616
- var _a;
617
- return __awaiter(this, void 0, void 0, function* () {
618
- const _response = yield core.fetcher({
619
- url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.ScorecardEnvironment.Default, `v1/prompt/${encodeURIComponent(id)}/graph`),
620
- method: "GET",
621
- headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.3.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
622
- contentType: "application/json",
623
- timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
624
- maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
625
- });
626
- if (_response.ok) {
627
- return yield serializers.prompt.getGraph.Response.parseOrThrow(_response.body, {
628
- unrecognizedObjectKeys: "passthrough",
629
- allowUnrecognizedUnionMembers: true,
630
- allowUnrecognizedEnumValues: true,
631
- skipValidation: true,
632
- breadcrumbsPrefix: ["response"],
633
- });
634
- }
635
- if (_response.error.reason === "status-code") {
636
- switch (_response.error.statusCode) {
637
- case 401:
638
- throw new Scorecard.UnauthorizedError(yield serializers.UnauthenticatedError.parseOrThrow(_response.error.body, {
639
- unrecognizedObjectKeys: "passthrough",
640
- allowUnrecognizedUnionMembers: true,
641
- allowUnrecognizedEnumValues: true,
642
- skipValidation: true,
643
- breadcrumbsPrefix: ["response"],
644
- }));
645
- case 403:
646
- throw new Scorecard.ForbiddenError(yield serializers.UnauthorizedErrorBody.parseOrThrow(_response.error.body, {
647
- unrecognizedObjectKeys: "passthrough",
648
- allowUnrecognizedUnionMembers: true,
649
- allowUnrecognizedEnumValues: true,
650
- skipValidation: true,
651
- breadcrumbsPrefix: ["response"],
652
- }));
653
- case 404:
654
- throw new Scorecard.NotFoundError(yield serializers.NotFoundErrorBody.parseOrThrow(_response.error.body, {
655
- unrecognizedObjectKeys: "passthrough",
656
- allowUnrecognizedUnionMembers: true,
657
- allowUnrecognizedEnumValues: true,
658
- skipValidation: true,
659
- breadcrumbsPrefix: ["response"],
660
- }));
661
- case 422:
662
- throw new Scorecard.UnprocessableEntityError(yield serializers.HttpValidationError.parseOrThrow(_response.error.body, {
663
- unrecognizedObjectKeys: "passthrough",
664
- allowUnrecognizedUnionMembers: true,
665
- allowUnrecognizedEnumValues: true,
666
- skipValidation: true,
667
- breadcrumbsPrefix: ["response"],
668
- }));
669
- default:
670
- throw new errors.ScorecardError({
671
- statusCode: _response.error.statusCode,
672
- body: _response.error.body,
673
- });
674
- }
675
- }
676
- switch (_response.error.reason) {
677
- case "non-json":
678
- throw new errors.ScorecardError({
679
- statusCode: _response.error.statusCode,
680
- body: _response.error.rawBody,
681
- });
682
- case "timeout":
683
- throw new errors.ScorecardTimeoutError();
684
- case "unknown":
685
- throw new errors.ScorecardError({
686
- message: _response.error.errorMessage,
687
- });
688
- }
689
- });
690
- }
691
536
  _getCustomAuthorizationHeaders() {
692
537
  var _a;
693
538
  return __awaiter(this, void 0, void 0, function* () {
@@ -5,7 +5,7 @@ import * as Scorecard from "../../../../index";
5
5
  /**
6
6
  * @example
7
7
  * {
8
- * promptTemplate: "You are a virtual assistant",
8
+ * promptTemplate: "<system>\nYou are a helpful assistant. Use the provided context to answer the user's query.\n\nContext: {context}\n</system>\n\n<user>\n{user_query}\n</user>",
9
9
  * name: "Prompt Name",
10
10
  * description: "Description of the prompt",
11
11
  * modelParams: {
@@ -18,7 +18,7 @@ import * as Scorecard from "../../../../index";
18
18
  *
19
19
  * @example
20
20
  * {
21
- * promptTemplate: "You are a virtual assistant",
21
+ * promptTemplate: "<system>\nYou are a helpful assistant. Use the provided context to answer the user's query.\n\nContext: {context}\n</system>\n\n<user>\n{user_query}\n</user>",
22
22
  * parentId: "7ac3cbd5-3b99-4e72-97f3-9cd2e749cace",
23
23
  * description: "Description of the prompt",
24
24
  * modelParams: {
@@ -4,10 +4,9 @@
4
4
  /**
5
5
  * @example
6
6
  * {
7
- * isArchived: true
7
+ * isProd: true
8
8
  * }
9
9
  */
10
10
  export interface PromptUpdateParams {
11
- isArchived?: boolean;
12
11
  isProd?: boolean;
13
12
  }
@@ -8,10 +8,12 @@ export declare namespace Run {
8
8
  interface Options {
9
9
  environment?: core.Supplier<environments.ScorecardEnvironment | string>;
10
10
  apiKey: core.Supplier<string>;
11
+ fetcher?: core.FetchFunction;
11
12
  }
12
13
  interface RequestOptions {
13
14
  timeoutInSeconds?: number;
14
15
  maxRetries?: number;
16
+ abortSignal?: AbortSignal;
15
17
  }
16
18
  }
17
19
  export declare class Run {
@@ -29,15 +31,7 @@ export declare class Run {
29
31
  * @throws {@link Scorecard.UnprocessableEntityError}
30
32
  *
31
33
  * @example
32
- * await scorecard.run.create({
33
- * testsetId: 1,
34
- * status: "RUNNING_EXECUTION",
35
- * modelParams: {
36
- * "param1": "value1",
37
- * "param2": "value2"
38
- * },
39
- * metrics: [1, 2]
40
- * })
34
+ * await scorecard.run.create()
41
35
  */
42
36
  create(request?: Scorecard.RunCreateParams, requestOptions?: Run.RequestOptions): Promise<Scorecard.Run>;
43
37
  /**
@@ -68,11 +62,9 @@ export declare class Run {
68
62
  * @throws {@link Scorecard.UnprocessableEntityError}
69
63
  *
70
64
  * @example
71
- * await scorecard.run.updateStatus(1, {
72
- * status: Scorecard.RunStatus.Pending
73
- * })
65
+ * await scorecard.run.updateStatus(1)
74
66
  */
75
- updateStatus(runId: number, request: Scorecard.UpdateStatusParams, requestOptions?: Run.RequestOptions): Promise<Scorecard.Run>;
67
+ updateStatus(runId: number, request?: Scorecard.UpdateStatusParams, requestOptions?: Run.RequestOptions): Promise<Scorecard.Run>;
76
68
  protected _getCustomAuthorizationHeaders(): Promise<{
77
69
  "X-API-Key": string;
78
70
  }>;