notdiamond 1.1.3 → 2.0.0-rc1

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 (409) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/LICENSE +201 -0
  3. package/README.md +449 -105
  4. package/api-promise.d.mts +2 -0
  5. package/api-promise.d.mts.map +1 -0
  6. package/api-promise.d.ts +2 -0
  7. package/api-promise.d.ts.map +1 -0
  8. package/api-promise.js +6 -0
  9. package/api-promise.js.map +1 -0
  10. package/api-promise.mjs +2 -0
  11. package/api-promise.mjs.map +1 -0
  12. package/client.d.mts +206 -0
  13. package/client.d.mts.map +1 -0
  14. package/client.d.ts +206 -0
  15. package/client.d.ts.map +1 -0
  16. package/client.js +479 -0
  17. package/client.js.map +1 -0
  18. package/client.mjs +475 -0
  19. package/client.mjs.map +1 -0
  20. package/core/api-promise.d.mts +46 -0
  21. package/core/api-promise.d.mts.map +1 -0
  22. package/core/api-promise.d.ts +46 -0
  23. package/core/api-promise.d.ts.map +1 -0
  24. package/core/api-promise.js +74 -0
  25. package/core/api-promise.js.map +1 -0
  26. package/core/api-promise.mjs +70 -0
  27. package/core/api-promise.mjs.map +1 -0
  28. package/core/error.d.mts +46 -0
  29. package/core/error.d.mts.map +1 -0
  30. package/core/error.d.ts +46 -0
  31. package/core/error.d.ts.map +1 -0
  32. package/core/error.js +113 -0
  33. package/core/error.js.map +1 -0
  34. package/core/error.mjs +97 -0
  35. package/core/error.mjs.map +1 -0
  36. package/core/resource.d.mts +6 -0
  37. package/core/resource.d.mts.map +1 -0
  38. package/core/resource.d.ts +6 -0
  39. package/core/resource.d.ts.map +1 -0
  40. package/core/resource.js +11 -0
  41. package/core/resource.js.map +1 -0
  42. package/core/resource.mjs +7 -0
  43. package/core/resource.mjs.map +1 -0
  44. package/core/uploads.d.mts +3 -0
  45. package/core/uploads.d.mts.map +1 -0
  46. package/core/uploads.d.ts +3 -0
  47. package/core/uploads.d.ts.map +1 -0
  48. package/core/uploads.js +6 -0
  49. package/core/uploads.js.map +1 -0
  50. package/core/uploads.mjs +2 -0
  51. package/core/uploads.mjs.map +1 -0
  52. package/error.d.mts +2 -0
  53. package/error.d.mts.map +1 -0
  54. package/error.d.ts +2 -0
  55. package/error.d.ts.map +1 -0
  56. package/error.js +6 -0
  57. package/error.js.map +1 -0
  58. package/error.mjs +2 -0
  59. package/error.mjs.map +1 -0
  60. package/index.d.mts +6 -0
  61. package/index.d.mts.map +1 -0
  62. package/index.d.ts +6 -0
  63. package/index.d.ts.map +1 -0
  64. package/index.js +30 -0
  65. package/index.js.map +1 -0
  66. package/index.mjs +7 -0
  67. package/index.mjs.map +1 -0
  68. package/internal/builtin-types.d.mts +73 -0
  69. package/internal/builtin-types.d.mts.map +1 -0
  70. package/internal/builtin-types.d.ts +73 -0
  71. package/internal/builtin-types.d.ts.map +1 -0
  72. package/internal/builtin-types.js +4 -0
  73. package/internal/builtin-types.js.map +1 -0
  74. package/internal/builtin-types.mjs +3 -0
  75. package/internal/builtin-types.mjs.map +1 -0
  76. package/internal/detect-platform.d.mts +15 -0
  77. package/internal/detect-platform.d.mts.map +1 -0
  78. package/internal/detect-platform.d.ts +15 -0
  79. package/internal/detect-platform.d.ts.map +1 -0
  80. package/internal/detect-platform.js +162 -0
  81. package/internal/detect-platform.js.map +1 -0
  82. package/internal/detect-platform.mjs +157 -0
  83. package/internal/detect-platform.mjs.map +1 -0
  84. package/internal/errors.d.mts +3 -0
  85. package/internal/errors.d.mts.map +1 -0
  86. package/internal/errors.d.ts +3 -0
  87. package/internal/errors.d.ts.map +1 -0
  88. package/internal/errors.js +41 -0
  89. package/internal/errors.js.map +1 -0
  90. package/internal/errors.mjs +36 -0
  91. package/internal/errors.mjs.map +1 -0
  92. package/internal/headers.d.mts +20 -0
  93. package/internal/headers.d.mts.map +1 -0
  94. package/internal/headers.d.ts +20 -0
  95. package/internal/headers.d.ts.map +1 -0
  96. package/internal/headers.js +79 -0
  97. package/internal/headers.js.map +1 -0
  98. package/internal/headers.mjs +74 -0
  99. package/internal/headers.mjs.map +1 -0
  100. package/internal/parse.d.mts +12 -0
  101. package/internal/parse.d.mts.map +1 -0
  102. package/internal/parse.d.ts +12 -0
  103. package/internal/parse.d.ts.map +1 -0
  104. package/internal/parse.js +35 -0
  105. package/internal/parse.js.map +1 -0
  106. package/internal/parse.mjs +32 -0
  107. package/internal/parse.mjs.map +1 -0
  108. package/internal/qs/formats.d.mts +7 -0
  109. package/internal/qs/formats.d.mts.map +1 -0
  110. package/internal/qs/formats.d.ts +7 -0
  111. package/internal/qs/formats.d.ts.map +1 -0
  112. package/internal/qs/formats.js +13 -0
  113. package/internal/qs/formats.js.map +1 -0
  114. package/internal/qs/formats.mjs +9 -0
  115. package/internal/qs/formats.mjs.map +1 -0
  116. package/internal/qs/index.d.mts +10 -0
  117. package/internal/qs/index.d.mts.map +1 -0
  118. package/internal/qs/index.d.ts +10 -0
  119. package/internal/qs/index.d.ts.map +1 -0
  120. package/internal/qs/index.js +14 -0
  121. package/internal/qs/index.js.map +1 -0
  122. package/internal/qs/index.mjs +10 -0
  123. package/internal/qs/index.mjs.map +1 -0
  124. package/internal/qs/stringify.d.mts +3 -0
  125. package/internal/qs/stringify.d.mts.map +1 -0
  126. package/internal/qs/stringify.d.ts +3 -0
  127. package/internal/qs/stringify.d.ts.map +1 -0
  128. package/internal/qs/stringify.js +277 -0
  129. package/internal/qs/stringify.js.map +1 -0
  130. package/internal/qs/stringify.mjs +274 -0
  131. package/internal/qs/stringify.mjs.map +1 -0
  132. package/internal/qs/types.d.mts +57 -0
  133. package/internal/qs/types.d.mts.map +1 -0
  134. package/internal/qs/types.d.ts +57 -0
  135. package/internal/qs/types.d.ts.map +1 -0
  136. package/internal/qs/types.js +3 -0
  137. package/internal/qs/types.js.map +1 -0
  138. package/internal/qs/types.mjs +2 -0
  139. package/internal/qs/types.mjs.map +1 -0
  140. package/internal/qs/utils.d.mts +15 -0
  141. package/internal/qs/utils.d.mts.map +1 -0
  142. package/internal/qs/utils.d.ts +15 -0
  143. package/internal/qs/utils.d.ts.map +1 -0
  144. package/internal/qs/utils.js +230 -0
  145. package/internal/qs/utils.js.map +1 -0
  146. package/internal/qs/utils.mjs +217 -0
  147. package/internal/qs/utils.mjs.map +1 -0
  148. package/internal/request-options.d.mts +75 -0
  149. package/internal/request-options.d.mts.map +1 -0
  150. package/internal/request-options.d.ts +75 -0
  151. package/internal/request-options.d.ts.map +1 -0
  152. package/internal/request-options.js +14 -0
  153. package/internal/request-options.js.map +1 -0
  154. package/internal/request-options.mjs +10 -0
  155. package/internal/request-options.mjs.map +1 -0
  156. package/internal/shim-types.d.mts +17 -0
  157. package/internal/shim-types.d.mts.map +1 -0
  158. package/internal/shim-types.d.ts +17 -0
  159. package/internal/shim-types.d.ts.map +1 -0
  160. package/internal/shim-types.js +4 -0
  161. package/internal/shim-types.js.map +1 -0
  162. package/internal/shim-types.mjs +3 -0
  163. package/internal/shim-types.mjs.map +1 -0
  164. package/internal/shims.d.mts +20 -0
  165. package/internal/shims.d.mts.map +1 -0
  166. package/internal/shims.d.ts +20 -0
  167. package/internal/shims.d.ts.map +1 -0
  168. package/internal/shims.js +92 -0
  169. package/internal/shims.js.map +1 -0
  170. package/internal/shims.mjs +85 -0
  171. package/internal/shims.mjs.map +1 -0
  172. package/internal/to-file.d.mts +45 -0
  173. package/internal/to-file.d.mts.map +1 -0
  174. package/internal/to-file.d.ts +45 -0
  175. package/internal/to-file.d.ts.map +1 -0
  176. package/internal/to-file.js +91 -0
  177. package/internal/to-file.js.map +1 -0
  178. package/internal/to-file.mjs +88 -0
  179. package/internal/to-file.mjs.map +1 -0
  180. package/internal/tslib.js +81 -0
  181. package/internal/tslib.mjs +17 -0
  182. package/internal/types.d.mts +69 -0
  183. package/internal/types.d.mts.map +1 -0
  184. package/internal/types.d.ts +69 -0
  185. package/internal/types.d.ts.map +1 -0
  186. package/internal/types.js +4 -0
  187. package/internal/types.js.map +1 -0
  188. package/internal/types.mjs +3 -0
  189. package/internal/types.mjs.map +1 -0
  190. package/internal/uploads.d.mts +42 -0
  191. package/internal/uploads.d.mts.map +1 -0
  192. package/internal/uploads.d.ts +42 -0
  193. package/internal/uploads.d.ts.map +1 -0
  194. package/internal/uploads.js +141 -0
  195. package/internal/uploads.js.map +1 -0
  196. package/internal/uploads.mjs +131 -0
  197. package/internal/uploads.mjs.map +1 -0
  198. package/internal/utils/base64.d.mts +3 -0
  199. package/internal/utils/base64.d.mts.map +1 -0
  200. package/internal/utils/base64.d.ts +3 -0
  201. package/internal/utils/base64.d.ts.map +1 -0
  202. package/internal/utils/base64.js +38 -0
  203. package/internal/utils/base64.js.map +1 -0
  204. package/internal/utils/base64.mjs +33 -0
  205. package/internal/utils/base64.mjs.map +1 -0
  206. package/internal/utils/bytes.d.mts +4 -0
  207. package/internal/utils/bytes.d.mts.map +1 -0
  208. package/internal/utils/bytes.d.ts +4 -0
  209. package/internal/utils/bytes.d.ts.map +1 -0
  210. package/internal/utils/bytes.js +31 -0
  211. package/internal/utils/bytes.js.map +1 -0
  212. package/internal/utils/bytes.mjs +26 -0
  213. package/internal/utils/bytes.mjs.map +1 -0
  214. package/internal/utils/env.d.mts +9 -0
  215. package/internal/utils/env.d.mts.map +1 -0
  216. package/internal/utils/env.d.ts +9 -0
  217. package/internal/utils/env.d.ts.map +1 -0
  218. package/internal/utils/env.js +22 -0
  219. package/internal/utils/env.js.map +1 -0
  220. package/internal/utils/env.mjs +18 -0
  221. package/internal/utils/env.mjs.map +1 -0
  222. package/internal/utils/log.d.mts +37 -0
  223. package/internal/utils/log.d.mts.map +1 -0
  224. package/internal/utils/log.d.ts +37 -0
  225. package/internal/utils/log.d.ts.map +1 -0
  226. package/internal/utils/log.js +85 -0
  227. package/internal/utils/log.js.map +1 -0
  228. package/internal/utils/log.mjs +79 -0
  229. package/internal/utils/log.mjs.map +1 -0
  230. package/internal/utils/path.d.mts +15 -0
  231. package/internal/utils/path.d.mts.map +1 -0
  232. package/internal/utils/path.d.ts +15 -0
  233. package/internal/utils/path.d.ts.map +1 -0
  234. package/internal/utils/path.js +79 -0
  235. package/internal/utils/path.js.map +1 -0
  236. package/internal/utils/path.mjs +74 -0
  237. package/internal/utils/path.mjs.map +1 -0
  238. package/internal/utils/sleep.d.mts +2 -0
  239. package/internal/utils/sleep.d.mts.map +1 -0
  240. package/internal/utils/sleep.d.ts +2 -0
  241. package/internal/utils/sleep.d.ts.map +1 -0
  242. package/internal/utils/sleep.js +7 -0
  243. package/internal/utils/sleep.js.map +1 -0
  244. package/internal/utils/sleep.mjs +3 -0
  245. package/internal/utils/sleep.mjs.map +1 -0
  246. package/internal/utils/uuid.d.mts +5 -0
  247. package/internal/utils/uuid.d.mts.map +1 -0
  248. package/internal/utils/uuid.d.ts +5 -0
  249. package/internal/utils/uuid.d.ts.map +1 -0
  250. package/internal/utils/uuid.js +19 -0
  251. package/internal/utils/uuid.js.map +1 -0
  252. package/internal/utils/uuid.mjs +15 -0
  253. package/internal/utils/uuid.mjs.map +1 -0
  254. package/internal/utils/values.d.mts +18 -0
  255. package/internal/utils/values.d.mts.map +1 -0
  256. package/internal/utils/values.d.ts +18 -0
  257. package/internal/utils/values.d.ts.map +1 -0
  258. package/internal/utils/values.js +112 -0
  259. package/internal/utils/values.js.map +1 -0
  260. package/internal/utils/values.mjs +94 -0
  261. package/internal/utils/values.mjs.map +1 -0
  262. package/internal/utils.d.mts +7 -0
  263. package/internal/utils.d.mts.map +1 -0
  264. package/internal/utils.d.ts +7 -0
  265. package/internal/utils.d.ts.map +1 -0
  266. package/internal/utils.js +11 -0
  267. package/internal/utils.js.map +1 -0
  268. package/internal/utils.mjs +8 -0
  269. package/internal/utils.mjs.map +1 -0
  270. package/package.json +131 -124
  271. package/resource.d.mts +2 -0
  272. package/resource.d.mts.map +1 -0
  273. package/resource.d.ts +2 -0
  274. package/resource.d.ts.map +1 -0
  275. package/resource.js +6 -0
  276. package/resource.js.map +1 -0
  277. package/resource.mjs +2 -0
  278. package/resource.mjs.map +1 -0
  279. package/resources/admin.d.mts +4 -0
  280. package/resources/admin.d.mts.map +1 -0
  281. package/resources/admin.d.ts +4 -0
  282. package/resources/admin.d.ts.map +1 -0
  283. package/resources/admin.js +9 -0
  284. package/resources/admin.js.map +1 -0
  285. package/resources/admin.mjs +5 -0
  286. package/resources/admin.mjs.map +1 -0
  287. package/resources/index.d.mts +7 -0
  288. package/resources/index.d.mts.map +1 -0
  289. package/resources/index.d.ts +7 -0
  290. package/resources/index.d.ts.map +1 -0
  291. package/resources/index.js +17 -0
  292. package/resources/index.js.map +1 -0
  293. package/resources/index.mjs +8 -0
  294. package/resources/index.mjs.map +1 -0
  295. package/resources/models.d.mts +85 -0
  296. package/resources/models.d.mts.map +1 -0
  297. package/resources/models.d.ts +85 -0
  298. package/resources/models.d.ts.map +1 -0
  299. package/resources/models.js +44 -0
  300. package/resources/models.js.map +1 -0
  301. package/resources/models.mjs +40 -0
  302. package/resources/models.mjs.map +1 -0
  303. package/resources/preferences.d.mts +111 -0
  304. package/resources/preferences.d.mts.map +1 -0
  305. package/resources/preferences.d.ts +111 -0
  306. package/resources/preferences.d.ts.map +1 -0
  307. package/resources/preferences.js +92 -0
  308. package/resources/preferences.js.map +1 -0
  309. package/resources/preferences.mjs +88 -0
  310. package/resources/preferences.mjs.map +1 -0
  311. package/resources/prompt-adaptation.d.mts +574 -0
  312. package/resources/prompt-adaptation.d.mts.map +1 -0
  313. package/resources/prompt-adaptation.d.ts +574 -0
  314. package/resources/prompt-adaptation.d.ts.map +1 -0
  315. package/resources/prompt-adaptation.js +289 -0
  316. package/resources/prompt-adaptation.js.map +1 -0
  317. package/resources/prompt-adaptation.mjs +285 -0
  318. package/resources/prompt-adaptation.mjs.map +1 -0
  319. package/resources/report.d.mts +245 -0
  320. package/resources/report.d.mts.map +1 -0
  321. package/resources/report.d.ts +245 -0
  322. package/resources/report.d.ts.map +1 -0
  323. package/resources/report.js +86 -0
  324. package/resources/report.js.map +1 -0
  325. package/resources/report.mjs +82 -0
  326. package/resources/report.mjs.map +1 -0
  327. package/resources/routing.d.mts +391 -0
  328. package/resources/routing.d.mts.map +1 -0
  329. package/resources/routing.d.ts +391 -0
  330. package/resources/routing.d.ts.map +1 -0
  331. package/resources/routing.js +163 -0
  332. package/resources/routing.js.map +1 -0
  333. package/resources/routing.mjs +159 -0
  334. package/resources/routing.mjs.map +1 -0
  335. package/resources.d.mts +2 -0
  336. package/resources.d.mts.map +1 -0
  337. package/resources.d.ts +2 -0
  338. package/resources.d.ts.map +1 -0
  339. package/resources.js +5 -0
  340. package/resources.js.map +1 -0
  341. package/resources.mjs +2 -0
  342. package/resources.mjs.map +1 -0
  343. package/src/api-promise.ts +2 -0
  344. package/src/client.ts +842 -0
  345. package/src/core/README.md +3 -0
  346. package/src/core/api-promise.ts +92 -0
  347. package/src/core/error.ts +130 -0
  348. package/src/core/resource.ts +11 -0
  349. package/src/core/uploads.ts +2 -0
  350. package/src/error.ts +2 -0
  351. package/src/index.ts +22 -0
  352. package/src/internal/README.md +3 -0
  353. package/src/internal/builtin-types.ts +93 -0
  354. package/src/internal/detect-platform.ts +196 -0
  355. package/src/internal/errors.ts +33 -0
  356. package/src/internal/headers.ts +97 -0
  357. package/src/internal/parse.ts +50 -0
  358. package/src/internal/qs/LICENSE.md +13 -0
  359. package/src/internal/qs/README.md +3 -0
  360. package/src/internal/qs/formats.ts +10 -0
  361. package/src/internal/qs/index.ts +13 -0
  362. package/src/internal/qs/stringify.ts +385 -0
  363. package/src/internal/qs/types.ts +71 -0
  364. package/src/internal/qs/utils.ts +265 -0
  365. package/src/internal/request-options.ts +91 -0
  366. package/src/internal/shim-types.ts +26 -0
  367. package/src/internal/shims.ts +107 -0
  368. package/src/internal/to-file.ts +154 -0
  369. package/src/internal/types.ts +95 -0
  370. package/src/internal/uploads.ts +187 -0
  371. package/src/internal/utils/base64.ts +40 -0
  372. package/src/internal/utils/bytes.ts +32 -0
  373. package/src/internal/utils/env.ts +18 -0
  374. package/src/internal/utils/log.ts +126 -0
  375. package/src/internal/utils/path.ts +88 -0
  376. package/src/internal/utils/sleep.ts +3 -0
  377. package/src/internal/utils/uuid.ts +17 -0
  378. package/src/internal/utils/values.ts +105 -0
  379. package/src/internal/utils.ts +8 -0
  380. package/src/lib/.keep +4 -0
  381. package/src/resource.ts +2 -0
  382. package/src/resources/admin.ts +5 -0
  383. package/src/resources/index.ts +44 -0
  384. package/src/resources/models.ts +110 -0
  385. package/src/resources/preferences.ts +158 -0
  386. package/src/resources/prompt-adaptation.ts +700 -0
  387. package/src/resources/report.ts +300 -0
  388. package/src/resources/routing.ts +476 -0
  389. package/src/resources.ts +1 -0
  390. package/src/tsconfig.json +11 -0
  391. package/src/uploads.ts +2 -0
  392. package/src/version.ts +1 -0
  393. package/uploads.d.mts +2 -0
  394. package/uploads.d.mts.map +1 -0
  395. package/uploads.d.ts +2 -0
  396. package/uploads.d.ts.map +1 -0
  397. package/uploads.js +6 -0
  398. package/uploads.js.map +1 -0
  399. package/uploads.mjs +2 -0
  400. package/uploads.mjs.map +1 -0
  401. package/version.d.mts +2 -0
  402. package/version.d.mts.map +1 -0
  403. package/version.d.ts +2 -0
  404. package/version.d.ts.map +1 -0
  405. package/version.js +5 -0
  406. package/version.js.map +1 -0
  407. package/version.mjs +2 -0
  408. package/version.mjs.map +1 -0
  409. package/LICENCE +0 -21
@@ -0,0 +1,700 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as PromptAdaptationAPI from './prompt-adaptation';
5
+ import { APIPromise } from '../core/api-promise';
6
+ import { buildHeaders } from '../internal/headers';
7
+ import { RequestOptions } from '../internal/request-options';
8
+ import { path } from '../internal/utils/path';
9
+
10
+ export class PromptAdaptation extends APIResource {
11
+ /**
12
+ * Adapt your prompt from one LLM to work optimally across different target LLMs.
13
+ *
14
+ * This endpoint automatically optimizes your prompt (system prompt + user message
15
+ * template) to achieve better performance when switching between different
16
+ * language models. Each model has unique characteristics, and what works well for
17
+ * GPT-4 might not work as well for Claude or Gemini.
18
+ *
19
+ * **How Prompt Adaptation Works:**
20
+ *
21
+ * 1. You provide your current prompt optimized for an origin model
22
+ * 2. You specify target models you want to adapt to
23
+ * 3. You provide evaluation examples (golden records) with expected answers
24
+ * 4. The system runs optimization to find the best prompt for each target model
25
+ * 5. You receive adapted prompts that perform well on your target models
26
+ *
27
+ * **Evaluation Metrics:** Choose either a standard metric or provide custom
28
+ * evaluation:
29
+ *
30
+ * - **Standard metrics**: LLMaaJ:SQL, LLMaaJ:Sem_Sim_1/3/10 (semantic similarity),
31
+ * JSON_Match
32
+ * - **Custom evaluation**: Provide evaluation_config with your own LLM judge,
33
+ * prompt, and cutoff
34
+ *
35
+ * **Dataset Requirements:**
36
+ *
37
+ * - Minimum 5 examples in train_goldens (more examples = better adaptation)
38
+ * - Each example must have fields matching your template placeholders
39
+ * - Supervised evaluation requires 'answer' field in each golden record
40
+ * - Unsupervised evaluation can work without answers
41
+ *
42
+ * **Training Time:**
43
+ *
44
+ * - Processing is asynchronous and typically takes 10-30 minutes
45
+ * - Time depends on: number of target models, dataset size, model availability
46
+ * - Use the returned adaptation_run_id to check status and retrieve results
47
+ *
48
+ * **Subscription Tiers:**
49
+ *
50
+ * - Free: 1 target model
51
+ * - Starter: 3 target models
52
+ * - Startup: 5 target models
53
+ * - Enterprise: 10 target models
54
+ *
55
+ * **Best Practices:**
56
+ *
57
+ * 1. Use diverse, representative examples from your production workload
58
+ * 2. Include 10-20 examples for best results (5 minimum)
59
+ * 3. Ensure consistent evaluation across all examples
60
+ * 4. Test both train_goldens and test_goldens split for validation
61
+ * 5. Use the same model versions you'll use in production
62
+ *
63
+ * **Example Workflow:**
64
+ *
65
+ * ```
66
+ * 1. POST /v2/prompt/adapt - Submit adaptation request
67
+ * 2. GET /v2/prompt/adaptStatus/{id} - Poll status until completed
68
+ * 3. GET /v2/prompt/adaptResults/{id} - Retrieve optimized prompts
69
+ * 4. Use optimized prompts in production with target models
70
+ * ```
71
+ *
72
+ * **Related Documentation:** See
73
+ * https://docs.notdiamond.ai/docs/adapting-prompts-to-new-models for detailed
74
+ * guide.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const response = await client.promptAdaptation.adapt({
79
+ * fields: ['question'],
80
+ * origin_model: { provider: 'openai', model: 'gpt-4o' },
81
+ * system_prompt: 'You are a helpful assistant that answers questions accurately.',
82
+ * target_models: [
83
+ * { provider: 'anthropic', model: 'claude-3-5-sonnet-20241022' },
84
+ * { provider: 'google', model: 'gemini-1.5-pro' },
85
+ * ],
86
+ * template: 'Question: {question}\nAnswer:',
87
+ * evaluation_metric: 'LLMaaJ:Sem_Sim_3',
88
+ * test_goldens: [
89
+ * {
90
+ * fields: { ... },
91
+ * answer: '9',
92
+ * },
93
+ * {
94
+ * fields: { ... },
95
+ * answer: 'Pacific Ocean',
96
+ * },
97
+ * ],
98
+ * train_goldens: [
99
+ * {
100
+ * fields: { ... },
101
+ * answer: '4',
102
+ * },
103
+ * {
104
+ * fields: { ... },
105
+ * answer: 'Paris',
106
+ * },
107
+ * {
108
+ * fields: { ... },
109
+ * answer: 'William Shakespeare',
110
+ * },
111
+ * {
112
+ * fields: { ... },
113
+ * answer: 'Water',
114
+ * },
115
+ * {
116
+ * fields: { ... },
117
+ * answer: '7',
118
+ * },
119
+ * ],
120
+ * });
121
+ * ```
122
+ */
123
+ adapt(
124
+ body: PromptAdaptationAdaptParams,
125
+ options?: RequestOptions,
126
+ ): APIPromise<PromptAdaptationAdaptResponse> {
127
+ return this._client.post('/v2/prompt/adapt', { body, ...options });
128
+ }
129
+
130
+ /**
131
+ * Retrieve the complete results of a prompt adaptation run, including optimized
132
+ * prompts for all target models.
133
+ *
134
+ * This endpoint returns the adapted prompts and evaluation metrics for each target
135
+ * model in your adaptation request. Call this endpoint after the adaptation status
136
+ * is 'completed' to get your optimized prompts.
137
+ *
138
+ * **Response Structure:**
139
+ *
140
+ * - **origin_model**: Baseline performance of your original prompt on the origin
141
+ * model
142
+ * - Includes: system_prompt, user_message_template, score, evaluation metrics,
143
+ * cost
144
+ * - **target_models**: Array of results for each target model
145
+ * - Includes: optimized system_prompt, user_message_template, template_fields
146
+ * - pre_optimization_score: Performance before adaptation
147
+ * - post_optimization_score: Performance after adaptation
148
+ * - Evaluation metrics and cost information
149
+ *
150
+ * **Using Adapted Prompts:**
151
+ *
152
+ * 1. Extract the `system_prompt` and `user_message_template` from each target
153
+ * model result
154
+ * 2. Use `user_message_template_fields` to know which fields to substitute
155
+ * 3. Apply the optimized prompts when calling the respective target models
156
+ * 4. Compare pre/post optimization scores to see improvement
157
+ *
158
+ * **Evaluation Scores:**
159
+ *
160
+ * - Scores range from 0-10 (higher is better)
161
+ * - Compare origin_model score with target_models pre_optimization_score for
162
+ * baseline
163
+ * - Compare pre_optimization_score with post_optimization_score to see improvement
164
+ * from adaptation
165
+ * - Typical improvements range from 5-30% on evaluation metrics
166
+ *
167
+ * **Status Handling:**
168
+ *
169
+ * - If adaptation is still processing, target model results will have
170
+ * `result_status: "processing"`
171
+ * - Only completed target models will have system_prompt and template values
172
+ * - Failed target models will have `result_status: "failed"` with null values
173
+ *
174
+ * **Cost Information:**
175
+ *
176
+ * - Each model result includes cost in USD for the adaptation process
177
+ * - Costs vary based on model pricing and number of evaluation examples
178
+ * - Typical range: $0.10 - $2.00 per target model
179
+ *
180
+ * **Best Practices:**
181
+ *
182
+ * 1. Wait for status 'completed' before calling this endpoint
183
+ * 2. Check result_status for each target model
184
+ * 3. Validate that post_optimization_score > pre_optimization_score
185
+ * 4. Save optimized prompts for production use
186
+ * 5. A/B test adapted prompts against originals in production
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * const adaptationRunResults =
191
+ * await client.promptAdaptation.getAdaptResults(
192
+ * 'adaptation_run_id',
193
+ * );
194
+ * ```
195
+ */
196
+ getAdaptResults(adaptationRunID: string, options?: RequestOptions): APIPromise<AdaptationRunResults> {
197
+ return this._client.get(path`/v2/prompt/adaptResults/${adaptationRunID}`, options);
198
+ }
199
+
200
+ /**
201
+ * Get Adapt Run Results
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * const adaptationRunResults =
206
+ * await client.promptAdaptation.getAdaptRunResults(
207
+ * 'adaptation_run_id',
208
+ * { user_id: 'user_id', 'x-token': 'x-token' },
209
+ * );
210
+ * ```
211
+ */
212
+ getAdaptRunResults(
213
+ adaptationRunID: string,
214
+ params: PromptAdaptationGetAdaptRunResultsParams,
215
+ options?: RequestOptions,
216
+ ): APIPromise<AdaptationRunResults> {
217
+ const { user_id, 'x-token': xToken } = params;
218
+ return this._client.get(path`/v2/prompt/frontendAdaptRunResults/${user_id}/${adaptationRunID}`, {
219
+ ...options,
220
+ headers: buildHeaders([{ 'x-token': xToken }, options?.headers]),
221
+ });
222
+ }
223
+
224
+ /**
225
+ * Get Adapt Runs
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * const adaptationRunResults =
230
+ * await client.promptAdaptation.getAdaptRuns('user_id', {
231
+ * 'x-token': 'x-token',
232
+ * });
233
+ * ```
234
+ */
235
+ getAdaptRuns(
236
+ userID: string,
237
+ params: PromptAdaptationGetAdaptRunsParams,
238
+ options?: RequestOptions,
239
+ ): APIPromise<PromptAdaptationGetAdaptRunsResponse> {
240
+ const { 'x-token': xToken } = params;
241
+ return this._client.get(path`/v2/prompt/frontendAdaptRuns/${userID}`, {
242
+ ...options,
243
+ headers: buildHeaders([{ 'x-token': xToken }, options?.headers]),
244
+ });
245
+ }
246
+
247
+ /**
248
+ * Check the status of a prompt adaptation run.
249
+ *
250
+ * Use this endpoint to poll the status of your adaptation request. Processing is
251
+ * asynchronous, so you'll need to check periodically until the status indicates
252
+ * completion.
253
+ *
254
+ * **Status Values:**
255
+ *
256
+ * - `created`: Initial state, not yet processing
257
+ * - `queued`: Waiting for processing capacity (check queue_position)
258
+ * - `processing`: Currently optimizing prompts
259
+ * - `completed`: All target models have been processed successfully
260
+ * - `failed`: One or more target models failed to process
261
+ *
262
+ * **Polling Recommendations:**
263
+ *
264
+ * - Poll every 30-60 seconds during processing
265
+ * - Check queue_position if status is 'queued' to estimate wait time
266
+ * - Stop polling once status is 'completed' or 'failed'
267
+ * - Use GET /v2/prompt/adaptResults to retrieve results after completion
268
+ *
269
+ * **Queue Position:**
270
+ *
271
+ * - Only present when status is 'queued'
272
+ * - Lower numbers mean earlier processing (position 1 is next)
273
+ * - Typical wait time: 1-5 minutes per position
274
+ *
275
+ * **Note:** This endpoint only returns status information. To get the actual
276
+ * adapted prompts and evaluation results, use GET /v2/prompt/adaptResults once
277
+ * status is 'completed'.
278
+ *
279
+ * @example
280
+ * ```ts
281
+ * const response =
282
+ * await client.promptAdaptation.getAdaptStatus(
283
+ * 'adaptation_run_id',
284
+ * );
285
+ * ```
286
+ */
287
+ getAdaptStatus(
288
+ adaptationRunID: string,
289
+ options?: RequestOptions,
290
+ ): APIPromise<PromptAdaptationGetAdaptStatusResponse> {
291
+ return this._client.get(path`/v2/prompt/adaptStatus/${adaptationRunID}`, options);
292
+ }
293
+
294
+ /**
295
+ * Get LLM costs for a specific adaptation run
296
+ *
297
+ * @example
298
+ * ```ts
299
+ * const response =
300
+ * await client.promptAdaptation.retrieveCosts(
301
+ * 'adaptation_run_id',
302
+ * );
303
+ * ```
304
+ */
305
+ retrieveCosts(
306
+ adaptationRunID: string,
307
+ options?: RequestOptions,
308
+ ): APIPromise<PromptAdaptationRetrieveCostsResponse> {
309
+ return this._client.get(path`/v1/adaptation-runs/${adaptationRunID}/costs`, options);
310
+ }
311
+ }
312
+
313
+ /**
314
+ * Complete results for a prompt adaptation run including all target models.
315
+ */
316
+ export interface AdaptationRunResults {
317
+ /**
318
+ * Unique ID for this adaptation run
319
+ */
320
+ id: string;
321
+
322
+ /**
323
+ * Timestamp when this adaptation run was created
324
+ */
325
+ created_at: string;
326
+
327
+ /**
328
+ * Overall status of the adaptation run
329
+ */
330
+ job_status: JobStatus;
331
+
332
+ /**
333
+ * Results for the origin model (baseline performance)
334
+ */
335
+ origin_model: AdaptationRunResults.OriginModel;
336
+
337
+ /**
338
+ * Results for each target model with optimized prompts
339
+ */
340
+ target_models: Array<AdaptationRunResults.TargetModel>;
341
+
342
+ /**
343
+ * Timestamp of last update to this adaptation run
344
+ */
345
+ updated_at: string | null;
346
+
347
+ evaluation_config?: string | null;
348
+
349
+ evaluation_metric?: string | null;
350
+ }
351
+
352
+ export namespace AdaptationRunResults {
353
+ /**
354
+ * Results for the origin model (baseline performance)
355
+ */
356
+ export interface OriginModel {
357
+ cost: number | null;
358
+
359
+ evals: { [key: string]: unknown } | null;
360
+
361
+ model_name: string;
362
+
363
+ result_status: PromptAdaptationAPI.JobStatus | null;
364
+
365
+ score: number | null;
366
+
367
+ system_prompt: string | null;
368
+
369
+ user_message_template: string | null;
370
+ }
371
+
372
+ /**
373
+ * Results for a single target model adaptation.
374
+ */
375
+ export interface TargetModel {
376
+ cost: number | null;
377
+
378
+ model_name: string;
379
+
380
+ post_optimization_evals: { [key: string]: unknown } | null;
381
+
382
+ post_optimization_score: number | null;
383
+
384
+ pre_optimization_evals: { [key: string]: unknown } | null;
385
+
386
+ pre_optimization_score: number | null;
387
+
388
+ /**
389
+ * Status of this specific target model adaptation
390
+ */
391
+ result_status: PromptAdaptationAPI.JobStatus | null;
392
+
393
+ /**
394
+ * Optimized system prompt for this target model
395
+ */
396
+ system_prompt: string | null;
397
+
398
+ /**
399
+ * Optimized user message template for this target model
400
+ */
401
+ user_message_template: string | null;
402
+
403
+ /**
404
+ * Field names used in the optimized template
405
+ */
406
+ user_message_template_fields: Array<string> | null;
407
+ }
408
+ }
409
+
410
+ export type JobStatus = 'created' | 'queued' | 'processing' | 'completed' | 'failed';
411
+
412
+ /**
413
+ * Response from prompt adaptation request.
414
+ */
415
+ export interface PromptAdaptationAdaptResponse {
416
+ /**
417
+ * Unique ID for this adaptation run. Use this to check status and retrieve results
418
+ */
419
+ adaptation_run_id: string;
420
+ }
421
+
422
+ export type PromptAdaptationGetAdaptRunsResponse = Array<AdaptationRunResults>;
423
+
424
+ /**
425
+ * Status response for a prompt adaptation run.
426
+ */
427
+ export interface PromptAdaptationGetAdaptStatusResponse {
428
+ /**
429
+ * Unique ID for this adaptation run. Use this to check status and retrieve results
430
+ */
431
+ adaptation_run_id: string;
432
+
433
+ /**
434
+ * Current status of the adaptation run (created, queued, processing, completed, or
435
+ * failed)
436
+ */
437
+ status: JobStatus;
438
+
439
+ /**
440
+ * Position in queue if status is 'queued'. Lower numbers mean earlier processing
441
+ */
442
+ queue_position?: number | null;
443
+ }
444
+
445
+ export interface PromptAdaptationRetrieveCostsResponse {
446
+ adaptation_run_id: string;
447
+
448
+ total_cost: number;
449
+
450
+ usage_records: Array<PromptAdaptationRetrieveCostsResponse.UsageRecord>;
451
+ }
452
+
453
+ export namespace PromptAdaptationRetrieveCostsResponse {
454
+ export interface UsageRecord {
455
+ id: string;
456
+
457
+ adaptation_run_id: string;
458
+
459
+ input_cost: number;
460
+
461
+ input_tokens: number;
462
+
463
+ model: string;
464
+
465
+ organization_id: string;
466
+
467
+ output_cost: number;
468
+
469
+ output_tokens: number;
470
+
471
+ provider: string;
472
+
473
+ task_type: string;
474
+
475
+ timestamp: number;
476
+
477
+ total_cost: number;
478
+
479
+ user_id: string;
480
+ }
481
+ }
482
+
483
+ export interface PromptAdaptationAdaptParams {
484
+ /**
485
+ * List of field names that will be substituted into the template. Must match keys
486
+ * in golden records
487
+ */
488
+ fields: Array<string>;
489
+
490
+ /**
491
+ * The model your current prompt is optimized for
492
+ */
493
+ origin_model: PromptAdaptationAdaptParams.OriginModel;
494
+
495
+ /**
496
+ * System prompt to use with the origin model. This sets the context and role for
497
+ * the LLM
498
+ */
499
+ system_prompt: string;
500
+
501
+ /**
502
+ * List of models to adapt the prompt for. Maximum count depends on your
503
+ * subscription tier
504
+ */
505
+ target_models: Array<PromptAdaptationAdaptParams.TargetModel>;
506
+
507
+ /**
508
+ * User message template with placeholders for fields. Use curly braces for field
509
+ * substitution
510
+ */
511
+ template: string;
512
+
513
+ evaluation_config?: string | null;
514
+
515
+ evaluation_metric?: string | null;
516
+
517
+ /**
518
+ * Training examples (legacy parameter). Use train_goldens and test_goldens for
519
+ * better control
520
+ */
521
+ goldens?: Array<PromptAdaptationAdaptParams.Golden> | null;
522
+
523
+ /**
524
+ * Optional baseline score for the origin model
525
+ */
526
+ origin_model_evaluation_score?: number | null;
527
+
528
+ /**
529
+ * Test examples for evaluation. Required if train_goldens is provided
530
+ */
531
+ test_goldens?: Array<PromptAdaptationAdaptParams.TestGolden> | null;
532
+
533
+ /**
534
+ * Training examples for prompt optimization. Minimum 5 examples required
535
+ */
536
+ train_goldens?: Array<PromptAdaptationAdaptParams.TrainGolden> | null;
537
+ }
538
+
539
+ export namespace PromptAdaptationAdaptParams {
540
+ /**
541
+ * The model your current prompt is optimized for
542
+ */
543
+ export interface OriginModel {
544
+ /**
545
+ * Model name (e.g., 'gpt-4o', 'claude-3-5-sonnet-20241022')
546
+ */
547
+ model: string;
548
+
549
+ /**
550
+ * Provider name (e.g., 'openai', 'anthropic', 'google')
551
+ */
552
+ provider: string;
553
+
554
+ /**
555
+ * Maximum context length for the model (required for custom models)
556
+ */
557
+ context_length?: number | null;
558
+
559
+ /**
560
+ * Input token price per million tokens in USD (required for custom models)
561
+ */
562
+ input_price?: number | null;
563
+
564
+ /**
565
+ * Whether this is a custom model not in Not Diamond's supported model list
566
+ */
567
+ is_custom?: boolean;
568
+
569
+ /**
570
+ * Average latency in seconds (required for custom models)
571
+ */
572
+ latency?: number | null;
573
+
574
+ /**
575
+ * Output token price per million tokens in USD (required for custom models)
576
+ */
577
+ output_price?: number | null;
578
+ }
579
+
580
+ /**
581
+ * Model for specifying an LLM provider in API requests.
582
+ */
583
+ export interface TargetModel {
584
+ /**
585
+ * Model name (e.g., 'gpt-4o', 'claude-3-5-sonnet-20241022')
586
+ */
587
+ model: string;
588
+
589
+ /**
590
+ * Provider name (e.g., 'openai', 'anthropic', 'google')
591
+ */
592
+ provider: string;
593
+
594
+ /**
595
+ * Maximum context length for the model (required for custom models)
596
+ */
597
+ context_length?: number | null;
598
+
599
+ /**
600
+ * Input token price per million tokens in USD (required for custom models)
601
+ */
602
+ input_price?: number | null;
603
+
604
+ /**
605
+ * Whether this is a custom model not in Not Diamond's supported model list
606
+ */
607
+ is_custom?: boolean;
608
+
609
+ /**
610
+ * Average latency in seconds (required for custom models)
611
+ */
612
+ latency?: number | null;
613
+
614
+ /**
615
+ * Output token price per million tokens in USD (required for custom models)
616
+ */
617
+ output_price?: number | null;
618
+ }
619
+
620
+ /**
621
+ * A training or test example for prompt adaptation.
622
+ */
623
+ export interface Golden {
624
+ /**
625
+ * Dictionary mapping field names to their values. Keys must match the fields
626
+ * specified in the template
627
+ */
628
+ fields: { [key: string]: string };
629
+
630
+ /**
631
+ * Expected answer for supervised evaluation. Required for supervised metrics,
632
+ * optional for unsupervised
633
+ */
634
+ answer?: string | null;
635
+ }
636
+
637
+ /**
638
+ * A training or test example for prompt adaptation.
639
+ */
640
+ export interface TestGolden {
641
+ /**
642
+ * Dictionary mapping field names to their values. Keys must match the fields
643
+ * specified in the template
644
+ */
645
+ fields: { [key: string]: string };
646
+
647
+ /**
648
+ * Expected answer for supervised evaluation. Required for supervised metrics,
649
+ * optional for unsupervised
650
+ */
651
+ answer?: string | null;
652
+ }
653
+
654
+ /**
655
+ * A training or test example for prompt adaptation.
656
+ */
657
+ export interface TrainGolden {
658
+ /**
659
+ * Dictionary mapping field names to their values. Keys must match the fields
660
+ * specified in the template
661
+ */
662
+ fields: { [key: string]: string };
663
+
664
+ /**
665
+ * Expected answer for supervised evaluation. Required for supervised metrics,
666
+ * optional for unsupervised
667
+ */
668
+ answer?: string | null;
669
+ }
670
+ }
671
+
672
+ export interface PromptAdaptationGetAdaptRunResultsParams {
673
+ /**
674
+ * Path param:
675
+ */
676
+ user_id: string;
677
+
678
+ /**
679
+ * Header param:
680
+ */
681
+ 'x-token': string;
682
+ }
683
+
684
+ export interface PromptAdaptationGetAdaptRunsParams {
685
+ 'x-token': string;
686
+ }
687
+
688
+ export declare namespace PromptAdaptation {
689
+ export {
690
+ type AdaptationRunResults as AdaptationRunResults,
691
+ type JobStatus as JobStatus,
692
+ type PromptAdaptationAdaptResponse as PromptAdaptationAdaptResponse,
693
+ type PromptAdaptationGetAdaptRunsResponse as PromptAdaptationGetAdaptRunsResponse,
694
+ type PromptAdaptationGetAdaptStatusResponse as PromptAdaptationGetAdaptStatusResponse,
695
+ type PromptAdaptationRetrieveCostsResponse as PromptAdaptationRetrieveCostsResponse,
696
+ type PromptAdaptationAdaptParams as PromptAdaptationAdaptParams,
697
+ type PromptAdaptationGetAdaptRunResultsParams as PromptAdaptationGetAdaptRunResultsParams,
698
+ type PromptAdaptationGetAdaptRunsParams as PromptAdaptationGetAdaptRunsParams,
699
+ };
700
+ }