@@ -221,69 +221,66 @@ class ChatStore {
221
221
*/
222
222
private getApiOptions ( ) : Record < string , unknown > {
223
223
const currentConfig = config ( ) ;
224
+ const hasValue = ( value : unknown ) : boolean =>
225
+ value !== undefined && value !== null && value !== '' ;
226
+
224
227
const apiOptions : Record < string , unknown > = {
225
228
stream : true ,
226
229
timings_per_token : true
227
230
} ;
228
231
229
- if ( currentConfig . temperature !== undefined && currentConfig . temperature !== null ) {
232
+ if ( hasValue ( currentConfig . temperature ) ) {
230
233
apiOptions . temperature = Number ( currentConfig . temperature ) ;
231
234
}
232
- if ( currentConfig . max_tokens !== undefined && currentConfig . max_tokens !== null ) {
235
+ if ( hasValue ( currentConfig . max_tokens ) ) {
233
236
apiOptions . max_tokens = Number ( currentConfig . max_tokens ) ;
234
237
}
235
- if ( currentConfig . dynatemp_range !== undefined && currentConfig . dynatemp_range !== null ) {
238
+ if ( hasValue ( currentConfig . dynatemp_range ) ) {
236
239
apiOptions . dynatemp_range = Number ( currentConfig . dynatemp_range ) ;
237
240
}
238
- if ( currentConfig . dynatemp_exponent !== undefined && currentConfig . dynatemp_exponent !== null ) {
241
+ if ( hasValue ( currentConfig . dynatemp_exponent ) ) {
239
242
apiOptions . dynatemp_exponent = Number ( currentConfig . dynatemp_exponent ) ;
240
243
}
241
- if ( currentConfig . top_k !== undefined && currentConfig . top_k !== null ) {
244
+ if ( hasValue ( currentConfig . top_k ) ) {
242
245
apiOptions . top_k = Number ( currentConfig . top_k ) ;
243
246
}
244
- if ( currentConfig . top_p !== undefined && currentConfig . top_p !== null ) {
247
+ if ( hasValue ( currentConfig . top_p ) ) {
245
248
apiOptions . top_p = Number ( currentConfig . top_p ) ;
246
249
}
247
- if ( currentConfig . min_p !== undefined && currentConfig . min_p !== null ) {
250
+ if ( hasValue ( currentConfig . min_p ) ) {
248
251
apiOptions . min_p = Number ( currentConfig . min_p ) ;
249
252
}
250
- if ( currentConfig . xtc_probability !== undefined && currentConfig . xtc_probability !== null ) {
253
+ if ( hasValue ( currentConfig . xtc_probability ) ) {
251
254
apiOptions . xtc_probability = Number ( currentConfig . xtc_probability ) ;
252
255
}
253
- if ( currentConfig . xtc_threshold !== undefined && currentConfig . xtc_threshold !== null ) {
256
+ if ( hasValue ( currentConfig . xtc_threshold ) ) {
254
257
apiOptions . xtc_threshold = Number ( currentConfig . xtc_threshold ) ;
255
258
}
256
- if ( currentConfig . typ_p !== undefined && currentConfig . typ_p !== null ) {
259
+ if ( hasValue ( currentConfig . typ_p ) ) {
257
260
apiOptions . typ_p = Number ( currentConfig . typ_p ) ;
258
261
}
259
- if ( currentConfig . repeat_last_n !== undefined && currentConfig . repeat_last_n !== null ) {
262
+ if ( hasValue ( currentConfig . repeat_last_n ) ) {
260
263
apiOptions . repeat_last_n = Number ( currentConfig . repeat_last_n ) ;
261
264
}
262
- if ( currentConfig . repeat_penalty !== undefined && currentConfig . repeat_penalty !== null ) {
265
+ if ( hasValue ( currentConfig . repeat_penalty ) ) {
263
266
apiOptions . repeat_penalty = Number ( currentConfig . repeat_penalty ) ;
264
267
}
265
- if ( currentConfig . presence_penalty !== undefined && currentConfig . presence_penalty !== null ) {
268
+ if ( hasValue ( currentConfig . presence_penalty ) ) {
266
269
apiOptions . presence_penalty = Number ( currentConfig . presence_penalty ) ;
267
270
}
268
- if ( currentConfig . frequency_penalty !== undefined && currentConfig . frequency_penalty !== null ) {
271
+ if ( hasValue ( currentConfig . frequency_penalty ) ) {
269
272
apiOptions . frequency_penalty = Number ( currentConfig . frequency_penalty ) ;
270
273
}
271
- if ( currentConfig . dry_multiplier !== undefined && currentConfig . dry_multiplier !== null ) {
274
+ if ( hasValue ( currentConfig . dry_multiplier ) ) {
272
275
apiOptions . dry_multiplier = Number ( currentConfig . dry_multiplier ) ;
273
276
}
274
- if ( currentConfig . dry_base !== undefined && currentConfig . dry_base !== null ) {
277
+ if ( hasValue ( currentConfig . dry_base ) ) {
275
278
apiOptions . dry_base = Number ( currentConfig . dry_base ) ;
276
279
}
277
- if (
278
- currentConfig . dry_allowed_length !== undefined &&
279
- currentConfig . dry_allowed_length !== null
280
- ) {
280
+ if ( hasValue ( currentConfig . dry_allowed_length ) ) {
281
281
apiOptions . dry_allowed_length = Number ( currentConfig . dry_allowed_length ) ;
282
282
}
283
- if (
284
- currentConfig . dry_penalty_last_n !== undefined &&
285
- currentConfig . dry_penalty_last_n !== null
286
- ) {
283
+ if ( hasValue ( currentConfig . dry_penalty_last_n ) ) {
287
284
apiOptions . dry_penalty_last_n = Number ( currentConfig . dry_penalty_last_n ) ;
288
285
}
289
286
if ( currentConfig . samplers ) {
0 commit comments