Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,16 @@ irm https://bailian.aliyun.com/cli/install.ps1 | iex

Once installed, just describe your task to your AI Agent — no need to assemble commands by hand.

| Scenario | What to say to your Agent |
| ------------------------ | --------------------------------------------------------------------------------- |
| Managed Agent | "Create a Managed Agent that can generate short-film storyboards and videos." |
| Image & video generation | "Generate an image of a cat in a spacesuit on Mars, then turn it into a video." |
| Speech recognition | "Transcribe this audio; if proper nouns are wrong, add hot words and try again." |
| Usage & quota | "Show my recent model usage, free-tier quota, and rate limits." |
| Monitoring & alerts | "Show my model call stats, failures and logs, and create an alert rule." |
| Model selection | "Recommend a model for image understanding and customer support." |
| About Bailian CLI | "Tell me what Bailian CLI can do for me, and suggest how to use it for my needs." |
| Scenario | What to say to your Agent |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| Managed Agent | "Create a Managed Agent that can generate short-film storyboards and videos." |
| Image & video generation | "Generate an image of a cat in a spacesuit on Mars, then turn it into a video." |
| Speech recognition | "Transcribe this audio; if proper nouns are wrong, add hot words and try again." |
| Usage & quota | "Show my recent model usage, free-tier quota, and rate limits." |
| Monitoring & alerts | "Show my model call stats, failures and logs, and create an alert rule." |
| Throughput reservations | "List my throughput reservations and capacity instances, then scale, renew or release capacity and wait for the operation to finish." |
| Model selection | "Recommend a model for image understanding and customer support." |
| About Bailian CLI | "Tell me what Bailian CLI can do for me, and suggest how to use it for my needs." |

> More examples and scenarios: [Aliyun Model Studio CLI Site](https://bailian.console.aliyun.com/cli?source_channel=cli_github&)

Expand Down
19 changes: 10 additions & 9 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,16 @@ irm https://bailian.aliyun.com/cli/install.ps1 | iex

安装完成后,直接在 AI Agent 中描述你的任务,无需手动拼接命令。

| 场景 | 可以这样对 Agent 说 |
| ---------------- | ----------------------------------------------------------------------- |
| Managed Agent | “帮我创建一个能够生成短片分镜和视频的 Managed Agent。” |
| 图片和视频生成 | “生成一张穿着太空服的猫站在火星上的图片,再把它制作成一段视频。” |
| 语音识别 | “把这段音频转写成文字,专有名词识别不准的话帮我加上热词再试。” |
| 用量与额度 | “查看最近的模型用量、免费额度和限流情况。” |
| 监控与告警 | “查看我的模型调用统计、失败明细和调用日志,并创建一条告警规则。” |
| 模型选型 | “推荐一个适合图片理解和智能客服的模型。” |
| 了解 Bailian CLI | “介绍一下 Bailian CLI 能帮我完成哪些任务,并根据我的需求推荐使用方式。” |
| 场景 | 可以这样对 Agent 说 |
| ---------------- | ---------------------------------------------------------------------------- |
| Managed Agent | “帮我创建一个能够生成短片分镜和视频的 Managed Agent。” |
| 图片和视频生成 | “生成一张穿着太空服的猫站在火星上的图片,再把它制作成一段视频。” |
| 语音识别 | “把这段音频转写成文字,专有名词识别不准的话帮我加上热词再试。” |
| 用量与额度 | “查看最近的模型用量、免费额度和限流情况。” |
| 监控与告警 | “查看我的模型调用统计、失败明细和调用日志,并创建一条告警规则。” |
| 吞吐预留 | “查看我的吞吐预留及容量实例,并对容量进行扩缩、续订或释放,再等待操作完成。” |
| 模型选型 | “推荐一个适合图片理解和智能客服的模型。” |
| 了解 Bailian CLI | “介绍一下 Bailian CLI 能帮我完成哪些任务,并根据我的需求推荐使用方式。” |

> 更多案例与使用场景:[阿里云百炼 CLI 官方主页](https://bailian.console.aliyun.com/cli?source_channel=cli_github&)

Expand Down
20 changes: 20 additions & 0 deletions packages/cli/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ import {
deployImageCreate,
deployList,
deployGet,
deployCapacityList,
deployCapacityGet,
deployCapacityCreate,
deployCapacityScale,
deployCapacityRenew,
deployCapacityDelete,
deployCapacityUnsubscribe,
deployOverflow,
deployOperationGet,
deployOperationWait,
deployModels,
deployScale,
deployUpdate,
Expand Down Expand Up @@ -435,6 +445,16 @@ export const commands: Record<string, AnyCommand> = {
"deploy image create": deployImageCreate,
"deploy list": deployList,
"deploy get": deployGet,
"deploy capacity list": deployCapacityList,
"deploy capacity get": deployCapacityGet,
"deploy capacity create": deployCapacityCreate,
"deploy capacity scale": deployCapacityScale,
"deploy capacity renew": deployCapacityRenew,
"deploy capacity delete": deployCapacityDelete,
"deploy capacity unsubscribe": deployCapacityUnsubscribe,
"deploy overflow": deployOverflow,
"deploy operation get": deployOperationGet,
"deploy operation wait": deployOperationWait,
"deploy models": deployModels,
"deploy scale": deployScale,
"deploy update": deployUpdate,
Expand Down
41 changes: 41 additions & 0 deletions packages/commands/src/commands/deploy/capacity-get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { defineCommand, getCapacityInstance } from "bailian-cli-core";
import { emitResult } from "bailian-cli-runtime";
import { CAPACITY_INSTANCE_FLAG, DEPLOYED_MODEL_FLAG, validateQueryIds } from "./query-shared.ts";

export default defineCommand({
description: {
"en-US": "Get a throughput reservation capacity instance",
"zh-CN": "查询吞吐预留容量实例详情",
},
auth: "apiKey",
flags: { ...DEPLOYED_MODEL_FLAG, ...CAPACITY_INSTANCE_FLAG },
usageArgs: "--deployed-model <code> --instance-id <id>",
exampleArgs: ["--deployed-model example-model-code --instance-id example-capacity-instance"],
notes: [
{
"en-US":
"Read-only; released instances can also be queried. Preserves the API envelope, capacity fields, can_scale/can_renew/can_delete and deleted. Capacities are kTPM; the instance must belong to this ModelCode.",
"zh-CN":
"只读查询,已释放实例也可查询。保留 API 响应结构、容量字段、can_scale/can_renew/can_delete 和 deleted。容量单位为 kTPM,实例必须属于指定 ModelCode。",
},
],
validate: validateQueryIds,
async run(ctx) {
const { settings, flags } = ctx;
if (settings.dryRun) {
emitResult(
{
action: "deploy.capacity.get",
deployed_model: flags.deployedModel,
instance_id: flags.instanceId,
},
"json",
);
return;
}
emitResult(
await getCapacityInstance(ctx.client, flags.deployedModel, flags.instanceId),
"json",
);
},
});
117 changes: 117 additions & 0 deletions packages/commands/src/commands/deploy/capacity-list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { defineCommand, listCapacityInstances, type FlagsDef } from "bailian-cli-core";
import { emitResult } from "bailian-cli-runtime";
import {
DEPLOYED_MODEL_FLAG,
queryValues,
validatePagination,
validateQueryIds,
} from "./query-shared.ts";

const FLAGS = {
...DEPLOYED_MODEL_FLAG,
page: {
type: "number",
valueHint: "<n>",
description: { "en-US": "Page number (default: 1)", "zh-CN": "页码(默认:1)" },
},
pageSize: {
type: "number",
valueHint: "<n>",
description: {
"en-US": "Results per page (1–100, default: 20)",
"zh-CN": "每页条数(1–100,默认:20)",
},
},
includeDeleted: {
type: "boolean",
valueHint: "<true|false>",
description: {
"en-US": "Include released instances (default: true)",
"zh-CN": "包含已释放实例(默认:true)",
},
},
statuses: {
type: "string",
valueHint: "<status,...>",
description: {
"en-US": "Instance statuses, comma-separated (not ModelCode statuses)",
"zh-CN": "实例状态,逗号分隔(非 ModelCode 状态)",
},
},
chargeTypes: {
type: "string",
valueHint: "<pre_paid,post_paid>",
description: {
"en-US": "Charge types: pre_paid, post_paid; comma-separated",
"zh-CN": "付费类型:pre_paid、post_paid,逗号分隔",
},
},
} satisfies FlagsDef;

export default defineCommand({
description: {
"en-US": "List throughput reservation capacity instances",
"zh-CN": "查询吞吐预留容量实例列表",
},
auth: "apiKey",
flags: FLAGS,
usageArgs:
"--deployed-model <code> [--page <n>] [--page-size <n>] [--include-deleted <true|false>] [--statuses <status,...>] [--charge-types <pre_paid,post_paid>]",
exampleArgs: [
"--deployed-model example-model-code",
"--deployed-model example-model-code --include-deleted false --statuses RUNNING,STOPPED",
],
notes: [
{
"en-US":
"Preserves the API envelope and records/items/page/itemsPerPage/pageCount pagination. Capacities are kTPM; effective, configured and target capacities are distinct. STOPPED alone does not mean released: inspect deleted.",
"zh-CN":
"保留 API 响应结构及 records/items/page/itemsPerPage/pageCount 分页字段。容量单位为 kTPM,区分生效、配置和目标容量。仅 STOPPED 不代表已释放,需检查 deleted。",
},
],
validate(flags) {
const error = validateQueryIds(flags) ?? validatePagination(flags);
if (error) return error;
if (
[flags.statuses, flags.chargeTypes].some((value) =>
queryValues(value)?.some((entry) => !entry),
)
) {
return "Filter lists must not contain empty values. / 筛选列表不能包含空值。";
}
if (
queryValues(flags.chargeTypes)?.some((value) => !["pre_paid", "post_paid"].includes(value))
) {
return "--charge-types accepts pre_paid,post_paid. / --charge-types 仅支持 pre_paid、post_paid。";
}
return undefined;
},
async run(ctx) {
const { flags, settings } = ctx;
const params = {
pageNo: flags.page ?? 1,
pageSize: flags.pageSize ?? 20,
includeDeleted: flags.includeDeleted ?? true,
statuses: queryValues(flags.statuses),
chargeTypes: queryValues(flags.chargeTypes),
};
if (settings.dryRun) {
emitResult(
{
action: "deploy.capacity.list",
deployed_model: flags.deployedModel,
query: {
page_no: params.pageNo,
page_size: params.pageSize,
include_deleted: params.includeDeleted,
statuses: params.statuses?.join(","),
charge_types: params.chargeTypes?.join(","),
},
},
"json",
);
return;
}
emitResult(await listCapacityInstances(ctx.client, flags.deployedModel, params), "json");
},
});
46 changes: 46 additions & 0 deletions packages/commands/src/commands/deploy/capacity-unsubscribe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { defineCommand } from "bailian-cli-core";
import { emitResult, emitBare, refundConsolePage } from "bailian-cli-runtime";
import { CAPACITY_INSTANCE_FLAG, validateQueryIds } from "./query-shared.ts";

export default defineCommand({
description: {
"en-US": "Build the Aliyun billing console unsubscribe link for a prepaid capacity instance",
"zh-CN": "生成预付费容量实例在阿里云费用中心的退订链接",
},
auth: "none",
flags: CAPACITY_INSTANCE_FLAG,
usageArgs: "--instance-id <id>",
exampleArgs: ["--instance-id example-instance"],
notes: [
{
"en-US":
"No API is called and nothing is unsubscribed by this command; it only builds the refund page link. Open the link and finish the unsubscribe flow in the billing console with the account that placed the order.",
"zh-CN":
"本命令不调用任何接口,也不会执行退订,只生成费用中心退订页面链接。请用下单账号打开链接,在费用中心完成退订流程。",
},
{
"en-US":
"Only prepaid instances are unsubscribed this way; postpaid instances are released with `deploy capacity delete`. The ID is the capacity instance ID (see `deploy capacity list` / `get`), not the ModelCode. Unsubscription may interrupt serving and is irreversible; refund rules are decided by the billing console.",
"zh-CN":
"仅预付费实例通过此方式退订;后付费实例请使用 `deploy capacity delete` 释放。此处为容量实例 ID(见 `deploy capacity list` / `get`),不是 ModelCode。退订可能中断服务且不可撤销,退款规则以费用中心为准。",
},
],
validate: validateQueryIds,
async run(ctx) {
const { settings, flags } = ctx;
// Pure link builder: no network call, so dry-run and execution share one path.
const refundUrl = refundConsolePage(flags.instanceId);
if (settings.quiet) {
emitBare(refundUrl);
return;
}
emitResult(
{
action: "deploy.capacity.unsubscribe",
instance_id: flags.instanceId,
refund_url: refundUrl,
},
"json",
);
},
});
Loading
Loading