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,266 @@
|
|
|
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.PromptAdaptation = void 0;
|
|
5
|
+
const resource_1 = require("../core/resource.js");
|
|
6
|
+
const path_1 = require("../internal/utils/path.js");
|
|
7
|
+
class PromptAdaptation extends resource_1.APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Adapt your prompt from one LLM to work optimally across different target LLMs.
|
|
10
|
+
*
|
|
11
|
+
* This endpoint automatically optimizes your prompt (system prompt + user message
|
|
12
|
+
* template) to achieve better performance when switching between different
|
|
13
|
+
* language models. Each model has unique characteristics, and what works well for
|
|
14
|
+
* GPT-4 might not work as well for Claude or Gemini.
|
|
15
|
+
*
|
|
16
|
+
* **How Prompt Adaptation Works:**
|
|
17
|
+
*
|
|
18
|
+
* 1. You provide your current prompt optimized for an origin model
|
|
19
|
+
* 2. You specify target models you want to adapt to
|
|
20
|
+
* 3. You provide evaluation examples (golden records) with expected answers
|
|
21
|
+
* 4. The system runs optimization to find the best prompt for each target model
|
|
22
|
+
* 5. You receive adapted prompts that perform well on your target models
|
|
23
|
+
*
|
|
24
|
+
* **Evaluation Metrics:** Choose either a standard metric or provide custom
|
|
25
|
+
* evaluation:
|
|
26
|
+
*
|
|
27
|
+
* - **Standard metrics**: LLMaaJ:SQL, LLMaaJ:Sem_Sim_1/3/10 (semantic similarity),
|
|
28
|
+
* JSON_Match
|
|
29
|
+
* - **Custom evaluation**: Provide evaluation_config with your own LLM judge,
|
|
30
|
+
* prompt, and cutoff
|
|
31
|
+
*
|
|
32
|
+
* **Dataset Requirements:**
|
|
33
|
+
*
|
|
34
|
+
* - Minimum 25 examples in train_goldens (more examples = better adaptation)
|
|
35
|
+
* - Each example must have fields matching your template placeholders
|
|
36
|
+
* - Supervised evaluation requires 'answer' field in each golden record
|
|
37
|
+
* - Unsupervised evaluation can work without answers
|
|
38
|
+
*
|
|
39
|
+
* **Training Time:**
|
|
40
|
+
*
|
|
41
|
+
* - Processing is asynchronous and typically takes 10-30 minutes
|
|
42
|
+
* - Time depends on: number of target models, dataset size, model availability
|
|
43
|
+
* - Use the returned adaptation_run_id to check status and retrieve results
|
|
44
|
+
*
|
|
45
|
+
* **Subscription Tiers:**
|
|
46
|
+
*
|
|
47
|
+
* - Free: 1 target model
|
|
48
|
+
* - Starter: 3 target models
|
|
49
|
+
* - Startup: 5 target models
|
|
50
|
+
* - Enterprise: 10 target models
|
|
51
|
+
*
|
|
52
|
+
* **Best Practices:**
|
|
53
|
+
*
|
|
54
|
+
* 1. Use diverse, representative examples from your production workload
|
|
55
|
+
* 2. Include examples for best results (25 minimum)
|
|
56
|
+
* 3. Ensure consistent evaluation across all examples
|
|
57
|
+
* 4. Test both train_goldens and test_goldens split for validation
|
|
58
|
+
* 5. Use the same model versions you'll use in production
|
|
59
|
+
*
|
|
60
|
+
* **Example Workflow:**
|
|
61
|
+
*
|
|
62
|
+
* ```
|
|
63
|
+
* 1. POST /v2/prompt/adapt - Submit adaptation request
|
|
64
|
+
* 2. GET /v2/prompt/adaptStatus/{id} - Poll status until completed
|
|
65
|
+
* 3. GET /v2/prompt/adaptResults/{id} - Retrieve optimized prompts
|
|
66
|
+
* 4. Use optimized prompts in production with target models
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* **Related Documentation:** See
|
|
70
|
+
* https://docs.notdiamond.ai/docs/adapting-prompts-to-new-models for detailed
|
|
71
|
+
* guide.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const promptAdaptation = await client.promptAdaptation.create({
|
|
76
|
+
* fields: ['question'],
|
|
77
|
+
* system_prompt: 'You are a helpful assistant that answers questions accurately.',
|
|
78
|
+
* target_models: [
|
|
79
|
+
* { provider: 'anthropic', model: 'claude-sonnet-4-5-20250929' },
|
|
80
|
+
* { provider: 'google', model: 'gemini-2.5-flash' },
|
|
81
|
+
* ],
|
|
82
|
+
* template: 'Question: {question}\nAnswer:',
|
|
83
|
+
* evaluation_metric: 'LLMaaJ:Sem_Sim_3',
|
|
84
|
+
* origin_model: { provider: 'openai', model: 'gpt-4o' },
|
|
85
|
+
* test_goldens: [
|
|
86
|
+
* {
|
|
87
|
+
* fields: { ... },
|
|
88
|
+
* answer: '9',
|
|
89
|
+
* },
|
|
90
|
+
* {
|
|
91
|
+
* fields: { ... },
|
|
92
|
+
* answer: 'Pacific Ocean',
|
|
93
|
+
* },
|
|
94
|
+
* ],
|
|
95
|
+
* train_goldens: [
|
|
96
|
+
* {
|
|
97
|
+
* fields: { ... },
|
|
98
|
+
* answer: '4',
|
|
99
|
+
* },
|
|
100
|
+
* {
|
|
101
|
+
* fields: { ... },
|
|
102
|
+
* answer: 'Paris',
|
|
103
|
+
* },
|
|
104
|
+
* {
|
|
105
|
+
* fields: { ... },
|
|
106
|
+
* answer: 'William Shakespeare',
|
|
107
|
+
* },
|
|
108
|
+
* {
|
|
109
|
+
* fields: { ... },
|
|
110
|
+
* answer: 'Water',
|
|
111
|
+
* },
|
|
112
|
+
* {
|
|
113
|
+
* fields: { ... },
|
|
114
|
+
* answer: '7',
|
|
115
|
+
* },
|
|
116
|
+
* ],
|
|
117
|
+
* });
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
create(body, options) {
|
|
121
|
+
return this._client.post('/v2/prompt/adapt', { body, ...options });
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Retrieve the complete results of a prompt adaptation run, including optimized
|
|
125
|
+
* prompts for all target models.
|
|
126
|
+
*
|
|
127
|
+
* This endpoint returns the adapted prompts and evaluation metrics for each target
|
|
128
|
+
* model in your adaptation request. Call this endpoint after the adaptation status
|
|
129
|
+
* is 'completed' to get your optimized prompts.
|
|
130
|
+
*
|
|
131
|
+
* **Response Structure:**
|
|
132
|
+
*
|
|
133
|
+
* - **origin_model**: Baseline performance of your original prompt on the origin
|
|
134
|
+
* model
|
|
135
|
+
* - Includes: system_prompt, user_message_template, score, evaluation metrics,
|
|
136
|
+
* cost
|
|
137
|
+
* - **target_models**: Array of results for each target model
|
|
138
|
+
* - Includes: optimized system_prompt, user_message_template, template_fields
|
|
139
|
+
* - pre_optimization_score: Performance before adaptation
|
|
140
|
+
* - post_optimization_score: Performance after adaptation
|
|
141
|
+
* - Evaluation metrics and cost information
|
|
142
|
+
*
|
|
143
|
+
* **Using Adapted Prompts:**
|
|
144
|
+
*
|
|
145
|
+
* 1. Extract the `system_prompt` and `user_message_template` from each target
|
|
146
|
+
* model result
|
|
147
|
+
* 2. Use `user_message_template_fields` to know which fields to substitute
|
|
148
|
+
* 3. Apply the optimized prompts when calling the respective target models
|
|
149
|
+
* 4. Compare pre/post optimization scores to see improvement
|
|
150
|
+
*
|
|
151
|
+
* **Evaluation Scores:**
|
|
152
|
+
*
|
|
153
|
+
* - Scores range from 0-10 (higher is better)
|
|
154
|
+
* - Compare origin_model score with target_models pre_optimization_score for
|
|
155
|
+
* baseline
|
|
156
|
+
* - Compare pre_optimization_score with post_optimization_score to see improvement
|
|
157
|
+
* from adaptation
|
|
158
|
+
* - Typical improvements range from 5-30% on evaluation metrics
|
|
159
|
+
*
|
|
160
|
+
* **Status Handling:**
|
|
161
|
+
*
|
|
162
|
+
* - If adaptation is still processing, target model results will have
|
|
163
|
+
* `result_status: "processing"`
|
|
164
|
+
* - Only completed target models will have system_prompt and template values
|
|
165
|
+
* - Failed target models will have `result_status: "failed"` with null values
|
|
166
|
+
*
|
|
167
|
+
* **Cost Information:**
|
|
168
|
+
*
|
|
169
|
+
* - Each model result includes cost in USD for the adaptation process
|
|
170
|
+
* - Costs vary based on model pricing and number of evaluation examples
|
|
171
|
+
* - Typical range: $0.10 - $2.00 per target model
|
|
172
|
+
*
|
|
173
|
+
* **Best Practices:**
|
|
174
|
+
*
|
|
175
|
+
* 1. Wait for status 'completed' before calling this endpoint
|
|
176
|
+
* 2. Check result_status for each target model
|
|
177
|
+
* 3. Validate that post_optimization_score > pre_optimization_score
|
|
178
|
+
* 4. Save optimized prompts for production use
|
|
179
|
+
* 5. A/B test adapted prompts against originals in production
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* const response =
|
|
184
|
+
* await client.promptAdaptation.getAdaptResults(
|
|
185
|
+
* 'adaptation_run_id',
|
|
186
|
+
* );
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
getAdaptResults(adaptationRunID, options) {
|
|
190
|
+
return this._client.get((0, path_1.path) `/v2/prompt/adaptResults/${adaptationRunID}`, options);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Check the status of a prompt adaptation run.
|
|
194
|
+
*
|
|
195
|
+
* Use this endpoint to poll the status of your adaptation request. Processing is
|
|
196
|
+
* asynchronous, so you'll need to check periodically until the status indicates
|
|
197
|
+
* completion.
|
|
198
|
+
*
|
|
199
|
+
* **Status Values:**
|
|
200
|
+
*
|
|
201
|
+
* - `created`: Initial state, not yet processing
|
|
202
|
+
* - `queued`: Waiting for processing capacity (check queue_position)
|
|
203
|
+
* - `processing`: Currently optimizing prompts
|
|
204
|
+
* - `completed`: All target models have been processed successfully
|
|
205
|
+
* - `failed`: One or more target models failed to process
|
|
206
|
+
*
|
|
207
|
+
* **Polling Recommendations:**
|
|
208
|
+
*
|
|
209
|
+
* - Poll every 30-60 seconds during processing
|
|
210
|
+
* - Check queue_position if status is 'queued' to estimate wait time
|
|
211
|
+
* - Stop polling once status is 'completed' or 'failed'
|
|
212
|
+
* - Use GET /v2/prompt/adaptResults to retrieve results after completion
|
|
213
|
+
*
|
|
214
|
+
* **Queue Position:**
|
|
215
|
+
*
|
|
216
|
+
* - Only present when status is 'queued'
|
|
217
|
+
* - Lower numbers mean earlier processing (position 1 is next)
|
|
218
|
+
* - Typical wait time: 1-5 minutes per position
|
|
219
|
+
*
|
|
220
|
+
* **Note:** This endpoint only returns status information. To get the actual
|
|
221
|
+
* adapted prompts and evaluation results, use GET /v2/prompt/adaptResults once
|
|
222
|
+
* status is 'completed'.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* const response =
|
|
227
|
+
* await client.promptAdaptation.getAdaptStatus(
|
|
228
|
+
* 'adaptation_run_id',
|
|
229
|
+
* );
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
getAdaptStatus(adaptationRunID, options) {
|
|
233
|
+
return this._client.get((0, path_1.path) `/v2/prompt/adaptStatus/${adaptationRunID}`, options);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get LLM usage costs for a specific prompt adaptation run.
|
|
237
|
+
*
|
|
238
|
+
* This endpoint returns the total cost and detailed usage records for all LLM
|
|
239
|
+
* requests made during a prompt adaptation run. Use this to track costs associated
|
|
240
|
+
* with optimizing prompts for different target models.
|
|
241
|
+
*
|
|
242
|
+
* **Cost Breakdown:**
|
|
243
|
+
*
|
|
244
|
+
* - Total cost across all models used in the adaptation
|
|
245
|
+
* - Individual usage records with provider, model, tokens, and costs
|
|
246
|
+
* - Timestamps for each LLM request
|
|
247
|
+
* - Task type (e.g., optimization, evaluation)
|
|
248
|
+
*
|
|
249
|
+
* **Access Control:**
|
|
250
|
+
*
|
|
251
|
+
* - Only accessible by the user who created the adaptation run
|
|
252
|
+
* - Requires prompt adaptation access
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* const response = await client.promptAdaptation.getCosts(
|
|
257
|
+
* 'adaptation_run_id',
|
|
258
|
+
* );
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
getCosts(adaptationRunID, options) {
|
|
262
|
+
return this._client.get((0, path_1.path) `/v2/prompt/adapt/${adaptationRunID}/costs`, options);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
exports.PromptAdaptation = PromptAdaptation;
|
|
266
|
+
//# sourceMappingURL=prompt-adaptation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-adaptation.js","sourceRoot":"","sources":["../src/resources/prompt-adaptation.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,oDAA8C;AAE9C,MAAa,gBAAiB,SAAQ,sBAAW;IAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+GG;IACH,MAAM,CACJ,IAAkC,EAClC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiEG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;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;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QAAQ,CAAC,eAAuB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,oBAAoB,eAAe,QAAQ,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC;CACF;AA7QD,4CA6QC"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../core/resource.mjs";
|
|
3
|
+
import { path } from "../internal/utils/path.mjs";
|
|
4
|
+
export class PromptAdaptation extends APIResource {
|
|
5
|
+
/**
|
|
6
|
+
* Adapt your prompt from one LLM to work optimally across different target LLMs.
|
|
7
|
+
*
|
|
8
|
+
* This endpoint automatically optimizes your prompt (system prompt + user message
|
|
9
|
+
* template) to achieve better performance when switching between different
|
|
10
|
+
* language models. Each model has unique characteristics, and what works well for
|
|
11
|
+
* GPT-4 might not work as well for Claude or Gemini.
|
|
12
|
+
*
|
|
13
|
+
* **How Prompt Adaptation Works:**
|
|
14
|
+
*
|
|
15
|
+
* 1. You provide your current prompt optimized for an origin model
|
|
16
|
+
* 2. You specify target models you want to adapt to
|
|
17
|
+
* 3. You provide evaluation examples (golden records) with expected answers
|
|
18
|
+
* 4. The system runs optimization to find the best prompt for each target model
|
|
19
|
+
* 5. You receive adapted prompts that perform well on your target models
|
|
20
|
+
*
|
|
21
|
+
* **Evaluation Metrics:** Choose either a standard metric or provide custom
|
|
22
|
+
* evaluation:
|
|
23
|
+
*
|
|
24
|
+
* - **Standard metrics**: LLMaaJ:SQL, LLMaaJ:Sem_Sim_1/3/10 (semantic similarity),
|
|
25
|
+
* JSON_Match
|
|
26
|
+
* - **Custom evaluation**: Provide evaluation_config with your own LLM judge,
|
|
27
|
+
* prompt, and cutoff
|
|
28
|
+
*
|
|
29
|
+
* **Dataset Requirements:**
|
|
30
|
+
*
|
|
31
|
+
* - Minimum 25 examples in train_goldens (more examples = better adaptation)
|
|
32
|
+
* - Each example must have fields matching your template placeholders
|
|
33
|
+
* - Supervised evaluation requires 'answer' field in each golden record
|
|
34
|
+
* - Unsupervised evaluation can work without answers
|
|
35
|
+
*
|
|
36
|
+
* **Training Time:**
|
|
37
|
+
*
|
|
38
|
+
* - Processing is asynchronous and typically takes 10-30 minutes
|
|
39
|
+
* - Time depends on: number of target models, dataset size, model availability
|
|
40
|
+
* - Use the returned adaptation_run_id to check status and retrieve results
|
|
41
|
+
*
|
|
42
|
+
* **Subscription Tiers:**
|
|
43
|
+
*
|
|
44
|
+
* - Free: 1 target model
|
|
45
|
+
* - Starter: 3 target models
|
|
46
|
+
* - Startup: 5 target models
|
|
47
|
+
* - Enterprise: 10 target models
|
|
48
|
+
*
|
|
49
|
+
* **Best Practices:**
|
|
50
|
+
*
|
|
51
|
+
* 1. Use diverse, representative examples from your production workload
|
|
52
|
+
* 2. Include examples for best results (25 minimum)
|
|
53
|
+
* 3. Ensure consistent evaluation across all examples
|
|
54
|
+
* 4. Test both train_goldens and test_goldens split for validation
|
|
55
|
+
* 5. Use the same model versions you'll use in production
|
|
56
|
+
*
|
|
57
|
+
* **Example Workflow:**
|
|
58
|
+
*
|
|
59
|
+
* ```
|
|
60
|
+
* 1. POST /v2/prompt/adapt - Submit adaptation request
|
|
61
|
+
* 2. GET /v2/prompt/adaptStatus/{id} - Poll status until completed
|
|
62
|
+
* 3. GET /v2/prompt/adaptResults/{id} - Retrieve optimized prompts
|
|
63
|
+
* 4. Use optimized prompts in production with target models
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* **Related Documentation:** See
|
|
67
|
+
* https://docs.notdiamond.ai/docs/adapting-prompts-to-new-models for detailed
|
|
68
|
+
* guide.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const promptAdaptation = await client.promptAdaptation.create({
|
|
73
|
+
* fields: ['question'],
|
|
74
|
+
* system_prompt: 'You are a helpful assistant that answers questions accurately.',
|
|
75
|
+
* target_models: [
|
|
76
|
+
* { provider: 'anthropic', model: 'claude-sonnet-4-5-20250929' },
|
|
77
|
+
* { provider: 'google', model: 'gemini-2.5-flash' },
|
|
78
|
+
* ],
|
|
79
|
+
* template: 'Question: {question}\nAnswer:',
|
|
80
|
+
* evaluation_metric: 'LLMaaJ:Sem_Sim_3',
|
|
81
|
+
* origin_model: { provider: 'openai', model: 'gpt-4o' },
|
|
82
|
+
* test_goldens: [
|
|
83
|
+
* {
|
|
84
|
+
* fields: { ... },
|
|
85
|
+
* answer: '9',
|
|
86
|
+
* },
|
|
87
|
+
* {
|
|
88
|
+
* fields: { ... },
|
|
89
|
+
* answer: 'Pacific Ocean',
|
|
90
|
+
* },
|
|
91
|
+
* ],
|
|
92
|
+
* train_goldens: [
|
|
93
|
+
* {
|
|
94
|
+
* fields: { ... },
|
|
95
|
+
* answer: '4',
|
|
96
|
+
* },
|
|
97
|
+
* {
|
|
98
|
+
* fields: { ... },
|
|
99
|
+
* answer: 'Paris',
|
|
100
|
+
* },
|
|
101
|
+
* {
|
|
102
|
+
* fields: { ... },
|
|
103
|
+
* answer: 'William Shakespeare',
|
|
104
|
+
* },
|
|
105
|
+
* {
|
|
106
|
+
* fields: { ... },
|
|
107
|
+
* answer: 'Water',
|
|
108
|
+
* },
|
|
109
|
+
* {
|
|
110
|
+
* fields: { ... },
|
|
111
|
+
* answer: '7',
|
|
112
|
+
* },
|
|
113
|
+
* ],
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
create(body, options) {
|
|
118
|
+
return this._client.post('/v2/prompt/adapt', { body, ...options });
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Retrieve the complete results of a prompt adaptation run, including optimized
|
|
122
|
+
* prompts for all target models.
|
|
123
|
+
*
|
|
124
|
+
* This endpoint returns the adapted prompts and evaluation metrics for each target
|
|
125
|
+
* model in your adaptation request. Call this endpoint after the adaptation status
|
|
126
|
+
* is 'completed' to get your optimized prompts.
|
|
127
|
+
*
|
|
128
|
+
* **Response Structure:**
|
|
129
|
+
*
|
|
130
|
+
* - **origin_model**: Baseline performance of your original prompt on the origin
|
|
131
|
+
* model
|
|
132
|
+
* - Includes: system_prompt, user_message_template, score, evaluation metrics,
|
|
133
|
+
* cost
|
|
134
|
+
* - **target_models**: Array of results for each target model
|
|
135
|
+
* - Includes: optimized system_prompt, user_message_template, template_fields
|
|
136
|
+
* - pre_optimization_score: Performance before adaptation
|
|
137
|
+
* - post_optimization_score: Performance after adaptation
|
|
138
|
+
* - Evaluation metrics and cost information
|
|
139
|
+
*
|
|
140
|
+
* **Using Adapted Prompts:**
|
|
141
|
+
*
|
|
142
|
+
* 1. Extract the `system_prompt` and `user_message_template` from each target
|
|
143
|
+
* model result
|
|
144
|
+
* 2. Use `user_message_template_fields` to know which fields to substitute
|
|
145
|
+
* 3. Apply the optimized prompts when calling the respective target models
|
|
146
|
+
* 4. Compare pre/post optimization scores to see improvement
|
|
147
|
+
*
|
|
148
|
+
* **Evaluation Scores:**
|
|
149
|
+
*
|
|
150
|
+
* - Scores range from 0-10 (higher is better)
|
|
151
|
+
* - Compare origin_model score with target_models pre_optimization_score for
|
|
152
|
+
* baseline
|
|
153
|
+
* - Compare pre_optimization_score with post_optimization_score to see improvement
|
|
154
|
+
* from adaptation
|
|
155
|
+
* - Typical improvements range from 5-30% on evaluation metrics
|
|
156
|
+
*
|
|
157
|
+
* **Status Handling:**
|
|
158
|
+
*
|
|
159
|
+
* - If adaptation is still processing, target model results will have
|
|
160
|
+
* `result_status: "processing"`
|
|
161
|
+
* - Only completed target models will have system_prompt and template values
|
|
162
|
+
* - Failed target models will have `result_status: "failed"` with null values
|
|
163
|
+
*
|
|
164
|
+
* **Cost Information:**
|
|
165
|
+
*
|
|
166
|
+
* - Each model result includes cost in USD for the adaptation process
|
|
167
|
+
* - Costs vary based on model pricing and number of evaluation examples
|
|
168
|
+
* - Typical range: $0.10 - $2.00 per target model
|
|
169
|
+
*
|
|
170
|
+
* **Best Practices:**
|
|
171
|
+
*
|
|
172
|
+
* 1. Wait for status 'completed' before calling this endpoint
|
|
173
|
+
* 2. Check result_status for each target model
|
|
174
|
+
* 3. Validate that post_optimization_score > pre_optimization_score
|
|
175
|
+
* 4. Save optimized prompts for production use
|
|
176
|
+
* 5. A/B test adapted prompts against originals in production
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* const response =
|
|
181
|
+
* await client.promptAdaptation.getAdaptResults(
|
|
182
|
+
* 'adaptation_run_id',
|
|
183
|
+
* );
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
getAdaptResults(adaptationRunID, options) {
|
|
187
|
+
return this._client.get(path `/v2/prompt/adaptResults/${adaptationRunID}`, options);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Check the status of a prompt adaptation run.
|
|
191
|
+
*
|
|
192
|
+
* Use this endpoint to poll the status of your adaptation request. Processing is
|
|
193
|
+
* asynchronous, so you'll need to check periodically until the status indicates
|
|
194
|
+
* completion.
|
|
195
|
+
*
|
|
196
|
+
* **Status Values:**
|
|
197
|
+
*
|
|
198
|
+
* - `created`: Initial state, not yet processing
|
|
199
|
+
* - `queued`: Waiting for processing capacity (check queue_position)
|
|
200
|
+
* - `processing`: Currently optimizing prompts
|
|
201
|
+
* - `completed`: All target models have been processed successfully
|
|
202
|
+
* - `failed`: One or more target models failed to process
|
|
203
|
+
*
|
|
204
|
+
* **Polling Recommendations:**
|
|
205
|
+
*
|
|
206
|
+
* - Poll every 30-60 seconds during processing
|
|
207
|
+
* - Check queue_position if status is 'queued' to estimate wait time
|
|
208
|
+
* - Stop polling once status is 'completed' or 'failed'
|
|
209
|
+
* - Use GET /v2/prompt/adaptResults to retrieve results after completion
|
|
210
|
+
*
|
|
211
|
+
* **Queue Position:**
|
|
212
|
+
*
|
|
213
|
+
* - Only present when status is 'queued'
|
|
214
|
+
* - Lower numbers mean earlier processing (position 1 is next)
|
|
215
|
+
* - Typical wait time: 1-5 minutes per position
|
|
216
|
+
*
|
|
217
|
+
* **Note:** This endpoint only returns status information. To get the actual
|
|
218
|
+
* adapted prompts and evaluation results, use GET /v2/prompt/adaptResults once
|
|
219
|
+
* status is 'completed'.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* const response =
|
|
224
|
+
* await client.promptAdaptation.getAdaptStatus(
|
|
225
|
+
* 'adaptation_run_id',
|
|
226
|
+
* );
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
getAdaptStatus(adaptationRunID, options) {
|
|
230
|
+
return this._client.get(path `/v2/prompt/adaptStatus/${adaptationRunID}`, options);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Get LLM usage costs for a specific prompt adaptation run.
|
|
234
|
+
*
|
|
235
|
+
* This endpoint returns the total cost and detailed usage records for all LLM
|
|
236
|
+
* requests made during a prompt adaptation run. Use this to track costs associated
|
|
237
|
+
* with optimizing prompts for different target models.
|
|
238
|
+
*
|
|
239
|
+
* **Cost Breakdown:**
|
|
240
|
+
*
|
|
241
|
+
* - Total cost across all models used in the adaptation
|
|
242
|
+
* - Individual usage records with provider, model, tokens, and costs
|
|
243
|
+
* - Timestamps for each LLM request
|
|
244
|
+
* - Task type (e.g., optimization, evaluation)
|
|
245
|
+
*
|
|
246
|
+
* **Access Control:**
|
|
247
|
+
*
|
|
248
|
+
* - Only accessible by the user who created the adaptation run
|
|
249
|
+
* - Requires prompt adaptation access
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* const response = await client.promptAdaptation.getCosts(
|
|
254
|
+
* 'adaptation_run_id',
|
|
255
|
+
* );
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
getCosts(adaptationRunID, options) {
|
|
259
|
+
return this._client.get(path `/v2/prompt/adapt/${adaptationRunID}/costs`, options);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=prompt-adaptation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-adaptation.mjs","sourceRoot":"","sources":["../src/resources/prompt-adaptation.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAIf,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+GG;IACH,MAAM,CACJ,IAAkC,EAClC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiEG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;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;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QAAQ,CAAC,eAAuB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,oBAAoB,eAAe,QAAQ,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/resources/report/index.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAE,KAAK,4BAA4B,EAAE,KAAK,0BAA0B,EAAE;OAC/E,EAAE,MAAM,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/report/index.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAE,KAAK,4BAA4B,EAAE,KAAK,0BAA0B,EAAE;OAC/E,EAAE,MAAM,EAAE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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.Report = exports.Metrics = void 0;
|
|
5
|
+
var metrics_1 = require("./metrics.js");
|
|
6
|
+
Object.defineProperty(exports, "Metrics", { enumerable: true, get: function () { return metrics_1.Metrics; } });
|
|
7
|
+
var report_1 = require("./report.js");
|
|
8
|
+
Object.defineProperty(exports, "Report", { enumerable: true, get: function () { return report_1.Report; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/report/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wCAAwG;AAA/F,kGAAA,OAAO,OAAA;AAChB,sCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/resources/report/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,OAAO,EAAsE;OAC/E,EAAE,MAAM,EAAE"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { APIResource } from "../../core/resource.mjs";
|
|
2
|
+
import * as PromptAdaptationAPI from "../prompt-adaptation.mjs";
|
|
3
|
+
import { APIPromise } from "../../core/api-promise.mjs";
|
|
4
|
+
import { RequestOptions } from "../../internal/request-options.mjs";
|
|
5
|
+
export declare class Metrics extends APIResource {
|
|
6
|
+
/**
|
|
7
|
+
* Submit feedback on a routing decision to improve future recommendations.
|
|
8
|
+
*
|
|
9
|
+
* This endpoint allows you to provide feedback on whether the router selected the
|
|
10
|
+
* right model for your query. Your feedback is used to:
|
|
11
|
+
*
|
|
12
|
+
* 1. Personalize routing decisions for your preference_id
|
|
13
|
+
* 2. Improve the overall routing quality
|
|
14
|
+
* 3. Train and refine custom routers
|
|
15
|
+
*
|
|
16
|
+
* **Feedback Format:**
|
|
17
|
+
*
|
|
18
|
+
* - `accuracy: 1` - Thumbs up (the model performed well)
|
|
19
|
+
* - `accuracy: 0` - Thumbs down (the model did not perform well)
|
|
20
|
+
*
|
|
21
|
+
* **Requirements:**
|
|
22
|
+
*
|
|
23
|
+
* - You must have used a preference_id in the original model_select() call
|
|
24
|
+
* - The session_id must be valid and belong to your account
|
|
25
|
+
* - The provider must match one of the providers returned by model_select()
|
|
26
|
+
*
|
|
27
|
+
* **How Feedback Works:** When you submit thumbs down, the router will:
|
|
28
|
+
*
|
|
29
|
+
* - Decrease the ranking of the selected model for similar queries
|
|
30
|
+
* - Consider alternative models more favorably
|
|
31
|
+
*
|
|
32
|
+
* When you submit thumbs up, the router will:
|
|
33
|
+
*
|
|
34
|
+
* - Increase the ranking of the selected model for similar queries
|
|
35
|
+
* - Prioritize this model for similar future requests
|
|
36
|
+
*
|
|
37
|
+
* **Note:** Feedback requires a valid preference_id. Create one via POST
|
|
38
|
+
* /v2/preferences/userPreferenceCreate
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const response = await client.report.metrics.submitFeedback(
|
|
43
|
+
* {
|
|
44
|
+
* feedback: { accuracy: 1 },
|
|
45
|
+
* provider: { provider: 'openai', model: 'gpt-4o' },
|
|
46
|
+
* session_id: '550e8400-e29b-41d4-a716-446655440000',
|
|
47
|
+
* },
|
|
48
|
+
* );
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
submitFeedback(body: MetricSubmitFeedbackParams, options?: RequestOptions): APIPromise<MetricSubmitFeedbackResponse>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Response from feedback submission endpoint.
|
|
55
|
+
*/
|
|
56
|
+
export interface MetricSubmitFeedbackResponse {
|
|
57
|
+
/**
|
|
58
|
+
* The processed feedback
|
|
59
|
+
*/
|
|
60
|
+
feedback: {
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The session ID for which feedback was submitted
|
|
65
|
+
*/
|
|
66
|
+
session_id: string;
|
|
67
|
+
}
|
|
68
|
+
export interface MetricSubmitFeedbackParams {
|
|
69
|
+
/**
|
|
70
|
+
* Feedback dictionary with 'accuracy' key (0 for thumbs down, 1 for thumbs up)
|
|
71
|
+
*/
|
|
72
|
+
feedback: {
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* The provider that was selected by the router
|
|
77
|
+
*/
|
|
78
|
+
provider: PromptAdaptationAPI.RequestProvider;
|
|
79
|
+
/**
|
|
80
|
+
* Session ID returned from POST /v2/modelRouter/modelSelect
|
|
81
|
+
*/
|
|
82
|
+
session_id: string;
|
|
83
|
+
}
|
|
84
|
+
export declare namespace Metrics {
|
|
85
|
+
export { type MetricSubmitFeedbackResponse as MetricSubmitFeedbackResponse, type MetricSubmitFeedbackParams as MetricSubmitFeedbackParams, };
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=metrics.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.mts","sourceRoot":"","sources":["../../src/resources/report/metrics.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,mBAAmB;OACxB,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,OAAQ,SAAQ,WAAW;IACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,cAAc,CACZ,IAAI,EAAE,0BAA0B,EAChC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,4BAA4B,CAAC;CAG5C;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAErC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAErC;;OAEG;IACH,QAAQ,EAAE,mBAAmB,CAAC,eAAe,CAAC;IAE9C;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,OAAO,EACL,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,0BAA0B,IAAI,0BAA0B,GAC9D,CAAC;CACH"}
|