Skip to content

Commit 1a63fcd

Browse files
committed
feat: add model list / opt usage
1 parent 03405d5 commit 1a63fcd

16 files changed

Lines changed: 1677 additions & 204 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Equip your AI Agent out-of-the-box with these capabilities, composable across co
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
4141
- **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`)
42-
- **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`)
42+
- **Console capabilities** — Browse Bailian apps (`app list`), review a unified usage view (`usage summary`), 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

4545
## Showcase: One-Sentence Cinematic Video
@@ -121,6 +121,7 @@ bl deploy text create --model qwen3-8b --name my-svc --plan mu # Deploy the tra
121121

122122
# Browse apps / free-tier quota / usage statistics / workspaces
123123
bl app list
124+
bl usage summary # Unified view: free-tier quota + recent usage overview
124125
bl usage free # Free-tier quota across models (add --model/--expiring/--sort)
125126
bl usage stats --workspace-id <id> # Model usage statistics (add --model for per-model)
126127
bl workspace list # List all workspaces

README.zh.md

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

4545
## 示例:一句话生成一部电影短片
@@ -119,6 +119,7 @@ bl deploy text create --model qwen3-8b --name my-svc --plan mu # 把训练好
119119

120120
# 浏览应用 / 免费额度 / 用量统计 / 业务空间
121121
bl app list
122+
bl usage summary # 统一视图:免费额度 + 近期用量概览
122123
bl usage free # 各模型免费额度(可加 --model/--expiring/--sort)
123124
bl usage stats --workspace-id <id> # 模型用量统计(加 --model 查单模型)
124125
bl workspace list # 列出所有业务空间

packages/cli/src/commands.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ import {
3939
usageFree,
4040
usageFreetier,
4141
usageStats,
42+
usageSummary,
4243
pipelineRun,
4344
pipelineValidate,
4445
advisorRecommend,
46+
modelList,
4547
workspaceList,
4648
quotaList,
4749
quotaRequest,
@@ -124,9 +126,11 @@ export const commands: Record<string, AnyCommand> = {
124126
"usage free": usageFree,
125127
"usage freetier": usageFreetier,
126128
"usage stats": usageStats,
129+
"usage summary": usageSummary,
127130
"pipeline run": pipelineRun,
128131
"pipeline validate": pipelineValidate,
129132
"advisor recommend": advisorRecommend,
133+
"model list": modelList,
130134
"workspace list": workspaceList,
131135
"quota list": quotaList,
132136
"quota request": quotaRequest,
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { describe, expect, test } from "vite-plus/test";
2+
import { isConsoleE2EReady, isConsoleAuthFailure, parseStdoutJson, runCli } from "./helpers.ts";
3+
4+
describe("e2e: usage summary", () => {
5+
test("usage summary --help 正常退出", async () => {
6+
const { stderr, exitCode } = await runCli(["usage", "summary", "--help"]);
7+
expect(exitCode, stderr).toBe(0);
8+
expect(stderr).toMatch(/--days|summary|usage/i);
9+
});
10+
11+
test("usage summary --help 包含所有示例", async () => {
12+
const { stderr, exitCode } = await runCli(["usage", "summary", "--help"]);
13+
expect(exitCode, stderr).toBe(0);
14+
expect(stderr).toContain("bl usage summary");
15+
expect(stderr).toContain("bl usage summary --days 30");
16+
});
17+
});
18+
19+
describe.skipIf(!isConsoleE2EReady())("e2e: usage summary(Console)", () => {
20+
test("usage summary --dry-run 输出 free-tier 计划请求", async () => {
21+
const { stdout, stderr, exitCode } = await runCli([
22+
"usage",
23+
"summary",
24+
"--dry-run",
25+
"--output",
26+
"json",
27+
]);
28+
expect(exitCode, stderr).toBe(0);
29+
const data = parseStdoutJson<{ freeTier?: { api?: string }; usage?: unknown }>(stdout);
30+
expect(data.freeTier?.api).toContain("queryFreeTierQuota");
31+
});
32+
33+
test("usage summary --dry-run --workspace-id 附带用量概览计划请求", async () => {
34+
const { stdout, stderr, exitCode } = await runCli([
35+
"usage",
36+
"summary",
37+
"--dry-run",
38+
"--workspace-id",
39+
"ws-e2e-dry-run",
40+
"--output",
41+
"json",
42+
]);
43+
expect(exitCode, stderr).toBe(0);
44+
const data = parseStdoutJson<{
45+
usage?: { api?: string; data?: { reqDTO?: { filterWorkspaceId?: string } } };
46+
}>(stdout);
47+
expect(data.usage?.api).toContain("getModelUsageStatistic");
48+
expect(data.usage?.data?.reqDTO?.filterWorkspaceId).toBe("ws-e2e-dry-run");
49+
});
50+
51+
test("usage summary 文本输出正常返回", async () => {
52+
const result = await runCli(["usage", "summary", "--output", "text"]);
53+
if (isConsoleAuthFailure(result)) return;
54+
expect(result.exitCode, result.stderr).toBe(0);
55+
});
56+
57+
test("usage summary JSON 输出包含 freeTier 字段", async () => {
58+
const result = await runCli(["usage", "summary", "--output", "json"]);
59+
if (isConsoleAuthFailure(result)) return;
60+
expect(result.exitCode, result.stderr).toBe(0);
61+
const data = parseStdoutJson<{ freeTier?: unknown; period?: unknown }>(result.stdout);
62+
expect(data.period).toBeTypeOf("object");
63+
expect(Array.isArray(data.freeTier)).toBe(true);
64+
});
65+
});

0 commit comments

Comments
 (0)