Skip to content

Commit eddacd4

Browse files
committed
fixing NaN on backspace
1 parent 50c06ca commit eddacd4

File tree

1 file changed

+18
-3
lines changed
  • webapp/src/components/system_console

1 file changed

+18
-3
lines changed

webapp/src/components/system_console/bot.tsx

+18-3
Original file line numberDiff line numberDiff line change
@@ -296,19 +296,34 @@ const ServiceItem = (props: ServiceItemProps) => {
296296
/>
297297
<TextItem
298298
label={intl.formatMessage({defaultMessage: 'Input token limit'})}
299+
type='number'
299300
value={props.service.tokenLimit.toString()}
300-
onChange={(e) => props.onChange({...props.service, tokenLimit: parseInt(e.target.value, 10)})}
301+
onChange={(e) => {
302+
const value = parseInt(e.target.value, 10);
303+
const tokenLimit = isNaN(value) ? 0 : value;
304+
props.onChange({...props.service, tokenLimit});
305+
}}
301306
/>
302307
<TextItem
303308
label={intl.formatMessage({defaultMessage: 'Output token limit'})}
309+
type='number'
304310
value={props.service.outputTokenLimit?.toString() || getDefaultOutputTokenLimit()}
305-
onChange={(e) => props.onChange({...props.service, outputTokenLimit: parseInt(e.target.value, 10)})}
311+
onChange={(e) => {
312+
const value = parseInt(e.target.value, 10);
313+
const outputTokenLimit = isNaN(value) ? 0 : value;
314+
props.onChange({...props.service, outputTokenLimit});
315+
}}
306316
/>
307317
{isOpenAIType && (
308318
<TextItem
309319
label={intl.formatMessage({defaultMessage: 'Streaming Timeout Seconds'})}
320+
type='number'
310321
value={props.service.streamingTimeoutSeconds?.toString() || '0'}
311-
onChange={(e) => props.onChange({...props.service, streamingTimeoutSeconds: parseInt(e.target.value, 10)})}
322+
onChange={(e) => {
323+
const value = parseInt(e.target.value, 10);
324+
const streamingTimeoutSeconds = isNaN(value) ? 0 : value;
325+
props.onChange({...props.service, streamingTimeoutSeconds});
326+
}}
312327
/>
313328
)}
314329
</>

0 commit comments

Comments
 (0)