@@ -166,13 +166,12 @@ private OkHttpClient okHttpClient() {
166166 }
167167 this .authInterceptor .setApiKey (this .apiKey );
168168 this .authInterceptor .setKeyStrategy (this .keyStrategy );
169- OkHttpClient okHttpClient = new OkHttpClient
169+ return new OkHttpClient
170170 .Builder ()
171171 .addInterceptor (this .authInterceptor )
172172 .connectTimeout (30 , TimeUnit .SECONDS )
173173 .writeTimeout (30 , TimeUnit .SECONDS )
174174 .readTimeout (30 , TimeUnit .SECONDS ).build ();
175- return okHttpClient ;
176175 }
177176
178177 /**
@@ -182,8 +181,7 @@ private OkHttpClient okHttpClient() {
182181 */
183182 public List <Model > models () {
184183 Single <ModelResponse > models = this .openAiApi .models ();
185- List <Model > modelList = models .blockingGet ().getData ();
186- return modelList ;
184+ return models .blockingGet ().getData ();
187185 }
188186
189187 /**
@@ -727,7 +725,7 @@ public WhisperResponse speechToTextTranslations(java.io.File file, Translations
727725 RequestBody fileBody = RequestBody .create (MediaType .parse ("multipart/form-data" ), file );
728726 MultipartBody .Part multipartBody = MultipartBody .Part .createFormData ("file" , file .getName (), fileBody );
729727 //自定义参数
730- Map <String , RequestBody > requestBodyMap = new HashMap <>();
728+ Map <String , RequestBody > requestBodyMap = new HashMap <>(5 , 1L );
731729
732730 if (StrUtil .isNotBlank (translations .getModel ())) {
733731 requestBodyMap .put (Translations .Fields .model , RequestBody .create (MediaType .parse ("multipart/form-data" ), translations .getModel ()));
@@ -738,9 +736,7 @@ public WhisperResponse speechToTextTranslations(java.io.File file, Translations
738736 if (StrUtil .isNotBlank (translations .getResponseFormat ())) {
739737 requestBodyMap .put (Translations .Fields .responseFormat , RequestBody .create (MediaType .parse ("multipart/form-data" ), translations .getResponseFormat ()));
740738 }
741- if (Objects .nonNull (translations .getTemperature ())) {
742- requestBodyMap .put (Translations .Fields .temperature , RequestBody .create (MediaType .parse ("multipart/form-data" ), String .valueOf (translations .getTemperature ())));
743- }
739+ requestBodyMap .put (Translations .Fields .temperature , RequestBody .create (MediaType .parse ("multipart/form-data" ), String .valueOf (translations .getTemperature ())));
744740 Single <WhisperResponse > whisperResponse = this .openAiApi .speechToTextTranslations (multipartBody , requestBodyMap );
745741 return whisperResponse .blockingGet ();
746742 }
0 commit comments