11import {
22 defineCommand ,
3- detectOutputFormat ,
43 uploadDataset ,
54 validateDataset ,
65 parseDatasetSchemaFlag ,
76 formatIssue ,
87 MAX_DATASET_BYTES ,
8+ MAX_CPT_BYTES ,
99 MAX_MEDIA_ZIP_BYTES ,
1010 BailianError ,
1111 ExitCode ,
1212 type FlagsDef ,
1313} from "bailian-cli-core" ;
14- import { emitResult , emitBare , emitRequestId } from "bailian-cli-runtime" ;
14+ import { emitResult , emitBare } from "bailian-cli-runtime" ;
1515
1616const UPLOAD_FLAGS = {
1717 file : {
1818 type : "string" ,
1919 valueHint : "<path>" ,
20- description : "Local dataset file (.jsonl or .zip; ≤300MB text , ≤1GB image )" ,
20+ description : "Local dataset file (.jsonl or .zip; ≤200MB SFT/DPO, ≤ 300MB CPT , ≤2GB media zip )" ,
2121 required : true ,
2222 } ,
2323 purpose : {
@@ -29,7 +29,7 @@ const UPLOAD_FLAGS = {
2929 type : "string" ,
3030 valueHint : "<s>" ,
3131 description :
32- 'Record schema: "chatml" (SFT), "dpo" (chosen/rejected), "cpt" (raw text), "tts" (audio), or "image" (image generation). Default auto-detects per record.' ,
32+ 'Record schema: "chatml" (SFT), "dpo" (chosen/rejected), "cpt" (raw text), "tts" (audio), "image" (image generation), or "video" (video generation). Default auto-detects per record.' ,
3333 } ,
3434 noValidate : {
3535 type : "switch" ,
@@ -45,7 +45,7 @@ export default defineCommand({
4545 description : "Upload a dataset file (.jsonl or .zip) to Bailian" ,
4646 auth : "apiKey" ,
4747 usageArgs :
48- "--file <path> [--purpose <name>] [--schema <chatml|dpo|cpt|tts|image>] [--no-validate] [--full-validate]" ,
48+ "--file <path> [--purpose <name>] [--schema <chatml|dpo|cpt|tts|image|video >] [--no-validate] [--full-validate]" ,
4949 flags : UPLOAD_FLAGS ,
5050 exampleArgs : [
5151 "--file train.jsonl" ,
@@ -58,13 +58,14 @@ export default defineCommand({
5858 ] ,
5959 notes : [
6060 "Supports .jsonl (text) and .zip (audio/image archives with a data.jsonl" ,
61- "manifest). Five record schemas are recognized: chatml = {messages:[...]}" ,
61+ "manifest). Six record schemas are recognized: chatml = {messages:[...]}" ,
6262 '(SFT); dpo = {messages:[...], chosen, rejected}; cpt = {text:"..."}' ,
6363 '(continual pre-training, raw text); tts = {wav_fn:"train/xxx.wav",' ,
6464 'text:"..."} (audio fine-tuning); image = {img_path:"..."} (image' ,
65- "generation). With no --schema, a record carrying wav_fn is validated as" ,
66- "TTS, img_path as image, chosen/rejected as DPO, text (no messages) as CPT," ,
67- "otherwise ChatML. Upload cap: 300MB text, 1GB image. Upload uses the" ,
65+ "generation); video = {first_frame_path:...} (video generation). With no" ,
66+ "--schema, a record carrying wav_fn is validated as TTS, img_path as image," ,
67+ "chosen/rejected as DPO, text (no messages) as CPT, otherwise ChatML." ,
68+ "Upload cap: 200MB SFT/DPO text, 300MB CPT, 2GB media zip. Upload uses the" ,
6869 "OpenAI-compatible /compatible-mode/v1/files endpoint so the purpose tag is" ,
6970 "persisted (the DashScope-native /api/v1/files drops it)." ,
7071 ] ,
@@ -73,19 +74,15 @@ export default defineCommand({
7374 const filePath = flags . file ;
7475 const purpose = flags . purpose || "fine-tune" ;
7576 const schema = parseDatasetSchemaFlag ( flags . schema ) ;
76- if ( schema === "video" ) {
77- throw new BailianError (
78- `--schema video is not supported.` ,
79- ExitCode . USAGE ,
80- `Supported schemas: chatml, dpo, cpt, tts, image.` ,
81- ) ;
82- }
83- const format = detectOutputFormat ( settings . output ) ;
84- // Image schema allows larger ZIPs (1 GB vs 300 MB for text).
85- const isMediaSchema = schema === "image" ;
77+ // Size caps differ per training type: SFT/DPO 200MB, CPT 300MB, media ZIP 2GB.
78+ const isMediaSchema = schema === "image" || schema === "video" ;
79+ const maxBytes = isMediaSchema
80+ ? MAX_MEDIA_ZIP_BYTES
81+ : schema === "cpt"
82+ ? MAX_CPT_BYTES
83+ : MAX_DATASET_BYTES ;
8684
8785 if ( ! flags . noValidate ) {
88- const maxBytes = isMediaSchema ? MAX_MEDIA_ZIP_BYTES : MAX_DATASET_BYTES ;
8986 const result = await validateDataset ( filePath , {
9087 fullValidate : flags . fullValidate ,
9188 schema,
@@ -125,11 +122,11 @@ export default defineCommand({
125122 action : "dataset.upload" ,
126123 file : filePath ,
127124 purpose,
128- max_bytes : isMediaSchema ? MAX_MEDIA_ZIP_BYTES : MAX_DATASET_BYTES ,
125+ max_bytes : maxBytes ,
129126 validate : ! flags . noValidate ,
130127 schema : schema ?? "auto" ,
131128 } ,
132- format ,
129+ "json" ,
133130 ) ;
134131 return ;
135132 }
@@ -142,11 +139,8 @@ export default defineCommand({
142139
143140 if ( settings . quiet ) {
144141 emitBare ( file . file_id ) ;
145- } else if ( format === "text" ) {
146- emitBare ( `Uploaded ${ file . name } → file_id=${ file . file_id } ` ) ;
147- emitRequestId ( request_id , settings . quiet ) ;
148142 } else {
149- emitResult ( { ...file , request_id } , format ) ;
143+ emitResult ( { ...file , request_id } , "json" ) ;
150144 }
151145 } ,
152146} ) ;
0 commit comments