99import lombok .NoArgsConstructor ;
1010import lombok .ToString ;
1111import org .devlive .sdk .openai .exception .ParamException ;
12+ import org .devlive .sdk .openai .model .CompletionModel ;
1213
1314@ Data
1415@ Builder
@@ -32,6 +33,20 @@ public class FineTuningEntity
3233 @ JsonProperty (value = "limit" )
3334 private Integer limit ;
3435
36+ /**
37+ * The name of the model to fine-tune.
38+ * 要微调的模型的名称。
39+ */
40+ @ JsonProperty (value = "model" )
41+ private String model ;
42+
43+ /**
44+ * The ID of an uploaded file that contains training data.
45+ * 包含训练数据的已上传文件的 ID。
46+ */
47+ @ JsonProperty (value = "training_file" )
48+ private String file ;
49+
3550 @ JsonProperty (value = "object" )
3651 private String object ;
3752
@@ -57,23 +72,33 @@ public class FineTuningEntity
5772 private FineTuningEntity (FineTuningEntityBuilder builder )
5873 {
5974 if (builder .limit == null ) {
60- builder .limit (20 );
75+ builder .limit (null );
6176 }
6277 this .limit = builder .limit ;
6378 this .after = builder .after ;
79+
80+ if (builder .model == null ) {
81+ builder .model (CompletionModel .GPT_35_TURBO );
82+ }
83+ this .model = builder .model ;
84+
85+ if (builder .file == null ) {
86+ builder .file (null );
87+ }
88+ this .file = builder .file ;
6489 }
6590
6691 public static class FineTuningEntityBuilder
6792 {
6893 public FineTuningEntityBuilder limit (Integer limit )
6994 {
70- if (limit == null ) {
71- limit = 20 ;
72- }
73-
74- if (limit < 1 ) {
75- throw new ParamException ("Invalid limit must not be less than 1" );
76- }
95+ // if (limit == null) {
96+ // limit = 20;
97+ // }
98+ //
99+ // if (limit < 1) {
100+ // throw new ParamException("Invalid limit must not be less than 1");
101+ // }
77102 this .limit = limit ;
78103 return this ;
79104 }
@@ -84,6 +109,35 @@ public FineTuningEntityBuilder after(String after)
84109 return this ;
85110 }
86111
112+ public FineTuningEntityBuilder model (CompletionModel model )
113+ {
114+ if (model == null ) {
115+ model = CompletionModel .GPT_35_TURBO ;
116+ }
117+
118+ switch (model ) {
119+ case GPT_35_TURBO :
120+ case GPT_35_TURBO_0613 :
121+ case BABBAGE_002 :
122+ case DAVINCI_002 :
123+ case GPT_4_0613 :
124+ this .model = model .getName ();
125+ break ;
126+ default :
127+ throw new ParamException (String .format ("Not support completion model %s" , model ));
128+ }
129+ return this ;
130+ }
131+
132+ public FineTuningEntityBuilder file (String file )
133+ {
134+ if (file == null ) {
135+ throw new ParamException ("Invalid file name must not be empty" );
136+ }
137+ this .file = file ;
138+ return this ;
139+ }
140+
87141 public FineTuningEntity build ()
88142 {
89143 return new FineTuningEntity (this );
0 commit comments