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