notdiamond 2.0.0-rc1 → 2.0.0-rc11
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 +102 -0
- package/LICENSE +1 -1
- package/README.md +327 -124
- package/client.d.mts +28 -42
- package/client.d.mts.map +1 -1
- package/client.d.ts +28 -42
- package/client.d.ts.map +1 -1
- package/client.js +52 -68
- package/client.js.map +1 -1
- package/client.mjs +50 -66
- package/client.mjs.map +1 -1
- package/core/api-promise.d.mts +2 -2
- package/core/api-promise.d.ts +2 -2
- package/core/error.d.mts +2 -2
- package/core/error.d.ts +2 -2
- package/core/error.js +4 -4
- package/core/error.mjs +2 -2
- package/core/resource.d.mts +3 -3
- package/core/resource.d.ts +3 -3
- package/index.d.mts +3 -3
- package/index.d.ts +3 -3
- package/index.js +4 -4
- package/index.mjs +3 -3
- package/internal/parse.d.mts +2 -2
- package/internal/parse.d.ts +2 -2
- package/internal/shims.js +1 -1
- package/internal/shims.mjs +1 -1
- package/internal/tslib.js +17 -17
- package/internal/uploads.d.mts +4 -4
- package/internal/uploads.d.ts +4 -4
- package/internal/utils/base64.js +2 -2
- package/internal/utils/base64.mjs +3 -3
- package/internal/utils/env.d.mts.map +1 -1
- package/internal/utils/env.d.ts.map +1 -1
- package/internal/utils/env.js +4 -2
- package/internal/utils/env.js.map +1 -1
- package/internal/utils/env.mjs +4 -2
- package/internal/utils/env.mjs.map +1 -1
- package/internal/utils/log.d.mts +3 -3
- package/internal/utils/log.d.ts +3 -3
- package/internal/utils/path.js +1 -1
- package/internal/utils/path.mjs +2 -2
- package/internal/utils/values.js +5 -5
- package/internal/utils/values.mjs +6 -6
- package/package.json +11 -12
- 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 +6 -6
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +6 -6
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +6 -6
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +3 -3
- package/resources/index.mjs.map +1 -1
- 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 +50 -25
- package/resources/models.d.mts.map +1 -1
- package/resources/models.d.ts +50 -25
- package/resources/models.d.ts.map +1 -1
- package/resources/models.js +5 -0
- package/resources/models.js.map +1 -1
- package/resources/models.mjs +5 -0
- package/resources/models.mjs.map +1 -1
- package/resources/preferences.d.mts +34 -48
- package/resources/preferences.d.mts.map +1 -1
- package/resources/preferences.d.ts +34 -48
- package/resources/preferences.d.ts.map +1 -1
- package/resources/preferences.js +14 -36
- package/resources/preferences.js.map +1 -1
- package/resources/preferences.mjs +14 -36
- package/resources/preferences.mjs.map +1 -1
- package/resources/prompt-adaptation.d.mts +339 -234
- package/resources/prompt-adaptation.d.mts.map +1 -1
- package/resources/prompt-adaptation.d.ts +339 -234
- package/resources/prompt-adaptation.d.ts.map +1 -1
- package/resources/prompt-adaptation.js +30 -53
- package/resources/prompt-adaptation.js.map +1 -1
- package/resources/prompt-adaptation.mjs +30 -53
- package/resources/prompt-adaptation.mjs.map +1 -1
- 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 +1 -244
- package/resources/report.d.mts.map +1 -1
- package/resources/report.d.ts +1 -244
- package/resources/report.d.ts.map +1 -1
- package/resources/report.js +2 -82
- package/resources/report.js.map +1 -1
- package/resources/report.mjs +1 -80
- package/resources/report.mjs.map +1 -1
- package/src/client.ts +80 -131
- package/src/core/api-promise.ts +4 -4
- package/src/core/error.ts +2 -2
- package/src/core/resource.ts +3 -3
- package/src/index.ts +3 -3
- package/src/internal/parse.ts +2 -2
- package/src/internal/shims.ts +1 -1
- package/src/internal/uploads.ts +5 -5
- package/src/internal/utils/base64.ts +3 -3
- package/src/internal/utils/env.ts +4 -2
- package/src/internal/utils/log.ts +3 -3
- package/src/internal/utils/path.ts +2 -2
- package/src/internal/utils/values.ts +6 -6
- package/src/resources/custom-router.ts +168 -0
- package/src/resources/index.ts +23 -34
- package/src/resources/model-router.ts +224 -0
- package/src/resources/models.ts +55 -32
- package/src/resources/preferences.ts +40 -77
- package/src/resources/prompt-adaptation.ts +361 -291
- 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 +1 -298
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/resources/admin.d.mts +0 -4
- package/resources/admin.d.mts.map +0 -1
- package/resources/admin.d.ts +0 -4
- package/resources/admin.d.ts.map +0 -1
- package/resources/admin.js +0 -9
- package/resources/admin.js.map +0 -1
- package/resources/admin.mjs +0 -5
- package/resources/admin.mjs.map +0 -1
- package/resources/routing.d.mts +0 -391
- package/resources/routing.d.mts.map +0 -1
- package/resources/routing.d.ts +0 -391
- package/resources/routing.d.ts.map +0 -1
- package/resources/routing.js +0 -163
- package/resources/routing.js.map +0 -1
- package/resources/routing.mjs +0 -159
- package/resources/routing.mjs.map +0 -1
- package/src/resources/admin.ts +0 -5
- package/src/resources/routing.ts +0 -476
package/client.d.mts
CHANGED
|
@@ -6,38 +6,25 @@ import * as Errors from "./core/error.mjs";
|
|
|
6
6
|
import * as Uploads from "./core/uploads.mjs";
|
|
7
7
|
import * as API from "./resources/index.mjs";
|
|
8
8
|
import { APIPromise } from "./core/api-promise.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
9
|
+
import { CustomRouter, CustomRouterTrainCustomRouterParams, CustomRouterTrainCustomRouterResponse } from "./resources/custom-router.mjs";
|
|
10
|
+
import { ModelRouter, ModelRouterSelectModelParams, ModelRouterSelectModelResponse } from "./resources/model-router.mjs";
|
|
11
|
+
import { Model, ModelListParams, ModelListResponse, Models } from "./resources/models.mjs";
|
|
12
|
+
import { PreferenceCreateParams, PreferenceCreateResponse, PreferenceDeleteResponse, PreferenceUpdateParams, PreferenceUpdateResponse, Preferences } from "./resources/preferences.mjs";
|
|
13
|
+
import { GoldenRecord, JobStatus, PromptAdaptation, PromptAdaptationCreateParams, PromptAdaptationCreateResponse, PromptAdaptationGetAdaptResultsResponse, PromptAdaptationGetAdaptStatusResponse, PromptAdaptationGetCostsResponse, RequestProvider } from "./resources/prompt-adaptation.mjs";
|
|
14
|
+
import { Report } from "./resources/report/report.mjs";
|
|
15
15
|
import { type Fetch } from "./internal/builtin-types.mjs";
|
|
16
16
|
import { HeadersLike, NullableHeaders } from "./internal/headers.mjs";
|
|
17
17
|
import { FinalRequestOptions, RequestOptions } from "./internal/request-options.mjs";
|
|
18
18
|
import { type LogLevel, type Logger } from "./internal/utils/log.mjs";
|
|
19
|
-
declare const environments: {
|
|
20
|
-
production: string;
|
|
21
|
-
staging: string;
|
|
22
|
-
};
|
|
23
|
-
type Environment = keyof typeof environments;
|
|
24
19
|
export interface ClientOptions {
|
|
25
20
|
/**
|
|
26
|
-
*
|
|
21
|
+
* API key authentication using Bearer token
|
|
27
22
|
*/
|
|
28
|
-
apiKey?: string |
|
|
29
|
-
/**
|
|
30
|
-
* Specifies the environment to use for the API.
|
|
31
|
-
*
|
|
32
|
-
* Each environment maps to a different base URL:
|
|
33
|
-
* - `production` corresponds to `https://api.notdiamond.ai`
|
|
34
|
-
* - `staging` corresponds to `https://staging-api.notdiamond.ai`
|
|
35
|
-
*/
|
|
36
|
-
environment?: Environment | undefined;
|
|
23
|
+
apiKey?: string | undefined;
|
|
37
24
|
/**
|
|
38
25
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
39
26
|
*
|
|
40
|
-
* Defaults to process.env['
|
|
27
|
+
* Defaults to process.env['NOTDIAMOND_BASE_URL'].
|
|
41
28
|
*/
|
|
42
29
|
baseURL?: string | null | undefined;
|
|
43
30
|
/**
|
|
@@ -85,7 +72,7 @@ export interface ClientOptions {
|
|
|
85
72
|
/**
|
|
86
73
|
* Set the log level.
|
|
87
74
|
*
|
|
88
|
-
* Defaults to process.env['
|
|
75
|
+
* Defaults to process.env['NOTDIAMOND_LOG'] or 'warn' if it isn't set.
|
|
89
76
|
*/
|
|
90
77
|
logLevel?: LogLevel | undefined;
|
|
91
78
|
/**
|
|
@@ -96,11 +83,11 @@ export interface ClientOptions {
|
|
|
96
83
|
logger?: Logger | undefined;
|
|
97
84
|
}
|
|
98
85
|
/**
|
|
99
|
-
* API Client for interfacing with the
|
|
86
|
+
* API Client for interfacing with the Notdiamond API.
|
|
100
87
|
*/
|
|
101
|
-
export declare class
|
|
88
|
+
export declare class Notdiamond {
|
|
102
89
|
#private;
|
|
103
|
-
apiKey: string
|
|
90
|
+
apiKey: string;
|
|
104
91
|
baseURL: string;
|
|
105
92
|
maxRetries: number;
|
|
106
93
|
timeout: number;
|
|
@@ -111,11 +98,10 @@ export declare class NotDiamond {
|
|
|
111
98
|
protected idempotencyHeader?: string;
|
|
112
99
|
private _options;
|
|
113
100
|
/**
|
|
114
|
-
* API Client for interfacing with the
|
|
101
|
+
* API Client for interfacing with the Notdiamond API.
|
|
115
102
|
*
|
|
116
|
-
* @param {string |
|
|
117
|
-
* @param {
|
|
118
|
-
* @param {string} [opts.baseURL=process.env['NOT_DIAMOND_BASE_URL'] ?? https://api.notdiamond.ai] - Override the default base URL for the API.
|
|
103
|
+
* @param {string | undefined} [opts.apiKey=process.env['NOT_DIAMOND_API_KEY'] ?? undefined]
|
|
104
|
+
* @param {string} [opts.baseURL=process.env['NOTDIAMOND_BASE_URL'] ?? https://api.notdiamond.ai] - Override the default base URL for the API.
|
|
119
105
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
120
106
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
121
107
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -171,9 +157,9 @@ export declare class NotDiamond {
|
|
|
171
157
|
}>;
|
|
172
158
|
private buildHeaders;
|
|
173
159
|
private buildBody;
|
|
174
|
-
static
|
|
160
|
+
static Notdiamond: typeof Notdiamond;
|
|
175
161
|
static DEFAULT_TIMEOUT: number;
|
|
176
|
-
static
|
|
162
|
+
static NotdiamondError: typeof Errors.NotdiamondError;
|
|
177
163
|
static APIError: typeof Errors.APIError;
|
|
178
164
|
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
179
165
|
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
@@ -187,20 +173,20 @@ export declare class NotDiamond {
|
|
|
187
173
|
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
188
174
|
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
189
175
|
static toFile: typeof Uploads.toFile;
|
|
190
|
-
|
|
176
|
+
modelRouter: API.ModelRouter;
|
|
177
|
+
report: API.Report;
|
|
191
178
|
preferences: API.Preferences;
|
|
192
179
|
promptAdaptation: API.PromptAdaptation;
|
|
193
|
-
|
|
180
|
+
customRouter: API.CustomRouter;
|
|
194
181
|
models: API.Models;
|
|
195
|
-
admin: API.Admin;
|
|
196
182
|
}
|
|
197
|
-
export declare namespace
|
|
183
|
+
export declare namespace Notdiamond {
|
|
198
184
|
export type RequestOptions = Opts.RequestOptions;
|
|
199
|
-
export {
|
|
200
|
-
export {
|
|
201
|
-
export {
|
|
202
|
-
export {
|
|
203
|
-
export {
|
|
204
|
-
export {
|
|
185
|
+
export { ModelRouter as ModelRouter, type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse, type ModelRouterSelectModelParams as ModelRouterSelectModelParams, };
|
|
186
|
+
export { Report as Report };
|
|
187
|
+
export { Preferences as Preferences, type PreferenceCreateResponse as PreferenceCreateResponse, type PreferenceUpdateResponse as PreferenceUpdateResponse, type PreferenceDeleteResponse as PreferenceDeleteResponse, type PreferenceCreateParams as PreferenceCreateParams, type PreferenceUpdateParams as PreferenceUpdateParams, };
|
|
188
|
+
export { PromptAdaptation as PromptAdaptation, type GoldenRecord as GoldenRecord, type JobStatus as JobStatus, type RequestProvider as RequestProvider, type PromptAdaptationCreateResponse as PromptAdaptationCreateResponse, type PromptAdaptationGetAdaptResultsResponse as PromptAdaptationGetAdaptResultsResponse, type PromptAdaptationGetAdaptStatusResponse as PromptAdaptationGetAdaptStatusResponse, type PromptAdaptationGetCostsResponse as PromptAdaptationGetCostsResponse, type PromptAdaptationCreateParams as PromptAdaptationCreateParams, };
|
|
189
|
+
export { CustomRouter as CustomRouter, type CustomRouterTrainCustomRouterResponse as CustomRouterTrainCustomRouterResponse, type CustomRouterTrainCustomRouterParams as CustomRouterTrainCustomRouterParams, };
|
|
190
|
+
export { Models as Models, type Model as Model, type ModelListResponse as ModelListResponse, type ModelListParams as ModelListParams, };
|
|
205
191
|
}
|
|
206
192
|
//# sourceMappingURL=client.d.mts.map
|
package/client.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;OAC3C,KAAK,EAAc,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE;YAIvE,EAAE,MAAM,EAAE,QAAQ,EAAE;OAKzB,KAAK,IAAI;OAGT,KAAK,MAAM;OACX,KAAK,OAAO;OACZ,KAAK,GAAG;OACR,EAAE,UAAU,EAAE;OACd,EAAE,KAAK,EAAE
|
|
1
|
+
{"version":3,"file":"client.d.mts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;OAC3C,KAAK,EAAc,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE;YAIvE,EAAE,MAAM,EAAE,QAAQ,EAAE;OAKzB,KAAK,IAAI;OAGT,KAAK,MAAM;OACX,KAAK,OAAO;OACZ,KAAK,GAAG;OACR,EAAE,UAAU,EAAE;OACd,EACL,YAAY,EACZ,mCAAmC,EACnC,qCAAqC,EACtC;OACM,EACL,WAAW,EACX,4BAA4B,EAC5B,8BAA8B,EAC/B;OACM,EAAE,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,EAAE;OACrD,EACL,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,WAAW,EACZ;OACM,EACL,YAAY,EACZ,SAAS,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CAAC;IAEF,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,CAAC;IAE5B,OAAO,EACL,WAAW,IAAI,WAAW,EAC1B,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,sBAAsB,IAAI,sBAAsB,GACtD,CAAC;IAEF,OAAO,EACL,gBAAgB,IAAI,gBAAgB,EACpC,KAAK,YAAY,IAAI,YAAY,EACjC,KAAK,SAAS,IAAI,SAAS,EAC3B,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,8BAA8B,IAAI,8BAA8B,EACrE,KAAK,uCAAuC,IAAI,uCAAuC,EACvF,KAAK,sCAAsC,IAAI,sCAAsC,EACrF,KAAK,gCAAgC,IAAI,gCAAgC,EACzE,KAAK,4BAA4B,IAAI,4BAA4B,GAClE,CAAC;IAEF,OAAO,EACL,YAAY,IAAI,YAAY,EAC5B,KAAK,qCAAqC,IAAI,qCAAqC,EACnF,KAAK,mCAAmC,IAAI,mCAAmC,GAChF,CAAC;IAEF,OAAO,EACL,MAAM,IAAI,MAAM,EAChB,KAAK,KAAK,IAAI,KAAK,EACnB,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,eAAe,IAAI,eAAe,GACxC,CAAC;CACH"}
|
package/client.d.ts
CHANGED
|
@@ -6,38 +6,25 @@ import * as Errors from "./core/error.js";
|
|
|
6
6
|
import * as Uploads from "./core/uploads.js";
|
|
7
7
|
import * as API from "./resources/index.js";
|
|
8
8
|
import { APIPromise } from "./core/api-promise.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
9
|
+
import { CustomRouter, CustomRouterTrainCustomRouterParams, CustomRouterTrainCustomRouterResponse } from "./resources/custom-router.js";
|
|
10
|
+
import { ModelRouter, ModelRouterSelectModelParams, ModelRouterSelectModelResponse } from "./resources/model-router.js";
|
|
11
|
+
import { Model, ModelListParams, ModelListResponse, Models } from "./resources/models.js";
|
|
12
|
+
import { PreferenceCreateParams, PreferenceCreateResponse, PreferenceDeleteResponse, PreferenceUpdateParams, PreferenceUpdateResponse, Preferences } from "./resources/preferences.js";
|
|
13
|
+
import { GoldenRecord, JobStatus, PromptAdaptation, PromptAdaptationCreateParams, PromptAdaptationCreateResponse, PromptAdaptationGetAdaptResultsResponse, PromptAdaptationGetAdaptStatusResponse, PromptAdaptationGetCostsResponse, RequestProvider } from "./resources/prompt-adaptation.js";
|
|
14
|
+
import { Report } from "./resources/report/report.js";
|
|
15
15
|
import { type Fetch } from "./internal/builtin-types.js";
|
|
16
16
|
import { HeadersLike, NullableHeaders } from "./internal/headers.js";
|
|
17
17
|
import { FinalRequestOptions, RequestOptions } from "./internal/request-options.js";
|
|
18
18
|
import { type LogLevel, type Logger } from "./internal/utils/log.js";
|
|
19
|
-
declare const environments: {
|
|
20
|
-
production: string;
|
|
21
|
-
staging: string;
|
|
22
|
-
};
|
|
23
|
-
type Environment = keyof typeof environments;
|
|
24
19
|
export interface ClientOptions {
|
|
25
20
|
/**
|
|
26
|
-
*
|
|
21
|
+
* API key authentication using Bearer token
|
|
27
22
|
*/
|
|
28
|
-
apiKey?: string |
|
|
29
|
-
/**
|
|
30
|
-
* Specifies the environment to use for the API.
|
|
31
|
-
*
|
|
32
|
-
* Each environment maps to a different base URL:
|
|
33
|
-
* - `production` corresponds to `https://api.notdiamond.ai`
|
|
34
|
-
* - `staging` corresponds to `https://staging-api.notdiamond.ai`
|
|
35
|
-
*/
|
|
36
|
-
environment?: Environment | undefined;
|
|
23
|
+
apiKey?: string | undefined;
|
|
37
24
|
/**
|
|
38
25
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
39
26
|
*
|
|
40
|
-
* Defaults to process.env['
|
|
27
|
+
* Defaults to process.env['NOTDIAMOND_BASE_URL'].
|
|
41
28
|
*/
|
|
42
29
|
baseURL?: string | null | undefined;
|
|
43
30
|
/**
|
|
@@ -85,7 +72,7 @@ export interface ClientOptions {
|
|
|
85
72
|
/**
|
|
86
73
|
* Set the log level.
|
|
87
74
|
*
|
|
88
|
-
* Defaults to process.env['
|
|
75
|
+
* Defaults to process.env['NOTDIAMOND_LOG'] or 'warn' if it isn't set.
|
|
89
76
|
*/
|
|
90
77
|
logLevel?: LogLevel | undefined;
|
|
91
78
|
/**
|
|
@@ -96,11 +83,11 @@ export interface ClientOptions {
|
|
|
96
83
|
logger?: Logger | undefined;
|
|
97
84
|
}
|
|
98
85
|
/**
|
|
99
|
-
* API Client for interfacing with the
|
|
86
|
+
* API Client for interfacing with the Notdiamond API.
|
|
100
87
|
*/
|
|
101
|
-
export declare class
|
|
88
|
+
export declare class Notdiamond {
|
|
102
89
|
#private;
|
|
103
|
-
apiKey: string
|
|
90
|
+
apiKey: string;
|
|
104
91
|
baseURL: string;
|
|
105
92
|
maxRetries: number;
|
|
106
93
|
timeout: number;
|
|
@@ -111,11 +98,10 @@ export declare class NotDiamond {
|
|
|
111
98
|
protected idempotencyHeader?: string;
|
|
112
99
|
private _options;
|
|
113
100
|
/**
|
|
114
|
-
* API Client for interfacing with the
|
|
101
|
+
* API Client for interfacing with the Notdiamond API.
|
|
115
102
|
*
|
|
116
|
-
* @param {string |
|
|
117
|
-
* @param {
|
|
118
|
-
* @param {string} [opts.baseURL=process.env['NOT_DIAMOND_BASE_URL'] ?? https://api.notdiamond.ai] - Override the default base URL for the API.
|
|
103
|
+
* @param {string | undefined} [opts.apiKey=process.env['NOT_DIAMOND_API_KEY'] ?? undefined]
|
|
104
|
+
* @param {string} [opts.baseURL=process.env['NOTDIAMOND_BASE_URL'] ?? https://api.notdiamond.ai] - Override the default base URL for the API.
|
|
119
105
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
120
106
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
121
107
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -171,9 +157,9 @@ export declare class NotDiamond {
|
|
|
171
157
|
}>;
|
|
172
158
|
private buildHeaders;
|
|
173
159
|
private buildBody;
|
|
174
|
-
static
|
|
160
|
+
static Notdiamond: typeof Notdiamond;
|
|
175
161
|
static DEFAULT_TIMEOUT: number;
|
|
176
|
-
static
|
|
162
|
+
static NotdiamondError: typeof Errors.NotdiamondError;
|
|
177
163
|
static APIError: typeof Errors.APIError;
|
|
178
164
|
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
179
165
|
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
@@ -187,20 +173,20 @@ export declare class NotDiamond {
|
|
|
187
173
|
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
188
174
|
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
189
175
|
static toFile: typeof Uploads.toFile;
|
|
190
|
-
|
|
176
|
+
modelRouter: API.ModelRouter;
|
|
177
|
+
report: API.Report;
|
|
191
178
|
preferences: API.Preferences;
|
|
192
179
|
promptAdaptation: API.PromptAdaptation;
|
|
193
|
-
|
|
180
|
+
customRouter: API.CustomRouter;
|
|
194
181
|
models: API.Models;
|
|
195
|
-
admin: API.Admin;
|
|
196
182
|
}
|
|
197
|
-
export declare namespace
|
|
183
|
+
export declare namespace Notdiamond {
|
|
198
184
|
export type RequestOptions = Opts.RequestOptions;
|
|
199
|
-
export {
|
|
200
|
-
export {
|
|
201
|
-
export {
|
|
202
|
-
export {
|
|
203
|
-
export {
|
|
204
|
-
export {
|
|
185
|
+
export { ModelRouter as ModelRouter, type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse, type ModelRouterSelectModelParams as ModelRouterSelectModelParams, };
|
|
186
|
+
export { Report as Report };
|
|
187
|
+
export { Preferences as Preferences, type PreferenceCreateResponse as PreferenceCreateResponse, type PreferenceUpdateResponse as PreferenceUpdateResponse, type PreferenceDeleteResponse as PreferenceDeleteResponse, type PreferenceCreateParams as PreferenceCreateParams, type PreferenceUpdateParams as PreferenceUpdateParams, };
|
|
188
|
+
export { PromptAdaptation as PromptAdaptation, type GoldenRecord as GoldenRecord, type JobStatus as JobStatus, type RequestProvider as RequestProvider, type PromptAdaptationCreateResponse as PromptAdaptationCreateResponse, type PromptAdaptationGetAdaptResultsResponse as PromptAdaptationGetAdaptResultsResponse, type PromptAdaptationGetAdaptStatusResponse as PromptAdaptationGetAdaptStatusResponse, type PromptAdaptationGetCostsResponse as PromptAdaptationGetCostsResponse, type PromptAdaptationCreateParams as PromptAdaptationCreateParams, };
|
|
189
|
+
export { CustomRouter as CustomRouter, type CustomRouterTrainCustomRouterResponse as CustomRouterTrainCustomRouterResponse, type CustomRouterTrainCustomRouterParams as CustomRouterTrainCustomRouterParams, };
|
|
190
|
+
export { Models as Models, type Model as Model, type ModelListResponse as ModelListResponse, type ModelListParams as ModelListParams, };
|
|
205
191
|
}
|
|
206
192
|
//# sourceMappingURL=client.d.ts.map
|
package/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;OAC3C,KAAK,EAAc,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE;YAIvE,EAAE,MAAM,EAAE,QAAQ,EAAE;OAKzB,KAAK,IAAI;OAGT,KAAK,MAAM;OACX,KAAK,OAAO;OACZ,KAAK,GAAG;OACR,EAAE,UAAU,EAAE;OACd,EAAE,KAAK,EAAE
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;OAC3C,KAAK,EAAc,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE;YAIvE,EAAE,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,eAAe,IAAI,eAAe,GACxC,CAAC;CACH"}
|
package/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
-
var
|
|
3
|
+
var _Notdiamond_instances, _a, _Notdiamond_encoder, _Notdiamond_baseURLOverridden;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.
|
|
5
|
+
exports.Notdiamond = void 0;
|
|
6
6
|
const tslib_1 = require("./internal/tslib.js");
|
|
7
7
|
const uuid_1 = require("./internal/utils/uuid.js");
|
|
8
8
|
const values_1 = require("./internal/utils/values.js");
|
|
@@ -17,30 +17,25 @@ const Errors = tslib_1.__importStar(require("./core/error.js"));
|
|
|
17
17
|
const Uploads = tslib_1.__importStar(require("./core/uploads.js"));
|
|
18
18
|
const API = tslib_1.__importStar(require("./resources/index.js"));
|
|
19
19
|
const api_promise_1 = require("./core/api-promise.js");
|
|
20
|
-
const
|
|
20
|
+
const custom_router_1 = require("./resources/custom-router.js");
|
|
21
|
+
const model_router_1 = require("./resources/model-router.js");
|
|
21
22
|
const models_1 = require("./resources/models.js");
|
|
22
23
|
const preferences_1 = require("./resources/preferences.js");
|
|
23
24
|
const prompt_adaptation_1 = require("./resources/prompt-adaptation.js");
|
|
24
|
-
const report_1 = require("./resources/report.js");
|
|
25
|
-
const routing_1 = require("./resources/routing.js");
|
|
25
|
+
const report_1 = require("./resources/report/report.js");
|
|
26
26
|
const headers_1 = require("./internal/headers.js");
|
|
27
27
|
const env_1 = require("./internal/utils/env.js");
|
|
28
28
|
const log_1 = require("./internal/utils/log.js");
|
|
29
29
|
const values_2 = require("./internal/utils/values.js");
|
|
30
|
-
const environments = {
|
|
31
|
-
production: 'https://api.notdiamond.ai',
|
|
32
|
-
staging: 'https://staging-api.notdiamond.ai',
|
|
33
|
-
};
|
|
34
30
|
/**
|
|
35
|
-
* API Client for interfacing with the
|
|
31
|
+
* API Client for interfacing with the Notdiamond API.
|
|
36
32
|
*/
|
|
37
|
-
class
|
|
33
|
+
class Notdiamond {
|
|
38
34
|
/**
|
|
39
|
-
* API Client for interfacing with the
|
|
35
|
+
* API Client for interfacing with the Notdiamond API.
|
|
40
36
|
*
|
|
41
|
-
* @param {string |
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {string} [opts.baseURL=process.env['NOT_DIAMOND_BASE_URL'] ?? https://api.notdiamond.ai] - Override the default base URL for the API.
|
|
37
|
+
* @param {string | undefined} [opts.apiKey=process.env['NOT_DIAMOND_API_KEY'] ?? undefined]
|
|
38
|
+
* @param {string} [opts.baseURL=process.env['NOTDIAMOND_BASE_URL'] ?? https://api.notdiamond.ai] - Override the default base URL for the API.
|
|
44
39
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
45
40
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
46
41
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -48,25 +43,24 @@ class NotDiamond {
|
|
|
48
43
|
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
49
44
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
50
45
|
*/
|
|
51
|
-
constructor({ baseURL = (0, env_1.readEnv)('
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this.
|
|
46
|
+
constructor({ baseURL = (0, env_1.readEnv)('NOTDIAMOND_BASE_URL'), apiKey = (0, env_1.readEnv)('NOT_DIAMOND_API_KEY'), ...opts } = {}) {
|
|
47
|
+
_Notdiamond_instances.add(this);
|
|
48
|
+
_Notdiamond_encoder.set(this, void 0);
|
|
49
|
+
this.modelRouter = new API.ModelRouter(this);
|
|
50
|
+
this.report = new API.Report(this);
|
|
55
51
|
this.preferences = new API.Preferences(this);
|
|
56
52
|
this.promptAdaptation = new API.PromptAdaptation(this);
|
|
57
|
-
this.
|
|
53
|
+
this.customRouter = new API.CustomRouter(this);
|
|
58
54
|
this.models = new API.Models(this);
|
|
59
|
-
|
|
55
|
+
if (apiKey === undefined) {
|
|
56
|
+
throw new Errors.NotdiamondError("The NOT_DIAMOND_API_KEY environment variable is missing or empty; either provide it, or instantiate the Notdiamond client with an apiKey option, like new Notdiamond({ apiKey: 'My API Key' }).");
|
|
57
|
+
}
|
|
60
58
|
const options = {
|
|
61
59
|
apiKey,
|
|
62
60
|
...opts,
|
|
63
|
-
baseURL
|
|
64
|
-
environment: opts.environment ?? 'production',
|
|
61
|
+
baseURL: baseURL || `https://api.notdiamond.ai`,
|
|
65
62
|
};
|
|
66
|
-
|
|
67
|
-
throw new Errors.NotDiamondError('Ambiguous URL; The `baseURL` option (or NOT_DIAMOND_BASE_URL env var) and the `environment` option are given. If you want to use the environment you must pass baseURL: null');
|
|
68
|
-
}
|
|
69
|
-
this.baseURL = options.baseURL || environments[options.environment || 'production'];
|
|
63
|
+
this.baseURL = options.baseURL;
|
|
70
64
|
this.timeout = options.timeout ?? _a.DEFAULT_TIMEOUT /* 1 minute */;
|
|
71
65
|
this.logger = options.logger ?? console;
|
|
72
66
|
const defaultLogLevel = 'warn';
|
|
@@ -74,12 +68,12 @@ class NotDiamond {
|
|
|
74
68
|
this.logLevel = defaultLogLevel;
|
|
75
69
|
this.logLevel =
|
|
76
70
|
(0, log_1.parseLogLevel)(options.logLevel, 'ClientOptions.logLevel', this) ??
|
|
77
|
-
(0, log_1.parseLogLevel)((0, env_1.readEnv)('
|
|
71
|
+
(0, log_1.parseLogLevel)((0, env_1.readEnv)('NOTDIAMOND_LOG'), "process.env['NOTDIAMOND_LOG']", this) ??
|
|
78
72
|
defaultLogLevel;
|
|
79
73
|
this.fetchOptions = options.fetchOptions;
|
|
80
74
|
this.maxRetries = options.maxRetries ?? 2;
|
|
81
75
|
this.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
82
|
-
tslib_1.__classPrivateFieldSet(this,
|
|
76
|
+
tslib_1.__classPrivateFieldSet(this, _Notdiamond_encoder, Opts.FallbackEncoder, "f");
|
|
83
77
|
this._options = options;
|
|
84
78
|
this.apiKey = apiKey;
|
|
85
79
|
}
|
|
@@ -89,8 +83,7 @@ class NotDiamond {
|
|
|
89
83
|
withOptions(options) {
|
|
90
84
|
const client = new this.constructor({
|
|
91
85
|
...this._options,
|
|
92
|
-
|
|
93
|
-
baseURL: options.environment ? undefined : this.baseURL,
|
|
86
|
+
baseURL: this.baseURL,
|
|
94
87
|
maxRetries: this.maxRetries,
|
|
95
88
|
timeout: this.timeout,
|
|
96
89
|
logger: this.logger,
|
|
@@ -106,18 +99,9 @@ class NotDiamond {
|
|
|
106
99
|
return this._options.defaultQuery;
|
|
107
100
|
}
|
|
108
101
|
validateHeaders({ values, nulls }) {
|
|
109
|
-
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (nulls.has('authorization')) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "Authorization" headers to be explicitly omitted');
|
|
102
|
+
return;
|
|
116
103
|
}
|
|
117
104
|
async authHeaders(opts) {
|
|
118
|
-
if (this.apiKey == null) {
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
105
|
return (0, headers_1.buildHeaders)([{ Authorization: `Bearer ${this.apiKey}` }]);
|
|
122
106
|
}
|
|
123
107
|
stringifyQuery(query) {
|
|
@@ -133,7 +117,7 @@ class NotDiamond {
|
|
|
133
117
|
return Errors.APIError.generate(status, error, message, headers);
|
|
134
118
|
}
|
|
135
119
|
buildURL(path, query, defaultBaseURL) {
|
|
136
|
-
const baseURL = (!tslib_1.__classPrivateFieldGet(this,
|
|
120
|
+
const baseURL = (!tslib_1.__classPrivateFieldGet(this, _Notdiamond_instances, "m", _Notdiamond_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
|
|
137
121
|
const url = (0, values_1.isAbsoluteURL)(path) ?
|
|
138
122
|
new URL(path)
|
|
139
123
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
@@ -446,34 +430,34 @@ class NotDiamond {
|
|
|
446
430
|
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body) };
|
|
447
431
|
}
|
|
448
432
|
else {
|
|
449
|
-
return tslib_1.__classPrivateFieldGet(this,
|
|
433
|
+
return tslib_1.__classPrivateFieldGet(this, _Notdiamond_encoder, "f").call(this, { body, headers });
|
|
450
434
|
}
|
|
451
435
|
}
|
|
452
436
|
}
|
|
453
|
-
exports.
|
|
454
|
-
_a =
|
|
455
|
-
return this.baseURL !==
|
|
437
|
+
exports.Notdiamond = Notdiamond;
|
|
438
|
+
_a = Notdiamond, _Notdiamond_encoder = new WeakMap(), _Notdiamond_instances = new WeakSet(), _Notdiamond_baseURLOverridden = function _Notdiamond_baseURLOverridden() {
|
|
439
|
+
return this.baseURL !== 'https://api.notdiamond.ai';
|
|
456
440
|
};
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
441
|
+
Notdiamond.Notdiamond = _a;
|
|
442
|
+
Notdiamond.DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
443
|
+
Notdiamond.NotdiamondError = Errors.NotdiamondError;
|
|
444
|
+
Notdiamond.APIError = Errors.APIError;
|
|
445
|
+
Notdiamond.APIConnectionError = Errors.APIConnectionError;
|
|
446
|
+
Notdiamond.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
447
|
+
Notdiamond.APIUserAbortError = Errors.APIUserAbortError;
|
|
448
|
+
Notdiamond.NotFoundError = Errors.NotFoundError;
|
|
449
|
+
Notdiamond.ConflictError = Errors.ConflictError;
|
|
450
|
+
Notdiamond.RateLimitError = Errors.RateLimitError;
|
|
451
|
+
Notdiamond.BadRequestError = Errors.BadRequestError;
|
|
452
|
+
Notdiamond.AuthenticationError = Errors.AuthenticationError;
|
|
453
|
+
Notdiamond.InternalServerError = Errors.InternalServerError;
|
|
454
|
+
Notdiamond.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
455
|
+
Notdiamond.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
456
|
+
Notdiamond.toFile = Uploads.toFile;
|
|
457
|
+
Notdiamond.ModelRouter = model_router_1.ModelRouter;
|
|
458
|
+
Notdiamond.Report = report_1.Report;
|
|
459
|
+
Notdiamond.Preferences = preferences_1.Preferences;
|
|
460
|
+
Notdiamond.PromptAdaptation = prompt_adaptation_1.PromptAdaptation;
|
|
461
|
+
Notdiamond.CustomRouter = custom_router_1.CustomRouter;
|
|
462
|
+
Notdiamond.Models = models_1.Models;
|
|
479
463
|
//# sourceMappingURL=client.js.map
|