Skip to content

Commit

Permalink
fixing NaN on backspace (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCookie95 authored Feb 5, 2025
1 parent 50c06ca commit 00e0c95
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions webapp/src/components/system_console/bot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,19 +296,34 @@ const ServiceItem = (props: ServiceItemProps) => {
/>
<TextItem
label={intl.formatMessage({defaultMessage: 'Input token limit'})}
type='number'
value={props.service.tokenLimit.toString()}
onChange={(e) => props.onChange({...props.service, tokenLimit: parseInt(e.target.value, 10)})}
onChange={(e) => {
const value = parseInt(e.target.value, 10);
const tokenLimit = isNaN(value) ? 0 : value;
props.onChange({...props.service, tokenLimit});
}}
/>
<TextItem
label={intl.formatMessage({defaultMessage: 'Output token limit'})}
type='number'
value={props.service.outputTokenLimit?.toString() || getDefaultOutputTokenLimit()}
onChange={(e) => props.onChange({...props.service, outputTokenLimit: parseInt(e.target.value, 10)})}
onChange={(e) => {
const value = parseInt(e.target.value, 10);
const outputTokenLimit = isNaN(value) ? 0 : value;
props.onChange({...props.service, outputTokenLimit});
}}
/>
{isOpenAIType && (
<TextItem
label={intl.formatMessage({defaultMessage: 'Streaming Timeout Seconds'})}
type='number'
value={props.service.streamingTimeoutSeconds?.toString() || '0'}
onChange={(e) => props.onChange({...props.service, streamingTimeoutSeconds: parseInt(e.target.value, 10)})}
onChange={(e) => {
const value = parseInt(e.target.value, 10);
const streamingTimeoutSeconds = isNaN(value) ? 0 : value;
props.onChange({...props.service, streamingTimeoutSeconds});
}}
/>
)}
</>
Expand Down

0 comments on commit 00e0c95

Please sign in to comment.