@toloka-platform/sdk 0.27.0 → 0.28.0
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/README.md +5 -3
- package/dist/cli/toloka.js +179 -190
- package/dist/cli/toloka.js.jsc +0 -0
- package/dist/cli/toloka.js.jsc.sha256 +1 -1
- package/dist/cli/toloka.js.sha256 +1 -1
- package/examples/video-pair-rating/nodes/adjudicate/node.ts +1 -1
- package/examples/video-pair-rating/nodes/adjudicate_op/node.ts +1 -1
- package/examples/video-pair-rating/nodes/overall_preference_pick/node.ts +5 -1
- package/examples/video-pair-rating/nodes/rate_pair/node.ts +5 -1
- package/openapi/gen/api.schemas.ts +51 -758
- package/openapi/gen/api.ts +0 -860
- package/package.json +2 -2
- package/skills/catalog.json +6 -40
- package/skills/toloka-build/references/human-work.md +15 -6
- package/skills/toloka-build/references/local-setup.md +2 -2
- package/skills/toloka-build/references/workflow-and-cli.md +3 -22
- package/skills/toloka-get-started/SKILL.md +9 -13
- package/src/cli/analytics.ts +0 -31
- package/src/cli/auth.ts +15 -7
- package/src/cli/config.ts +67 -3
- package/src/cli/context.ts +3 -124
- package/src/cli/credentials.ts +11 -10
- package/src/cli/init.ts +1 -1
- package/src/cli/program.ts +0 -6
- package/src/cli/project.ts +9 -1
- package/src/client.ts +3 -261
- package/src/importer.ts +12 -2
- package/src/index.ts +0 -2
- package/src/pipeline-graph-v1.contract.json +130 -128
- package/skills/toloka-fine-tuning/SKILL.md +0 -177
- package/skills/toloka-gisting/SKILL.md +0 -186
- package/src/cli/batch-inference.ts +0 -267
- package/src/cli/commands/batch-inference.ts +0 -116
- package/src/cli/commands/models.ts +0 -121
- package/src/cli/commands/training.ts +0 -275
- package/src/cli/models.ts +0 -304
- package/src/cli/trainings.ts +0 -880
package/src/cli/context.ts
CHANGED
|
@@ -8,10 +8,11 @@ import type { TolokaState } from "../state";
|
|
|
8
8
|
import type { AuthChoose, AuthPrompt } from "./auth";
|
|
9
9
|
import type { CliAnalytics } from "./analytics";
|
|
10
10
|
import type { BrowserLoginFlow } from "./browser-login";
|
|
11
|
-
import {
|
|
11
|
+
import { findBrowserLogin } from "./browser-session";
|
|
12
12
|
import type { checkProject } from "./check";
|
|
13
13
|
import type { DescribeTaskUiComponents } from "../testing/task-ui-browser";
|
|
14
14
|
import {
|
|
15
|
+
clientConfigFor,
|
|
15
16
|
PRODUCTION_BASE_URL,
|
|
16
17
|
resolveBaseUrl,
|
|
17
18
|
resolveConfiguredCredential,
|
|
@@ -22,7 +23,6 @@ import { findCommandCredentials } from "./credentials";
|
|
|
22
23
|
import type { StoredCredentials } from "./credentials";
|
|
23
24
|
import { resolveProjectContext } from "./project-context";
|
|
24
25
|
import { findSourceRoot } from "./source";
|
|
25
|
-
import type { TrainingDraftOptions } from "./trainings";
|
|
26
26
|
import type { RunOutcome } from "./runs";
|
|
27
27
|
|
|
28
28
|
export type CliIo = {
|
|
@@ -97,48 +97,6 @@ export const nonNegativeInteger = (raw: string): number => {
|
|
|
97
97
|
return value;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
export const samplingTemperature = (raw: string): number => {
|
|
101
|
-
const value = Number(raw);
|
|
102
|
-
if (raw.trim() === "" || !Number.isFinite(value) || value < 0 || value > 2)
|
|
103
|
-
throw new InvalidArgumentError("Expected a temperature from 0 to 2.");
|
|
104
|
-
return value;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export const samplingTopP = (raw: string): number => {
|
|
108
|
-
const value = Number(raw);
|
|
109
|
-
if (raw.trim() === "" || !Number.isFinite(value) || value <= 0 || value > 1)
|
|
110
|
-
throw new InvalidArgumentError("Expected a top-p above 0 and at most 1.");
|
|
111
|
-
return value;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const trainingMethod = (raw: string): "sft" | "gisting" => {
|
|
115
|
-
if (raw !== "sft" && raw !== "gisting") {
|
|
116
|
-
throw new InvalidArgumentError('Expected training method "sft" or "gisting".');
|
|
117
|
-
}
|
|
118
|
-
return raw;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export const trainingLoraRank = (raw: string): 8 | 16 | 32 => {
|
|
122
|
-
const value = Number(raw);
|
|
123
|
-
if (value !== 8 && value !== 16 && value !== 32) {
|
|
124
|
-
throw new InvalidArgumentError("Expected a LoRA rank of 8, 16, or 32.");
|
|
125
|
-
}
|
|
126
|
-
return value;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
export const trainingGistTokens = (raw: string): 8 | 32 | 64 | "1/4" | "1/8" | "1/16" | "1/32" => {
|
|
130
|
-
if (raw === "1/4" || raw === "1/8" || raw === "1/16" || raw === "1/32") {
|
|
131
|
-
return raw;
|
|
132
|
-
}
|
|
133
|
-
const value = Number(raw);
|
|
134
|
-
if (value !== 8 && value !== 32 && value !== 64) {
|
|
135
|
-
throw new InvalidArgumentError(
|
|
136
|
-
'Expected 8, 32, or 64 gist tokens, or a fraction of the prompt: "1/4", "1/8", "1/16", or "1/32".',
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
return value;
|
|
140
|
-
};
|
|
141
|
-
|
|
142
100
|
export const splitRatios = (raw: string): { train: number; validate: number; test: number } => {
|
|
143
101
|
const parts = raw.split("/").map(Number);
|
|
144
102
|
const [train, validate, test] = parts;
|
|
@@ -221,72 +179,6 @@ export const splitSeed = (raw: string): number => {
|
|
|
221
179
|
return value;
|
|
222
180
|
};
|
|
223
181
|
|
|
224
|
-
export const trainingEpochs = (raw: string): number => {
|
|
225
|
-
const value = Number(raw);
|
|
226
|
-
if (!Number.isInteger(value) || value < 1 || value > 5) {
|
|
227
|
-
throw new InvalidArgumentError("Expected epochs from 1 through 5.");
|
|
228
|
-
}
|
|
229
|
-
return value;
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
export const trainingLearningRate = (raw: string): number => {
|
|
233
|
-
const value = Number(raw);
|
|
234
|
-
if (!Number.isFinite(value) || value <= 0) {
|
|
235
|
-
throw new InvalidArgumentError("Expected a positive learning rate, for example 0.00015.");
|
|
236
|
-
}
|
|
237
|
-
return value;
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
export const trainingBatchSize = (raw: string): 8 | 16 | 32 | 64 => {
|
|
241
|
-
const value = Number(raw);
|
|
242
|
-
if (value !== 8 && value !== 16 && value !== 32 && value !== 64) {
|
|
243
|
-
throw new InvalidArgumentError("Expected a batch size of 8, 16, 32, or 64.");
|
|
244
|
-
}
|
|
245
|
-
return value;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
export const trainingMaxSequenceLength = (raw: string): number => {
|
|
249
|
-
const value = Number(raw);
|
|
250
|
-
if (!Number.isInteger(value) || value < 64 || value > 16384) {
|
|
251
|
-
throw new InvalidArgumentError("Expected a maximum sequence length from 64 through 16384 tokens.");
|
|
252
|
-
}
|
|
253
|
-
return value;
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
export type RawTrainingDraftOptions = {
|
|
257
|
-
method?: TrainingDraftOptions["method"];
|
|
258
|
-
baseModel?: TrainingDraftOptions["baseModelId"];
|
|
259
|
-
modelVersion?: string;
|
|
260
|
-
dataset?: string;
|
|
261
|
-
slice?: string;
|
|
262
|
-
splitColumn?: string;
|
|
263
|
-
parts?: string[];
|
|
264
|
-
loraRank?: TrainingDraftOptions["loraRank"];
|
|
265
|
-
gistTokens?: TrainingDraftOptions["gistTokens"];
|
|
266
|
-
epochs?: number;
|
|
267
|
-
learningRate?: number;
|
|
268
|
-
batchSize?: TrainingDraftOptions["batchSize"];
|
|
269
|
-
maxSequenceLength?: number;
|
|
270
|
-
promptFile?: string;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
export const trainingDraftOptions = (options: RawTrainingDraftOptions): TrainingDraftOptions => ({
|
|
274
|
-
method: options.method,
|
|
275
|
-
baseModelId: options.baseModel,
|
|
276
|
-
modelVersionId: options.modelVersion,
|
|
277
|
-
datasetName: options.dataset,
|
|
278
|
-
sliceId: options.slice,
|
|
279
|
-
splitColumn: options.splitColumn,
|
|
280
|
-
trainParts: options.parts,
|
|
281
|
-
loraRank: options.loraRank,
|
|
282
|
-
gistTokens: options.gistTokens,
|
|
283
|
-
epochs: options.epochs,
|
|
284
|
-
learningRate: options.learningRate,
|
|
285
|
-
batchSize: options.batchSize,
|
|
286
|
-
maxSequenceLength: options.maxSequenceLength,
|
|
287
|
-
promptFilePath: options.promptFile,
|
|
288
|
-
});
|
|
289
|
-
|
|
290
182
|
export const exitCodeForOutcome = (outcome: RunOutcome): number => {
|
|
291
183
|
if (outcome === "failed") return 1;
|
|
292
184
|
if (outcome === "timedOut") return 2;
|
|
@@ -343,20 +235,7 @@ export const resolveClient = async (
|
|
|
343
235
|
const { baseUrl, credential } = config;
|
|
344
236
|
const client =
|
|
345
237
|
context.injectedClient ??
|
|
346
|
-
createClient(
|
|
347
|
-
credential.type === "apiKey"
|
|
348
|
-
? { baseUrl, apiKey: credential.apiKey }
|
|
349
|
-
: credential.type === "scopedToken"
|
|
350
|
-
? { baseUrl, scopedToken: credential.scopedToken }
|
|
351
|
-
: {
|
|
352
|
-
baseUrl,
|
|
353
|
-
accessToken: createBrowserSessionAuth({
|
|
354
|
-
provider: credential.provider,
|
|
355
|
-
baseUrl,
|
|
356
|
-
environment,
|
|
357
|
-
}),
|
|
358
|
-
},
|
|
359
|
-
);
|
|
238
|
+
createClient(clientConfigFor(baseUrl, credential, environment));
|
|
360
239
|
return { config, client };
|
|
361
240
|
};
|
|
362
241
|
|
package/src/cli/credentials.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { chmod, lstat, mkdir, rm, stat, writeFile } from "node:fs/promises";
|
|
2
3
|
import { homedir } from "node:os";
|
|
3
4
|
import { dirname, join } from "node:path";
|
|
4
5
|
import { assertCli, TolokaCliError } from "./cli-error";
|
|
@@ -144,10 +145,10 @@ const asCredentials = (payload: unknown): StoredCredentials | undefined => {
|
|
|
144
145
|
return { ...identity, ...registry };
|
|
145
146
|
};
|
|
146
147
|
|
|
147
|
-
export
|
|
148
|
+
export function inspectCredentialsFile(path: string): InspectedCredentialsFile {
|
|
148
149
|
let raw: string;
|
|
149
150
|
try {
|
|
150
|
-
raw =
|
|
151
|
+
raw = readFileSync(path, "utf8");
|
|
151
152
|
} catch (error) {
|
|
152
153
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") return "missing";
|
|
153
154
|
return "invalid";
|
|
@@ -161,11 +162,11 @@ export async function inspectCredentialsFile(path: string): Promise<InspectedCre
|
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
export
|
|
165
|
+
export function findStoredCredentials(
|
|
165
166
|
environment: CliEnvironment = process.env,
|
|
166
|
-
):
|
|
167
|
+
): FoundCredentials | undefined {
|
|
167
168
|
const path = credentialsPath(environment);
|
|
168
|
-
const primary =
|
|
169
|
+
const primary = inspectCredentialsFile(path);
|
|
169
170
|
if (primary !== "missing") {
|
|
170
171
|
if (primary === "invalid") {
|
|
171
172
|
throw new CredentialsError(
|
|
@@ -179,7 +180,7 @@ export async function findStoredCredentials(
|
|
|
179
180
|
if (environment.TOLOKA_CREDENTIALS_FILE !== undefined) return undefined;
|
|
180
181
|
|
|
181
182
|
const legacyPath = legacyCredentialsPath(environment);
|
|
182
|
-
const legacy =
|
|
183
|
+
const legacy = inspectCredentialsFile(legacyPath);
|
|
183
184
|
if (legacy === "missing") return undefined;
|
|
184
185
|
if (legacy === "invalid") {
|
|
185
186
|
throw new CredentialsError(
|
|
@@ -195,7 +196,7 @@ export async function findCommandCredentials(
|
|
|
195
196
|
overrideCredential: string | undefined,
|
|
196
197
|
): Promise<CommandCredentialLookup> {
|
|
197
198
|
try {
|
|
198
|
-
return { found:
|
|
199
|
+
return { found: findStoredCredentials(environment) };
|
|
199
200
|
} catch (error) {
|
|
200
201
|
if (!(error instanceof CredentialsError) || overrideCredential === undefined) throw error;
|
|
201
202
|
return { found: undefined, warning: error.message };
|
|
@@ -205,13 +206,13 @@ export async function findCommandCredentials(
|
|
|
205
206
|
export async function readStoredCredentials(
|
|
206
207
|
environment: CliEnvironment = process.env,
|
|
207
208
|
): Promise<StoredCredentials | undefined> {
|
|
208
|
-
return
|
|
209
|
+
return findStoredCredentials(environment)?.credentials;
|
|
209
210
|
}
|
|
210
211
|
|
|
211
212
|
export async function requireStoredCredentials(
|
|
212
213
|
environment: CliEnvironment = process.env,
|
|
213
214
|
): Promise<FoundCredentials> {
|
|
214
|
-
const found =
|
|
215
|
+
const found = findStoredCredentials(environment);
|
|
215
216
|
if (found !== undefined) return found;
|
|
216
217
|
throw new CredentialsError(
|
|
217
218
|
`No stored credentials found at ${credentialsPath(environment)}. Run toloka login.`,
|
package/src/cli/init.ts
CHANGED
|
@@ -280,7 +280,7 @@ export async function initProject(
|
|
|
280
280
|
];
|
|
281
281
|
const warning = dependencyReady
|
|
282
282
|
? undefined
|
|
283
|
-
: `Warning: ${SDK_PACKAGE_NAME} is not listed in dependencies or devDependencies in ${join(targetRoot, "package.json")}. Install it with npm or Bun before authoring pipelines, then re-run \`toloka init
|
|
283
|
+
: `Warning: ${SDK_PACKAGE_NAME} is not listed in dependencies or devDependencies in ${join(targetRoot, "package.json")}. Install it with npm or Bun before authoring pipelines, then re-run \`toloka init\`.`;
|
|
284
284
|
return {
|
|
285
285
|
targetDirectory: targetRoot,
|
|
286
286
|
files,
|
package/src/cli/program.ts
CHANGED
|
@@ -13,7 +13,6 @@ import { registerConfigCommands } from "./commands/config";
|
|
|
13
13
|
import { registerDatasetCommands } from "./commands/dataset";
|
|
14
14
|
import { registerGenerationModelCommands } from "./commands/generation-model";
|
|
15
15
|
import { registerDeliveryOrderCommands } from "./commands/delivery-order";
|
|
16
|
-
import { registerModelCommands } from "./commands/models";
|
|
17
16
|
import { registerPipelineCommands } from "./commands/pipeline";
|
|
18
17
|
import { registerProjectCommands } from "./commands/project";
|
|
19
18
|
import { registerReportCommand } from "./commands/report";
|
|
@@ -25,9 +24,7 @@ import { registerSecretCommands } from "./commands/secret";
|
|
|
25
24
|
import { registerSkillCommands } from "./commands/skill";
|
|
26
25
|
import { registerSourceCommands } from "./commands/source";
|
|
27
26
|
import { registerStatusCommand } from "./commands/status";
|
|
28
|
-
import { registerTrainingCommands } from "./commands/training";
|
|
29
27
|
import { registerUiCommands } from "./commands/ui";
|
|
30
|
-
import { registerBatchInferenceCommands } from "./commands/batch-inference";
|
|
31
28
|
import { registerVersionCommand } from "./commands/version";
|
|
32
29
|
import type { TolokaEnvironment } from "./config";
|
|
33
30
|
import {
|
|
@@ -110,9 +107,6 @@ export function createProgram(context: ProgramContext): CreatedProgram {
|
|
|
110
107
|
registerSecretCommands(program, host);
|
|
111
108
|
registerExpertListCommands(program, host);
|
|
112
109
|
registerExpertBanListCommands(program, host);
|
|
113
|
-
registerModelCommands(program, host);
|
|
114
|
-
registerTrainingCommands(program, host);
|
|
115
|
-
registerBatchInferenceCommands(program, host);
|
|
116
110
|
registerDatasetCommands(program, host);
|
|
117
111
|
registerPipelineCommands(program, host);
|
|
118
112
|
registerReviewCommands(program, host);
|
package/src/cli/project.ts
CHANGED
|
@@ -247,6 +247,14 @@ const withoutEmptyEntityRelations = (node: unknown): unknown => {
|
|
|
247
247
|
};
|
|
248
248
|
};
|
|
249
249
|
|
|
250
|
+
const withoutIgnoredSettings = (node: PipelineGraphV1["nodes"][number]): unknown => {
|
|
251
|
+
if (node.type !== "generation" && node.type !== "quorum") return node;
|
|
252
|
+
|
|
253
|
+
const { reuseAudienceWithNodeId: _reuseAudienceWithNodeId, smartSearch: _smartSearch, ...settings } = node.settings;
|
|
254
|
+
|
|
255
|
+
return { ...node, settings };
|
|
256
|
+
};
|
|
257
|
+
|
|
250
258
|
const withAudienceSourcingDefaults = (node: PipelineGraphV1["nodes"][number]): unknown => {
|
|
251
259
|
if (node.type !== "generation" && node.type !== "quorum") return node;
|
|
252
260
|
|
|
@@ -357,7 +365,7 @@ export function diffPipelineGraphs(
|
|
|
357
365
|
liveNodes,
|
|
358
366
|
(authored, live) =>
|
|
359
367
|
matchesAuthored(
|
|
360
|
-
withoutEmptyEntityRelations(withCanonicalExpertListConditions(authored)),
|
|
368
|
+
withoutEmptyEntityRelations(withCanonicalExpertListConditions(withoutIgnoredSettings(authored))),
|
|
361
369
|
withoutEmptyEntityRelations(
|
|
362
370
|
withCanonicalExpertListConditions(withAudienceSourcingDefaults(live)),
|
|
363
371
|
),
|
package/src/client.ts
CHANGED
|
@@ -13,19 +13,14 @@ import type {
|
|
|
13
13
|
RemoveExpertBanListExpertsBody,
|
|
14
14
|
UpdateExpertListBody,
|
|
15
15
|
AttachPipelineDatasetBody,
|
|
16
|
-
BatchInferenceRun as GeneratedBatchInferenceRun,
|
|
17
16
|
CancelPipelineRunBody,
|
|
18
17
|
CheckJob as GeneratedCheckJob,
|
|
19
18
|
CopyPipelineBody,
|
|
20
|
-
CreateBatchInferenceRunBody,
|
|
21
19
|
CreateDatasetBody,
|
|
22
20
|
CreateDatasetExportBody,
|
|
23
21
|
CreateDatasetFieldsFromUploadedRowsBody,
|
|
24
22
|
CreateDatasetSliceBody,
|
|
25
|
-
CreateTrainingRunBody,
|
|
26
|
-
CreateProjectModelBody,
|
|
27
23
|
CreateDatasetFieldBody,
|
|
28
|
-
CreateProjectTrainingBody,
|
|
29
24
|
CreateDatasetUploadBody,
|
|
30
25
|
CreatePipelineCheckBody,
|
|
31
26
|
CreateProjectBody,
|
|
@@ -36,15 +31,11 @@ import type {
|
|
|
36
31
|
DatasetItem as GeneratedDatasetItem,
|
|
37
32
|
DatasetSlice as GeneratedDatasetSlice,
|
|
38
33
|
ExportJob as GeneratedExportJob,
|
|
39
|
-
EstimateTrainingCostBody,
|
|
40
34
|
EstimatePipelineCostBody,
|
|
41
35
|
ImportPipelineBody,
|
|
42
36
|
InferredField as GeneratedInferredField,
|
|
43
|
-
GetTrainingRunLogsParams,
|
|
44
|
-
GetTrainingRunMetricHistoryParams,
|
|
45
37
|
ListDatasetFieldsParams,
|
|
46
38
|
ListDatasetSlicesParams,
|
|
47
|
-
ListModelVersionsParams,
|
|
48
39
|
ListDatasetItemsParams,
|
|
49
40
|
ListPipelineRunItemsParams,
|
|
50
41
|
ListPipelineRunReviewsParams,
|
|
@@ -52,27 +43,11 @@ import type {
|
|
|
52
43
|
ListProjectDatasetsParams,
|
|
53
44
|
ListProjectPipelinesParams,
|
|
54
45
|
ListAudienceSpecializationsParams,
|
|
55
|
-
ListBatchInferenceRunsParams,
|
|
56
|
-
ListProjectModelsParams,
|
|
57
46
|
ListProjectsParams,
|
|
58
47
|
ListProjectTokensParams,
|
|
59
|
-
ListTrainingRunsParams,
|
|
60
|
-
ListProjectTrainingsParams,
|
|
61
48
|
Pipeline as GeneratedPipeline,
|
|
62
|
-
Model as GeneratedModel,
|
|
63
|
-
ModelVersion as GeneratedModelVersion,
|
|
64
|
-
PrepareTrainingCostEstimateInputsBody,
|
|
65
49
|
PatchPipelineNodeBody,
|
|
66
50
|
SplitDatasetBody,
|
|
67
|
-
Training as GeneratedTraining,
|
|
68
|
-
TrainingCostEstimate as GeneratedTrainingCostEstimate,
|
|
69
|
-
TrainingCostEstimateInputSet as GeneratedTrainingCostEstimateInputSet,
|
|
70
|
-
TrainingRun as GeneratedTrainingRun,
|
|
71
|
-
TrainingRunMetricHistory as GeneratedTrainingRunMetricHistory,
|
|
72
|
-
TrainingRunMetrics as GeneratedTrainingRunMetrics,
|
|
73
|
-
TrainingRunLogs as GeneratedTrainingRunLogs,
|
|
74
|
-
ReplaceTrainingConfigurationBody,
|
|
75
|
-
UpdateTrainingMetadataBody,
|
|
76
51
|
PipelineGraphSnapshot,
|
|
77
52
|
Project as GeneratedProject,
|
|
78
53
|
ProjectFile as GeneratedProjectFile,
|
|
@@ -85,14 +60,13 @@ import type {
|
|
|
85
60
|
RunJob as GeneratedRunJob,
|
|
86
61
|
RunSummary as GeneratedRunSummary,
|
|
87
62
|
SetProjectSecretBody,
|
|
88
|
-
BaseModel as GeneratedBaseModel,
|
|
89
|
-
BaseModelId as GeneratedBaseModelId,
|
|
90
63
|
UpdatePipelineBody,
|
|
91
64
|
UpdateProjectBody,
|
|
92
65
|
JsonValue as GeneratedJsonValue,
|
|
93
66
|
UploadJob as GeneratedUploadJob,
|
|
94
67
|
ValidatePipelineGraphBody,
|
|
95
68
|
} from "../openapi/gen/api.schemas";
|
|
69
|
+
import { resolveLoginClientConfig } from "./cli/config";
|
|
96
70
|
import { listAllPages, readAllPagesFirst } from "./pagination";
|
|
97
71
|
import { createRequestOptions } from "./transport";
|
|
98
72
|
import type { ClientCredential } from "./transport";
|
|
@@ -104,18 +78,12 @@ type Brand<B> = { [__brand]: B };
|
|
|
104
78
|
type CreateDatasetFieldInput = Exclude<CreateDatasetFieldBody, { fields: unknown }>;
|
|
105
79
|
export type Branded<T extends string, B> = T & Brand<B>;
|
|
106
80
|
|
|
107
|
-
export type BatchInferenceRunId = Branded<string, "BatchInferenceRunId">;
|
|
108
81
|
export type CheckRunId = Branded<string, "CheckRunId">;
|
|
109
82
|
export type DatasetFieldId = Branded<string, "DatasetFieldId">;
|
|
110
83
|
export type DatasetId = Branded<string, "DatasetId">;
|
|
111
84
|
export type DatasetItemId = Branded<string, "DatasetItemId">;
|
|
112
85
|
export type DatasetSliceId = Branded<string, "DatasetSliceId">;
|
|
113
86
|
export type ExportId = Branded<string, "ExportId">;
|
|
114
|
-
export type ModelId = Branded<string, "ModelId">;
|
|
115
|
-
export type ModelVersionId = Branded<string, "ModelVersionId">;
|
|
116
|
-
export type TrainingId = Branded<string, "TrainingId">;
|
|
117
|
-
export type TrainingCostEstimateInputSetId = Branded<string, "TrainingCostEstimateInputSetId">;
|
|
118
|
-
export type TrainingRunId = Branded<string, "TrainingRunId">;
|
|
119
87
|
export type PipelineId = Branded<string, "PipelineId">;
|
|
120
88
|
export type ProjectFileId = Branded<string, "ProjectFileId">;
|
|
121
89
|
export type ProjectId = Branded<string, "ProjectId">;
|
|
@@ -129,7 +97,6 @@ type ResourceIdInput<T extends Branded<string, unknown>> = string & {
|
|
|
129
97
|
};
|
|
130
98
|
|
|
131
99
|
type ResourceIdsByProperty = {
|
|
132
|
-
batchInferenceRunId: BatchInferenceRunId;
|
|
133
100
|
checkRunId: CheckRunId;
|
|
134
101
|
datasetFieldId: DatasetFieldId;
|
|
135
102
|
datasetId: DatasetId;
|
|
@@ -137,11 +104,6 @@ type ResourceIdsByProperty = {
|
|
|
137
104
|
exportId: ExportId;
|
|
138
105
|
fieldId: DatasetFieldId;
|
|
139
106
|
fileId: ProjectFileId;
|
|
140
|
-
modelId: ModelId;
|
|
141
|
-
modelVersionId: ModelVersionId;
|
|
142
|
-
trainingId: TrainingId;
|
|
143
|
-
inputSetId: TrainingCostEstimateInputSetId;
|
|
144
|
-
trainingRunId: TrainingRunId;
|
|
145
107
|
goldenDatasetId: DatasetId;
|
|
146
108
|
itemId: RunItemId;
|
|
147
109
|
fromSliceId: DatasetSliceId;
|
|
@@ -189,9 +151,6 @@ type PublicInput<T> = IsJsonValue<T> extends true
|
|
|
189
151
|
}
|
|
190
152
|
: T;
|
|
191
153
|
|
|
192
|
-
type BrandResourceUnion<T> = T extends object ? BrandResourceReferences<T> : T;
|
|
193
|
-
|
|
194
|
-
export type BatchInferenceRun = BrandedResource<GeneratedBatchInferenceRun, BatchInferenceRunId>;
|
|
195
154
|
export type CheckJob = BrandedResource<GeneratedCheckJob, CheckRunId>;
|
|
196
155
|
export type Dataset = BrandedResource<GeneratedDataset, DatasetId>;
|
|
197
156
|
export type DatasetField = BrandedResource<GeneratedDatasetField, DatasetFieldId>;
|
|
@@ -199,20 +158,6 @@ export type DatasetItem = BrandedResource<GeneratedDatasetItem, DatasetItemId>;
|
|
|
199
158
|
export type DatasetSlice = BrandedResource<GeneratedDatasetSlice, DatasetSliceId>;
|
|
200
159
|
export type ExportJob = BrandedResource<GeneratedExportJob, ExportId>;
|
|
201
160
|
export type InferredField = GeneratedInferredField;
|
|
202
|
-
export type Model = BrandedResource<GeneratedModel, ModelId>;
|
|
203
|
-
export type ModelVersion = BrandedResource<GeneratedModelVersion, ModelVersionId>;
|
|
204
|
-
export type Training = BrandedResource<GeneratedTraining, TrainingId>;
|
|
205
|
-
export type TrainingCostEstimateInputSet = BrandedResource<
|
|
206
|
-
GeneratedTrainingCostEstimateInputSet,
|
|
207
|
-
TrainingCostEstimateInputSetId
|
|
208
|
-
>;
|
|
209
|
-
export type TrainingCostEstimate = BrandResourceUnion<GeneratedTrainingCostEstimate>;
|
|
210
|
-
export type TrainingRun = BrandedResource<GeneratedTrainingRun, TrainingRunId>;
|
|
211
|
-
export type TrainingRunLogs = GeneratedTrainingRunLogs;
|
|
212
|
-
export type TrainingRunMetrics = GeneratedTrainingRunMetrics;
|
|
213
|
-
export type TrainingRunMetricHistory = GeneratedTrainingRunMetricHistory;
|
|
214
|
-
export type BaseModel = GeneratedBaseModel;
|
|
215
|
-
export type BaseModelId = GeneratedBaseModelId;
|
|
216
161
|
export type Pipeline = BrandedResource<GeneratedPipeline, PipelineId>;
|
|
217
162
|
export type Project = BrandedResource<GeneratedProject, ProjectId>;
|
|
218
163
|
export type ProjectFile = BrandedResource<GeneratedProjectFile, ProjectFileId>;
|
|
@@ -477,191 +422,6 @@ const createClientImplementation = (config: ClientConfig) => {
|
|
|
477
422
|
wire.copyPipeline(pipelineId, body, requestOptions),
|
|
478
423
|
};
|
|
479
424
|
|
|
480
|
-
const baseModels = {
|
|
481
|
-
list: async () => (await wire.listBaseModels(requestOptions)).baseModels,
|
|
482
|
-
get: ({ id }: { id: BaseModelId }) => wire.getBaseModel(id, requestOptions),
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
const models = {
|
|
486
|
-
listPage: ({ projectId, ...params }: { projectId: ProjectId } & ListProjectModelsParams) =>
|
|
487
|
-
wire.listProjectModels(projectId, params, requestOptions),
|
|
488
|
-
listAll: ({ projectId, ...params }: { projectId: ProjectId } & ListProjectModelsParams) =>
|
|
489
|
-
listAllPages(async (pageOptions) => {
|
|
490
|
-
const page = await wire.listProjectModels(
|
|
491
|
-
projectId,
|
|
492
|
-
{ ...params, ...pageOptions },
|
|
493
|
-
requestOptions,
|
|
494
|
-
);
|
|
495
|
-
return { items: page.models, pagination: page.pagination };
|
|
496
|
-
}, params),
|
|
497
|
-
get: ({ projectId, modelId }: { projectId: ProjectId; modelId: ModelId }) =>
|
|
498
|
-
wire.getProjectModel(projectId, modelId, requestOptions),
|
|
499
|
-
listVersionsPage: ({
|
|
500
|
-
projectId,
|
|
501
|
-
modelId,
|
|
502
|
-
...params
|
|
503
|
-
}: { projectId: ProjectId; modelId: ModelId } & ListModelVersionsParams) =>
|
|
504
|
-
wire.listModelVersions(projectId, modelId, params, requestOptions),
|
|
505
|
-
listAllVersions: ({
|
|
506
|
-
projectId,
|
|
507
|
-
modelId,
|
|
508
|
-
...params
|
|
509
|
-
}: { projectId: ProjectId; modelId: ModelId } & ListModelVersionsParams) =>
|
|
510
|
-
listAllPages(async (pageOptions) => {
|
|
511
|
-
const page = await wire.listModelVersions(
|
|
512
|
-
projectId,
|
|
513
|
-
modelId,
|
|
514
|
-
{ ...params, ...pageOptions },
|
|
515
|
-
requestOptions,
|
|
516
|
-
);
|
|
517
|
-
return { items: page.versions, pagination: page.pagination };
|
|
518
|
-
}, params),
|
|
519
|
-
create: ({ projectId, ...body }: { projectId: ProjectId } & CreateProjectModelBody) =>
|
|
520
|
-
wire.createProjectModel(projectId, body, requestOptions),
|
|
521
|
-
getVersion: ({ modelVersionId }: { modelVersionId: ModelVersionId }) =>
|
|
522
|
-
wire.getModelVersion(modelVersionId, requestOptions),
|
|
523
|
-
getVersionContent: ({ modelVersionId }: { modelVersionId: ModelVersionId }) =>
|
|
524
|
-
wire.getModelVersionContent(modelVersionId, requestOptions),
|
|
525
|
-
archive: ({ projectId, modelId }: { projectId: ProjectId; modelId: ModelId }) => {
|
|
526
|
-
const headers = new Headers(requestOptions.headers);
|
|
527
|
-
headers.set("Content-Type", "application/json");
|
|
528
|
-
return wire.archiveProjectModel(projectId, modelId, { ...requestOptions, headers });
|
|
529
|
-
},
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
const trainings = {
|
|
533
|
-
listPage: ({ projectId, ...params }: { projectId: ProjectId } & ListProjectTrainingsParams) =>
|
|
534
|
-
wire.listProjectTrainings(projectId, params, requestOptions),
|
|
535
|
-
listAll: ({ projectId, ...params }: { projectId: ProjectId } & ListProjectTrainingsParams) =>
|
|
536
|
-
listAllPages(async (pageOptions) => {
|
|
537
|
-
const page = await wire.listProjectTrainings(
|
|
538
|
-
projectId,
|
|
539
|
-
{ ...params, ...pageOptions },
|
|
540
|
-
requestOptions,
|
|
541
|
-
);
|
|
542
|
-
return { items: page.trainings, pagination: page.pagination };
|
|
543
|
-
}, params),
|
|
544
|
-
get: ({ trainingId }: { trainingId: TrainingId }) =>
|
|
545
|
-
wire.getTraining(trainingId, requestOptions),
|
|
546
|
-
create: ({ projectId, ...body }: { projectId: ProjectId } & CreateProjectTrainingBody) =>
|
|
547
|
-
wire.createProjectTraining(projectId, body, requestOptions),
|
|
548
|
-
updateMetadata: ({
|
|
549
|
-
trainingId,
|
|
550
|
-
...body
|
|
551
|
-
}: { trainingId: TrainingId } & UpdateTrainingMetadataBody) =>
|
|
552
|
-
wire.updateTrainingMetadata(trainingId, body, requestOptions),
|
|
553
|
-
replaceConfiguration: ({
|
|
554
|
-
trainingId,
|
|
555
|
-
...body
|
|
556
|
-
}: { trainingId: TrainingId } & ReplaceTrainingConfigurationBody) =>
|
|
557
|
-
wire.replaceTrainingConfiguration(trainingId, body, requestOptions),
|
|
558
|
-
prepareCostEstimateInputs: ({
|
|
559
|
-
trainingId,
|
|
560
|
-
idempotencyKey,
|
|
561
|
-
...body
|
|
562
|
-
}: {
|
|
563
|
-
trainingId: TrainingId;
|
|
564
|
-
idempotencyKey: string;
|
|
565
|
-
} & PrepareTrainingCostEstimateInputsBody) => {
|
|
566
|
-
const headers = new Headers(requestOptions.headers);
|
|
567
|
-
headers.set("Idempotency-Key", idempotencyKey);
|
|
568
|
-
return wire.prepareTrainingCostEstimateInputs(trainingId, body, {
|
|
569
|
-
...requestOptions,
|
|
570
|
-
headers: Object.fromEntries(headers.entries()),
|
|
571
|
-
});
|
|
572
|
-
},
|
|
573
|
-
estimateCost: ({
|
|
574
|
-
trainingId,
|
|
575
|
-
...body
|
|
576
|
-
}: { trainingId: TrainingId } & EstimateTrainingCostBody) =>
|
|
577
|
-
wire.estimateTrainingCost(trainingId, body, requestOptions),
|
|
578
|
-
resumeRun: ({ trainingRunId }: { trainingRunId: TrainingRunId }) =>
|
|
579
|
-
wire.resumeTrainingRun(trainingRunId, requestOptions),
|
|
580
|
-
cancelRun: ({ trainingRunId }: { trainingRunId: TrainingRunId }) =>
|
|
581
|
-
wire.cancelTrainingRun(trainingRunId, requestOptions),
|
|
582
|
-
createRun: ({
|
|
583
|
-
trainingId,
|
|
584
|
-
idempotencyKey,
|
|
585
|
-
...body
|
|
586
|
-
}: { trainingId: TrainingId; idempotencyKey: string } & CreateTrainingRunBody) => {
|
|
587
|
-
const headers = new Headers(requestOptions.headers);
|
|
588
|
-
headers.set("Idempotency-Key", idempotencyKey);
|
|
589
|
-
return wire.createTrainingRun(trainingId, body, {
|
|
590
|
-
...requestOptions,
|
|
591
|
-
headers: Object.fromEntries(headers.entries()),
|
|
592
|
-
});
|
|
593
|
-
},
|
|
594
|
-
listRunsPage: ({
|
|
595
|
-
trainingId,
|
|
596
|
-
...params
|
|
597
|
-
}: { trainingId: TrainingId } & ListTrainingRunsParams) =>
|
|
598
|
-
wire.listTrainingRuns(trainingId, params, requestOptions),
|
|
599
|
-
listAllRuns: ({ trainingId, ...params }: { trainingId: TrainingId } & ListTrainingRunsParams) =>
|
|
600
|
-
listAllPages(async (pageOptions) => {
|
|
601
|
-
const page = await wire.listTrainingRuns(
|
|
602
|
-
trainingId,
|
|
603
|
-
{ ...params, ...pageOptions },
|
|
604
|
-
requestOptions,
|
|
605
|
-
);
|
|
606
|
-
return { items: page.trainingRuns, pagination: page.pagination };
|
|
607
|
-
}, params),
|
|
608
|
-
getRun: ({ trainingRunId }: { trainingRunId: TrainingRunId }) =>
|
|
609
|
-
wire.getTrainingRun(trainingRunId, requestOptions),
|
|
610
|
-
getRunLogs: ({
|
|
611
|
-
trainingRunId,
|
|
612
|
-
...params
|
|
613
|
-
}: { trainingRunId: TrainingRunId } & GetTrainingRunLogsParams) =>
|
|
614
|
-
wire.getTrainingRunLogs(trainingRunId, params, requestOptions),
|
|
615
|
-
getRunMetrics: ({ trainingRunId }: { trainingRunId: TrainingRunId }) =>
|
|
616
|
-
wire.getTrainingRunMetrics(trainingRunId, requestOptions),
|
|
617
|
-
getRunMetricHistory: ({
|
|
618
|
-
trainingRunId,
|
|
619
|
-
metricKey,
|
|
620
|
-
...params
|
|
621
|
-
}: { trainingRunId: TrainingRunId; metricKey: string } & GetTrainingRunMetricHistoryParams) =>
|
|
622
|
-
wire.getTrainingRunMetricHistory(trainingRunId, metricKey, params, requestOptions),
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
const batchInference = {
|
|
626
|
-
createRun: ({
|
|
627
|
-
projectId,
|
|
628
|
-
idempotencyKey,
|
|
629
|
-
...body
|
|
630
|
-
}: { projectId: ProjectId; idempotencyKey: string } & CreateBatchInferenceRunBody) => {
|
|
631
|
-
const headers = new Headers(requestOptions.headers);
|
|
632
|
-
headers.set("Idempotency-Key", idempotencyKey);
|
|
633
|
-
return wire.createBatchInferenceRun(projectId, body, {
|
|
634
|
-
...requestOptions,
|
|
635
|
-
headers: Object.fromEntries(headers.entries()),
|
|
636
|
-
});
|
|
637
|
-
},
|
|
638
|
-
listRunsPage: ({
|
|
639
|
-
projectId,
|
|
640
|
-
...params
|
|
641
|
-
}: { projectId: ProjectId } & ListBatchInferenceRunsParams) =>
|
|
642
|
-
wire.listBatchInferenceRuns(projectId, params, requestOptions),
|
|
643
|
-
listAllRuns: ({
|
|
644
|
-
projectId,
|
|
645
|
-
...params
|
|
646
|
-
}: { projectId: ProjectId } & ListBatchInferenceRunsParams) =>
|
|
647
|
-
listAllPages(async (pageOptions) => {
|
|
648
|
-
const page = await wire.listBatchInferenceRuns(
|
|
649
|
-
projectId,
|
|
650
|
-
{ ...params, ...pageOptions },
|
|
651
|
-
requestOptions,
|
|
652
|
-
);
|
|
653
|
-
return { items: page.batchInferenceRuns, pagination: page.pagination };
|
|
654
|
-
}, params),
|
|
655
|
-
getRun: ({ batchInferenceRunId }: { batchInferenceRunId: BatchInferenceRunId }) =>
|
|
656
|
-
wire.getBatchInferenceRun(batchInferenceRunId, requestOptions),
|
|
657
|
-
confirmRun: ({ batchInferenceRunId }: { batchInferenceRunId: BatchInferenceRunId }) =>
|
|
658
|
-
wire.confirmBatchInferenceRun(batchInferenceRunId, requestOptions),
|
|
659
|
-
resumeRun: ({ batchInferenceRunId }: { batchInferenceRunId: BatchInferenceRunId }) =>
|
|
660
|
-
wire.resumeBatchInferenceRun(batchInferenceRunId, requestOptions),
|
|
661
|
-
cancelRun: ({ batchInferenceRunId }: { batchInferenceRunId: BatchInferenceRunId }) =>
|
|
662
|
-
wire.cancelBatchInferenceRun(batchInferenceRunId, requestOptions),
|
|
663
|
-
};
|
|
664
|
-
|
|
665
425
|
const datasets = {
|
|
666
426
|
create: ({ projectId, ...body }: { projectId: ProjectId } & CreateDatasetBody) =>
|
|
667
427
|
wire.createDataset(projectId, body, requestOptions),
|
|
@@ -900,11 +660,7 @@ const createClientImplementation = (config: ClientConfig) => {
|
|
|
900
660
|
projects,
|
|
901
661
|
pipelines,
|
|
902
662
|
datasets,
|
|
903
|
-
baseModels,
|
|
904
663
|
generationModels,
|
|
905
|
-
models,
|
|
906
|
-
trainings,
|
|
907
|
-
batchInference,
|
|
908
664
|
runs,
|
|
909
665
|
reviews,
|
|
910
666
|
secrets,
|
|
@@ -927,20 +683,6 @@ type PublicOutput<T> = IsJsonValue<T> extends true
|
|
|
927
683
|
? ExportJob
|
|
928
684
|
: T extends GeneratedUploadJob
|
|
929
685
|
? UploadJob
|
|
930
|
-
: T extends GeneratedModel
|
|
931
|
-
? Model
|
|
932
|
-
: T extends GeneratedTraining
|
|
933
|
-
? Training
|
|
934
|
-
: T extends GeneratedModelVersion
|
|
935
|
-
? ModelVersion
|
|
936
|
-
: T extends GeneratedTrainingCostEstimateInputSet
|
|
937
|
-
? TrainingCostEstimateInputSet
|
|
938
|
-
: T extends GeneratedTrainingCostEstimate
|
|
939
|
-
? TrainingCostEstimate
|
|
940
|
-
: T extends GeneratedTrainingRun
|
|
941
|
-
? TrainingRun
|
|
942
|
-
: T extends GeneratedBatchInferenceRun
|
|
943
|
-
? BatchInferenceRun
|
|
944
686
|
: T extends GeneratedProject
|
|
945
687
|
? Project
|
|
946
688
|
: T extends GeneratedPipeline
|
|
@@ -999,7 +741,7 @@ type PublicClient<T extends (...args: never[]) => unknown> = T extends (
|
|
|
999
741
|
|
|
1000
742
|
export type PotatoClient = PublicClient<typeof createClientImplementation>;
|
|
1001
743
|
|
|
1002
|
-
export function createClient(config
|
|
1003
|
-
export function createClient(config: ClientConfig) {
|
|
744
|
+
export function createClient(config?: ClientConfig): PotatoClient;
|
|
745
|
+
export function createClient(config: ClientConfig = resolveLoginClientConfig(process.env)) {
|
|
1004
746
|
return createClientImplementation(config);
|
|
1005
747
|
}
|