small fix

This commit is contained in:
josc146 2024-05-28 21:19:26 +08:00
parent 79476f66a6
commit 1b3aa629da

View File

@ -115,28 +115,31 @@ const Configs: FC = observer(() => {
const onClickSave = () => { const onClickSave = () => {
commonStore.setModelConfig(selectedIndex, selectedConfig); commonStore.setModelConfig(selectedIndex, selectedConfig);
// When clicking RunButton in Configs page, updateConfig will be called twice, const webgpu = selectedConfig.modelParameters.device === 'WebGPU';
// because there are also RunButton in other pages, and the calls to updateConfig in both places are necessary. if (!webgpu) {
updateConfig({ // When clicking RunButton in Configs page, updateConfig will be called twice,
max_tokens: selectedConfig.apiParameters.maxResponseToken, // because there are also RunButton in other pages, and the calls to updateConfig in both places are necessary.
temperature: selectedConfig.apiParameters.temperature, updateConfig({
top_p: selectedConfig.apiParameters.topP, max_tokens: selectedConfig.apiParameters.maxResponseToken,
presence_penalty: selectedConfig.apiParameters.presencePenalty, temperature: selectedConfig.apiParameters.temperature,
frequency_penalty: selectedConfig.apiParameters.frequencyPenalty, top_p: selectedConfig.apiParameters.topP,
penalty_decay: selectedConfig.apiParameters.penaltyDecay, presence_penalty: selectedConfig.apiParameters.presencePenalty,
global_penalty: selectedConfig.apiParameters.globalPenalty, frequency_penalty: selectedConfig.apiParameters.frequencyPenalty,
state: selectedConfig.apiParameters.stateModel penalty_decay: selectedConfig.apiParameters.penaltyDecay,
}).then(async r => { global_penalty: selectedConfig.apiParameters.globalPenalty,
if (r.status !== 200) { state: selectedConfig.apiParameters.stateModel
const error = await r.text(); }).then(async r => {
if (error.includes('state shape mismatch')) if (r.status !== 200) {
toast(t('State model mismatch'), { type: 'error' }); const error = await r.text();
else if (error.includes('file format of the model or state model not supported')) if (error.includes('state shape mismatch'))
toast(t('File format of the model or state model not supported'), { type: 'error' }); toast(t('State model mismatch'), { type: 'error' });
else else if (error.includes('file format of the model or state model not supported'))
toast(error, { type: 'error' }); toast(t('File format of the model or state model not supported'), { type: 'error' });
} else
}); toast(error, { type: 'error' });
}
});
}
toast(t('Config Saved'), { autoClose: 300, type: 'success' }); toast(t('Config Saved'), { autoClose: 300, type: 'success' });
}; };