diff --git a/frontend/src/components/ModelBox/ModelConfigurationSlider.tsx b/frontend/src/components/ModelBox/ModelConfigurationSlider.tsx index 223f4cd55..764e86b40 100644 --- a/frontend/src/components/ModelBox/ModelConfigurationSlider.tsx +++ b/frontend/src/components/ModelBox/ModelConfigurationSlider.tsx @@ -12,6 +12,9 @@ function ModelConfigurationSlider({ config: CustomChatModelConfiguration; }) { const [value, setValue] = useState(config.value); + const [currentConfiguredValue, setCurrentConfiguredValue] = useState( + config.value + ); function handleValueChange( _: Event | SyntheticEvent, @@ -21,6 +24,14 @@ function ModelConfigurationSlider({ setValue(val); } + function handleValueCommitted() { + const valueChanged = value !== currentConfiguredValue; + if (valueChanged) { + void configureGptModel(config.id, value); + setCurrentConfiguredValue(value); + } + } + useEffect(() => { setValue(config.value); }, [config]); @@ -37,9 +48,7 @@ function ModelConfigurationSlider({ valueLabelDisplay="auto" value={value} onChange={handleValueChange} - onChangeCommitted={() => { - void configureGptModel(config.id, value); - }} + onChangeCommitted={handleValueCommitted} sx={{ color: '#2bb3bb', }}