notdiamond 2.0.0-rc2 → 2.0.0-rc4

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 (167) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +14 -16
  3. package/client.d.mts +21 -35
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +21 -35
  6. package/client.d.ts.map +1 -1
  7. package/client.js +23 -39
  8. package/client.js.map +1 -1
  9. package/client.mjs +23 -39
  10. package/client.mjs.map +1 -1
  11. package/internal/tslib.js +17 -17
  12. package/internal/utils/env.d.mts.map +1 -1
  13. package/internal/utils/env.d.ts.map +1 -1
  14. package/internal/utils/env.js +4 -2
  15. package/internal/utils/env.js.map +1 -1
  16. package/internal/utils/env.mjs +4 -2
  17. package/internal/utils/env.mjs.map +1 -1
  18. package/package.json +10 -11
  19. package/resources/index.d.mts +6 -6
  20. package/resources/index.d.mts.map +1 -1
  21. package/resources/index.d.ts +6 -6
  22. package/resources/index.d.ts.map +1 -1
  23. package/resources/index.js +8 -8
  24. package/resources/index.js.map +1 -1
  25. package/resources/index.mjs +4 -4
  26. package/resources/index.mjs.map +1 -1
  27. package/resources/model-router.d.mts +311 -0
  28. package/resources/model-router.d.mts.map +1 -0
  29. package/resources/model-router.d.ts +311 -0
  30. package/resources/model-router.d.ts.map +1 -0
  31. package/resources/model-router.js +97 -0
  32. package/resources/model-router.js.map +1 -0
  33. package/resources/model-router.mjs +93 -0
  34. package/resources/model-router.mjs.map +1 -0
  35. package/resources/models.d.mts +50 -25
  36. package/resources/models.d.mts.map +1 -1
  37. package/resources/models.d.ts +50 -25
  38. package/resources/models.d.ts.map +1 -1
  39. package/resources/models.js +5 -0
  40. package/resources/models.js.map +1 -1
  41. package/resources/models.mjs +5 -0
  42. package/resources/models.mjs.map +1 -1
  43. package/resources/preferences.d.mts +49 -47
  44. package/resources/preferences.d.mts.map +1 -1
  45. package/resources/preferences.d.ts +49 -47
  46. package/resources/preferences.d.ts.map +1 -1
  47. package/resources/preferences.js +30 -33
  48. package/resources/preferences.js.map +1 -1
  49. package/resources/preferences.mjs +30 -33
  50. package/resources/preferences.mjs.map +1 -1
  51. package/resources/prompt/adapt.d.mts +352 -0
  52. package/resources/prompt/adapt.d.mts.map +1 -0
  53. package/resources/prompt/adapt.d.ts +352 -0
  54. package/resources/prompt/adapt.d.ts.map +1 -0
  55. package/resources/prompt/adapt.js +154 -0
  56. package/resources/prompt/adapt.js.map +1 -0
  57. package/resources/prompt/adapt.mjs +150 -0
  58. package/resources/prompt/adapt.mjs.map +1 -0
  59. package/resources/prompt/index.d.mts +3 -0
  60. package/resources/prompt/index.d.mts.map +1 -0
  61. package/resources/prompt/index.d.ts +3 -0
  62. package/resources/prompt/index.d.ts.map +1 -0
  63. package/resources/prompt/index.js +9 -0
  64. package/resources/prompt/index.js.map +1 -0
  65. package/resources/prompt/index.mjs +4 -0
  66. package/resources/prompt/index.mjs.map +1 -0
  67. package/resources/prompt/prompt.d.mts +338 -0
  68. package/resources/prompt/prompt.d.mts.map +1 -0
  69. package/resources/prompt/prompt.d.ts +338 -0
  70. package/resources/prompt/prompt.d.ts.map +1 -0
  71. package/resources/prompt/prompt.js +128 -0
  72. package/resources/prompt/prompt.js.map +1 -0
  73. package/resources/prompt/prompt.mjs +123 -0
  74. package/resources/prompt/prompt.mjs.map +1 -0
  75. package/resources/prompt.d.mts +2 -0
  76. package/resources/prompt.d.mts.map +1 -0
  77. package/resources/prompt.d.ts +2 -0
  78. package/resources/prompt.d.ts.map +1 -0
  79. package/resources/prompt.js +6 -0
  80. package/resources/prompt.js.map +1 -0
  81. package/resources/prompt.mjs +3 -0
  82. package/resources/prompt.mjs.map +1 -0
  83. package/resources/pzn.d.mts +225 -0
  84. package/resources/pzn.d.mts.map +1 -0
  85. package/resources/pzn.d.ts +225 -0
  86. package/resources/pzn.d.ts.map +1 -0
  87. package/resources/{routing.js → pzn.js} +26 -69
  88. package/resources/pzn.js.map +1 -0
  89. package/resources/{routing.mjs → pzn.mjs} +24 -67
  90. package/resources/pzn.mjs.map +1 -0
  91. package/resources/report/index.d.mts +3 -0
  92. package/resources/report/index.d.mts.map +1 -0
  93. package/resources/report/index.d.ts +3 -0
  94. package/resources/report/index.d.ts.map +1 -0
  95. package/resources/report/index.js +9 -0
  96. package/resources/report/index.js.map +1 -0
  97. package/resources/report/index.mjs +4 -0
  98. package/resources/report/index.mjs.map +1 -0
  99. package/resources/report/metrics.d.mts +87 -0
  100. package/resources/report/metrics.d.mts.map +1 -0
  101. package/resources/report/metrics.d.ts +87 -0
  102. package/resources/report/metrics.d.ts.map +1 -0
  103. package/resources/report/metrics.js +57 -0
  104. package/resources/report/metrics.js.map +1 -0
  105. package/resources/report/metrics.mjs +53 -0
  106. package/resources/report/metrics.mjs.map +1 -0
  107. package/resources/report/report.d.mts +10 -0
  108. package/resources/report/report.d.mts.map +1 -0
  109. package/resources/report/report.d.ts +10 -0
  110. package/resources/report/report.d.ts.map +1 -0
  111. package/resources/report/report.js +17 -0
  112. package/resources/report/report.js.map +1 -0
  113. package/resources/report/report.mjs +12 -0
  114. package/resources/report/report.mjs.map +1 -0
  115. package/resources/report.d.mts +1 -244
  116. package/resources/report.d.mts.map +1 -1
  117. package/resources/report.d.ts +1 -244
  118. package/resources/report.d.ts.map +1 -1
  119. package/resources/report.js +2 -82
  120. package/resources/report.js.map +1 -1
  121. package/resources/report.mjs +1 -80
  122. package/resources/report.mjs.map +1 -1
  123. package/src/client.ts +71 -120
  124. package/src/internal/utils/env.ts +4 -2
  125. package/src/resources/index.ts +24 -34
  126. package/src/resources/model-router.ts +356 -0
  127. package/src/resources/models.ts +55 -32
  128. package/src/resources/preferences.ts +61 -70
  129. package/src/resources/prompt/adapt.ts +402 -0
  130. package/src/resources/prompt/index.ts +16 -0
  131. package/src/resources/prompt/prompt.ts +398 -0
  132. package/src/resources/prompt.ts +3 -0
  133. package/src/resources/pzn.ts +273 -0
  134. package/src/resources/report/index.ts +4 -0
  135. package/src/resources/report/metrics.ts +99 -0
  136. package/src/resources/report/report.ts +19 -0
  137. package/src/resources/report.ts +1 -298
  138. package/src/version.ts +1 -1
  139. package/version.d.mts +1 -1
  140. package/version.d.ts +1 -1
  141. package/version.js +1 -1
  142. package/version.mjs +1 -1
  143. package/resources/admin.d.mts +0 -4
  144. package/resources/admin.d.mts.map +0 -1
  145. package/resources/admin.d.ts +0 -4
  146. package/resources/admin.d.ts.map +0 -1
  147. package/resources/admin.js +0 -9
  148. package/resources/admin.js.map +0 -1
  149. package/resources/admin.mjs +0 -5
  150. package/resources/admin.mjs.map +0 -1
  151. package/resources/prompt-adaptation.d.mts +0 -581
  152. package/resources/prompt-adaptation.d.mts.map +0 -1
  153. package/resources/prompt-adaptation.d.ts +0 -581
  154. package/resources/prompt-adaptation.d.ts.map +0 -1
  155. package/resources/prompt-adaptation.js +0 -289
  156. package/resources/prompt-adaptation.js.map +0 -1
  157. package/resources/prompt-adaptation.mjs +0 -285
  158. package/resources/prompt-adaptation.mjs.map +0 -1
  159. package/resources/routing.d.mts +0 -391
  160. package/resources/routing.d.mts.map +0 -1
  161. package/resources/routing.d.ts +0 -391
  162. package/resources/routing.d.ts.map +0 -1
  163. package/resources/routing.js.map +0 -1
  164. package/resources/routing.mjs.map +0 -1
  165. package/src/resources/admin.ts +0 -5
  166. package/src/resources/prompt-adaptation.ts +0 -707
  167. package/src/resources/routing.ts +0 -476
@@ -0,0 +1,338 @@
1
+ import { APIResource } from "../../core/resource.js";
2
+ import * as PromptAPI from "./prompt.js";
3
+ import * as AdaptAPI from "./adapt.js";
4
+ import { Adapt, AdaptCreateParams, AdaptCreateResponse, AdaptGetCostsResponse, GoldenRecord, RequestProvider } from "./adapt.js";
5
+ import { APIPromise } from "../../core/api-promise.js";
6
+ import { RequestOptions } from "../../internal/request-options.js";
7
+ export declare class Prompt extends APIResource {
8
+ adapt: AdaptAPI.Adapt;
9
+ /**
10
+ * Retrieve the complete results of a prompt adaptation run, including optimized
11
+ * prompts for all target models.
12
+ *
13
+ * This endpoint returns the adapted prompts and evaluation metrics for each target
14
+ * model in your adaptation request. Call this endpoint after the adaptation status
15
+ * is 'completed' to get your optimized prompts.
16
+ *
17
+ * **Response Structure:**
18
+ *
19
+ * - **origin_model**: Baseline performance of your original prompt on the origin
20
+ * model
21
+ * - Includes: system_prompt, user_message_template, score, evaluation metrics,
22
+ * cost
23
+ * - **target_models**: Array of results for each target model
24
+ * - Includes: optimized system_prompt, user_message_template, template_fields
25
+ * - pre_optimization_score: Performance before adaptation
26
+ * - post_optimization_score: Performance after adaptation
27
+ * - Evaluation metrics and cost information
28
+ *
29
+ * **Using Adapted Prompts:**
30
+ *
31
+ * 1. Extract the `system_prompt` and `user_message_template` from each target
32
+ * model result
33
+ * 2. Use `user_message_template_fields` to know which fields to substitute
34
+ * 3. Apply the optimized prompts when calling the respective target models
35
+ * 4. Compare pre/post optimization scores to see improvement
36
+ *
37
+ * **Evaluation Scores:**
38
+ *
39
+ * - Scores range from 0-10 (higher is better)
40
+ * - Compare origin_model score with target_models pre_optimization_score for
41
+ * baseline
42
+ * - Compare pre_optimization_score with post_optimization_score to see improvement
43
+ * from adaptation
44
+ * - Typical improvements range from 5-30% on evaluation metrics
45
+ *
46
+ * **Status Handling:**
47
+ *
48
+ * - If adaptation is still processing, target model results will have
49
+ * `result_status: "processing"`
50
+ * - Only completed target models will have system_prompt and template values
51
+ * - Failed target models will have `result_status: "failed"` with null values
52
+ *
53
+ * **Cost Information:**
54
+ *
55
+ * - Each model result includes cost in USD for the adaptation process
56
+ * - Costs vary based on model pricing and number of evaluation examples
57
+ * - Typical range: $0.10 - $2.00 per target model
58
+ *
59
+ * **Best Practices:**
60
+ *
61
+ * 1. Wait for status 'completed' before calling this endpoint
62
+ * 2. Check result_status for each target model
63
+ * 3. Validate that post_optimization_score > pre_optimization_score
64
+ * 4. Save optimized prompts for production use
65
+ * 5. A/B test adapted prompts against originals in production
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const response = await client.prompt.getAdaptResults(
70
+ * 'adaptation_run_id',
71
+ * );
72
+ * ```
73
+ */
74
+ getAdaptResults(adaptationRunID: string, options?: RequestOptions): APIPromise<PromptGetAdaptResultsResponse>;
75
+ /**
76
+ * Check the status of a prompt adaptation run.
77
+ *
78
+ * Use this endpoint to poll the status of your adaptation request. Processing is
79
+ * asynchronous, so you'll need to check periodically until the status indicates
80
+ * completion.
81
+ *
82
+ * **Status Values:**
83
+ *
84
+ * - `created`: Initial state, not yet processing
85
+ * - `queued`: Waiting for processing capacity (check queue_position)
86
+ * - `processing`: Currently optimizing prompts
87
+ * - `completed`: All target models have been processed successfully
88
+ * - `failed`: One or more target models failed to process
89
+ *
90
+ * **Polling Recommendations:**
91
+ *
92
+ * - Poll every 30-60 seconds during processing
93
+ * - Check queue_position if status is 'queued' to estimate wait time
94
+ * - Stop polling once status is 'completed' or 'failed'
95
+ * - Use GET /v2/prompt/adaptResults to retrieve results after completion
96
+ *
97
+ * **Queue Position:**
98
+ *
99
+ * - Only present when status is 'queued'
100
+ * - Lower numbers mean earlier processing (position 1 is next)
101
+ * - Typical wait time: 1-5 minutes per position
102
+ *
103
+ * **Note:** This endpoint only returns status information. To get the actual
104
+ * adapted prompts and evaluation results, use GET /v2/prompt/adaptResults once
105
+ * status is 'completed'.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * const response = await client.prompt.getAdaptStatus(
110
+ * 'adaptation_run_id',
111
+ * );
112
+ * ```
113
+ */
114
+ getAdaptStatus(adaptationRunID: string, options?: RequestOptions): APIPromise<PromptGetAdaptStatusResponse>;
115
+ }
116
+ /**
117
+ * Status enum for asynchronous jobs (prompt adaptation, custom router training,
118
+ * etc.).
119
+ *
120
+ * Represents the current state of a long-running operation:
121
+ *
122
+ * - **created**: Job has been initialized but not yet queued
123
+ * - **queued**: Job is waiting in the queue to be processed
124
+ * - **processing**: Job is currently being executed
125
+ * - **completed**: Job finished successfully and results are available
126
+ * - **failed**: Job encountered an error and did not complete
127
+ */
128
+ export type JobStatus = 'created' | 'queued' | 'processing' | 'completed' | 'failed';
129
+ /**
130
+ * Response model for GET /v2/prompt/adaptResults/{adaptation_run_id} endpoint.
131
+ *
132
+ * Contains the complete results of a prompt adaptation run, including optimized
133
+ * prompts and evaluation metrics for all target models. Use this to retrieve your
134
+ * adapted prompts after the adaptation status is 'completed'.
135
+ *
136
+ * The response includes:
137
+ *
138
+ * - Baseline performance of your original prompt on the origin model
139
+ * - Optimized prompts for each target model with pre/post optimization scores
140
+ * - Evaluation metrics and cost information for each model
141
+ */
142
+ export interface PromptGetAdaptResultsResponse {
143
+ /**
144
+ * Unique ID for this adaptation run
145
+ */
146
+ id: string;
147
+ /**
148
+ * Timestamp when this adaptation run was created
149
+ */
150
+ created_at: string;
151
+ /**
152
+ * Overall status of the adaptation run (queued, running, completed, failed)
153
+ */
154
+ job_status: JobStatus;
155
+ /**
156
+ * Results for each target model with optimized prompts and improvement scores
157
+ */
158
+ target_models: Array<PromptGetAdaptResultsResponse.TargetModel>;
159
+ /**
160
+ * Timestamp of last update to this adaptation run
161
+ */
162
+ updated_at: string | null;
163
+ evaluation_config?: string | null;
164
+ evaluation_metric?: string | null;
165
+ /**
166
+ * Metrics for the LLM requests made during the adaptation run (e.g.,
167
+ * total_requests, avg_latency)
168
+ */
169
+ llm_request_metrics?: {
170
+ [key: string]: number;
171
+ };
172
+ /**
173
+ * Baseline results for the origin model in prompt adaptation.
174
+ *
175
+ * Part of AdaptationRunResultsResponse. Contains the performance metrics and
176
+ * prompt configuration for your original prompt on the origin model. This serves
177
+ * as the baseline to compare against optimized prompts for target models.
178
+ *
179
+ * **Fields include:**
180
+ *
181
+ * - Original system prompt and user message template
182
+ * - Baseline performance score and evaluation metrics
183
+ * - Cost of running the baseline evaluation
184
+ * - Job status for the origin model evaluation
185
+ */
186
+ origin_model?: PromptGetAdaptResultsResponse.OriginModel | null;
187
+ }
188
+ export declare namespace PromptGetAdaptResultsResponse {
189
+ /**
190
+ * Optimized prompt results for a single target model in prompt adaptation.
191
+ *
192
+ * Part of AdaptationRunResultsResponse. Contains the optimized system prompt and
193
+ * user message template for a specific target model, along with performance scores
194
+ * before and after optimization. Use these optimized prompts with the target model
195
+ * to achieve better performance than the original prompt.
196
+ *
197
+ * **Key metrics:**
198
+ *
199
+ * - **pre_optimization_score**: Performance with original prompt on this target
200
+ * model
201
+ * - **post_optimization_score**: Performance with optimized prompt on this target
202
+ * model
203
+ * - **Score improvement**: post - pre shows how much optimization helped
204
+ *
205
+ * **Usage:**
206
+ *
207
+ * 1. Extract the optimized system_prompt and user_message_template
208
+ * 2. Replace placeholders in user_message_template using fields from your data
209
+ * 3. Use these prompts when calling this target model
210
+ * 4. Compare pre/post scores to see improvement gained
211
+ */
212
+ interface TargetModel {
213
+ cost: number | null;
214
+ model_name: string;
215
+ post_optimization_evals: {
216
+ [key: string]: unknown;
217
+ } | null;
218
+ post_optimization_score: number | null;
219
+ pre_optimization_evals: {
220
+ [key: string]: unknown;
221
+ } | null;
222
+ pre_optimization_score: number | null;
223
+ task_type: string | null;
224
+ /**
225
+ * Status enum for asynchronous jobs (prompt adaptation, custom router training,
226
+ * etc.).
227
+ *
228
+ * Represents the current state of a long-running operation:
229
+ *
230
+ * - **created**: Job has been initialized but not yet queued
231
+ * - **queued**: Job is waiting in the queue to be processed
232
+ * - **processing**: Job is currently being executed
233
+ * - **completed**: Job finished successfully and results are available
234
+ * - **failed**: Job encountered an error and did not complete
235
+ */
236
+ result_status?: PromptAPI.JobStatus | null;
237
+ /**
238
+ * Optimized system prompt for this target model. Use this as the system message in
239
+ * your LLM calls
240
+ */
241
+ system_prompt?: string | null;
242
+ /**
243
+ * Optimized user message template with placeholders. Substitute fields using your
244
+ * data before calling the LLM
245
+ */
246
+ user_message_template?: string | null;
247
+ /**
248
+ * List of field names to substitute in the template (e.g., ['question',
249
+ * 'context']). These match the curly-brace placeholders in user_message_template
250
+ */
251
+ user_message_template_fields?: Array<string> | null;
252
+ }
253
+ /**
254
+ * Baseline results for the origin model in prompt adaptation.
255
+ *
256
+ * Part of AdaptationRunResultsResponse. Contains the performance metrics and
257
+ * prompt configuration for your original prompt on the origin model. This serves
258
+ * as the baseline to compare against optimized prompts for target models.
259
+ *
260
+ * **Fields include:**
261
+ *
262
+ * - Original system prompt and user message template
263
+ * - Baseline performance score and evaluation metrics
264
+ * - Cost of running the baseline evaluation
265
+ * - Job status for the origin model evaluation
266
+ */
267
+ interface OriginModel {
268
+ cost: number | null;
269
+ evals: {
270
+ [key: string]: unknown;
271
+ } | null;
272
+ model_name: string | null;
273
+ score: number | null;
274
+ /**
275
+ * Status enum for asynchronous jobs (prompt adaptation, custom router training,
276
+ * etc.).
277
+ *
278
+ * Represents the current state of a long-running operation:
279
+ *
280
+ * - **created**: Job has been initialized but not yet queued
281
+ * - **queued**: Job is waiting in the queue to be processed
282
+ * - **processing**: Job is currently being executed
283
+ * - **completed**: Job finished successfully and results are available
284
+ * - **failed**: Job encountered an error and did not complete
285
+ */
286
+ result_status?: PromptAPI.JobStatus | null;
287
+ /**
288
+ * Original system prompt used for the origin model
289
+ */
290
+ system_prompt?: string | null;
291
+ /**
292
+ * Original user message template used for the origin model
293
+ */
294
+ user_message_template?: string | null;
295
+ }
296
+ }
297
+ /**
298
+ * Response model for GET /v2/prompt/adaptStatus/{adaptation_run_id} endpoint.
299
+ *
300
+ * Returns the current status of an asynchronous prompt adaptation job. Poll this
301
+ * endpoint periodically to track progress. When status is 'completed', you can
302
+ * retrieve the optimized prompts using the /adaptResults endpoint.
303
+ *
304
+ * **Status values:**
305
+ *
306
+ * - **created**: Job has been initialized
307
+ * - **queued**: Waiting in queue (check queue_position for your place in line)
308
+ * - **processing**: Currently running optimization
309
+ * - **completed**: Finished successfully, results available via /adaptResults
310
+ * - **failed**: Encountered an error during processing
311
+ *
312
+ * **Polling recommendations:**
313
+ *
314
+ * - Poll every 30-60 seconds while status is incomplete
315
+ * - Stop polling once status is 'completed' or 'failed'
316
+ * - Adaptation typically takes 10-30 minutes total
317
+ */
318
+ export interface PromptGetAdaptStatusResponse {
319
+ /**
320
+ * Unique identifier for this adaptation run. Use this to poll status and retrieve
321
+ * optimized prompts when complete
322
+ */
323
+ adaptation_run_id: string;
324
+ /**
325
+ * Current status of the adaptation run. Poll until this is 'completed' or 'failed'
326
+ */
327
+ status: JobStatus;
328
+ /**
329
+ * Position in queue when status is 'queued'. Lower numbers process sooner. Null
330
+ * when not queued
331
+ */
332
+ queue_position?: number | null;
333
+ }
334
+ export declare namespace Prompt {
335
+ export { type JobStatus as JobStatus, type PromptGetAdaptResultsResponse as PromptGetAdaptResultsResponse, type PromptGetAdaptStatusResponse as PromptGetAdaptStatusResponse, };
336
+ export { Adapt as Adapt, type GoldenRecord as GoldenRecord, type RequestProvider as RequestProvider, type AdaptCreateResponse as AdaptCreateResponse, type AdaptGetCostsResponse as AdaptGetCostsResponse, type AdaptCreateParams as AdaptCreateParams, };
337
+ }
338
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/resources/prompt/prompt.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,SAAS;OACd,KAAK,QAAQ;OACb,EACL,KAAK,EACL,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EAChB;OACM,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAGzB,qBAAa,MAAO,SAAQ,WAAW;IACrC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAoC;IAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgEG;IACH,eAAe,CACb,eAAe,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,6BAA6B,CAAC;IAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,cAAc,CACZ,eAAe,EAAE,M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KAAK,IAAI,KAAK,EACd,KAAK,YAAY,IAAI,YAAY,EACjC,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,iBAAiB,IAAI,iBAAiB,GAC5C,CAAC;CACH"}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Prompt = void 0;
5
+ const tslib_1 = require("../../internal/tslib.js");
6
+ const resource_1 = require("../../core/resource.js");
7
+ const AdaptAPI = tslib_1.__importStar(require("./adapt.js"));
8
+ const adapt_1 = require("./adapt.js");
9
+ const path_1 = require("../../internal/utils/path.js");
10
+ class Prompt extends resource_1.APIResource {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.adapt = new AdaptAPI.Adapt(this._client);
14
+ }
15
+ /**
16
+ * Retrieve the complete results of a prompt adaptation run, including optimized
17
+ * prompts for all target models.
18
+ *
19
+ * This endpoint returns the adapted prompts and evaluation metrics for each target
20
+ * model in your adaptation request. Call this endpoint after the adaptation status
21
+ * is 'completed' to get your optimized prompts.
22
+ *
23
+ * **Response Structure:**
24
+ *
25
+ * - **origin_model**: Baseline performance of your original prompt on the origin
26
+ * model
27
+ * - Includes: system_prompt, user_message_template, score, evaluation metrics,
28
+ * cost
29
+ * - **target_models**: Array of results for each target model
30
+ * - Includes: optimized system_prompt, user_message_template, template_fields
31
+ * - pre_optimization_score: Performance before adaptation
32
+ * - post_optimization_score: Performance after adaptation
33
+ * - Evaluation metrics and cost information
34
+ *
35
+ * **Using Adapted Prompts:**
36
+ *
37
+ * 1. Extract the `system_prompt` and `user_message_template` from each target
38
+ * model result
39
+ * 2. Use `user_message_template_fields` to know which fields to substitute
40
+ * 3. Apply the optimized prompts when calling the respective target models
41
+ * 4. Compare pre/post optimization scores to see improvement
42
+ *
43
+ * **Evaluation Scores:**
44
+ *
45
+ * - Scores range from 0-10 (higher is better)
46
+ * - Compare origin_model score with target_models pre_optimization_score for
47
+ * baseline
48
+ * - Compare pre_optimization_score with post_optimization_score to see improvement
49
+ * from adaptation
50
+ * - Typical improvements range from 5-30% on evaluation metrics
51
+ *
52
+ * **Status Handling:**
53
+ *
54
+ * - If adaptation is still processing, target model results will have
55
+ * `result_status: "processing"`
56
+ * - Only completed target models will have system_prompt and template values
57
+ * - Failed target models will have `result_status: "failed"` with null values
58
+ *
59
+ * **Cost Information:**
60
+ *
61
+ * - Each model result includes cost in USD for the adaptation process
62
+ * - Costs vary based on model pricing and number of evaluation examples
63
+ * - Typical range: $0.10 - $2.00 per target model
64
+ *
65
+ * **Best Practices:**
66
+ *
67
+ * 1. Wait for status 'completed' before calling this endpoint
68
+ * 2. Check result_status for each target model
69
+ * 3. Validate that post_optimization_score > pre_optimization_score
70
+ * 4. Save optimized prompts for production use
71
+ * 5. A/B test adapted prompts against originals in production
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * const response = await client.prompt.getAdaptResults(
76
+ * 'adaptation_run_id',
77
+ * );
78
+ * ```
79
+ */
80
+ getAdaptResults(adaptationRunID, options) {
81
+ return this._client.get((0, path_1.path) `/v2/prompt/adaptResults/${adaptationRunID}`, options);
82
+ }
83
+ /**
84
+ * Check the status of a prompt adaptation run.
85
+ *
86
+ * Use this endpoint to poll the status of your adaptation request. Processing is
87
+ * asynchronous, so you'll need to check periodically until the status indicates
88
+ * completion.
89
+ *
90
+ * **Status Values:**
91
+ *
92
+ * - `created`: Initial state, not yet processing
93
+ * - `queued`: Waiting for processing capacity (check queue_position)
94
+ * - `processing`: Currently optimizing prompts
95
+ * - `completed`: All target models have been processed successfully
96
+ * - `failed`: One or more target models failed to process
97
+ *
98
+ * **Polling Recommendations:**
99
+ *
100
+ * - Poll every 30-60 seconds during processing
101
+ * - Check queue_position if status is 'queued' to estimate wait time
102
+ * - Stop polling once status is 'completed' or 'failed'
103
+ * - Use GET /v2/prompt/adaptResults to retrieve results after completion
104
+ *
105
+ * **Queue Position:**
106
+ *
107
+ * - Only present when status is 'queued'
108
+ * - Lower numbers mean earlier processing (position 1 is next)
109
+ * - Typical wait time: 1-5 minutes per position
110
+ *
111
+ * **Note:** This endpoint only returns status information. To get the actual
112
+ * adapted prompts and evaluation results, use GET /v2/prompt/adaptResults once
113
+ * status is 'completed'.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const response = await client.prompt.getAdaptStatus(
118
+ * 'adaptation_run_id',
119
+ * );
120
+ * ```
121
+ */
122
+ getAdaptStatus(adaptationRunID, options) {
123
+ return this._client.get((0, path_1.path) `/v2/prompt/adaptStatus/${adaptationRunID}`, options);
124
+ }
125
+ }
126
+ exports.Prompt = Prompt;
127
+ Prompt.Adapt = adapt_1.Adapt;
128
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/resources/prompt/prompt.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,qDAAkD;AAElD,6DAAoC;AACpC,sCAOiB;AAGjB,uDAAiD;AAEjD,MAAa,MAAO,SAAQ,sBAAW;IAAvC;;QACE,UAAK,GAAmB,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAuH3D,CAAC;IArHC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgEG;IACH,eAAe,CACb,eAAuB,EACvB,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,2BAA2B,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,cAAc,CACZ,eAAuB,EACvB,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,0BAA0B,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC;CACF;AAxHD,wBAwHC;AAmPD,MAAM,CAAC,KAAK,GAAG,aAAK,CAAC"}
@@ -0,0 +1,123 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { APIResource } from "../../core/resource.mjs";
3
+ import * as AdaptAPI from "./adapt.mjs";
4
+ import { Adapt, } from "./adapt.mjs";
5
+ import { path } from "../../internal/utils/path.mjs";
6
+ export class Prompt extends APIResource {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.adapt = new AdaptAPI.Adapt(this._client);
10
+ }
11
+ /**
12
+ * Retrieve the complete results of a prompt adaptation run, including optimized
13
+ * prompts for all target models.
14
+ *
15
+ * This endpoint returns the adapted prompts and evaluation metrics for each target
16
+ * model in your adaptation request. Call this endpoint after the adaptation status
17
+ * is 'completed' to get your optimized prompts.
18
+ *
19
+ * **Response Structure:**
20
+ *
21
+ * - **origin_model**: Baseline performance of your original prompt on the origin
22
+ * model
23
+ * - Includes: system_prompt, user_message_template, score, evaluation metrics,
24
+ * cost
25
+ * - **target_models**: Array of results for each target model
26
+ * - Includes: optimized system_prompt, user_message_template, template_fields
27
+ * - pre_optimization_score: Performance before adaptation
28
+ * - post_optimization_score: Performance after adaptation
29
+ * - Evaluation metrics and cost information
30
+ *
31
+ * **Using Adapted Prompts:**
32
+ *
33
+ * 1. Extract the `system_prompt` and `user_message_template` from each target
34
+ * model result
35
+ * 2. Use `user_message_template_fields` to know which fields to substitute
36
+ * 3. Apply the optimized prompts when calling the respective target models
37
+ * 4. Compare pre/post optimization scores to see improvement
38
+ *
39
+ * **Evaluation Scores:**
40
+ *
41
+ * - Scores range from 0-10 (higher is better)
42
+ * - Compare origin_model score with target_models pre_optimization_score for
43
+ * baseline
44
+ * - Compare pre_optimization_score with post_optimization_score to see improvement
45
+ * from adaptation
46
+ * - Typical improvements range from 5-30% on evaluation metrics
47
+ *
48
+ * **Status Handling:**
49
+ *
50
+ * - If adaptation is still processing, target model results will have
51
+ * `result_status: "processing"`
52
+ * - Only completed target models will have system_prompt and template values
53
+ * - Failed target models will have `result_status: "failed"` with null values
54
+ *
55
+ * **Cost Information:**
56
+ *
57
+ * - Each model result includes cost in USD for the adaptation process
58
+ * - Costs vary based on model pricing and number of evaluation examples
59
+ * - Typical range: $0.10 - $2.00 per target model
60
+ *
61
+ * **Best Practices:**
62
+ *
63
+ * 1. Wait for status 'completed' before calling this endpoint
64
+ * 2. Check result_status for each target model
65
+ * 3. Validate that post_optimization_score > pre_optimization_score
66
+ * 4. Save optimized prompts for production use
67
+ * 5. A/B test adapted prompts against originals in production
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const response = await client.prompt.getAdaptResults(
72
+ * 'adaptation_run_id',
73
+ * );
74
+ * ```
75
+ */
76
+ getAdaptResults(adaptationRunID, options) {
77
+ return this._client.get(path `/v2/prompt/adaptResults/${adaptationRunID}`, options);
78
+ }
79
+ /**
80
+ * Check the status of a prompt adaptation run.
81
+ *
82
+ * Use this endpoint to poll the status of your adaptation request. Processing is
83
+ * asynchronous, so you'll need to check periodically until the status indicates
84
+ * completion.
85
+ *
86
+ * **Status Values:**
87
+ *
88
+ * - `created`: Initial state, not yet processing
89
+ * - `queued`: Waiting for processing capacity (check queue_position)
90
+ * - `processing`: Currently optimizing prompts
91
+ * - `completed`: All target models have been processed successfully
92
+ * - `failed`: One or more target models failed to process
93
+ *
94
+ * **Polling Recommendations:**
95
+ *
96
+ * - Poll every 30-60 seconds during processing
97
+ * - Check queue_position if status is 'queued' to estimate wait time
98
+ * - Stop polling once status is 'completed' or 'failed'
99
+ * - Use GET /v2/prompt/adaptResults to retrieve results after completion
100
+ *
101
+ * **Queue Position:**
102
+ *
103
+ * - Only present when status is 'queued'
104
+ * - Lower numbers mean earlier processing (position 1 is next)
105
+ * - Typical wait time: 1-5 minutes per position
106
+ *
107
+ * **Note:** This endpoint only returns status information. To get the actual
108
+ * adapted prompts and evaluation results, use GET /v2/prompt/adaptResults once
109
+ * status is 'completed'.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * const response = await client.prompt.getAdaptStatus(
114
+ * 'adaptation_run_id',
115
+ * );
116
+ * ```
117
+ */
118
+ getAdaptStatus(adaptationRunID, options) {
119
+ return this._client.get(path `/v2/prompt/adaptStatus/${adaptationRunID}`, options);
120
+ }
121
+ }
122
+ Prompt.Adapt = Adapt;
123
+ //# sourceMappingURL=prompt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.mjs","sourceRoot":"","sources":["../../src/resources/prompt/prompt.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAEf,KAAK,QAAQ;OACb,EACL,KAAK,GAMN;OAGM,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,MAAO,SAAQ,WAAW;IAAvC;;QACE,UAAK,GAAmB,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAuH3D,CAAC;IArHC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgEG;IACH,eAAe,CACb,eAAuB,EACvB,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,2BAA2B,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,cAAc,CACZ,eAAuB,EACvB,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,0BAA0B,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC;CACF;AAmPD,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./prompt/index.mjs";
2
+ //# sourceMappingURL=prompt.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.mts","sourceRoot":"","sources":["../src/resources/prompt.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from "./prompt/index.js";
2
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/resources/prompt.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const tslib_1 = require("../internal/tslib.js");
5
+ tslib_1.__exportStar(require("./prompt/index.js"), exports);
6
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/resources/prompt.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,4DAA+B"}
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ export * from "./prompt/index.mjs";
3
+ //# sourceMappingURL=prompt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.mjs","sourceRoot":"","sources":["../src/resources/prompt.ts"],"names":[],"mappings":"AAAA,sFAAsF"}