notdiamond 2.0.0-rc2 → 2.0.0-rc20
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 +185 -0
- package/LICENSE +1 -1
- package/README.md +261 -168
- package/client.d.mts +26 -43
- package/client.d.mts.map +1 -1
- package/client.d.ts +26 -43
- package/client.d.ts.map +1 -1
- package/client.js +49 -68
- package/client.js.map +1 -1
- package/client.mjs +47 -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/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 +5 -6
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +5 -6
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +5 -7
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -3
- package/resources/index.mjs.map +1 -1
- package/resources/model-router.d.mts +194 -0
- package/resources/model-router.d.mts.map +1 -0
- package/resources/model-router.d.ts +194 -0
- package/resources/model-router.d.ts.map +1 -0
- package/resources/model-router.js +68 -0
- package/resources/model-router.js.map +1 -0
- package/resources/model-router.mjs +64 -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 +37 -54
- package/resources/preferences.d.mts.map +1 -1
- package/resources/preferences.d.ts +37 -54
- package/resources/preferences.d.ts.map +1 -1
- package/resources/preferences.js +17 -42
- package/resources/preferences.js.map +1 -1
- package/resources/preferences.mjs +17 -42
- package/resources/preferences.mjs.map +1 -1
- package/resources/prompt-adaptation.d.mts +340 -249
- package/resources/prompt-adaptation.d.mts.map +1 -1
- package/resources/prompt-adaptation.d.ts +340 -249
- package/resources/prompt-adaptation.d.ts.map +1 -1
- package/resources/prompt-adaptation.js +36 -79
- package/resources/prompt-adaptation.js.map +1 -1
- package/resources/prompt-adaptation.mjs +36 -79
- package/resources/prompt-adaptation.mjs.map +1 -1
- package/src/client.ts +72 -128
- 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 +20 -32
- package/src/resources/model-router.ts +222 -0
- package/src/resources/models.ts +55 -32
- package/src/resources/preferences.ts +43 -83
- package/src/resources/prompt-adaptation.ts +358 -300
- 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/report.d.mts +0 -245
- package/resources/report.d.mts.map +0 -1
- package/resources/report.d.ts +0 -245
- package/resources/report.d.ts.map +0 -1
- package/resources/report.js +0 -86
- package/resources/report.js.map +0 -1
- package/resources/report.mjs +0 -82
- package/resources/report.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/report.ts +0 -300
- package/src/resources/routing.ts +0 -476
package/client.d.mts
CHANGED
|
@@ -6,38 +6,24 @@ 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 { Routing, RoutingCreateSurveyResponseParams, RoutingCreateSurveyResponseResponse, RoutingSelectModelParams, RoutingSelectModelResponse, RoutingTrainCustomRouterParams, RoutingTrainCustomRouterResponse } from "./resources/routing.mjs";
|
|
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, PromptAdaptationAdaptParams, PromptAdaptationAdaptResponse, PromptAdaptationGetAdaptResultsResponse, PromptAdaptationGetAdaptStatusResponse, PromptAdaptationGetCostResponse, RequestProvider } from "./resources/prompt-adaptation.mjs";
|
|
15
14
|
import { type Fetch } from "./internal/builtin-types.mjs";
|
|
16
15
|
import { HeadersLike, NullableHeaders } from "./internal/headers.mjs";
|
|
17
16
|
import { FinalRequestOptions, RequestOptions } from "./internal/request-options.mjs";
|
|
18
17
|
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
18
|
export interface ClientOptions {
|
|
25
19
|
/**
|
|
26
|
-
*
|
|
20
|
+
* API key authentication using Bearer token
|
|
27
21
|
*/
|
|
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;
|
|
22
|
+
apiKey?: string | undefined;
|
|
37
23
|
/**
|
|
38
24
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
39
25
|
*
|
|
40
|
-
* Defaults to process.env['
|
|
26
|
+
* Defaults to process.env['NOTDIAMOND_BASE_URL'].
|
|
41
27
|
*/
|
|
42
28
|
baseURL?: string | null | undefined;
|
|
43
29
|
/**
|
|
@@ -85,7 +71,7 @@ export interface ClientOptions {
|
|
|
85
71
|
/**
|
|
86
72
|
* Set the log level.
|
|
87
73
|
*
|
|
88
|
-
* Defaults to process.env['
|
|
74
|
+
* Defaults to process.env['NOTDIAMOND_LOG'] or 'warn' if it isn't set.
|
|
89
75
|
*/
|
|
90
76
|
logLevel?: LogLevel | undefined;
|
|
91
77
|
/**
|
|
@@ -96,26 +82,25 @@ export interface ClientOptions {
|
|
|
96
82
|
logger?: Logger | undefined;
|
|
97
83
|
}
|
|
98
84
|
/**
|
|
99
|
-
* API Client for interfacing with the
|
|
85
|
+
* API Client for interfacing with the Notdiamond API.
|
|
100
86
|
*/
|
|
101
|
-
export declare class
|
|
87
|
+
export declare class Notdiamond {
|
|
102
88
|
#private;
|
|
103
|
-
apiKey: string
|
|
89
|
+
apiKey: string;
|
|
104
90
|
baseURL: string;
|
|
105
91
|
maxRetries: number;
|
|
106
92
|
timeout: number;
|
|
107
|
-
logger: Logger
|
|
93
|
+
logger: Logger;
|
|
108
94
|
logLevel: LogLevel | undefined;
|
|
109
95
|
fetchOptions: MergedRequestInit | undefined;
|
|
110
96
|
private fetch;
|
|
111
97
|
protected idempotencyHeader?: string;
|
|
112
98
|
private _options;
|
|
113
99
|
/**
|
|
114
|
-
* API Client for interfacing with the
|
|
100
|
+
* API Client for interfacing with the Notdiamond API.
|
|
115
101
|
*
|
|
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.
|
|
102
|
+
* @param {string | undefined} [opts.apiKey=process.env['NOT_DIAMOND_API_KEY'] ?? undefined]
|
|
103
|
+
* @param {string} [opts.baseURL=process.env['NOTDIAMOND_BASE_URL'] ?? https://api.notdiamond.ai] - Override the default base URL for the API.
|
|
119
104
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
120
105
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
121
106
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -171,9 +156,9 @@ export declare class NotDiamond {
|
|
|
171
156
|
}>;
|
|
172
157
|
private buildHeaders;
|
|
173
158
|
private buildBody;
|
|
174
|
-
static
|
|
159
|
+
static Notdiamond: typeof Notdiamond;
|
|
175
160
|
static DEFAULT_TIMEOUT: number;
|
|
176
|
-
static
|
|
161
|
+
static NotdiamondError: typeof Errors.NotdiamondError;
|
|
177
162
|
static APIError: typeof Errors.APIError;
|
|
178
163
|
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
179
164
|
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
@@ -187,20 +172,18 @@ export declare class NotDiamond {
|
|
|
187
172
|
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
188
173
|
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
189
174
|
static toFile: typeof Uploads.toFile;
|
|
190
|
-
|
|
175
|
+
modelRouter: API.ModelRouter;
|
|
191
176
|
preferences: API.Preferences;
|
|
192
177
|
promptAdaptation: API.PromptAdaptation;
|
|
193
|
-
|
|
178
|
+
customRouter: API.CustomRouter;
|
|
194
179
|
models: API.Models;
|
|
195
|
-
admin: API.Admin;
|
|
196
180
|
}
|
|
197
|
-
export declare namespace
|
|
181
|
+
export declare namespace Notdiamond {
|
|
198
182
|
export type RequestOptions = Opts.RequestOptions;
|
|
199
|
-
export {
|
|
200
|
-
export { Preferences as Preferences, type
|
|
201
|
-
export { PromptAdaptation as PromptAdaptation, type
|
|
202
|
-
export {
|
|
203
|
-
export { Models as Models, type ModelListResponse as ModelListResponse, type ModelListParams as ModelListParams, };
|
|
204
|
-
export { Admin as Admin };
|
|
183
|
+
export { ModelRouter as ModelRouter, type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse, type ModelRouterSelectModelParams as ModelRouterSelectModelParams, };
|
|
184
|
+
export { Preferences as Preferences, type PreferenceCreateResponse as PreferenceCreateResponse, type PreferenceUpdateResponse as PreferenceUpdateResponse, type PreferenceDeleteResponse as PreferenceDeleteResponse, type PreferenceCreateParams as PreferenceCreateParams, type PreferenceUpdateParams as PreferenceUpdateParams, };
|
|
185
|
+
export { PromptAdaptation as PromptAdaptation, type GoldenRecord as GoldenRecord, type JobStatus as JobStatus, type RequestProvider as RequestProvider, type PromptAdaptationAdaptResponse as PromptAdaptationAdaptResponse, type PromptAdaptationGetAdaptResultsResponse as PromptAdaptationGetAdaptResultsResponse, type PromptAdaptationGetAdaptStatusResponse as PromptAdaptationGetAdaptStatusResponse, type PromptAdaptationGetCostResponse as PromptAdaptationGetCostResponse, type PromptAdaptationAdaptParams as PromptAdaptationAdaptParams, };
|
|
186
|
+
export { CustomRouter as CustomRouter, type CustomRouterTrainCustomRouterResponse as CustomRouterTrainCustomRouterResponse, type CustomRouterTrainCustomRouterParams as CustomRouterTrainCustomRouterParams, };
|
|
187
|
+
export { Models as Models, type Model as Model, type ModelListResponse as ModelListResponse, type ModelListParams as ModelListParams, };
|
|
205
188
|
}
|
|
206
189
|
//# 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,i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GAChE,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,24 @@ 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 { Routing, RoutingCreateSurveyResponseParams, RoutingCreateSurveyResponseResponse, RoutingSelectModelParams, RoutingSelectModelResponse, RoutingTrainCustomRouterParams, RoutingTrainCustomRouterResponse } from "./resources/routing.js";
|
|
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, PromptAdaptationAdaptParams, PromptAdaptationAdaptResponse, PromptAdaptationGetAdaptResultsResponse, PromptAdaptationGetAdaptStatusResponse, PromptAdaptationGetCostResponse, RequestProvider } from "./resources/prompt-adaptation.js";
|
|
15
14
|
import { type Fetch } from "./internal/builtin-types.js";
|
|
16
15
|
import { HeadersLike, NullableHeaders } from "./internal/headers.js";
|
|
17
16
|
import { FinalRequestOptions, RequestOptions } from "./internal/request-options.js";
|
|
18
17
|
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
18
|
export interface ClientOptions {
|
|
25
19
|
/**
|
|
26
|
-
*
|
|
20
|
+
* API key authentication using Bearer token
|
|
27
21
|
*/
|
|
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;
|
|
22
|
+
apiKey?: string | undefined;
|
|
37
23
|
/**
|
|
38
24
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
39
25
|
*
|
|
40
|
-
* Defaults to process.env['
|
|
26
|
+
* Defaults to process.env['NOTDIAMOND_BASE_URL'].
|
|
41
27
|
*/
|
|
42
28
|
baseURL?: string | null | undefined;
|
|
43
29
|
/**
|
|
@@ -85,7 +71,7 @@ export interface ClientOptions {
|
|
|
85
71
|
/**
|
|
86
72
|
* Set the log level.
|
|
87
73
|
*
|
|
88
|
-
* Defaults to process.env['
|
|
74
|
+
* Defaults to process.env['NOTDIAMOND_LOG'] or 'warn' if it isn't set.
|
|
89
75
|
*/
|
|
90
76
|
logLevel?: LogLevel | undefined;
|
|
91
77
|
/**
|
|
@@ -96,26 +82,25 @@ export interface ClientOptions {
|
|
|
96
82
|
logger?: Logger | undefined;
|
|
97
83
|
}
|
|
98
84
|
/**
|
|
99
|
-
* API Client for interfacing with the
|
|
85
|
+
* API Client for interfacing with the Notdiamond API.
|
|
100
86
|
*/
|
|
101
|
-
export declare class
|
|
87
|
+
export declare class Notdiamond {
|
|
102
88
|
#private;
|
|
103
|
-
apiKey: string
|
|
89
|
+
apiKey: string;
|
|
104
90
|
baseURL: string;
|
|
105
91
|
maxRetries: number;
|
|
106
92
|
timeout: number;
|
|
107
|
-
logger: Logger
|
|
93
|
+
logger: Logger;
|
|
108
94
|
logLevel: LogLevel | undefined;
|
|
109
95
|
fetchOptions: MergedRequestInit | undefined;
|
|
110
96
|
private fetch;
|
|
111
97
|
protected idempotencyHeader?: string;
|
|
112
98
|
private _options;
|
|
113
99
|
/**
|
|
114
|
-
* API Client for interfacing with the
|
|
100
|
+
* API Client for interfacing with the Notdiamond API.
|
|
115
101
|
*
|
|
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.
|
|
102
|
+
* @param {string | undefined} [opts.apiKey=process.env['NOT_DIAMOND_API_KEY'] ?? undefined]
|
|
103
|
+
* @param {string} [opts.baseURL=process.env['NOTDIAMOND_BASE_URL'] ?? https://api.notdiamond.ai] - Override the default base URL for the API.
|
|
119
104
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
120
105
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
121
106
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -171,9 +156,9 @@ export declare class NotDiamond {
|
|
|
171
156
|
}>;
|
|
172
157
|
private buildHeaders;
|
|
173
158
|
private buildBody;
|
|
174
|
-
static
|
|
159
|
+
static Notdiamond: typeof Notdiamond;
|
|
175
160
|
static DEFAULT_TIMEOUT: number;
|
|
176
|
-
static
|
|
161
|
+
static NotdiamondError: typeof Errors.NotdiamondError;
|
|
177
162
|
static APIError: typeof Errors.APIError;
|
|
178
163
|
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
179
164
|
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
@@ -187,20 +172,18 @@ export declare class NotDiamond {
|
|
|
187
172
|
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
188
173
|
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
189
174
|
static toFile: typeof Uploads.toFile;
|
|
190
|
-
|
|
175
|
+
modelRouter: API.ModelRouter;
|
|
191
176
|
preferences: API.Preferences;
|
|
192
177
|
promptAdaptation: API.PromptAdaptation;
|
|
193
|
-
|
|
178
|
+
customRouter: API.CustomRouter;
|
|
194
179
|
models: API.Models;
|
|
195
|
-
admin: API.Admin;
|
|
196
180
|
}
|
|
197
|
-
export declare namespace
|
|
181
|
+
export declare namespace Notdiamond {
|
|
198
182
|
export type RequestOptions = Opts.RequestOptions;
|
|
199
|
-
export {
|
|
200
|
-
export { Preferences as Preferences, type
|
|
201
|
-
export { PromptAdaptation as PromptAdaptation, type
|
|
202
|
-
export {
|
|
203
|
-
export { Models as Models, type ModelListResponse as ModelListResponse, type ModelListParams as ModelListParams, };
|
|
204
|
-
export { Admin as Admin };
|
|
183
|
+
export { ModelRouter as ModelRouter, type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse, type ModelRouterSelectModelParams as ModelRouterSelectModelParams, };
|
|
184
|
+
export { Preferences as Preferences, type PreferenceCreateResponse as PreferenceCreateResponse, type PreferenceUpdateResponse as PreferenceUpdateResponse, type PreferenceDeleteResponse as PreferenceDeleteResponse, type PreferenceCreateParams as PreferenceCreateParams, type PreferenceUpdateParams as PreferenceUpdateParams, };
|
|
185
|
+
export { PromptAdaptation as PromptAdaptation, type GoldenRecord as GoldenRecord, type JobStatus as JobStatus, type RequestProvider as RequestProvider, type PromptAdaptationAdaptResponse as PromptAdaptationAdaptResponse, type PromptAdaptationGetAdaptResultsResponse as PromptAdaptationGetAdaptResultsResponse, type PromptAdaptationGetAdaptStatusResponse as PromptAdaptationGetAdaptStatusResponse, type PromptAdaptationGetCostResponse as PromptAdaptationGetCostResponse, type PromptAdaptationAdaptParams as PromptAdaptationAdaptParams, };
|
|
186
|
+
export { CustomRouter as CustomRouter, type CustomRouterTrainCustomRouterResponse as CustomRouterTrainCustomRouterResponse, type CustomRouterTrainCustomRouterParams as CustomRouterTrainCustomRouterParams, };
|
|
187
|
+
export { Models as Models, type Model as Model, type ModelListResponse as ModelListResponse, type ModelListParams as ModelListParams, };
|
|
205
188
|
}
|
|
206
189
|
//# 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,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,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ACL,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,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,uCAAuC,IAAI,uCAAuC,EACvF,KAAK,sCAAsC,IAAI,sCAAsC,EACrF,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,2BAA2B,IAAI,2BAA2B,GAChE,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.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,24 @@ 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");
|
|
26
25
|
const headers_1 = require("./internal/headers.js");
|
|
27
26
|
const env_1 = require("./internal/utils/env.js");
|
|
28
27
|
const log_1 = require("./internal/utils/log.js");
|
|
29
28
|
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
29
|
/**
|
|
35
|
-
* API Client for interfacing with the
|
|
30
|
+
* API Client for interfacing with the Notdiamond API.
|
|
36
31
|
*/
|
|
37
|
-
class
|
|
32
|
+
class Notdiamond {
|
|
38
33
|
/**
|
|
39
|
-
* API Client for interfacing with the
|
|
34
|
+
* API Client for interfacing with the Notdiamond API.
|
|
40
35
|
*
|
|
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.
|
|
36
|
+
* @param {string | undefined} [opts.apiKey=process.env['NOT_DIAMOND_API_KEY'] ?? undefined]
|
|
37
|
+
* @param {string} [opts.baseURL=process.env['NOTDIAMOND_BASE_URL'] ?? https://api.notdiamond.ai] - Override the default base URL for the API.
|
|
44
38
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
45
39
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
46
40
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -48,25 +42,23 @@ class NotDiamond {
|
|
|
48
42
|
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
49
43
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
50
44
|
*/
|
|
51
|
-
constructor({ baseURL = (0, env_1.readEnv)('
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this.
|
|
45
|
+
constructor({ baseURL = (0, env_1.readEnv)('NOTDIAMOND_BASE_URL'), apiKey = (0, env_1.readEnv)('NOT_DIAMOND_API_KEY'), ...opts } = {}) {
|
|
46
|
+
_Notdiamond_instances.add(this);
|
|
47
|
+
_Notdiamond_encoder.set(this, void 0);
|
|
48
|
+
this.modelRouter = new API.ModelRouter(this);
|
|
55
49
|
this.preferences = new API.Preferences(this);
|
|
56
50
|
this.promptAdaptation = new API.PromptAdaptation(this);
|
|
57
|
-
this.
|
|
51
|
+
this.customRouter = new API.CustomRouter(this);
|
|
58
52
|
this.models = new API.Models(this);
|
|
59
|
-
|
|
53
|
+
if (apiKey === undefined) {
|
|
54
|
+
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' }).");
|
|
55
|
+
}
|
|
60
56
|
const options = {
|
|
61
57
|
apiKey,
|
|
62
58
|
...opts,
|
|
63
|
-
baseURL
|
|
64
|
-
environment: opts.environment ?? 'production',
|
|
59
|
+
baseURL: baseURL || `https://api.notdiamond.ai`,
|
|
65
60
|
};
|
|
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'];
|
|
61
|
+
this.baseURL = options.baseURL;
|
|
70
62
|
this.timeout = options.timeout ?? _a.DEFAULT_TIMEOUT /* 1 minute */;
|
|
71
63
|
this.logger = options.logger ?? console;
|
|
72
64
|
const defaultLogLevel = 'warn';
|
|
@@ -74,12 +66,12 @@ class NotDiamond {
|
|
|
74
66
|
this.logLevel = defaultLogLevel;
|
|
75
67
|
this.logLevel =
|
|
76
68
|
(0, log_1.parseLogLevel)(options.logLevel, 'ClientOptions.logLevel', this) ??
|
|
77
|
-
(0, log_1.parseLogLevel)((0, env_1.readEnv)('
|
|
69
|
+
(0, log_1.parseLogLevel)((0, env_1.readEnv)('NOTDIAMOND_LOG'), "process.env['NOTDIAMOND_LOG']", this) ??
|
|
78
70
|
defaultLogLevel;
|
|
79
71
|
this.fetchOptions = options.fetchOptions;
|
|
80
72
|
this.maxRetries = options.maxRetries ?? 2;
|
|
81
73
|
this.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
82
|
-
tslib_1.__classPrivateFieldSet(this,
|
|
74
|
+
tslib_1.__classPrivateFieldSet(this, _Notdiamond_encoder, Opts.FallbackEncoder, "f");
|
|
83
75
|
this._options = options;
|
|
84
76
|
this.apiKey = apiKey;
|
|
85
77
|
}
|
|
@@ -89,8 +81,7 @@ class NotDiamond {
|
|
|
89
81
|
withOptions(options) {
|
|
90
82
|
const client = new this.constructor({
|
|
91
83
|
...this._options,
|
|
92
|
-
|
|
93
|
-
baseURL: options.environment ? undefined : this.baseURL,
|
|
84
|
+
baseURL: this.baseURL,
|
|
94
85
|
maxRetries: this.maxRetries,
|
|
95
86
|
timeout: this.timeout,
|
|
96
87
|
logger: this.logger,
|
|
@@ -106,18 +97,9 @@ class NotDiamond {
|
|
|
106
97
|
return this._options.defaultQuery;
|
|
107
98
|
}
|
|
108
99
|
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');
|
|
100
|
+
return;
|
|
116
101
|
}
|
|
117
102
|
async authHeaders(opts) {
|
|
118
|
-
if (this.apiKey == null) {
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
103
|
return (0, headers_1.buildHeaders)([{ Authorization: `Bearer ${this.apiKey}` }]);
|
|
122
104
|
}
|
|
123
105
|
stringifyQuery(query) {
|
|
@@ -133,7 +115,7 @@ class NotDiamond {
|
|
|
133
115
|
return Errors.APIError.generate(status, error, message, headers);
|
|
134
116
|
}
|
|
135
117
|
buildURL(path, query, defaultBaseURL) {
|
|
136
|
-
const baseURL = (!tslib_1.__classPrivateFieldGet(this,
|
|
118
|
+
const baseURL = (!tslib_1.__classPrivateFieldGet(this, _Notdiamond_instances, "m", _Notdiamond_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
|
|
137
119
|
const url = (0, values_1.isAbsoluteURL)(path) ?
|
|
138
120
|
new URL(path)
|
|
139
121
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
@@ -446,34 +428,33 @@ class NotDiamond {
|
|
|
446
428
|
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body) };
|
|
447
429
|
}
|
|
448
430
|
else {
|
|
449
|
-
return tslib_1.__classPrivateFieldGet(this,
|
|
431
|
+
return tslib_1.__classPrivateFieldGet(this, _Notdiamond_encoder, "f").call(this, { body, headers });
|
|
450
432
|
}
|
|
451
433
|
}
|
|
452
434
|
}
|
|
453
|
-
exports.
|
|
454
|
-
_a =
|
|
455
|
-
return this.baseURL !==
|
|
435
|
+
exports.Notdiamond = Notdiamond;
|
|
436
|
+
_a = Notdiamond, _Notdiamond_encoder = new WeakMap(), _Notdiamond_instances = new WeakSet(), _Notdiamond_baseURLOverridden = function _Notdiamond_baseURLOverridden() {
|
|
437
|
+
return this.baseURL !== 'https://api.notdiamond.ai';
|
|
456
438
|
};
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
NotDiamond.Admin = admin_1.Admin;
|
|
439
|
+
Notdiamond.Notdiamond = _a;
|
|
440
|
+
Notdiamond.DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
441
|
+
Notdiamond.NotdiamondError = Errors.NotdiamondError;
|
|
442
|
+
Notdiamond.APIError = Errors.APIError;
|
|
443
|
+
Notdiamond.APIConnectionError = Errors.APIConnectionError;
|
|
444
|
+
Notdiamond.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
445
|
+
Notdiamond.APIUserAbortError = Errors.APIUserAbortError;
|
|
446
|
+
Notdiamond.NotFoundError = Errors.NotFoundError;
|
|
447
|
+
Notdiamond.ConflictError = Errors.ConflictError;
|
|
448
|
+
Notdiamond.RateLimitError = Errors.RateLimitError;
|
|
449
|
+
Notdiamond.BadRequestError = Errors.BadRequestError;
|
|
450
|
+
Notdiamond.AuthenticationError = Errors.AuthenticationError;
|
|
451
|
+
Notdiamond.InternalServerError = Errors.InternalServerError;
|
|
452
|
+
Notdiamond.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
453
|
+
Notdiamond.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
454
|
+
Notdiamond.toFile = Uploads.toFile;
|
|
455
|
+
Notdiamond.ModelRouter = model_router_1.ModelRouter;
|
|
456
|
+
Notdiamond.Preferences = preferences_1.Preferences;
|
|
457
|
+
Notdiamond.PromptAdaptation = prompt_adaptation_1.PromptAdaptation;
|
|
458
|
+
Notdiamond.CustomRouter = custom_router_1.CustomRouter;
|
|
459
|
+
Notdiamond.Models = models_1.Models;
|
|
479
460
|
//# sourceMappingURL=client.js.map
|