Skip to content

Commit fd9bba7

Browse files
authored
Merge pull request #80 from modelstudioai/feat/model-train
feat: add model finetune/deploy/dataset commend to support one step model training by Agent
2 parents c303b51 + 0593c7e commit fd9bba7

77 files changed

Lines changed: 7453 additions & 382 deletions

Some content is hidden

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

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +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`)
4142
- **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`)
4243
- **Local file auto-upload** — Every URL parameter accepts a local path; uploaded to free temp storage with 48-hour validity
4344

@@ -111,22 +112,30 @@ bl advisor recommend --message "qwen-max vs deepseek-v3 for code generation"
111112
# Browser login (required for console capability commands)
112113
bl auth login --console
113114

115+
# Fine-tune & deploy — a one-shot train-to-serve workflow
116+
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
118+
bl finetune watch --job-id ft-xxx --output json # Non-blocking status probe (exit 0/1/3 = done/failed/running)
119+
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
121+
114122
# Browse apps / free-tier quota / usage statistics / workspaces
115123
bl app list
116-
bl usage free --model qwen3-max
117-
bl usage free --expiring 30 # Quotas expiring within 30 days
118-
bl usage free --sort remaining # Sort by remaining % ascending
119-
bl usage stats --workspace-id <id> # Usage overview for a workspace
120-
bl usage stats --model qwen-turbo --workspace-id <id> # Per-model usage
124+
bl usage free # Free-tier quota across models (add --model/--expiring/--sort)
125+
bl usage stats --workspace-id <id> # Model usage statistics (add --model for per-model)
121126
bl workspace list # List all workspaces
122127

123-
# Rate limit management
124-
bl quota list # View RPM/TPM limits for all models
125-
bl quota list --model qwen3.6-plus # View limits for a specific model
126-
bl quota check # Current usage vs rate limits
127-
bl quota check --model qwen3.6-plus --period 5 # Check usage over last 5 minutes
128+
# Rate limit management (list / check / request / history)
129+
bl quota list # View RPM/TPM limits (add --model to filter)
130+
bl quota check # Current usage vs rate limits (add --model/--period)
128131
bl quota request --model qwen3.6-plus --tpm 6000000 # Request a temporary TPM increase
129-
bl quota history # View quota change history
132+
bl quota history # View quota-change history
133+
134+
# Token Plan team management (requires AK/SK, see auth below)
135+
bl token-plan list-seats # View subscription seat details
136+
bl token-plan add-member --account-name dev --org-id org_xxx
137+
bl token-plan assign-seats --workspace-id ws_xxx --seat-type standard --account-id acc_xxx
138+
bl token-plan create-key --account-id acc_xxx --workspace-id ws_xxx
130139
```
131140

132141
> More examples and scenarios: [Aliyun Model Studio CLI Site](https://bailian.console.aliyun.com/cli?source_channel=cli_github&)
@@ -156,9 +165,9 @@ Required for console capability commands (`app list`, `usage free`, `usage stats
156165
bl auth login --console
157166
```
158167

159-
### Alibaba Cloud AK/SK (Knowledge Base only)
168+
### Alibaba Cloud AK/SK (Knowledge Base & Token Plan)
160169

161-
Required for `knowledge retrieve`. Get your AccessKey from [RAM Console](https://ram.console.aliyun.com/manage/ak).
170+
Required for `knowledge retrieve` and the `token-plan` command group. Get your AccessKey from [RAM Console](https://ram.console.aliyun.com/manage/ak).
162171

163172
> Recommended: create a RAM sub-account with minimum privileges instead of using the root account's AK/SK.
164173

README.zh.md

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

@@ -82,7 +83,10 @@ npx skills add modelstudioai/cli --all -g
8283
## 快速开始
8384

8485
```bash
85-
# 认证
86+
# 认证(推荐浏览器登录)
87+
bl auth login --console
88+
89+
# 或使用 API key 认证
8690
bl auth login --api-key sk-xxxxx
8791

8892
# 和通义千问对话
@@ -106,22 +110,30 @@ bl advisor recommend --message "qwen-max 和 deepseek-v3 哪个更适合做代
106110
# 浏览器登录(控制台能力相关命令需要)
107111
bl auth login --console
108112

113+
# 微调与部署 — 从训练到服务的一站式流程
114+
bl dataset upload --file ./train.jsonl # 上传 .jsonl 数据集(先校验)
115+
bl finetune create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # 本地路径自动上传
116+
bl finetune watch --job-id ft-xxx --output json # 非阻塞状态探测(退出码 0/1/3 = 成功/失败/进行中)
117+
bl finetune capability --model qwen3-8b # 查询模型支持哪些训练方式
118+
bl deploy create --model qwen3-8b --name my-svc --plan mu # 把训练好的模型部署为推理服务
119+
109120
# 浏览应用 / 免费额度 / 用量统计 / 业务空间
110121
bl app list
111-
bl usage free --model qwen3-max
112-
bl usage free --expiring 30 # 30 天内过期的额度
113-
bl usage free --sort remaining # 按剩余百分比升序排列
114-
bl usage stats --workspace-id <id> # 指定空间的用量概览
115-
bl usage stats --model qwen-turbo --workspace-id <id> # 指定模型用量
122+
bl usage free # 各模型免费额度(可加 --model/--expiring/--sort)
123+
bl usage stats --workspace-id <id> # 模型用量统计(加 --model 查单模型)
116124
bl workspace list # 列出所有业务空间
117125

118-
# 限流管理与提额
119-
bl quota list # 查看所有模型的 RPM/TPM 限额
120-
bl quota list --model qwen3.6-plus # 查看指定模型限额
121-
bl quota check # 查看当前用量 vs 限流阈值
122-
bl quota check --model qwen3.6-plus --period 5 # 查看最近 5 分钟用量
126+
# 限流管理与提额(list / check / request / history)
127+
bl quota list # 查看 RPM/TPM 限额(加 --model 过滤)
128+
bl quota check # 当前用量 vs 限流阈值(加 --model/--period)
123129
bl quota request --model qwen3.6-plus --tpm 6000000 # 申请临时 TPM 提额
124130
bl quota history # 查看提额历史记录
131+
132+
# Token Plan 团队版管理(需 AK/SK,见下方认证说明)
133+
bl token-plan list-seats # 查看订阅席位明细
134+
bl token-plan add-member --account-name dev --org-id org_xxx
135+
bl token-plan assign-seats --workspace-id ws_xxx --seat-type standard --account-id acc_xxx
136+
bl token-plan create-key --account-id acc_xxx --workspace-id ws_xxx
125137
```
126138

127139
> 更多案例与使用场景:[阿里云百炼 CLI 官方主页](https://bailian.console.aliyun.com/cli?source_channel=cli_github&)
@@ -151,9 +163,9 @@ bl text chat --api-key sk-xxxxx --message "你好"
151163
bl auth login --console
152164
```
153165

154-
### 阿里云 AK/SK(仅知识库检索
166+
### 阿里云 AK/SK(知识库检索与 Token Plan
155167

156-
`knowledge retrieve` 命令需要阿里云 AccessKey。前往 [RAM 控制台](https://ram.console.aliyun.com/manage/ak) 获取。
168+
`knowledge retrieve` `token-plan` 命令组需要阿里云 AccessKey。前往 [RAM 控制台](https://ram.console.aliyun.com/manage/ak) 获取。
157169

158170
> 建议:创建 RAM 子账号并授予最小权限,避免使用主账号 AK/SK。
159171

packages/cli/README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +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`)
4142
- **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`)
4243
- **Local file auto-upload** — Every URL parameter accepts a local path; uploaded to free temp storage with 48-hour validity
4344

@@ -111,22 +112,30 @@ bl advisor recommend --message "qwen-max vs deepseek-v3 for code generation"
111112
# Browser login (required for console capability commands)
112113
bl auth login --console
113114

115+
# Fine-tune & deploy — a one-shot train-to-serve workflow
116+
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
118+
bl finetune watch --job-id ft-xxx --output json # Non-blocking status probe (exit 0/1/3 = done/failed/running)
119+
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
121+
114122
# Browse apps / free-tier quota / usage statistics / workspaces
115123
bl app list
116-
bl usage free --model qwen3-max
117-
bl usage free --expiring 30 # Quotas expiring within 30 days
118-
bl usage free --sort remaining # Sort by remaining % ascending
119-
bl usage stats --workspace-id <id> # Usage overview for a workspace
120-
bl usage stats --model qwen-turbo --workspace-id <id> # Per-model usage
124+
bl usage free # Free-tier quota across models (add --model/--expiring/--sort)
125+
bl usage stats --workspace-id <id> # Model usage statistics (add --model for per-model)
121126
bl workspace list # List all workspaces
122127

123-
# Rate limit management
124-
bl quota list # View RPM/TPM limits for all models
125-
bl quota list --model qwen3.6-plus # View limits for a specific model
126-
bl quota check # Current usage vs rate limits
127-
bl quota check --model qwen3.6-plus --period 5 # Check usage over last 5 minutes
128+
# Rate limit management (list / check / request / history)
129+
bl quota list # View RPM/TPM limits (add --model to filter)
130+
bl quota check # Current usage vs rate limits (add --model/--period)
128131
bl quota request --model qwen3.6-plus --tpm 6000000 # Request a temporary TPM increase
129-
bl quota history # View quota change history
132+
bl quota history # View quota-change history
133+
134+
# Token Plan team management (requires AK/SK, see auth below)
135+
bl token-plan list-seats # View subscription seat details
136+
bl token-plan add-member --account-name dev --org-id org_xxx
137+
bl token-plan assign-seats --workspace-id ws_xxx --seat-type standard --account-id acc_xxx
138+
bl token-plan create-key --account-id acc_xxx --workspace-id ws_xxx
130139
```
131140

132141
> More examples and scenarios: [Aliyun Model Studio CLI Site](https://bailian.console.aliyun.com/cli?source_channel=cli_github&)
@@ -156,9 +165,9 @@ Required for console capability commands (`app list`, `usage free`, `usage stats
156165
bl auth login --console
157166
```
158167

159-
### Alibaba Cloud AK/SK (Knowledge Base only)
168+
### Alibaba Cloud AK/SK (Knowledge Base & Token Plan)
160169

161-
Required for `knowledge retrieve`. Get your AccessKey from [RAM Console](https://ram.console.aliyun.com/manage/ak).
170+
Required for `knowledge retrieve` and the `token-plan` command group. Get your AccessKey from [RAM Console](https://ram.console.aliyun.com/manage/ak).
162171

163172
> Recommended: create a RAM sub-account with minimum privileges instead of using the root account's AK/SK.
164173

packages/cli/README.zh.md

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

@@ -82,7 +83,10 @@ npx skills add modelstudioai/cli --all -g
8283
## 快速开始
8384

8485
```bash
85-
# 认证
86+
# 认证(推荐浏览器登录)
87+
bl auth login --console
88+
89+
# 或使用 API key 认证
8690
bl auth login --api-key sk-xxxxx
8791

8892
# 和通义千问对话
@@ -106,20 +110,22 @@ bl advisor recommend --message "qwen-max 和 deepseek-v3 哪个更适合做代
106110
# 浏览器登录(控制台能力相关命令需要)
107111
bl auth login --console
108112

113+
# 微调与部署 — 从训练到服务的一站式流程
114+
bl dataset upload --file ./train.jsonl # 上传 .jsonl 数据集(先校验)
115+
bl finetune create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # 本地路径自动上传
116+
bl finetune watch --job-id ft-xxx --output json # 非阻塞状态探测(退出码 0/1/3 = 成功/失败/进行中)
117+
bl finetune capability --model qwen3-8b # 查询模型支持哪些训练方式
118+
bl deploy create --model qwen3-8b --name my-svc --plan mu # 把训练好的模型部署为推理服务
119+
109120
# 浏览应用 / 免费额度 / 用量统计 / 业务空间
110121
bl app list
111-
bl usage free --model qwen3-max
112-
bl usage free --expiring 30 # 30 天内过期的额度
113-
bl usage free --sort remaining # 按剩余百分比升序排列
114-
bl usage stats --workspace-id <id> # 指定空间的用量概览
115-
bl usage stats --model qwen-turbo --workspace-id <id> # 指定模型用量
122+
bl usage free # 各模型免费额度(可加 --model/--expiring/--sort)
123+
bl usage stats --workspace-id <id> # 模型用量统计(加 --model 查单模型)
116124
bl workspace list # 列出所有业务空间
117125

118-
# 限流管理与提额
119-
bl quota list # 查看所有模型的 RPM/TPM 限额
120-
bl quota list --model qwen3.6-plus # 查看指定模型限额
121-
bl quota check # 查看当前用量 vs 限流阈值
122-
bl quota check --model qwen3.6-plus --period 5 # 查看最近 5 分钟用量
126+
# 限流管理与提额(list / check / request / history)
127+
bl quota list # 查看 RPM/TPM 限额(加 --model 过滤)
128+
bl quota check # 当前用量 vs 限流阈值(加 --model/--period)
123129
bl quota request --model qwen3.6-plus --tpm 6000000 # 申请临时 TPM 提额
124130
bl quota history # 查看提额历史记录
125131

packages/cli/src/commands/catalog.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,28 @@ import searchWeb from "./search/web.ts";
3434
import speechSynthesize from "./speech/synthesize.ts";
3535
import speechRecognize from "./speech/recognize.ts";
3636
import fileUpload from "./file/upload.ts";
37+
import datasetUpload from "./dataset/upload.ts";
38+
import datasetList from "./dataset/list.ts";
39+
import datasetGet from "./dataset/get.ts";
40+
import datasetDelete from "./dataset/delete.ts";
41+
import datasetValidate from "./dataset/validate.ts";
42+
import finetuneCreate from "./finetune/create.ts";
43+
import finetuneList from "./finetune/list.ts";
44+
import finetuneGet from "./finetune/get.ts";
45+
import finetuneCancel from "./finetune/cancel.ts";
46+
import finetuneDelete from "./finetune/delete.ts";
47+
import finetuneLogs from "./finetune/logs.ts";
48+
import finetuneCheckpoints from "./finetune/checkpoints.ts";
49+
import finetuneExport from "./finetune/export.ts";
50+
import finetuneWatch from "./finetune/watch.ts";
51+
import finetuneCapability from "./finetune/capability.ts";
52+
import deployCreate from "./deploy/create.ts";
53+
import deployList from "./deploy/list.ts";
54+
import deployGet from "./deploy/get.ts";
55+
import deployModels from "./deploy/models.ts";
56+
import deployScale from "./deploy/scale.ts";
57+
import deployUpdate from "./deploy/update.ts";
58+
import deployDelete from "./deploy/delete.ts";
3759
import consoleCall from "./console/call.ts";
3860
import usageFree from "./usage/free.ts";
3961
import usageFreetier from "./usage/freetier.ts";
@@ -83,6 +105,28 @@ export const commands: Record<string, Command> = {
83105
"speech synthesize": speechSynthesize,
84106
"speech recognize": speechRecognize,
85107
"file upload": fileUpload,
108+
"dataset upload": datasetUpload,
109+
"dataset list": datasetList,
110+
"dataset get": datasetGet,
111+
"dataset delete": datasetDelete,
112+
"dataset validate": datasetValidate,
113+
"finetune create": finetuneCreate,
114+
"finetune list": finetuneList,
115+
"finetune get": finetuneGet,
116+
"finetune cancel": finetuneCancel,
117+
"finetune delete": finetuneDelete,
118+
"finetune logs": finetuneLogs,
119+
"finetune checkpoints": finetuneCheckpoints,
120+
"finetune export": finetuneExport,
121+
"finetune watch": finetuneWatch,
122+
"finetune capability": finetuneCapability,
123+
"deploy create": deployCreate,
124+
"deploy list": deployList,
125+
"deploy get": deployGet,
126+
"deploy models": deployModels,
127+
"deploy scale": deployScale,
128+
"deploy update": deployUpdate,
129+
"deploy delete": deployDelete,
86130
"console call": consoleCall,
87131
"usage free": usageFree,
88132
"usage freetier": usageFreetier,

0 commit comments

Comments
 (0)