@@ -221,69 +221,66 @@ class ChatStore {
221221 */
222222 private getApiOptions ( ) : Record < string , unknown > {
223223 const currentConfig = config ( ) ;
224+ const hasValue = ( value : unknown ) : boolean =>
225+ value !== undefined && value !== null && value !== '' ;
226+
224227 const apiOptions : Record < string , unknown > = {
225228 stream : true ,
226229 timings_per_token : true
227230 } ;
228231
229- if ( currentConfig . temperature !== undefined && currentConfig . temperature !== null ) {
232+ if ( hasValue ( currentConfig . temperature ) ) {
230233 apiOptions . temperature = Number ( currentConfig . temperature ) ;
231234 }
232- if ( currentConfig . max_tokens !== undefined && currentConfig . max_tokens !== null ) {
235+ if ( hasValue ( currentConfig . max_tokens ) ) {
233236 apiOptions . max_tokens = Number ( currentConfig . max_tokens ) ;
234237 }
235- if ( currentConfig . dynatemp_range !== undefined && currentConfig . dynatemp_range !== null ) {
238+ if ( hasValue ( currentConfig . dynatemp_range ) ) {
236239 apiOptions . dynatemp_range = Number ( currentConfig . dynatemp_range ) ;
237240 }
238- if ( currentConfig . dynatemp_exponent !== undefined && currentConfig . dynatemp_exponent !== null ) {
241+ if ( hasValue ( currentConfig . dynatemp_exponent ) ) {
239242 apiOptions . dynatemp_exponent = Number ( currentConfig . dynatemp_exponent ) ;
240243 }
241- if ( currentConfig . top_k !== undefined && currentConfig . top_k !== null ) {
244+ if ( hasValue ( currentConfig . top_k ) ) {
242245 apiOptions . top_k = Number ( currentConfig . top_k ) ;
243246 }
244- if ( currentConfig . top_p !== undefined && currentConfig . top_p !== null ) {
247+ if ( hasValue ( currentConfig . top_p ) ) {
245248 apiOptions . top_p = Number ( currentConfig . top_p ) ;
246249 }
247- if ( currentConfig . min_p !== undefined && currentConfig . min_p !== null ) {
250+ if ( hasValue ( currentConfig . min_p ) ) {
248251 apiOptions . min_p = Number ( currentConfig . min_p ) ;
249252 }
250- if ( currentConfig . xtc_probability !== undefined && currentConfig . xtc_probability !== null ) {
253+ if ( hasValue ( currentConfig . xtc_probability ) ) {
251254 apiOptions . xtc_probability = Number ( currentConfig . xtc_probability ) ;
252255 }
253- if ( currentConfig . xtc_threshold !== undefined && currentConfig . xtc_threshold !== null ) {
256+ if ( hasValue ( currentConfig . xtc_threshold ) ) {
254257 apiOptions . xtc_threshold = Number ( currentConfig . xtc_threshold ) ;
255258 }
256- if ( currentConfig . typ_p !== undefined && currentConfig . typ_p !== null ) {
259+ if ( hasValue ( currentConfig . typ_p ) ) {
257260 apiOptions . typ_p = Number ( currentConfig . typ_p ) ;
258261 }
259- if ( currentConfig . repeat_last_n !== undefined && currentConfig . repeat_last_n !== null ) {
262+ if ( hasValue ( currentConfig . repeat_last_n ) ) {
260263 apiOptions . repeat_last_n = Number ( currentConfig . repeat_last_n ) ;
261264 }
262- if ( currentConfig . repeat_penalty !== undefined && currentConfig . repeat_penalty !== null ) {
265+ if ( hasValue ( currentConfig . repeat_penalty ) ) {
263266 apiOptions . repeat_penalty = Number ( currentConfig . repeat_penalty ) ;
264267 }
265- if ( currentConfig . presence_penalty !== undefined && currentConfig . presence_penalty !== null ) {
268+ if ( hasValue ( currentConfig . presence_penalty ) ) {
266269 apiOptions . presence_penalty = Number ( currentConfig . presence_penalty ) ;
267270 }
268- if ( currentConfig . frequency_penalty !== undefined && currentConfig . frequency_penalty !== null ) {
271+ if ( hasValue ( currentConfig . frequency_penalty ) ) {
269272 apiOptions . frequency_penalty = Number ( currentConfig . frequency_penalty ) ;
270273 }
271- if ( currentConfig . dry_multiplier !== undefined && currentConfig . dry_multiplier !== null ) {
274+ if ( hasValue ( currentConfig . dry_multiplier ) ) {
272275 apiOptions . dry_multiplier = Number ( currentConfig . dry_multiplier ) ;
273276 }
274- if ( currentConfig . dry_base !== undefined && currentConfig . dry_base !== null ) {
277+ if ( hasValue ( currentConfig . dry_base ) ) {
275278 apiOptions . dry_base = Number ( currentConfig . dry_base ) ;
276279 }
277- if (
278- currentConfig . dry_allowed_length !== undefined &&
279- currentConfig . dry_allowed_length !== null
280- ) {
280+ if ( hasValue ( currentConfig . dry_allowed_length ) ) {
281281 apiOptions . dry_allowed_length = Number ( currentConfig . dry_allowed_length ) ;
282282 }
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 ) ) {
287284 apiOptions . dry_penalty_last_n = Number ( currentConfig . dry_penalty_last_n ) ;
288285 }
289286 if ( currentConfig . samplers ) {
0 commit comments