Skip to content

Commit

Permalink
fixes bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarsh-scottlogic committed Jan 25, 2024
1 parent 00c47f2 commit 53daa26
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions frontend/src/components/ModelBox/ModelConfigurationSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ function ModelConfigurationSlider({
config: CustomChatModelConfiguration;
}) {
const [value, setValue] = useState<number>(config.value);
const [currentConfiguredValue, setCurrentConfiguredValue] = useState<number>(
config.value
);

function handleValueChange(
_: Event | SyntheticEvent,
Expand All @@ -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]);
Expand All @@ -37,9 +48,7 @@ function ModelConfigurationSlider({
valueLabelDisplay="auto"
value={value}
onChange={handleValueChange}
onChangeCommitted={() => {
void configureGptModel(config.id, value);
}}
onChangeCommitted={handleValueCommitted}
sx={{
color: '#2bb3bb',
}}
Expand Down

0 comments on commit 53daa26

Please sign in to comment.