Skip to content

Commit e8666b3

Browse files
committed
merge: merge main to feat/migtate-e2e
2 parents d646a4e + 03405d5 commit e8666b3

58 files changed

Lines changed: 3214 additions & 741 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ CLI 只为「自己能权威解释的错误」发出语义化信号,服务端的
104104

105105
如果命令调用 Console Gateway,`defineCommand` 必须设置 `auth: "console"`。runtime 会基于 `CONSOLE_AUTH_FLAGS` 自动在 help 中展示 `--console-region``--console-site``--console-switch-agent``--workspace-id`,并由 `authStage` 解析/注入 console credential。命令不要重复声明这些凭证域 flag,也不要手动从 env/config 解析 token。
106106

107+
### 5. 禁止单字母变量命名
108+
109+
所有变量、参数、回调形参必须使用有语义的命名,不允许单字母(如 `i``m``p``t``e``s`)。具体表现:
110+
111+
- 回调参数: `.map((m) => ...)``.map((model) => ...)`, `.find((t) => ...)``.find((template) => ...)`
112+
- catch 变量: `catch (e)``catch (error)`
113+
- for-of 循环: `for (const i of items)``for (const item of items)`
114+
- 临时变量: `const s = ...``const strategy = ...`
115+
116+
例外: 仅当作用域极小(≤3 行)且语义从上下文完全明确时,可使用 `k`/`v`(Object.entries 的 key/value)。
117+
107118
## 完成改动后的快速验证
108119

109120
```sh

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Equip your AI Agent out-of-the-box with these capabilities, composable across co
3838
- **MCP integration** — Orchestrate Bailian MCP servers: list services, inspect tools, and invoke any tool directly from the terminal
3939
- **Web search** — Real-time internet retrieval for up-to-date, accurate answers
4040
- **Model recommendation** — Describe your scenario and get best-fit model suggestions; supports scoped search, model comparison, and alternative discovery
41-
- **Fine-tuning & deployment** — Upload datasets, create SFT/LoRA/DPO/CPT jobs (`finetune create`), probe job status non-blockingly (`finetune watch`), query per-model training capability (`finetune capability`), and deploy trained models as endpoints (`deploy create`)
41+
- **Fine-tuning & deployment** — Upload datasets, create text/audio/image fine-tune jobs (`finetune text|audio|image create`; text covers SFT/LoRA/DPO/CPT), probe job status non-blockingly (`finetune watch`), query per-model training capability (`finetune capability`), and deploy trained models as endpoints (`deploy text|audio|image create`)
4242
- **Console capabilities** — Browse Bailian apps (`app list`), check free-tier quota (`usage free`), view model usage statistics (`usage stats`), manage workspaces (`workspace list`), and manage rate limits (`quota list/request/check/history`)
4343
- **Local file auto-upload** — Every URL parameter accepts a local path; uploaded to free temp storage with 48-hour validity
4444

@@ -114,10 +114,10 @@ bl auth login --console
114114

115115
# Fine-tune & deploy — a one-shot train-to-serve workflow
116116
bl dataset upload --file ./train.jsonl # Upload a .jsonl dataset (validated first)
117-
bl finetune create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # Local paths auto-upload
117+
bl finetune text create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # Local paths auto-upload
118118
bl finetune watch --job-id ft-xxx --output json # Non-blocking status probe (exit 0/1/3 = done/failed/running)
119119
bl finetune capability --model qwen3-8b # Which training types a model supports
120-
bl deploy create --model qwen3-8b --name my-svc --plan mu # Deploy the trained model as an endpoint
120+
bl deploy text create --model qwen3-8b --name my-svc --plan mu # Deploy the trained model as an endpoint
121121

122122
# Browse apps / free-tier quota / usage statistics / workspaces
123123
bl app list

README.zh.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ _专为 AI Agent 打造,每个命令均可作为结构化工具调用。_
3838
- **MCP 集成** — 统一调度百炼 MCP 服务:列出服务、查看工具、直接在终端调用任意工具
3939
- **联网搜索** — 实时互联网信息检索,提升回答准确性及时效性
4040
- **模型推荐** — 描述你的场景,智能推荐最适合的模型;支持限定范围搜索、模型对比和替代发现
41-
- **微调与部署** — 上传数据集、创建 SFT/LoRA/DPO/CPT 调优任务`finetune create`)、非阻塞探测任务状态(`finetune watch`)、按模型查训练能力(`finetune capability`),并把训练好的模型部署为推理服务(`deploy create`
41+
- **微调与部署** — 上传数据集、创建文本/音频/图像调优任务`finetune text|audio|image create`;文本涵盖 SFT/LoRA/DPO/CPT)、非阻塞探测任务状态(`finetune watch`)、按模型查训练能力(`finetune capability`),并把训练好的模型部署为推理服务(`deploy text|audio|image create`
4242
- **控制台能力** — 浏览百炼应用(`app list`),查询模型免费额度(`usage free`),查看模型用量统计(`usage stats`),管理业务空间(`workspace list`),管理限流与提额(`quota list/request/check/history`
4343
- **本地文件自动上传** — 所有 URL 参数同时支持本地路径,免费临时存储 48 小时
4444

@@ -112,10 +112,10 @@ bl auth login --console
112112

113113
# 微调与部署 — 从训练到服务的一站式流程
114114
bl dataset upload --file ./train.jsonl # 上传 .jsonl 数据集(先校验)
115-
bl finetune create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # 本地路径自动上传
115+
bl finetune text create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # 本地路径自动上传
116116
bl finetune watch --job-id ft-xxx --output json # 非阻塞状态探测(退出码 0/1/3 = 成功/失败/进行中)
117117
bl finetune capability --model qwen3-8b # 查询模型支持哪些训练方式
118-
bl deploy create --model qwen3-8b --name my-svc --plan mu # 把训练好的模型部署为推理服务
118+
bl deploy text create --model qwen3-8b --name my-svc --plan mu # 把训练好的模型部署为推理服务
119119

120120
# 浏览应用 / 免费额度 / 用量统计 / 业务空间
121121
bl app list

packages/cli/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Equip your AI Agent out-of-the-box with these capabilities, composable across co
3838
- **MCP integration** — Orchestrate Bailian MCP servers: list services, inspect tools, and invoke any tool directly from the terminal
3939
- **Web search** — Real-time internet retrieval for up-to-date, accurate answers
4040
- **Model recommendation** — Describe your scenario and get best-fit model suggestions; supports scoped search, model comparison, and alternative discovery
41-
- **Fine-tuning & deployment** — Upload datasets, create SFT/LoRA/DPO/CPT jobs (`finetune create`), probe job status non-blockingly (`finetune watch`), query per-model training capability (`finetune capability`), and deploy trained models as endpoints (`deploy create`)
41+
- **Fine-tuning & deployment** — Upload datasets, create text/audio/image fine-tune jobs (`finetune text|audio|image create`; text covers SFT/LoRA/DPO/CPT), probe job status non-blockingly (`finetune watch`), query per-model training capability (`finetune capability`), and deploy trained models as endpoints (`deploy text|audio|image create`)
4242
- **Console capabilities** — Browse Bailian apps (`app list`), check free-tier quota (`usage free`), view model usage statistics (`usage stats`), manage workspaces (`workspace list`), and manage rate limits (`quota list/request/check/history`)
4343
- **Local file auto-upload** — Every URL parameter accepts a local path; uploaded to free temp storage with 48-hour validity
4444

@@ -114,10 +114,10 @@ bl auth login --console
114114

115115
# Fine-tune & deploy — a one-shot train-to-serve workflow
116116
bl dataset upload --file ./train.jsonl # Upload a .jsonl dataset (validated first)
117-
bl finetune create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # Local paths auto-upload
117+
bl finetune text create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # Local paths auto-upload
118118
bl finetune watch --job-id ft-xxx --output json # Non-blocking status probe (exit 0/1/3 = done/failed/running)
119119
bl finetune capability --model qwen3-8b # Which training types a model supports
120-
bl deploy create --model qwen3-8b --name my-svc --plan mu # Deploy the trained model as an endpoint
120+
bl deploy text create --model qwen3-8b --name my-svc --plan mu # Deploy the trained model as an endpoint
121121

122122
# Browse apps / free-tier quota / usage statistics / workspaces
123123
bl app list

packages/cli/README.zh.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ _专为 AI Agent 打造,每个命令均可作为结构化工具调用。_
3838
- **MCP 集成** — 统一调度百炼 MCP 服务:列出服务、查看工具、直接在终端调用任意工具
3939
- **联网搜索** — 实时互联网信息检索,提升回答准确性及时效性
4040
- **模型推荐** — 描述你的场景,智能推荐最适合的模型;支持限定范围搜索、模型对比和替代发现
41-
- **微调与部署** — 上传数据集、创建 SFT/LoRA/DPO/CPT 调优任务`finetune create`)、非阻塞探测任务状态(`finetune watch`)、按模型查训练能力(`finetune capability`),并把训练好的模型部署为推理服务(`deploy create`
41+
- **微调与部署** — 上传数据集、创建文本/音频/图像调优任务`finetune text|audio|image create`;文本涵盖 SFT/LoRA/DPO/CPT)、非阻塞探测任务状态(`finetune watch`)、按模型查训练能力(`finetune capability`),并把训练好的模型部署为推理服务(`deploy text|audio|image create`
4242
- **控制台能力** — 浏览百炼应用(`app list`),查询模型免费额度(`usage free`),查看模型用量统计(`usage stats`),管理业务空间(`workspace list`),管理限流与提额(`quota list/request/check/history`
4343
- **本地文件自动上传** — 所有 URL 参数同时支持本地路径,免费临时存储 48 小时
4444

@@ -112,10 +112,10 @@ bl auth login --console
112112

113113
# 微调与部署 — 从训练到服务的一站式流程
114114
bl dataset upload --file ./train.jsonl # 上传 .jsonl 数据集(先校验)
115-
bl finetune create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # 本地路径自动上传
115+
bl finetune text create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # 本地路径自动上传
116116
bl finetune watch --job-id ft-xxx --output json # 非阻塞状态探测(退出码 0/1/3 = 成功/失败/进行中)
117117
bl finetune capability --model qwen3-8b # 查询模型支持哪些训练方式
118-
bl deploy create --model qwen3-8b --name my-svc --plan mu # 把训练好的模型部署为推理服务
118+
bl deploy text create --model qwen3-8b --name my-svc --plan mu # 把训练好的模型部署为推理服务
119119

120120
# 浏览应用 / 免费额度 / 用量统计 / 业务空间
121121
bl app list

packages/cli/src/commands.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ import {
5252
datasetGet,
5353
datasetDelete,
5454
datasetValidate,
55-
finetuneCreate,
55+
finetuneTextCreate,
56+
finetuneAudioCreate,
57+
finetuneImageCreate,
5658
finetuneList,
5759
finetuneGet,
5860
finetuneCancel,
@@ -62,7 +64,9 @@ import {
6264
finetuneExport,
6365
finetuneWatch,
6466
finetuneCapability,
65-
deployCreate,
67+
deployTextCreate,
68+
deployAudioCreate,
69+
deployImageCreate,
6670
deployList,
6771
deployGet,
6872
deployModels,
@@ -133,7 +137,9 @@ export const commands: Record<string, AnyCommand> = {
133137
"dataset get": datasetGet,
134138
"dataset delete": datasetDelete,
135139
"dataset validate": datasetValidate,
136-
"finetune create": finetuneCreate,
140+
"finetune text create": finetuneTextCreate,
141+
"finetune audio create": finetuneAudioCreate,
142+
"finetune image create": finetuneImageCreate,
137143
"finetune list": finetuneList,
138144
"finetune get": finetuneGet,
139145
"finetune cancel": finetuneCancel,
@@ -143,7 +149,9 @@ export const commands: Record<string, AnyCommand> = {
143149
"finetune export": finetuneExport,
144150
"finetune watch": finetuneWatch,
145151
"finetune capability": finetuneCapability,
146-
"deploy create": deployCreate,
152+
"deploy text create": deployTextCreate,
153+
"deploy audio create": deployAudioCreate,
154+
"deploy image create": deployImageCreate,
147155
"deploy list": deployList,
148156
"deploy get": deployGet,
149157
"deploy models": deployModels,

packages/commands/src/commands/dataset/upload.ts

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
parseDatasetSchemaFlag,
77
formatIssue,
88
MAX_DATASET_BYTES,
9+
MAX_MEDIA_ZIP_BYTES,
910
BailianError,
1011
ExitCode,
1112
type DatasetFile,
@@ -17,7 +18,7 @@ const UPLOAD_FLAGS = {
1718
file: {
1819
type: "string",
1920
valueHint: "<path>",
20-
description: "Local .jsonl dataset file (≤300MB)",
21+
description: "Local dataset file (.jsonl or .zip; ≤300MB text, ≤1GB image)",
2122
required: true,
2223
},
2324
purpose: {
@@ -29,7 +30,7 @@ const UPLOAD_FLAGS = {
2930
type: "string",
3031
valueHint: "<s>",
3132
description:
32-
'Record schema: "chatml" (SFT), "dpo" (chosen/rejected), or "cpt" (raw text). Default auto-detects per record.',
33+
'Record schema: "chatml" (SFT), "dpo" (chosen/rejected), "cpt" (raw text), "tts" (audio), or "image" (image generation). Default auto-detects per record.',
3334
},
3435
noValidate: {
3536
type: "switch",
@@ -42,42 +43,55 @@ const UPLOAD_FLAGS = {
4243
} satisfies FlagsDef;
4344

4445
export default defineCommand({
45-
description: "Upload a dataset file (.jsonl) to Bailian",
46+
description: "Upload a dataset file (.jsonl or .zip) to Bailian",
4647
auth: "apiKey",
4748
usageArgs:
48-
"--file <path> [--purpose <name>] [--schema <chatml|dpo|cpt>] [--no-validate] [--full-validate]",
49+
"--file <path> [--purpose <name>] [--schema <chatml|dpo|cpt|tts|image>] [--no-validate] [--full-validate]",
4950
flags: UPLOAD_FLAGS,
5051
exampleArgs: [
5152
"--file train.jsonl",
5253
"--file dpo.jsonl --schema dpo",
5354
"--file cpt.jsonl --schema cpt",
55+
"--file audio.zip --schema tts",
5456
"--file eval.jsonl --purpose evaluation",
5557
"--file train.jsonl --full-validate",
5658
"--file train.jsonl --no-validate",
5759
],
5860
notes: [
59-
"Only .jsonl is supported in this release. Three record schemas are",
60-
"recognized: chatml = {messages:[...]} (SFT); dpo = {messages:[...],",
61-
"chosen, rejected} where chosen/rejected are single assistant messages;",
62-
'cpt = {text:"..."} (continual pre-training, raw text). With no --schema,',
63-
"a record carrying chosen/rejected is validated as DPO, one with text (and",
64-
"no messages) as CPT, otherwise as ChatML. Pass --schema dpo / cpt to",
65-
"require that shape on every record, or --schema chatml to ignore the",
66-
"preference / text fields. Other purposes may carry a different schema in",
67-
"the future and would be served by a purpose-specific validator.",
68-
"The dataset upload cap is 300MB per file.",
69-
"Upload uses the OpenAI-compatible /compatible-mode/v1/files endpoint so",
70-
"the purpose tag is persisted (the DashScope-native /api/v1/files drops it).",
61+
"Supports .jsonl (text) and .zip (audio/image archives with a data.jsonl",
62+
"manifest). Five record schemas are recognized: chatml = {messages:[...]}",
63+
'(SFT); dpo = {messages:[...], chosen, rejected}; cpt = {text:"..."}',
64+
'(continual pre-training, raw text); tts = {wav_fn:"train/xxx.wav",',
65+
'text:"..."} (audio fine-tuning); image = {img_path:"..."} (image',
66+
"generation). With no --schema, a record carrying wav_fn is validated as",
67+
"TTS, img_path as image, chosen/rejected as DPO, text (no messages) as CPT,",
68+
"otherwise ChatML. Upload cap: 300MB text, 1GB image. Upload uses the",
69+
"OpenAI-compatible /compatible-mode/v1/files endpoint so the purpose tag is",
70+
"persisted (the DashScope-native /api/v1/files drops it).",
7171
],
7272
async run(ctx) {
7373
const { identity, settings, flags } = ctx;
7474
const filePath = flags.file;
7575
const purpose = flags.purpose || "fine-tune";
7676
const schema = parseDatasetSchemaFlag(flags.schema);
77+
if (schema === "video") {
78+
throw new BailianError(
79+
`--schema video is not supported.`,
80+
ExitCode.USAGE,
81+
`Supported schemas: chatml, dpo, cpt, tts, image.`,
82+
);
83+
}
7784
const format = detectOutputFormat(settings.output);
85+
// Image schema allows larger ZIPs (1 GB vs 300 MB for text).
86+
const isMediaSchema = schema === "image";
7887

7988
if (!flags.noValidate) {
80-
const result = await validateDataset(filePath, { fullValidate: flags.fullValidate, schema });
89+
const maxBytes = isMediaSchema ? MAX_MEDIA_ZIP_BYTES : MAX_DATASET_BYTES;
90+
const result = await validateDataset(filePath, {
91+
fullValidate: flags.fullValidate,
92+
schema,
93+
maxBytes,
94+
});
8195
if (!result.valid) {
8296
const lines = [
8397
`Dataset validation failed for ${filePath}`,
@@ -112,7 +126,7 @@ export default defineCommand({
112126
action: "dataset.upload",
113127
file: filePath,
114128
purpose,
115-
max_bytes: MAX_DATASET_BYTES,
129+
max_bytes: isMediaSchema ? MAX_MEDIA_ZIP_BYTES : MAX_DATASET_BYTES,
116130
validate: !flags.noValidate,
117131
schema: schema ?? "auto",
118132
},

packages/commands/src/commands/dataset/validate.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const VALIDATE_FLAGS = {
2525
file: {
2626
type: "string",
2727
valueHint: "<path>",
28-
description: "Local .jsonl dataset file",
28+
description: "Local dataset file (.jsonl or .zip)",
2929
required: true,
3030
},
3131
fullValidate: {
@@ -36,38 +36,49 @@ const VALIDATE_FLAGS = {
3636
type: "string",
3737
valueHint: "<s>",
3838
description:
39-
'Record schema: "chatml" (SFT), "dpo" (chosen/rejected), or "cpt" (raw text). Default auto-detects per record.',
39+
'Record schema: "chatml" (SFT), "dpo" (chosen/rejected), "cpt" (raw text), "tts" (audio), or "image" (image generation). Default auto-detects per record.',
4040
},
4141
} satisfies FlagsDef;
4242

4343
export default defineCommand({
44-
description: "Locally validate a dataset file (.jsonl) without uploading",
44+
description: "Locally validate a dataset file (.jsonl or .zip) without uploading",
4545
// 纯本地校验,不触网、不需 API key(与 `pipeline validate` 一致)。
4646
auth: "none",
47-
usageArgs: "--file <path> [--full-validate] [--schema <chatml|dpo|cpt>]",
47+
usageArgs: "--file <path> [--full-validate] [--schema <chatml|dpo|cpt|tts|image>]",
4848
flags: VALIDATE_FLAGS,
4949
exampleArgs: [
5050
"--file train.jsonl",
5151
"--file dpo.jsonl --schema dpo",
5252
"--file cpt.jsonl --schema cpt",
53+
"--file audio.zip --schema tts",
5354
"--file eval.jsonl --full-validate",
5455
"--file train.jsonl --output json",
5556
],
5657
notes: [
5758
"Default scan: every line gets a structural check, then ~160 lines (front 50,",
5859
"evenly spaced 100, last 10) are JSON.parsed against the active schema.",
5960
"Schemas: chatml = {messages:[...]} (SFT); dpo = {messages:[...], chosen,",
60-
"rejected} where chosen/rejected are single assistant messages; cpt =",
61-
'{text:"..."} (continual pre-training, raw text). With no --schema, a',
62-
"record carrying chosen/rejected is validated as DPO, one with text (and no",
63-
"messages) as CPT, otherwise as ChatML. Pass --schema dpo / cpt to require",
64-
"that shape on every record (strict), or --schema chatml to ignore the",
65-
"preference / text fields. Use --full-validate to JSON.parse every line.",
61+
'rejected}; cpt = {text:"..."} (continual pre-training, raw text);',
62+
'tts = {wav_fn:"train/xxx.wav", text:"..."} (audio fine-tuning);',
63+
'image = {img_path:"..."} (image generation). With no --schema, a record',
64+
"carrying wav_fn is validated as TTS, img_path as image, chosen/rejected",
65+
"as DPO, text (no messages) as CPT, otherwise ChatML. Pass --schema to",
66+
"require a specific shape on every record. ZIP archives (.zip) are",
67+
"validated structurally (data.jsonl present, media references resolve) in",
68+
"addition to per-record content checks. Use --full-validate to JSON.parse",
69+
"every line.",
6670
],
6771
async run(ctx) {
6872
const { settings, flags } = ctx;
6973
const filePath = flags.file;
7074
const schema = parseDatasetSchemaFlag(flags.schema);
75+
if (schema === "video") {
76+
throw new BailianError(
77+
`--schema video is not supported.`,
78+
ExitCode.USAGE,
79+
`Supported schemas: chatml, dpo, cpt, tts, image.`,
80+
);
81+
}
7182
const format = detectOutputFormat(settings.output);
7283

7384
if (settings.dryRun) {

0 commit comments

Comments
 (0)