11import { defineCommand , detectOutputFormat , modelsLimitsPath } from "bailian-cli-core" ;
2- import { emitResult } from "bailian-cli-runtime" ;
2+ import { emitResult , confirmDangerousAction } from "bailian-cli-runtime" ;
33import { formatNumber } from "../shared/format.ts" ;
44
55const MINUTE_SECONDS = 60 ;
@@ -10,7 +10,7 @@ export default defineCommand({
1010 "zh-CN" : "更新模型限流配置(QPM/TPM),或使用 --delete 清除配置" ,
1111 } ,
1212 auth : "apiKey" ,
13- usageArgs : "--model <model> [--rpm <n>] [--tpm <n>] [--delete]" ,
13+ usageArgs : "--model <model> [--rpm <n>] [--tpm <n>] [--delete] [--yes] " ,
1414 flags : {
1515 model : {
1616 type : "string" ,
@@ -41,11 +41,19 @@ export default defineCommand({
4141 "zh-CN" : "清除该模型的所有自定义限流配置" ,
4242 } ,
4343 } ,
44+ yes : {
45+ type : "switch" ,
46+ description : {
47+ "en-US" : "Skip the confirmation prompt for --delete" ,
48+ "zh-CN" : "使用 --delete 时跳过确认提示" ,
49+ } ,
50+ } ,
4451 } ,
4552 exampleArgs : [
4653 "--model qwen-plus --rpm 60 --tpm 100000" ,
4754 "--model qwen3-max --tpm 500000" ,
4855 "--model qwen-plus --delete" ,
56+ "--model qwen-plus --delete --yes" ,
4957 "--model qwen-plus --rpm 60 --output json" ,
5058 ] ,
5159 notes : [
@@ -55,6 +63,10 @@ export default defineCommand({
5563 "zh-CN" :
5664 "未指定的字段将保留当前值(服务端 OVERLAY 合并);--delete 会清除所有自定义限流配置。" ,
5765 } ,
66+ {
67+ "en-US" : "--delete requires confirmation; pass --yes to skip the prompt in scripts." ,
68+ "zh-CN" : "--delete 需要确认;脚本中可加 --yes 跳过交互提示。" ,
69+ } ,
5870 {
5971 "en-US" :
6072 "Setting TPM without an existing QPM limit is rejected server-side — pass --rpm first or together." ,
@@ -98,6 +110,13 @@ export default defineCommand({
98110 return ;
99111 }
100112
113+ if ( flags . delete ) {
114+ await confirmDangerousAction (
115+ `Clear all custom rate limits for model ${ modelName } .\nYour custom QPM/TPM configuration will be removed.` ,
116+ flags . yes ?? false ,
117+ ) ;
118+ }
119+
101120 const result = await ctx . client . requestJson < { request_id ?: string } > ( {
102121 path : modelsLimitsPath ( ) ,
103122 method : "POST" ,
0 commit comments