diff --git a/frontend/src/components/RunButton.tsx b/frontend/src/components/RunButton.tsx index 0fbbe7a..e64ebd2 100644 --- a/frontend/src/components/RunButton.tsx +++ b/frontend/src/components/RunButton.tsx @@ -43,8 +43,8 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean const navigate = useNavigate(); const onClickMainButton = async () => { - if (commonStore.status.modelStatus === ModelStatus.Offline) { - commonStore.setStatus({ modelStatus: ModelStatus.Starting }); + if (commonStore.status.status === ModelStatus.Offline) { + commonStore.setStatus({ status: ModelStatus.Starting }); const modelConfig = commonStore.getCurrentModelConfig(); let modelName = ''; @@ -54,7 +54,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean modelPath = `./${manifest.localModelDir}/${modelName}`; } else { toast(t('Model Config Exception'), { type: 'error' }); - commonStore.setStatus({ modelStatus: ModelStatus.Offline }); + commonStore.setStatus({ status: ModelStatus.Offline }); return; } @@ -80,7 +80,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean } }); if (depErrorMsg) { - commonStore.setStatus({ modelStatus: ModelStatus.Offline }); + commonStore.setStatus({ status: ModelStatus.Offline }); return; } commonStore.setDepComplete(true); @@ -102,7 +102,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean } }); - commonStore.setStatus({ modelStatus: ModelStatus.Offline }); + commonStore.setStatus({ status: ModelStatus.Offline }); return; } @@ -125,7 +125,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean if (status) commonStore.setStatus(status); }); - commonStore.setStatus({ modelStatus: ModelStatus.Loading }); + commonStore.setStatus({ status: ModelStatus.Loading }); toast(t('Loading Model'), { type: 'info' }); updateConfig({ max_tokens: modelConfig.apiParameters.maxResponseToken, @@ -161,51 +161,51 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean customCuda: customCudaFile !== '' }).then((r) => { if (r.ok) { - commonStore.setStatus({ modelStatus: ModelStatus.Working }); + commonStore.setStatus({ status: ModelStatus.Working }); toastWithButton(t('Startup Completed'), t('Chat'), () => { navigate({ pathname: '/chat' }); }, { type: 'success', autoClose: 3000 }); } else if (r.status === 304) { toast(t('Loading Model'), { type: 'info' }); } else { - commonStore.setStatus({ modelStatus: ModelStatus.Offline }); + commonStore.setStatus({ status: ModelStatus.Offline }); toast(t('Failed to switch model'), { type: 'error' }); } }).catch(() => { - commonStore.setStatus({ modelStatus: ModelStatus.Offline }); + commonStore.setStatus({ status: ModelStatus.Offline }); toast(t('Failed to switch model'), { type: 'error' }); }); } }).catch(() => { if (timeoutCount <= 0) { clearInterval(intervalId); - commonStore.setStatus({ modelStatus: ModelStatus.Offline }); + commonStore.setStatus({ status: ModelStatus.Offline }); } }); timeoutCount--; }, 1000); } else { - commonStore.setStatus({ modelStatus: ModelStatus.Offline }); + commonStore.setStatus({ status: ModelStatus.Offline }); exit(); } }; const onClick = async (e: any) => { - if (commonStore.status.modelStatus === ModelStatus.Offline) + if (commonStore.status.status === ModelStatus.Offline) await onClickRun?.(e); await onClickMainButton(); }; return (iconMode ? - : - ); }); diff --git a/frontend/src/components/WorkHeader.tsx b/frontend/src/components/WorkHeader.tsx index ec6100f..746fcd1 100644 --- a/frontend/src/components/WorkHeader.tsx +++ b/frontend/src/components/WorkHeader.tsx @@ -29,8 +29,8 @@ export const WorkHeader: FC = observer(() => {
- - {t('Model Status') + ': ' + t(statusText[commonStore.status.modelStatus])} + + {t('Model Status') + ': ' + t(statusText[commonStore.status.status])}
diff --git a/frontend/src/pages/Chat.tsx b/frontend/src/pages/Chat.tsx index 44f4b62..2592abc 100644 --- a/frontend/src/pages/Chat.tsx +++ b/frontend/src/pages/Chat.tsx @@ -93,7 +93,7 @@ const ChatPanel: FC = observer(() => { e.stopPropagation(); if (e.type === 'click' || (e.keyCode === 13 && !e.shiftKey)) { e.preventDefault(); - if (commonStore.status.modelStatus === ModelStatus.Offline) { + if (commonStore.status.status === ModelStatus.Offline) { toast(t('Please click the button in the top right corner to start the model'), { type: 'warning' }); return; } diff --git a/frontend/src/pages/Completion.tsx b/frontend/src/pages/Completion.tsx index f444006..b084fe3 100644 --- a/frontend/src/pages/Completion.tsx +++ b/frontend/src/pages/Completion.tsx @@ -135,7 +135,7 @@ const CompletionPanel: FC = observer(() => { }; const onSubmit = (prompt: string) => { - if (commonStore.status.modelStatus === ModelStatus.Offline) { + if (commonStore.status.status === ModelStatus.Offline) { toast(t('Please click the button in the top right corner to start the model'), { type: 'warning' }); commonStore.setCompletionGenerating(false); return; diff --git a/frontend/src/startup.ts b/frontend/src/startup.ts index a5a3596..fd810b2 100644 --- a/frontend/src/startup.ts +++ b/frontend/src/startup.ts @@ -33,7 +33,7 @@ export async function startup() { if (commonStore.settings.autoUpdatesCheck) // depends on config settings checkUpdate(); - getStatus(500).then(status => { // depends on config api port + getStatus(1000).then(status => { // depends on config api port if (status) commonStore.setStatus(status); }); diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts index 4c1b035..bae0cd1 100644 --- a/frontend/src/stores/commonStore.ts +++ b/frontend/src/stores/commonStore.ts @@ -20,7 +20,7 @@ export enum ModelStatus { } export type Status = { - modelStatus: ModelStatus; + status: ModelStatus; pid: number; device_name: string; } @@ -28,7 +28,7 @@ export type Status = { class CommonStore { // global status: Status = { - modelStatus: ModelStatus.Offline, + status: ModelStatus.Offline, pid: 0, device_name: 'CPU' };