bailian-cli-core 1.4.2 → 1.5.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/dist/index.d.mts +902 -10
- package/dist/index.mjs +65 -3236
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -625,6 +625,10 @@ declare function parseConfigFile(raw: unknown): ConfigFile;
|
|
|
625
625
|
interface Config {
|
|
626
626
|
clientName?: string;
|
|
627
627
|
clientVersion?: string;
|
|
628
|
+
/** Product binary name (e.g. "bl", "rag"), injected by createCli for command-facing output. */
|
|
629
|
+
binName?: string;
|
|
630
|
+
/** npm package name for self-update (e.g. "bailian-cli", "bailian-cli-rag"), injected by createCli. */
|
|
631
|
+
npmPackage?: string;
|
|
628
632
|
apiKey?: string;
|
|
629
633
|
/** `DASHSCOPE_ACCESS_TOKEN` env (explicit override). */
|
|
630
634
|
accessTokenEnv?: string;
|
|
@@ -906,6 +910,886 @@ declare function resolveFileUrl(input: string, apiKey: string, model: string, op
|
|
|
906
910
|
signal?: AbortSignal;
|
|
907
911
|
}): Promise<string>;
|
|
908
912
|
//#endregion
|
|
913
|
+
//#region src/dataset/types.d.ts
|
|
914
|
+
/**
|
|
915
|
+
* Dataset API types.
|
|
916
|
+
*
|
|
917
|
+
* Maps DashScope `/api/v1/files` responses. The same endpoint backs every
|
|
918
|
+
* dataset purpose the platform supports today (fine-tune training,
|
|
919
|
+
* evaluation, etc.) — these types are deliberately purpose-agnostic so new
|
|
920
|
+
* purposes can be plugged in without schema changes.
|
|
921
|
+
*/
|
|
922
|
+
/** A single uploaded dataset file as returned by the platform. */
|
|
923
|
+
interface DatasetFile {
|
|
924
|
+
/** File ID — the only stable handle for downstream consumers. */
|
|
925
|
+
file_id: string;
|
|
926
|
+
/** Original filename uploaded by the user. */
|
|
927
|
+
name: string;
|
|
928
|
+
/** Bytes. */
|
|
929
|
+
size?: number;
|
|
930
|
+
/** Content hash (server-computed). */
|
|
931
|
+
md5?: string;
|
|
932
|
+
/** Free-form purpose tag, e.g. "fine-tune", "evaluation". */
|
|
933
|
+
purpose?: string;
|
|
934
|
+
/** Optional internal/external URL (kept for parity with the API). */
|
|
935
|
+
url?: string;
|
|
936
|
+
/** Free-form description if the user supplied one at upload time. */
|
|
937
|
+
description?: string;
|
|
938
|
+
/** Server-side creation timestamp (string, format per platform). */
|
|
939
|
+
gmt_create?: string;
|
|
940
|
+
}
|
|
941
|
+
/** GET /api/v1/files response. */
|
|
942
|
+
interface DatasetListResponse {
|
|
943
|
+
request_id?: string;
|
|
944
|
+
data?: {
|
|
945
|
+
files?: DatasetFile[];
|
|
946
|
+
total?: number;
|
|
947
|
+
page_no?: number;
|
|
948
|
+
page_size?: number;
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
/** GET /api/v1/files/{file_id} response. */
|
|
952
|
+
interface DatasetGetResponse {
|
|
953
|
+
request_id?: string;
|
|
954
|
+
data?: DatasetFile;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* POST /compatible-mode/v1/files response (OpenAI-compatible).
|
|
958
|
+
*
|
|
959
|
+
* Flat shape — there is no `data` envelope on success. `id` is the file handle
|
|
960
|
+
* to pass to fine-tune jobs; `purpose` is echoed back so callers can confirm
|
|
961
|
+
* it landed. On business-level failure (HTTP 200 + `data.failed_uploads`)
|
|
962
|
+
* `id` is absent and `data.failed_uploads[]` carries the platform's reason.
|
|
963
|
+
*/
|
|
964
|
+
interface DatasetUploadResponse {
|
|
965
|
+
request_id?: string;
|
|
966
|
+
/** File ID — the handle returned to callers (e.g. `file-ft-…`). */
|
|
967
|
+
id?: string;
|
|
968
|
+
/** Always `"file"` for this endpoint. */
|
|
969
|
+
object?: string;
|
|
970
|
+
/** Bytes. */
|
|
971
|
+
bytes?: number;
|
|
972
|
+
/** Original filename uploaded by the user. */
|
|
973
|
+
filename?: string;
|
|
974
|
+
/** Purpose tag, e.g. `"fine-tune"`, `"file-extract"`, `"batch"`. */
|
|
975
|
+
purpose?: string;
|
|
976
|
+
/** Platform processing state, e.g. `"processed"`. */
|
|
977
|
+
status?: string;
|
|
978
|
+
/** Creation timestamp (Unix seconds). */
|
|
979
|
+
created_at?: number;
|
|
980
|
+
/**
|
|
981
|
+
* Failure envelope: HTTP 200 + business failure. When present the upload
|
|
982
|
+
* did NOT produce a file_id; callers must treat this as an error. Common
|
|
983
|
+
* cause: server-side schema rejection (e.g. malformed JSONL slipped past
|
|
984
|
+
* the local pre-flight).
|
|
985
|
+
*/
|
|
986
|
+
data?: {
|
|
987
|
+
failed_uploads?: Array<{
|
|
988
|
+
code?: string;
|
|
989
|
+
message?: string;
|
|
990
|
+
file_name?: string;
|
|
991
|
+
}>;
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
/** DELETE /api/v1/files/{file_id} response. */
|
|
995
|
+
interface DatasetDeleteResponse {
|
|
996
|
+
request_id?: string;
|
|
997
|
+
data?: {
|
|
998
|
+
deleted?: boolean;
|
|
999
|
+
file_id?: string;
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
//#endregion
|
|
1003
|
+
//#region src/dataset/api.d.ts
|
|
1004
|
+
interface DatasetUploadParams {
|
|
1005
|
+
filePath: string;
|
|
1006
|
+
/**
|
|
1007
|
+
* Purpose tag forwarded to the platform. Defaults to "fine-tune" because
|
|
1008
|
+
* the API requires the field, but callers should set this explicitly when
|
|
1009
|
+
* uploading evaluation or other dataset kinds.
|
|
1010
|
+
*/
|
|
1011
|
+
purpose?: string;
|
|
1012
|
+
signal?: AbortSignal;
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* POST /compatible-mode/v1/files (multipart/form-data)
|
|
1016
|
+
*
|
|
1017
|
+
* Streams the file from disk so we don't buffer 300MB into memory. Node's
|
|
1018
|
+
* `fetch` accepts a `Blob` produced from a Readable stream via `Response`'s
|
|
1019
|
+
* body shim, but the simplest portable approach (and the one used in
|
|
1020
|
+
* `files/upload.ts`) is to wrap the buffer in a Blob. Here we use `Blob`
|
|
1021
|
+
* with a stream-backed lazy `arrayBuffer()` for >50MB files via
|
|
1022
|
+
* `Response`'s helper to avoid the buffer doubling. Fall back to readFileSync
|
|
1023
|
+
* for small files where streaming overhead isn't worth it.
|
|
1024
|
+
*/
|
|
1025
|
+
declare function uploadDataset(config: Config, params: DatasetUploadParams): Promise<DatasetFile>;
|
|
1026
|
+
interface DatasetListParams {
|
|
1027
|
+
pageNo?: number;
|
|
1028
|
+
pageSize?: number;
|
|
1029
|
+
purpose?: string;
|
|
1030
|
+
signal?: AbortSignal;
|
|
1031
|
+
}
|
|
1032
|
+
/** GET /api/v1/files */
|
|
1033
|
+
declare function listDatasets(config: Config, params?: DatasetListParams): Promise<DatasetListResponse>;
|
|
1034
|
+
/** GET /api/v1/files/{file_id} */
|
|
1035
|
+
declare function getDataset(config: Config, fileId: string, signal?: AbortSignal): Promise<DatasetGetResponse>;
|
|
1036
|
+
/** DELETE /api/v1/files/{file_id} */
|
|
1037
|
+
declare function deleteDataset(config: Config, fileId: string, signal?: AbortSignal): Promise<DatasetDeleteResponse>;
|
|
1038
|
+
//#endregion
|
|
1039
|
+
//#region src/dataset/validate/types.d.ts
|
|
1040
|
+
/**
|
|
1041
|
+
* Validator types — the registry contract that every format adheres to.
|
|
1042
|
+
*
|
|
1043
|
+
* Design (Plan B from the architecture review):
|
|
1044
|
+
* - A `ValidatorSpec` is a plain object, not a class. Adding a new format =
|
|
1045
|
+
* one new file exporting one constant + one line in the registry.
|
|
1046
|
+
* - Common pre-flight checks (existence, size, extension) live in `common.ts`
|
|
1047
|
+
* and are applied by `validateDataset` before the format-specific validator
|
|
1048
|
+
* runs, so individual specs only handle structural concerns.
|
|
1049
|
+
*/
|
|
1050
|
+
interface ValidateOpts {
|
|
1051
|
+
/** When true, validators should do exhaustive checks (e.g. parse every line). */
|
|
1052
|
+
fullValidate?: boolean;
|
|
1053
|
+
/** Optional max bytes override (defaults to 300MB at the registry level). */
|
|
1054
|
+
maxBytes?: number;
|
|
1055
|
+
/** Optional abort signal for long-running scans. */
|
|
1056
|
+
signal?: AbortSignal;
|
|
1057
|
+
/**
|
|
1058
|
+
* Record-schema selector for formats that carry more than one schema under
|
|
1059
|
+
* the same extension. Today only the `.jsonl` ChatML family honors it:
|
|
1060
|
+
* - `"chatml"` — `{messages: [...]}` (SFT). `chosen`/`rejected` ignored.
|
|
1061
|
+
* - `"dpo"` — `{messages: [...], chosen: {role,content}, rejected: {...}}`.
|
|
1062
|
+
* Every record MUST carry `chosen` + `rejected`.
|
|
1063
|
+
* - `"cpt"` — `{text: "..."}` (continual pre-training). Raw text only,
|
|
1064
|
+
* no `messages[]`.
|
|
1065
|
+
* - `undefined` — auto-detect per record: a record with `chosen` or
|
|
1066
|
+
* `rejected` is validated as DPO, one with `text` (and no
|
|
1067
|
+
* `messages`) as CPT, otherwise as ChatML.
|
|
1068
|
+
* `finetune create` sets this from `--training-type` (dpo* → "dpo",
|
|
1069
|
+
* cpt → "cpt") so a malformed dataset fails at validate time, not on the
|
|
1070
|
+
* platform ten minutes in.
|
|
1071
|
+
*/
|
|
1072
|
+
schema?: DatasetSchema;
|
|
1073
|
+
}
|
|
1074
|
+
/** The schemas a `.jsonl` record can be validated against. */
|
|
1075
|
+
type DatasetSchema = "chatml" | "dpo" | "cpt";
|
|
1076
|
+
type ValidationSeverity = "error" | "warning";
|
|
1077
|
+
interface ValidationIssue {
|
|
1078
|
+
severity: ValidationSeverity;
|
|
1079
|
+
/** Stable machine-readable key, e.g. "EMPTY_FILE", "MALFORMED_JSON". */
|
|
1080
|
+
code: string;
|
|
1081
|
+
/** Human-readable message. */
|
|
1082
|
+
message: string;
|
|
1083
|
+
/** 1-indexed line number for line-oriented formats. */
|
|
1084
|
+
line?: number;
|
|
1085
|
+
/** Optional path inside the offending row, e.g. "messages[2].role". */
|
|
1086
|
+
path?: string;
|
|
1087
|
+
}
|
|
1088
|
+
interface ValidationStats {
|
|
1089
|
+
/** Total observed records (rows / samples / messages, depending on format). */
|
|
1090
|
+
totalRecords?: number;
|
|
1091
|
+
/** Records actually deep-checked (sampled). */
|
|
1092
|
+
sampledRecords?: number;
|
|
1093
|
+
/** Total file bytes. */
|
|
1094
|
+
bytes?: number;
|
|
1095
|
+
/** Wall time spent in the scan (ms). */
|
|
1096
|
+
durationMs?: number;
|
|
1097
|
+
}
|
|
1098
|
+
interface ValidationResult {
|
|
1099
|
+
valid: boolean;
|
|
1100
|
+
format: string;
|
|
1101
|
+
filePath: string;
|
|
1102
|
+
errors: ValidationIssue[];
|
|
1103
|
+
warnings: ValidationIssue[];
|
|
1104
|
+
stats: ValidationStats;
|
|
1105
|
+
}
|
|
1106
|
+
interface ValidatorSpec {
|
|
1107
|
+
/** Human-readable format identifier, e.g. "jsonl". */
|
|
1108
|
+
format: string;
|
|
1109
|
+
/** Lower-cased file extensions handled by this validator (include dot). */
|
|
1110
|
+
extensions: string[];
|
|
1111
|
+
/** Format-specific check. Pre-flight (existence/size) is applied by the registry. */
|
|
1112
|
+
validate(filePath: string, opts: ValidateOpts): Promise<ValidationResult>;
|
|
1113
|
+
}
|
|
1114
|
+
//#endregion
|
|
1115
|
+
//#region src/dataset/validate/registry.d.ts
|
|
1116
|
+
/** Lookup the validator that handles a given file extension. */
|
|
1117
|
+
declare function pickValidator(filePath: string): ValidatorSpec;
|
|
1118
|
+
/** Allow tests / future plugins to inject extra validators. Idempotent. */
|
|
1119
|
+
declare function registerValidator(spec: ValidatorSpec): void;
|
|
1120
|
+
/**
|
|
1121
|
+
* Top-level entry point. Applies common pre-flight (existence/size/extension)
|
|
1122
|
+
* then defers to the format-specific validator.
|
|
1123
|
+
*/
|
|
1124
|
+
declare function validateDataset(filePath: string, opts?: ValidateOpts): Promise<ValidationResult>;
|
|
1125
|
+
/** Read-only view of the active registry — handy for tests / `--help`. */
|
|
1126
|
+
declare function listSupportedFormats(): {
|
|
1127
|
+
format: string;
|
|
1128
|
+
extensions: string[];
|
|
1129
|
+
}[];
|
|
1130
|
+
//#endregion
|
|
1131
|
+
//#region src/dataset/validate/common.d.ts
|
|
1132
|
+
/**
|
|
1133
|
+
* The platform caps dataset uploads at 300MB per file. `bl dataset upload`
|
|
1134
|
+
* enforces this client-side so users learn early. Update if the platform
|
|
1135
|
+
* raises the cap or differentiates per-purpose limits.
|
|
1136
|
+
*/
|
|
1137
|
+
declare const MAX_DATASET_BYTES: number;
|
|
1138
|
+
/**
|
|
1139
|
+
* Parse a `--schema` CLI value into a `DatasetSchema` (or `undefined` for
|
|
1140
|
+
* auto-detect). Single source of truth for the schema vocabulary so `dataset
|
|
1141
|
+
* validate`, `dataset upload`, and any future caller agree on accepted values
|
|
1142
|
+
* and error wording. Throws USAGE for anything unrecognized.
|
|
1143
|
+
*/
|
|
1144
|
+
declare function parseDatasetSchemaFlag(value: string | undefined): DatasetSchema | undefined;
|
|
1145
|
+
//#endregion
|
|
1146
|
+
//#region src/dataset/validate/format.d.ts
|
|
1147
|
+
/**
|
|
1148
|
+
* Format a single validation issue as a one-line string.
|
|
1149
|
+
*
|
|
1150
|
+
* Shared across every entry point that surfaces dataset validation results
|
|
1151
|
+
* (`dataset validate`, `dataset upload`, `finetune create`) so the error
|
|
1152
|
+
* presentation stays consistent regardless of which command ran the validator.
|
|
1153
|
+
*/
|
|
1154
|
+
declare function formatIssue(issue: ValidationIssue): string;
|
|
1155
|
+
//#endregion
|
|
1156
|
+
//#region src/finetune/types.d.ts
|
|
1157
|
+
/**
|
|
1158
|
+
* Fine-tune job API types.
|
|
1159
|
+
*
|
|
1160
|
+
* Maps DashScope `/api/v1/fine-tunes` request/response shapes (snake_case
|
|
1161
|
+
* preserved verbatim — callers decide how to surface fields).
|
|
1162
|
+
*/
|
|
1163
|
+
/** Hyper-parameters honored by text/thinking/vision SFT models. */
|
|
1164
|
+
interface FineTuneHyperParameters {
|
|
1165
|
+
/** Number of training epochs. */
|
|
1166
|
+
n_epochs?: number;
|
|
1167
|
+
batch_size?: number;
|
|
1168
|
+
/** Sent as a string to avoid JSON-number precision loss (e.g. "1.6e-5"). */
|
|
1169
|
+
learning_rate?: string;
|
|
1170
|
+
max_length?: number;
|
|
1171
|
+
/** Train/validation split ratio when no validation file is provided. */
|
|
1172
|
+
split?: number;
|
|
1173
|
+
lr_scheduler_type?: string;
|
|
1174
|
+
/** Future-compat: arbitrary additional fields are forwarded as-is. */
|
|
1175
|
+
[k: string]: unknown;
|
|
1176
|
+
}
|
|
1177
|
+
/** POST /api/v1/fine-tunes request body. */
|
|
1178
|
+
interface CreateFineTuneRequest {
|
|
1179
|
+
/** Base model ID, or a previously fine-tuned model ID for continued training. */
|
|
1180
|
+
model: string;
|
|
1181
|
+
training_file_ids: string[];
|
|
1182
|
+
/**
|
|
1183
|
+
* Server-supported values: `cpt | sft | efficient_sft | dpo_full | dpo_lora`.
|
|
1184
|
+
*
|
|
1185
|
+
* NOTE — current bailian-cli scope: `sft` (default) and `efficient_sft`.
|
|
1186
|
+
* Other values are rejected by the CLI at parse time so users get an
|
|
1187
|
+
* immediate error instead of a vague server-side rejection. This type
|
|
1188
|
+
* stays open as `string` for forward compatibility (so adding `dpo_lora`
|
|
1189
|
+
* later is a CLI-only change).
|
|
1190
|
+
*/
|
|
1191
|
+
training_type: string;
|
|
1192
|
+
validation_file_ids?: string[];
|
|
1193
|
+
hyper_parameters?: FineTuneHyperParameters;
|
|
1194
|
+
/** Display name for the job (optional, server generates if omitted). */
|
|
1195
|
+
job_name?: string;
|
|
1196
|
+
/** Output model name. Either bring your own or let the server generate one. */
|
|
1197
|
+
model_name?: string;
|
|
1198
|
+
/** Suffix appended by the platform; field is `finetuned_output_suffix` (NOT `suffix`). */
|
|
1199
|
+
finetuned_output_suffix?: string;
|
|
1200
|
+
}
|
|
1201
|
+
/** GET /api/v1/fine-tunes/{id}/logs response. */
|
|
1202
|
+
interface FineTuneLogEntry {
|
|
1203
|
+
/** Server-defined log line — schema varies; preserve as-is. */
|
|
1204
|
+
[k: string]: unknown;
|
|
1205
|
+
}
|
|
1206
|
+
interface GetFineTuneLogsResponse {
|
|
1207
|
+
request_id?: string;
|
|
1208
|
+
output?: {
|
|
1209
|
+
logs?: Array<FineTuneLogEntry | string>;
|
|
1210
|
+
total?: number;
|
|
1211
|
+
page_no?: number;
|
|
1212
|
+
page_size?: number;
|
|
1213
|
+
[k: string]: unknown;
|
|
1214
|
+
};
|
|
1215
|
+
data?: {
|
|
1216
|
+
logs?: Array<FineTuneLogEntry | string>;
|
|
1217
|
+
total?: number;
|
|
1218
|
+
page_no?: number;
|
|
1219
|
+
page_size?: number;
|
|
1220
|
+
[k: string]: unknown;
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
/** A single checkpoint as returned by the platform. */
|
|
1224
|
+
interface FineTuneCheckpoint {
|
|
1225
|
+
checkpoint?: string;
|
|
1226
|
+
checkpoint_id?: string;
|
|
1227
|
+
full_name?: string;
|
|
1228
|
+
job_id?: string;
|
|
1229
|
+
model_name?: string;
|
|
1230
|
+
model_display_name?: string;
|
|
1231
|
+
/** SUCCEEDED | PENDING | FAILED | … */
|
|
1232
|
+
status?: string;
|
|
1233
|
+
step?: number;
|
|
1234
|
+
epoch?: number;
|
|
1235
|
+
create_time?: string;
|
|
1236
|
+
expire_time?: string;
|
|
1237
|
+
output_model_deleted?: boolean;
|
|
1238
|
+
metrics?: Record<string, unknown>;
|
|
1239
|
+
[k: string]: unknown;
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* GET /api/v1/fine-tunes/{job_id}/checkpoints response.
|
|
1243
|
+
*
|
|
1244
|
+
* Real shape: `output` is an array of checkpoints directly (NOT wrapped in
|
|
1245
|
+
* `{ checkpoints: [...] }`). The wrapped form is preserved as a fallback for
|
|
1246
|
+
* older deployments.
|
|
1247
|
+
*/
|
|
1248
|
+
interface ListCheckpointsResponse {
|
|
1249
|
+
request_id?: string;
|
|
1250
|
+
output?: FineTuneCheckpoint[] | {
|
|
1251
|
+
checkpoints?: FineTuneCheckpoint[];
|
|
1252
|
+
total?: number;
|
|
1253
|
+
[k: string]: unknown;
|
|
1254
|
+
};
|
|
1255
|
+
data?: FineTuneCheckpoint[] | {
|
|
1256
|
+
checkpoints?: FineTuneCheckpoint[];
|
|
1257
|
+
total?: number;
|
|
1258
|
+
[k: string]: unknown;
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
/** GET /api/v1/fine-tunes/{job_id}/export/{checkpoint}?model_name= response. */
|
|
1262
|
+
interface ExportCheckpointResponse {
|
|
1263
|
+
request_id?: string;
|
|
1264
|
+
output?: {
|
|
1265
|
+
/** Resulting deployable model name. */model_name?: string;
|
|
1266
|
+
[k: string]: unknown;
|
|
1267
|
+
};
|
|
1268
|
+
data?: {
|
|
1269
|
+
model_name?: string;
|
|
1270
|
+
[k: string]: unknown;
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
/** POST /api/v1/fine-tunes/{id}/cancel response. */
|
|
1274
|
+
interface CancelFineTuneResponse {
|
|
1275
|
+
request_id?: string;
|
|
1276
|
+
output?: FineTuneJob;
|
|
1277
|
+
data?: FineTuneJob;
|
|
1278
|
+
}
|
|
1279
|
+
/** DELETE /api/v1/fine-tunes/{id} response. */
|
|
1280
|
+
interface DeleteFineTuneResponse {
|
|
1281
|
+
request_id?: string;
|
|
1282
|
+
output?: {
|
|
1283
|
+
deleted?: boolean;
|
|
1284
|
+
job_id?: string;
|
|
1285
|
+
[k: string]: unknown;
|
|
1286
|
+
};
|
|
1287
|
+
data?: {
|
|
1288
|
+
deleted?: boolean;
|
|
1289
|
+
job_id?: string;
|
|
1290
|
+
[k: string]: unknown;
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
/** A single fine-tune job record as returned by the platform. */
|
|
1294
|
+
interface FineTuneJob {
|
|
1295
|
+
job_id?: string;
|
|
1296
|
+
job_name?: string;
|
|
1297
|
+
model?: string;
|
|
1298
|
+
base_model?: string;
|
|
1299
|
+
training_type?: string;
|
|
1300
|
+
/** PENDING | RUNNING | SUCCEEDED | FAILED | CANCELED */
|
|
1301
|
+
status?: string;
|
|
1302
|
+
finetuned_output?: string;
|
|
1303
|
+
finetuned_output_suffix?: string;
|
|
1304
|
+
model_name?: string;
|
|
1305
|
+
training_file_ids?: string[];
|
|
1306
|
+
validation_file_ids?: string[];
|
|
1307
|
+
hyper_parameters?: FineTuneHyperParameters;
|
|
1308
|
+
/** Server-side timestamps (DashScope uses snake_case `create_time` / `end_time`). */
|
|
1309
|
+
create_time?: string;
|
|
1310
|
+
end_time?: string;
|
|
1311
|
+
/** Legacy field names — kept for backward compatibility with older deployments. */
|
|
1312
|
+
gmt_create?: string;
|
|
1313
|
+
gmt_modified?: string;
|
|
1314
|
+
/** Free-form additional fields are preserved by callers. */
|
|
1315
|
+
[k: string]: unknown;
|
|
1316
|
+
}
|
|
1317
|
+
/** POST /api/v1/fine-tunes response. */
|
|
1318
|
+
interface CreateFineTuneResponse {
|
|
1319
|
+
request_id?: string;
|
|
1320
|
+
/** Modern DashScope shape. */
|
|
1321
|
+
output?: FineTuneJob;
|
|
1322
|
+
/** Legacy shape for older platform builds. */
|
|
1323
|
+
data?: FineTuneJob;
|
|
1324
|
+
}
|
|
1325
|
+
/** GET /api/v1/fine-tunes response. */
|
|
1326
|
+
interface ListFineTunesResponse {
|
|
1327
|
+
request_id?: string;
|
|
1328
|
+
output?: {
|
|
1329
|
+
jobs?: FineTuneJob[];
|
|
1330
|
+
total?: number;
|
|
1331
|
+
page_no?: number;
|
|
1332
|
+
page_size?: number;
|
|
1333
|
+
};
|
|
1334
|
+
data?: {
|
|
1335
|
+
jobs?: FineTuneJob[];
|
|
1336
|
+
total?: number;
|
|
1337
|
+
page_no?: number;
|
|
1338
|
+
page_size?: number;
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
/** GET /api/v1/fine-tunes/{job_id} response. */
|
|
1342
|
+
interface GetFineTuneResponse {
|
|
1343
|
+
request_id?: string;
|
|
1344
|
+
output?: FineTuneJob;
|
|
1345
|
+
data?: FineTuneJob;
|
|
1346
|
+
}
|
|
1347
|
+
//#endregion
|
|
1348
|
+
//#region src/finetune/api.d.ts
|
|
1349
|
+
/** POST /api/v1/fine-tunes */
|
|
1350
|
+
declare function createFineTune(config: Config, body: CreateFineTuneRequest, signal?: AbortSignal): Promise<CreateFineTuneResponse>;
|
|
1351
|
+
interface ListFineTunesParams {
|
|
1352
|
+
pageNo?: number;
|
|
1353
|
+
pageSize?: number;
|
|
1354
|
+
status?: string;
|
|
1355
|
+
signal?: AbortSignal;
|
|
1356
|
+
}
|
|
1357
|
+
/** GET /api/v1/fine-tunes */
|
|
1358
|
+
declare function listFineTunes(config: Config, params?: ListFineTunesParams): Promise<ListFineTunesResponse>;
|
|
1359
|
+
/** GET /api/v1/fine-tunes/{job_id} */
|
|
1360
|
+
declare function getFineTune(config: Config, jobId: string, signal?: AbortSignal): Promise<GetFineTuneResponse>;
|
|
1361
|
+
/** POST /api/v1/fine-tunes/{job_id}/cancel */
|
|
1362
|
+
declare function cancelFineTune(config: Config, jobId: string, signal?: AbortSignal): Promise<CancelFineTuneResponse>;
|
|
1363
|
+
/** DELETE /api/v1/fine-tunes/{job_id} */
|
|
1364
|
+
declare function deleteFineTune(config: Config, jobId: string, signal?: AbortSignal): Promise<DeleteFineTuneResponse>;
|
|
1365
|
+
interface GetFineTuneLogsParams {
|
|
1366
|
+
pageNo?: number;
|
|
1367
|
+
pageSize?: number;
|
|
1368
|
+
signal?: AbortSignal;
|
|
1369
|
+
}
|
|
1370
|
+
/** GET /api/v1/fine-tunes/{job_id}/logs */
|
|
1371
|
+
declare function getFineTuneLogs(config: Config, jobId: string, params?: GetFineTuneLogsParams): Promise<GetFineTuneLogsResponse>;
|
|
1372
|
+
/** GET /api/v1/fine-tunes/{job_id}/checkpoints */
|
|
1373
|
+
declare function listCheckpoints(config: Config, jobId: string, signal?: AbortSignal): Promise<ListCheckpointsResponse>;
|
|
1374
|
+
/**
|
|
1375
|
+
* GET /api/v1/fine-tunes/{job_id}/export/{checkpoint}?model_name={name}
|
|
1376
|
+
*
|
|
1377
|
+
* Publishes a training checkpoint as a deployable model — required before
|
|
1378
|
+
* `bl deploy create` can target it. The platform may auto-export the best
|
|
1379
|
+
* checkpoint on SUCCEEDED, but explicit export is the canonical path.
|
|
1380
|
+
*/
|
|
1381
|
+
declare function exportCheckpoint(config: Config, jobId: string, checkpoint: string, modelName: string, signal?: AbortSignal): Promise<ExportCheckpointResponse>;
|
|
1382
|
+
//#endregion
|
|
1383
|
+
//#region src/finetune/capability.d.ts
|
|
1384
|
+
/**
|
|
1385
|
+
* Training-type vocabulary exposed to users.
|
|
1386
|
+
*
|
|
1387
|
+
* Convention: the bare method name is **full-parameter** tuning; the `-lora`
|
|
1388
|
+
* suffix is the LoRA variant. This holds for `sft` and `dpo` (both have a
|
|
1389
|
+
* full + lora pair). `cpt` is the exception — the platform only supports
|
|
1390
|
+
* full-parameter CPT (no `cpt-lora` exists server-side), so it has no lora
|
|
1391
|
+
* sibling.
|
|
1392
|
+
*
|
|
1393
|
+
* Each CLI value maps 1:1 to a server `training_type`. The mapping happens at
|
|
1394
|
+
* the interface boundary (request body), so the rest of the CLI never sees the
|
|
1395
|
+
* raw server strings (`efficient_sft`, `dpo_full`, ...).
|
|
1396
|
+
*/
|
|
1397
|
+
declare const TRAINING_TYPE_MAP: {
|
|
1398
|
+
readonly sft: {
|
|
1399
|
+
readonly server: "sft";
|
|
1400
|
+
readonly method: "sft";
|
|
1401
|
+
readonly variant: "full";
|
|
1402
|
+
};
|
|
1403
|
+
readonly "sft-lora": {
|
|
1404
|
+
readonly server: "efficient_sft";
|
|
1405
|
+
readonly method: "sft";
|
|
1406
|
+
readonly variant: "lora";
|
|
1407
|
+
};
|
|
1408
|
+
readonly dpo: {
|
|
1409
|
+
readonly server: "dpo_full";
|
|
1410
|
+
readonly method: "dpo";
|
|
1411
|
+
readonly variant: "full";
|
|
1412
|
+
};
|
|
1413
|
+
readonly "dpo-lora": {
|
|
1414
|
+
readonly server: "dpo_lora";
|
|
1415
|
+
readonly method: "dpo";
|
|
1416
|
+
readonly variant: "lora";
|
|
1417
|
+
};
|
|
1418
|
+
readonly cpt: {
|
|
1419
|
+
readonly server: "cpt";
|
|
1420
|
+
readonly method: "cpt";
|
|
1421
|
+
readonly variant: "full";
|
|
1422
|
+
};
|
|
1423
|
+
};
|
|
1424
|
+
type TrainingTypeCli = keyof typeof TRAINING_TYPE_MAP;
|
|
1425
|
+
/** All accepted CLI training-type values (for whitelisting / help text). */
|
|
1426
|
+
declare const TRAINING_TYPES_CLI: readonly TrainingTypeCli[];
|
|
1427
|
+
/** Default training type when `--training-type` is omitted. */
|
|
1428
|
+
declare const DEFAULT_TRAINING_TYPE: TrainingTypeCli;
|
|
1429
|
+
/** Subset of `supports` relevant to training capability. */
|
|
1430
|
+
interface ModelSupports {
|
|
1431
|
+
sft?: boolean;
|
|
1432
|
+
dpo?: boolean;
|
|
1433
|
+
cpt?: boolean;
|
|
1434
|
+
[key: string]: unknown;
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* A model record's training-capability fields. The full listFoundationModels
|
|
1438
|
+
* item carries many more fields; only these are consulted here.
|
|
1439
|
+
*/
|
|
1440
|
+
interface ModelCapability {
|
|
1441
|
+
model?: string;
|
|
1442
|
+
supports?: ModelSupports;
|
|
1443
|
+
trainingTypes?: Record<string, string[]>;
|
|
1444
|
+
[key: string]: unknown;
|
|
1445
|
+
}
|
|
1446
|
+
/** True when `value` is one of the accepted CLI training types. */
|
|
1447
|
+
declare function isTrainingTypeCli(value: string): value is TrainingTypeCli;
|
|
1448
|
+
/** Map a CLI training type to the server `training_type` for the request body. */
|
|
1449
|
+
declare function toServerTrainingType(value: TrainingTypeCli): string;
|
|
1450
|
+
/** The (method, variant) pair a CLI training type resolves to. */
|
|
1451
|
+
declare function trainingTypeMethodVariant(value: TrainingTypeCli): {
|
|
1452
|
+
method: string;
|
|
1453
|
+
variant: string;
|
|
1454
|
+
};
|
|
1455
|
+
/**
|
|
1456
|
+
* Whether a model supports the given CLI training type.
|
|
1457
|
+
*
|
|
1458
|
+
* A model supports `<method>[-lora]` when both:
|
|
1459
|
+
* 1. `supports.<method> === true` (the high-level capability gate), and
|
|
1460
|
+
* 2. `trainingTypes.<method>` includes the corresponding variant
|
|
1461
|
+
* (`full` for the bare name, `lora` for the `-lora` suffix).
|
|
1462
|
+
*/
|
|
1463
|
+
declare function modelSupportsTrainingType(model: ModelCapability | undefined | null, value: TrainingTypeCli): boolean;
|
|
1464
|
+
/**
|
|
1465
|
+
* Every CLI training type a model supports, in canonical order
|
|
1466
|
+
* (sft, sft-lora, dpo, dpo-lora, cpt). Empty when the model carries no
|
|
1467
|
+
* capability metadata or supports none.
|
|
1468
|
+
*/
|
|
1469
|
+
declare function listSupportedTrainingTypes(model: ModelCapability | undefined | null): TrainingTypeCli[];
|
|
1470
|
+
/**
|
|
1471
|
+
* Fetch a single model's foundation metadata by name (console gateway
|
|
1472
|
+
* `listFoundationModels` with a `name` filter). No console login required —
|
|
1473
|
+
* `listFoundationModels` is a public API, so only a DashScope API key is needed.
|
|
1474
|
+
*
|
|
1475
|
+
* Returns the first exact-model match, or `null` when nothing matches (the
|
|
1476
|
+
* server's `name` filter is a substring match, so we additionally require an
|
|
1477
|
+
* exact `model` equality to avoid e.g. `qwen3-8b` matching `qwen3-8b-v2`).
|
|
1478
|
+
*/
|
|
1479
|
+
declare function fetchModelCapability(config: Config, modelName: string): Promise<ModelCapability | null>;
|
|
1480
|
+
//#endregion
|
|
1481
|
+
//#region src/finetune/preflight.d.ts
|
|
1482
|
+
/** Stable issue code for "too few training samples for the batch size". */
|
|
1483
|
+
declare const INSUFFICIENT_SAMPLES_CODE = "INSUFFICIENT_SAMPLES";
|
|
1484
|
+
interface BatchSizeGateInput {
|
|
1485
|
+
/**
|
|
1486
|
+
* Total training-sample count across all `--datasets` files. Sourced from
|
|
1487
|
+
* `validateDataset`'s `stats.totalRecords` (summed per file). The gate only
|
|
1488
|
+
* fires when this is known — i.e. every dataset token was a local file that
|
|
1489
|
+
* was validated; bare file-id tokens yield no count and fall through to the
|
|
1490
|
+
* platform.
|
|
1491
|
+
*/
|
|
1492
|
+
recordCount: number;
|
|
1493
|
+
/**
|
|
1494
|
+
* Effective batch_size the job will run with — after the CLI's clamp
|
|
1495
|
+
* ([8, 1024]) and small-file auto-adjust, or the platform default (16) when
|
|
1496
|
+
* neither the user nor auto-adjust set one.
|
|
1497
|
+
*/
|
|
1498
|
+
batchSize: number;
|
|
1499
|
+
}
|
|
1500
|
+
interface BatchSizeGateResult {
|
|
1501
|
+
ok: boolean;
|
|
1502
|
+
/** Present when `!ok`, in the same shape `validateDataset` issues use. */
|
|
1503
|
+
issue?: ValidationIssue;
|
|
1504
|
+
/** Actionable guidance; callers surface it as the `BailianError` detail. */
|
|
1505
|
+
hint?: string;
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Pre-flight the platform's "training samples must exceed batch_size" rule.
|
|
1509
|
+
*
|
|
1510
|
+
* The platform rejects a job whose number of training samples is not greater
|
|
1511
|
+
* than batch_size, but only surfaces that ~10 minutes into the run (after data
|
|
1512
|
+
* processing). This gate fails fast, before upload or quota consumption.
|
|
1513
|
+
*
|
|
1514
|
+
* Conservative by design — never false-positives: with the platform's default
|
|
1515
|
+
* 0.9 train split, training samples = 0.9 * recordCount <= recordCount, so
|
|
1516
|
+
* `recordCount <= batchSize` implies training samples <= batchSize implies
|
|
1517
|
+
* certain platform failure. Borderline counts (records just above batchSize)
|
|
1518
|
+
* may still fail on the platform; that's an acceptable false negative for a
|
|
1519
|
+
* pre-check, and the hint nudges users to leave margin for the split.
|
|
1520
|
+
*/
|
|
1521
|
+
declare function preflightBatchSizeGate(input: BatchSizeGateInput): BatchSizeGateResult;
|
|
1522
|
+
//#endregion
|
|
1523
|
+
//#region src/deploy/types.d.ts
|
|
1524
|
+
/**
|
|
1525
|
+
* Model-deployment API types.
|
|
1526
|
+
*
|
|
1527
|
+
* Maps DashScope `/api/v1/deployments` request/response shapes (snake_case
|
|
1528
|
+
* preserved verbatim — callers decide how to surface fields).
|
|
1529
|
+
*/
|
|
1530
|
+
/** A single deployment record as returned by the platform. */
|
|
1531
|
+
interface Deployment {
|
|
1532
|
+
/** Unique deployed-model identifier — used as the `model` parameter when invoking the deployed model. */
|
|
1533
|
+
deployed_model?: string;
|
|
1534
|
+
/** Human-friendly display name set at creation time. */
|
|
1535
|
+
name?: string;
|
|
1536
|
+
/** Underlying model identifier (e.g. fine-tuned output or catalog model). */
|
|
1537
|
+
model_name?: string;
|
|
1538
|
+
/** Catalog base model. */
|
|
1539
|
+
base_model?: string;
|
|
1540
|
+
/** PENDING | RUNNING | STOPPED | FAILED */
|
|
1541
|
+
status?: string;
|
|
1542
|
+
/** Billing plan: mu | cu | ptu | lora (Token-billed). */
|
|
1543
|
+
plan?: string;
|
|
1544
|
+
/** Spec descriptor for MU plan, e.g. "MU1". */
|
|
1545
|
+
model_unit_spec?: string;
|
|
1546
|
+
/** Charge type, e.g. "post_paid". */
|
|
1547
|
+
charge_type?: string;
|
|
1548
|
+
/** Capacity in plan units. */
|
|
1549
|
+
capacity?: number;
|
|
1550
|
+
base_capacity?: number;
|
|
1551
|
+
ready_capacity?: number;
|
|
1552
|
+
/** Rate limits (per minute). */
|
|
1553
|
+
rpm_limit?: number;
|
|
1554
|
+
tpm_limit?: number;
|
|
1555
|
+
/** PTU-only token-rate limits. */
|
|
1556
|
+
input_tpm?: number;
|
|
1557
|
+
output_tpm?: number;
|
|
1558
|
+
enable_thinking?: boolean;
|
|
1559
|
+
max_context_length?: number;
|
|
1560
|
+
workspace_id?: string;
|
|
1561
|
+
creator?: string;
|
|
1562
|
+
modifier?: string;
|
|
1563
|
+
gmt_create?: string;
|
|
1564
|
+
gmt_modified?: string;
|
|
1565
|
+
/** Free-form additional fields are preserved by callers. */
|
|
1566
|
+
[k: string]: unknown;
|
|
1567
|
+
}
|
|
1568
|
+
/** A single deployable model record (GET /deployments/models). */
|
|
1569
|
+
interface DeployableModel {
|
|
1570
|
+
model_name?: string;
|
|
1571
|
+
base_model?: string;
|
|
1572
|
+
/** custom | public | base | … */
|
|
1573
|
+
model_source?: string;
|
|
1574
|
+
/** Supported plans for `custom` (fine-tuned) models, e.g. ["mu","lora"]. */
|
|
1575
|
+
supported_plans?: string[];
|
|
1576
|
+
/**
|
|
1577
|
+
* Nested plan info for `base` (catalog) models. Each entry describes one
|
|
1578
|
+
* plan and (when applicable) its deployment templates.
|
|
1579
|
+
* - plan: "mu" | "ptu_v2" | "cu" | …
|
|
1580
|
+
* - templates: required when plan="mu" — picks deploy_spec / charge_type / role configs
|
|
1581
|
+
* - cu_specs: required when plan="cu" — light/basic etc
|
|
1582
|
+
*/
|
|
1583
|
+
plans?: Array<{
|
|
1584
|
+
plan?: string;
|
|
1585
|
+
templates?: Array<DeployableTemplate>;
|
|
1586
|
+
cu_specs?: string[];
|
|
1587
|
+
[k: string]: unknown;
|
|
1588
|
+
}>;
|
|
1589
|
+
display_name?: string;
|
|
1590
|
+
description?: string;
|
|
1591
|
+
version?: string;
|
|
1592
|
+
status?: string;
|
|
1593
|
+
gmt_create?: string;
|
|
1594
|
+
gmt_modified?: string;
|
|
1595
|
+
[k: string]: unknown;
|
|
1596
|
+
}
|
|
1597
|
+
/** A single deployment template (only used by `plan=mu` base models). */
|
|
1598
|
+
interface DeployableTemplate {
|
|
1599
|
+
template_id?: string;
|
|
1600
|
+
template_name?: string;
|
|
1601
|
+
template_desc?: string;
|
|
1602
|
+
/** pre_paid | post_paid */
|
|
1603
|
+
charge_type?: string;
|
|
1604
|
+
/** SYSTEM | CUSTOM */
|
|
1605
|
+
template_source?: string;
|
|
1606
|
+
/** COUPLED | SEPERATED */
|
|
1607
|
+
template_type?: string;
|
|
1608
|
+
template_version?: string;
|
|
1609
|
+
deploy_spec?: string;
|
|
1610
|
+
/** Role-specific resource specs. Either `unified` (COUPLED) or `prefill` + `decode` (SEPERATED). */
|
|
1611
|
+
roles?: {
|
|
1612
|
+
unified?: {
|
|
1613
|
+
model_unit_spec?: string;
|
|
1614
|
+
capacity_unit_per_instance?: number;
|
|
1615
|
+
capacity_unit_init?: number;
|
|
1616
|
+
};
|
|
1617
|
+
prefill?: {
|
|
1618
|
+
model_unit_spec?: string;
|
|
1619
|
+
capacity_unit_per_instance?: number;
|
|
1620
|
+
capacity_unit_init?: number;
|
|
1621
|
+
};
|
|
1622
|
+
decode?: {
|
|
1623
|
+
model_unit_spec?: string;
|
|
1624
|
+
capacity_unit_per_instance?: number;
|
|
1625
|
+
capacity_unit_init?: number;
|
|
1626
|
+
};
|
|
1627
|
+
[k: string]: unknown;
|
|
1628
|
+
};
|
|
1629
|
+
[k: string]: unknown;
|
|
1630
|
+
}
|
|
1631
|
+
/** POST /api/v1/deployments request body. */
|
|
1632
|
+
interface CreateDeploymentRequest {
|
|
1633
|
+
/** Required. The catalog or fine-tuned model identifier. */
|
|
1634
|
+
model_name: string;
|
|
1635
|
+
/** Required. Display name shown in the console. */
|
|
1636
|
+
name: string;
|
|
1637
|
+
/** Required. Billing plan: mu | cu | ptu | lora. CLI defaults to "lora". */
|
|
1638
|
+
plan: string;
|
|
1639
|
+
/** Required by API even for token-billed (lora) plans where it is ignored — CLI injects 1. */
|
|
1640
|
+
capacity?: number;
|
|
1641
|
+
/** Optional template id for advanced configurations. */
|
|
1642
|
+
template_id?: string;
|
|
1643
|
+
/**
|
|
1644
|
+
* PTU capacity (provisioned throughput limits). Only effective when
|
|
1645
|
+
* `plan === "ptu"`. The doc says this defaults to 10000/1000 when omitted,
|
|
1646
|
+
* but the platform currently rejects creation without it ("Miss ptu capacity
|
|
1647
|
+
* info"), so the CLI treats it as required for ptu.
|
|
1648
|
+
*/
|
|
1649
|
+
ptu_capacity?: PtuCapacity;
|
|
1650
|
+
/** Future-compat: arbitrary additional fields are forwarded as-is. */
|
|
1651
|
+
[k: string]: unknown;
|
|
1652
|
+
}
|
|
1653
|
+
/** PTU throughput limits — only used when `plan === "ptu"`. */
|
|
1654
|
+
interface PtuCapacity {
|
|
1655
|
+
/** Max input tokens per minute (all models). */
|
|
1656
|
+
input_tpm?: number;
|
|
1657
|
+
/** Max output tokens per minute (all models). */
|
|
1658
|
+
output_tpm?: number;
|
|
1659
|
+
/** Max thinking-output tokens per minute (some models only). */
|
|
1660
|
+
thinking_output_tpm?: number;
|
|
1661
|
+
}
|
|
1662
|
+
/** POST /api/v1/deployments response. */
|
|
1663
|
+
interface CreateDeploymentResponse {
|
|
1664
|
+
request_id?: string;
|
|
1665
|
+
output?: Deployment;
|
|
1666
|
+
data?: Deployment;
|
|
1667
|
+
}
|
|
1668
|
+
/** GET /api/v1/deployments response. */
|
|
1669
|
+
interface ListDeploymentsResponse {
|
|
1670
|
+
request_id?: string;
|
|
1671
|
+
output?: {
|
|
1672
|
+
deployments?: Deployment[];
|
|
1673
|
+
total?: number;
|
|
1674
|
+
page_no?: number;
|
|
1675
|
+
page_size?: number;
|
|
1676
|
+
[k: string]: unknown;
|
|
1677
|
+
};
|
|
1678
|
+
data?: {
|
|
1679
|
+
deployments?: Deployment[];
|
|
1680
|
+
total?: number;
|
|
1681
|
+
page_no?: number;
|
|
1682
|
+
page_size?: number;
|
|
1683
|
+
[k: string]: unknown;
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
/** GET /api/v1/deployments/{deployed_model} response. */
|
|
1687
|
+
interface GetDeploymentResponse {
|
|
1688
|
+
request_id?: string;
|
|
1689
|
+
output?: Deployment;
|
|
1690
|
+
data?: Deployment;
|
|
1691
|
+
}
|
|
1692
|
+
/** DELETE /api/v1/deployments/{deployed_model} response. */
|
|
1693
|
+
interface DeleteDeploymentResponse {
|
|
1694
|
+
request_id?: string;
|
|
1695
|
+
output?: {
|
|
1696
|
+
deleted?: boolean;
|
|
1697
|
+
deployed_model?: string;
|
|
1698
|
+
[k: string]: unknown;
|
|
1699
|
+
};
|
|
1700
|
+
data?: {
|
|
1701
|
+
deleted?: boolean;
|
|
1702
|
+
deployed_model?: string;
|
|
1703
|
+
[k: string]: unknown;
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
/** GET /api/v1/deployments/models response. */
|
|
1707
|
+
interface ListDeployableModelsResponse {
|
|
1708
|
+
request_id?: string;
|
|
1709
|
+
output?: {
|
|
1710
|
+
models?: DeployableModel[];
|
|
1711
|
+
total?: number;
|
|
1712
|
+
page_no?: number;
|
|
1713
|
+
page_size?: number;
|
|
1714
|
+
[k: string]: unknown;
|
|
1715
|
+
};
|
|
1716
|
+
data?: {
|
|
1717
|
+
models?: DeployableModel[];
|
|
1718
|
+
total?: number;
|
|
1719
|
+
page_no?: number;
|
|
1720
|
+
page_size?: number;
|
|
1721
|
+
[k: string]: unknown;
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
/** PUT /api/v1/deployments/{deployed_model}/scale request body. */
|
|
1725
|
+
interface ScaleDeploymentRequest {
|
|
1726
|
+
/** New capacity in plan units. Server-side constraint: integer multiple of `base_capacity`, < 1000. */
|
|
1727
|
+
capacity?: number;
|
|
1728
|
+
/** PTU-only token-rate adjustments. */
|
|
1729
|
+
input_tpm?: number;
|
|
1730
|
+
output_tpm?: number;
|
|
1731
|
+
[k: string]: unknown;
|
|
1732
|
+
}
|
|
1733
|
+
/** PUT /api/v1/deployments/{deployed_model}/scale response. */
|
|
1734
|
+
interface ScaleDeploymentResponse {
|
|
1735
|
+
request_id?: string;
|
|
1736
|
+
output?: Deployment;
|
|
1737
|
+
data?: Deployment;
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* PUT /api/v1/deployments/{deployed_model} request body.
|
|
1741
|
+
*
|
|
1742
|
+
* Update rate limits — at least one of `rpm_limit` / `tpm_limit` is required.
|
|
1743
|
+
* - rpm_limit: requests per minute
|
|
1744
|
+
* - tpm_limit: tokens per minute
|
|
1745
|
+
*/
|
|
1746
|
+
interface UpdateDeploymentRequest {
|
|
1747
|
+
rpm_limit?: number;
|
|
1748
|
+
tpm_limit?: number;
|
|
1749
|
+
[k: string]: unknown;
|
|
1750
|
+
}
|
|
1751
|
+
/** PUT /api/v1/deployments/{deployed_model} response. */
|
|
1752
|
+
interface UpdateDeploymentResponse {
|
|
1753
|
+
request_id?: string;
|
|
1754
|
+
output?: Deployment;
|
|
1755
|
+
data?: Deployment;
|
|
1756
|
+
}
|
|
1757
|
+
//#endregion
|
|
1758
|
+
//#region src/deploy/api.d.ts
|
|
1759
|
+
/** POST /api/v1/deployments */
|
|
1760
|
+
declare function createDeployment(config: Config, body: CreateDeploymentRequest, signal?: AbortSignal): Promise<CreateDeploymentResponse>;
|
|
1761
|
+
interface ListDeploymentsParams {
|
|
1762
|
+
pageNo?: number;
|
|
1763
|
+
pageSize?: number;
|
|
1764
|
+
status?: string;
|
|
1765
|
+
signal?: AbortSignal;
|
|
1766
|
+
}
|
|
1767
|
+
/** GET /api/v1/deployments */
|
|
1768
|
+
declare function listDeployments(config: Config, params?: ListDeploymentsParams): Promise<ListDeploymentsResponse>;
|
|
1769
|
+
/** GET /api/v1/deployments/{deployed_model} */
|
|
1770
|
+
declare function getDeployment(config: Config, deployedModel: string, signal?: AbortSignal): Promise<GetDeploymentResponse>;
|
|
1771
|
+
/** DELETE /api/v1/deployments/{deployed_model} */
|
|
1772
|
+
declare function deleteDeployment(config: Config, deployedModel: string, signal?: AbortSignal): Promise<DeleteDeploymentResponse>;
|
|
1773
|
+
interface ListDeployableModelsParams {
|
|
1774
|
+
pageNo?: number;
|
|
1775
|
+
pageSize?: number;
|
|
1776
|
+
/** Catalog version filter, e.g. "v1.0". */
|
|
1777
|
+
version?: string;
|
|
1778
|
+
/** Source filter: "custom" (fine-tuned outputs) | "public" | …. */
|
|
1779
|
+
modelSource?: string;
|
|
1780
|
+
signal?: AbortSignal;
|
|
1781
|
+
}
|
|
1782
|
+
/** GET /api/v1/deployments/models */
|
|
1783
|
+
declare function listDeployableModels(config: Config, params?: ListDeployableModelsParams): Promise<ListDeployableModelsResponse>;
|
|
1784
|
+
/** PUT /api/v1/deployments/{deployed_model}/scale */
|
|
1785
|
+
declare function scaleDeployment(config: Config, deployedModel: string, body: ScaleDeploymentRequest, signal?: AbortSignal): Promise<ScaleDeploymentResponse>;
|
|
1786
|
+
/**
|
|
1787
|
+
* PUT /api/v1/deployments/{deployed_model}/update
|
|
1788
|
+
*
|
|
1789
|
+
* Update rate limits. At least one of `rpm_limit` / `tpm_limit` must be set.
|
|
1790
|
+
*/
|
|
1791
|
+
declare function updateDeployment(config: Config, deployedModel: string, body: UpdateDeploymentRequest, signal?: AbortSignal): Promise<UpdateDeploymentResponse>;
|
|
1792
|
+
//#endregion
|
|
909
1793
|
//#region src/types/command.d.ts
|
|
910
1794
|
interface OptionDef {
|
|
911
1795
|
flag: string;
|
|
@@ -914,21 +1798,32 @@ interface OptionDef {
|
|
|
914
1798
|
required?: boolean;
|
|
915
1799
|
}
|
|
916
1800
|
interface Command {
|
|
917
|
-
name: string;
|
|
918
1801
|
description: string;
|
|
919
|
-
|
|
1802
|
+
/**
|
|
1803
|
+
* Argument portion of the usage line, WITHOUT the `<bin> <path>` prefix
|
|
1804
|
+
* (e.g. "--index-id <id> --query <text> [flags]"). The runtime prepends the
|
|
1805
|
+
* product binary name and the command's actual path when rendering help, so
|
|
1806
|
+
* the same command renders correctly under any product (bl / rag / …).
|
|
1807
|
+
*/
|
|
1808
|
+
usageArgs?: string;
|
|
920
1809
|
options?: OptionDef[];
|
|
921
|
-
|
|
1810
|
+
/**
|
|
1811
|
+
* Example argument strings, each WITHOUT the `<bin> <path>` prefix
|
|
1812
|
+
* (e.g. '--index-id idx_xxx --query "..."'). The runtime prepends
|
|
1813
|
+
* `<bin> <path>` per product when rendering help.
|
|
1814
|
+
*/
|
|
1815
|
+
exampleArgs?: string[];
|
|
922
1816
|
skipDefaultApiKeySetup?: boolean;
|
|
923
1817
|
notes?: string[];
|
|
924
1818
|
execute: (config: Config, flags: GlobalFlags) => Promise<void>;
|
|
925
1819
|
}
|
|
926
1820
|
interface CommandSpec {
|
|
927
|
-
name: string;
|
|
928
1821
|
description: string;
|
|
929
|
-
|
|
1822
|
+
/** See {@link Command.usageArgs} — argument portion only, no `<bin> <path>` prefix. */
|
|
1823
|
+
usageArgs?: string;
|
|
930
1824
|
options?: OptionDef[];
|
|
931
|
-
|
|
1825
|
+
/** See {@link Command.exampleArgs} — argument strings only, no `<bin> <path>` prefix. */
|
|
1826
|
+
exampleArgs?: string[];
|
|
932
1827
|
skipDefaultApiKeySetup?: boolean;
|
|
933
1828
|
notes?: string[];
|
|
934
1829
|
run: (config: Config, flags: GlobalFlags) => Promise<void>;
|
|
@@ -957,9 +1852,6 @@ declare function resolveOutputDir(config: Config, options?: {
|
|
|
957
1852
|
subDir?: string;
|
|
958
1853
|
}): string;
|
|
959
1854
|
//#endregion
|
|
960
|
-
//#region src/utils/schema.d.ts
|
|
961
|
-
declare function generateToolSchema(cmd: Command): Record<string, unknown>;
|
|
962
|
-
//#endregion
|
|
963
1855
|
//#region src/utils/token.d.ts
|
|
964
1856
|
declare function maskToken(token: string): string;
|
|
965
1857
|
//#endregion
|
|
@@ -1251,4 +2143,4 @@ interface ModelSource {
|
|
|
1251
2143
|
load(): Promise<ModelProfile[]>;
|
|
1252
2144
|
}
|
|
1253
2145
|
//#endregion
|
|
1254
|
-
export { AkSignConfig, type ApiErrorBody, AppCompletionRequest, AppCompletionResponse, AppStreamChunk, AuthMethod, BAILIAN_HOST, BailianError, Budget, Budgets, CHANNEL, CONSOLE_GATEWAY_NO_TOKEN_MESSAGE, Capabilities, Capability, ChatChoice, ChatMessage, ChatMessageContent, ChatRequest, ChatResponse, ChatTool, Command, CommandSpec, Complexities, Complexity, Config, ConfigFile, ConsoleGatewayRequest, ConsoleSite, ContextNeed, ContextNeeds, DOCS_HOSTS, DashScopeASRRequest, DashScopeASRTaskResult, DashScopeAsyncResponse, DashScopeImageRequest, DashScopeImageSyncResponse, DashScopeKnowledgeRetrieveRequest, DashScopeKnowledgeRetrieveResponse, DashScopeTTSRequest, DashScopeTTSResponse, DashScopeTTSStreamChunk, DashScopeTaskResponse, DashScopeVideoEditRequest, DashScopeVideoRefRequest, DashScopeVideoRequest, ExitCode, Feature, Features, GLOBAL_OPTIONS, GetModelsOptions, GlobalFlags, IntentProfile, IntentSegment, KnowledgeRetrieveRequest, KnowledgeRetrieveResponse, McpClient, McpTool, McpToolResult, MemoryAddRequest, MemoryAddResponse, MemoryMessage, MemoryNode, MemoryNodeListResponse, MemoryNodeUpdateRequest, MemorySearchRequest, MemorySearchResponse, Modalities, Modality, ModelCategories, ModelCategory, ModelListParams, ModelListResult, ModelPreference, ModelPrice, ModelProfile, ModelSource, OptionDef, OutputFormat, PipelineResult, PipelineStep, PreferenceMode, ProfileAttribute, ProfileSchemaCreateRequest, ProfileSchemaCreateResponse, QpmLimit, QualityPreference, QualityPreferences, REGIONS, RecommendOptions, RecommendResult, RecommendedModel, Region, RequestOpts, ResolvedCredential, SOURCE_CONFIG, ScoredCandidate, ServerSentEvent, SingleResult, StreamChoice, StreamChunk, TAGS, TrackingEvent, UserProfileResponse, analyzeIntent, appCompletionEndpoint, bailianMcpUrl, buildDocLink, callConsoleGateway, chatEndpoint, clearApiKey, createTrackingEvent, defineCommand, detectOutputFormat, effectiveConsoleGatewayConfig, ensureConfigDir, fetchModelList, flushTelemetry, formatErrorJson, formatJson, formatOutput, formatText, generateFilename,
|
|
2146
|
+
export { AkSignConfig, type ApiErrorBody, AppCompletionRequest, AppCompletionResponse, AppStreamChunk, AuthMethod, BAILIAN_HOST, BailianError, BatchSizeGateInput, BatchSizeGateResult, Budget, Budgets, CHANNEL, CONSOLE_GATEWAY_NO_TOKEN_MESSAGE, CancelFineTuneResponse, Capabilities, Capability, ChatChoice, ChatMessage, ChatMessageContent, ChatRequest, ChatResponse, ChatTool, Command, CommandSpec, Complexities, Complexity, Config, ConfigFile, ConsoleGatewayRequest, ConsoleSite, ContextNeed, ContextNeeds, CreateDeploymentRequest, CreateDeploymentResponse, CreateFineTuneRequest, CreateFineTuneResponse, DEFAULT_TRAINING_TYPE, DOCS_HOSTS, DashScopeASRRequest, DashScopeASRTaskResult, DashScopeAsyncResponse, DashScopeImageRequest, DashScopeImageSyncResponse, DashScopeKnowledgeRetrieveRequest, DashScopeKnowledgeRetrieveResponse, DashScopeTTSRequest, DashScopeTTSResponse, DashScopeTTSStreamChunk, DashScopeTaskResponse, DashScopeVideoEditRequest, DashScopeVideoRefRequest, DashScopeVideoRequest, DatasetDeleteResponse, DatasetFile, DatasetGetResponse, DatasetListParams, DatasetListResponse, DatasetSchema, DatasetUploadParams, DatasetUploadResponse, DeleteDeploymentResponse, DeleteFineTuneResponse, DeployableModel, DeployableTemplate, Deployment, ExitCode, ExportCheckpointResponse, Feature, Features, FineTuneCheckpoint, FineTuneHyperParameters, FineTuneJob, FineTuneLogEntry, GLOBAL_OPTIONS, GetDeploymentResponse, GetFineTuneLogsParams, GetFineTuneLogsResponse, GetFineTuneResponse, GetModelsOptions, GlobalFlags, INSUFFICIENT_SAMPLES_CODE, IntentProfile, IntentSegment, KnowledgeRetrieveRequest, KnowledgeRetrieveResponse, ListCheckpointsResponse, ListDeployableModelsParams, ListDeployableModelsResponse, ListDeploymentsParams, ListDeploymentsResponse, ListFineTunesParams, ListFineTunesResponse, MAX_DATASET_BYTES, McpClient, McpTool, McpToolResult, MemoryAddRequest, MemoryAddResponse, MemoryMessage, MemoryNode, MemoryNodeListResponse, MemoryNodeUpdateRequest, MemorySearchRequest, MemorySearchResponse, Modalities, Modality, ModelCapability, ModelCategories, ModelCategory, ModelListParams, ModelListResult, ModelPreference, ModelPrice, ModelProfile, ModelSource, OptionDef, OutputFormat, PipelineResult, PipelineStep, PreferenceMode, ProfileAttribute, ProfileSchemaCreateRequest, ProfileSchemaCreateResponse, PtuCapacity, QpmLimit, QualityPreference, QualityPreferences, REGIONS, RecommendOptions, RecommendResult, RecommendedModel, Region, RequestOpts, ResolvedCredential, SOURCE_CONFIG, ScaleDeploymentRequest, ScaleDeploymentResponse, ScoredCandidate, ServerSentEvent, SingleResult, StreamChoice, StreamChunk, TAGS, TRAINING_TYPES_CLI, TRAINING_TYPE_MAP, TrackingEvent, TrainingTypeCli, UpdateDeploymentRequest, UpdateDeploymentResponse, UserProfileResponse, ValidateOpts, ValidationIssue, ValidationResult, ValidationSeverity, ValidationStats, ValidatorSpec, analyzeIntent, appCompletionEndpoint, bailianMcpUrl, buildDocLink, callConsoleGateway, cancelFineTune, chatEndpoint, clearApiKey, createDeployment, createFineTune, createTrackingEvent, defineCommand, deleteDataset, deleteDeployment, deleteFineTune, detectOutputFormat, effectiveConsoleGatewayConfig, ensureConfigDir, exportCheckpoint, fetchModelCapability, fetchModelList, flushTelemetry, formatErrorJson, formatIssue, formatJson, formatOutput, formatText, generateFilename, getConfigDir, getConfigPath, getCredentialsPath, getDataset, getDeployment, getFineTune, getFineTuneLogs, getModels, imageEndpoint, imageSyncEndpoint, isCI, isInteractive, isLocalFile, isSemanticAvailable, isTrainingTypeCli, knowledgeRetrieveEndpoint, listCheckpoints, listDatasets, listDeployableModels, listDeployments, listFineTunes, listSupportedFormats, listSupportedTrainingTypes, loadApiKeyFromConfig, loadConfig, localSink, mapApiError, maskToken, mcpWebSearchEndpoint, memoryAddEndpoint, memoryListEndpoint, memoryNodeEndpoint, memorySearchEndpoint, modelSupportsTrainingType, parseBooleanValue, parseConfigFile, parseDatasetSchemaFlag, parseOptionalBooleanValue, parseSSE, pickValidator, preflightBatchSizeGate, profileSchemaEndpoint, rankModels, readConfigFile, recallCandidates, recallSemantic, registerValidator, remoteSink, request, requestJson, resolveBooleanFlag, resolveConsoleGatewayCredential, resolveCredential, resolveFileUrl, resolveOutputDir, resolveWatermark, saveApiKeyToConfig, scaleDeployment, signRequest, speechRecognizeEndpoint, speechSynthesizeEndpoint, stripUndefined, taskEndpoint, toServerTrainingType, trackCommandExecution, trackingHeaders, trainingTypeMethodVariant, updateDeployment, uploadDataset, uploadFile, userProfileEndpoint, validateDataset, videoGenerateEndpoint, writeConfigFile };
|