From 1b3aa629daa688253f8aa489d721dca4ca7b97d8 Mon Sep 17 00:00:00 2001 From: josc146 Date: Tue, 28 May 2024 21:19:26 +0800 Subject: [PATCH] small fix --- frontend/src/pages/Configs.tsx | 47 ++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/frontend/src/pages/Configs.tsx b/frontend/src/pages/Configs.tsx index 4612705..c53fed6 100644 --- a/frontend/src/pages/Configs.tsx +++ b/frontend/src/pages/Configs.tsx @@ -115,28 +115,31 @@ const Configs: FC = observer(() => { const onClickSave = () => { commonStore.setModelConfig(selectedIndex, selectedConfig); - // When clicking RunButton in Configs page, updateConfig will be called twice, - // because there are also RunButton in other pages, and the calls to updateConfig in both places are necessary. - updateConfig({ - max_tokens: selectedConfig.apiParameters.maxResponseToken, - temperature: selectedConfig.apiParameters.temperature, - top_p: selectedConfig.apiParameters.topP, - presence_penalty: selectedConfig.apiParameters.presencePenalty, - frequency_penalty: selectedConfig.apiParameters.frequencyPenalty, - penalty_decay: selectedConfig.apiParameters.penaltyDecay, - global_penalty: selectedConfig.apiParameters.globalPenalty, - state: selectedConfig.apiParameters.stateModel - }).then(async r => { - if (r.status !== 200) { - const error = await r.text(); - if (error.includes('state shape mismatch')) - toast(t('State model mismatch'), { type: 'error' }); - else if (error.includes('file format of the model or state model not supported')) - toast(t('File format of the model or state model not supported'), { type: 'error' }); - else - toast(error, { type: 'error' }); - } - }); + const webgpu = selectedConfig.modelParameters.device === 'WebGPU'; + if (!webgpu) { + // When clicking RunButton in Configs page, updateConfig will be called twice, + // because there are also RunButton in other pages, and the calls to updateConfig in both places are necessary. + updateConfig({ + max_tokens: selectedConfig.apiParameters.maxResponseToken, + temperature: selectedConfig.apiParameters.temperature, + top_p: selectedConfig.apiParameters.topP, + presence_penalty: selectedConfig.apiParameters.presencePenalty, + frequency_penalty: selectedConfig.apiParameters.frequencyPenalty, + penalty_decay: selectedConfig.apiParameters.penaltyDecay, + global_penalty: selectedConfig.apiParameters.globalPenalty, + state: selectedConfig.apiParameters.stateModel + }).then(async r => { + if (r.status !== 200) { + const error = await r.text(); + if (error.includes('state shape mismatch')) + toast(t('State model mismatch'), { type: 'error' }); + else if (error.includes('file format of the model or state model not supported')) + 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' }); };