88import lombok .NoArgsConstructor ;
99import lombok .ToString ;
1010import org .apache .commons .lang3 .ObjectUtils ;
11- import org .apache .commons .lang3 .StringUtils ;
1211import org .devlive .sdk .openai .exception .ParamException ;
1312import org .devlive .sdk .openai .model .CompletionModel ;
1413import org .devlive .sdk .openai .utils .EnumsUtils ;
@@ -48,7 +47,7 @@ public class ChatEntity
4847 private ChatEntity (ChatEntityBuilder builder )
4948 {
5049 if (ObjectUtils .isEmpty (builder .model )) {
51- builder .model (CompletionModel .GPT_35_TURBO . getName () );
50+ builder .model (CompletionModel .GPT_35_TURBO );
5251 }
5352 this .model = builder .model ;
5453 this .messages = builder .messages ;
@@ -71,33 +70,28 @@ private ChatEntity(ChatEntityBuilder builder)
7170
7271 public static class ChatEntityBuilder
7372 {
74- public ChatEntityBuilder model (String model )
73+ public ChatEntityBuilder model (CompletionModel model )
7574 {
76- if (StringUtils .isEmpty (model )) {
77- model = CompletionModel .GPT_35_TURBO . getName () ;
75+ if (ObjectUtils .isEmpty (model )) {
76+ model = CompletionModel .GPT_35_TURBO ;
7877 }
79-
80- CompletionModel completionModel = EnumsUtils .getCompleteModel (model );
81- if (ObjectUtils .isNotEmpty (completionModel )) {
82- switch (completionModel ) {
83- case GPT_35_TURBO :
84- case GPT_35_TURBO_16K :
85- case GPT_35_TURBO_0613 :
86- case GPT_35_TURBO_16K_0613 :
87- case GPT_4 :
88- case GPT_4_32K :
89- case GPT_4_0613 :
90- case GPT_4_32K_0613 :
91- case TEXT_DAVINCI_002 :
92- case TEXT_DAVINCI_003 :
93- case CODE_DAVINCI_002 :
94- model = completionModel .getName ();
95- break ;
96- default :
97- throw new ParamException (String .format ("Not support completion model %s" , model ));
98- }
78+ switch (model ) {
79+ case GPT_35_TURBO :
80+ case GPT_35_TURBO_16K :
81+ case GPT_35_TURBO_0613 :
82+ case GPT_35_TURBO_16K_0613 :
83+ case GPT_4 :
84+ case GPT_4_32K :
85+ case GPT_4_0613 :
86+ case GPT_4_32K_0613 :
87+ case TEXT_DAVINCI_002 :
88+ case TEXT_DAVINCI_003 :
89+ case CODE_DAVINCI_002 :
90+ this .model = model .getName ();
91+ break ;
92+ default :
93+ throw new ParamException (String .format ("Not support completion model %s" , model ));
9994 }
100- this .model = model ;
10195 return this ;
10296 }
10397
0 commit comments