improve details

This commit is contained in:
josc146 2023-11-26 22:54:59 +08:00
parent 2c1f89383f
commit 7ce464ecda
4 changed files with 18 additions and 7 deletions

View File

@ -33,9 +33,9 @@ type DownloadStatus struct {
var downloadList []*DownloadStatus var downloadList []*DownloadStatus
func existsInDownloadList(url string) bool { func existsInDownloadList(path string, url string) bool {
for _, ds := range downloadList { for _, ds := range downloadList {
if ds.Url == url { if ds.Path == path || ds.Url == url {
return true return true
} }
} }
@ -88,7 +88,7 @@ func (a *App) ContinueDownload(url string) {
} }
func (a *App) AddToDownloadList(path string, url string) { func (a *App) AddToDownloadList(path string, url string) {
if !existsInDownloadList(url) { if !existsInDownloadList(a.exDir+path, url) {
downloadList = append(downloadList, &DownloadStatus{ downloadList = append(downloadList, &DownloadStatus{
resp: nil, resp: nil,
Name: filepath.Base(path), Name: filepath.Base(path),

View File

@ -84,6 +84,10 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
showDownloadPrompt(t('Model file not found'), modelName); showDownloadPrompt(t('Model file not found'), modelName);
commonStore.setStatus({ status: ModelStatus.Offline }); commonStore.setStatus({ status: ModelStatus.Offline });
return; return;
} else if (!currentModelSource?.isComplete) {
showDownloadPrompt(t('Model file download is not complete'), modelName);
commonStore.setStatus({ status: ModelStatus.Offline });
return;
} else { } else {
toastWithButton(t('Please convert model to safe tensors format first'), t('Convert'), () => { toastWithButton(t('Please convert model to safe tensors format first'), t('Convert'), () => {
convertToSt(navigate, modelConfig); convertToSt(navigate, modelConfig);
@ -112,7 +116,9 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
showDownloadPrompt(t('Model file not found'), modelName); showDownloadPrompt(t('Model file not found'), modelName);
commonStore.setStatus({ status: ModelStatus.Offline }); commonStore.setStatus({ status: ModelStatus.Offline });
return; return;
} else if (!currentModelSource?.isComplete) { } else // If the user selects the .pth model with WebGPU mode, modelPath will be set to the .st model.
// However, if the .pth model is deleted, modelPath will exist and isComplete will be false.
if (!currentModelSource?.isComplete && modelPath.endsWith('.pth')) {
showDownloadPrompt(t('Model file download is not complete'), modelName); showDownloadPrompt(t('Model file download is not complete'), modelName);
commonStore.setStatus({ status: ModelStatus.Offline }); commonStore.setStatus({ status: ModelStatus.Offline });
return; return;
@ -145,6 +151,8 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
toast(t('Error') + ' - ' + errMsg, { type: 'error' }); toast(t('Error') + ' - ' + errMsg, { type: 'error' });
}); });
setTimeout(WindowShow, 1000); setTimeout(WindowShow, 1000);
setTimeout(WindowShow, 2000);
setTimeout(WindowShow, 3000);
let timeoutCount = 6; let timeoutCount = 6;
let loading = false; let loading = false;
@ -161,7 +169,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
}); });
} }
commonStore.setStatus({ status: ModelStatus.Loading }); commonStore.setStatus({ status: ModelStatus.Loading });
toast(t('Loading Model'), { type: 'info' }); const loadingId = toast(t('Loading Model'), { type: 'info' });
if (!webgpu) { if (!webgpu) {
updateConfig({ updateConfig({
max_tokens: modelConfig.apiParameters.maxResponseToken, max_tokens: modelConfig.apiParameters.maxResponseToken,
@ -247,6 +255,8 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
}).catch((e) => { }).catch((e) => {
commonStore.setStatus({ status: ModelStatus.Offline }); commonStore.setStatus({ status: ModelStatus.Offline });
toast(t('Failed to switch model') + ' - ' + (e.message || e), { type: 'error' }); toast(t('Failed to switch model') + ' - ' + (e.message || e), { type: 'error' });
}).finally(() => {
toast.dismiss(loadingId);
}); });
} }
}).catch(() => { }).catch(() => {

View File

@ -567,7 +567,7 @@ const ChatPanel: FC = observer(() => {
const filterPattern = '*.txt;*.pdf'; const filterPattern = '*.txt;*.pdf';
const setUploading = () => commonStore.setAttachmentUploading(true); const setUploading = () => commonStore.setAttachmentUploading(true);
// actually, status of web platform is always Offline // actually, status of web platform is always Offline
if (commonStore.platform === 'web' || commonStore.status.status === ModelStatus.Offline) { if (commonStore.platform === 'web' || commonStore.status.status === ModelStatus.Offline || currentConfig.modelParameters.device === 'WebGPU') {
webOpenOpenFileDialog({ filterPattern, fnStartLoading: setUploading }).then(webReturn => { webOpenOpenFileDialog({ filterPattern, fnStartLoading: setUploading }).then(webReturn => {
if (webReturn.content) if (webReturn.content)
commonStore.setCurrentTempAttachment( commonStore.setCurrentTempAttachment(

View File

@ -23,7 +23,8 @@ export const convertToSt = async (navigate: NavigateFunction, selectedConfig: Mo
const newModelPath = modelPath.replace(/\.pth$/, '.st'); const newModelPath = modelPath.replace(/\.pth$/, '.st');
ConvertSafetensors(commonStore.settings.customPythonPath, modelPath, newModelPath).then(async () => { ConvertSafetensors(commonStore.settings.customPythonPath, modelPath, newModelPath).then(async () => {
if (!await FileExists(newModelPath)) { if (!await FileExists(newModelPath)) {
toast(t('Convert Failed') + ' - ' + await GetPyError(), { type: 'error' }); if (commonStore.platform === 'windows')
toast(t('Convert Failed') + ' - ' + await GetPyError(), { type: 'error' });
} else { } else {
toast(`${t('Convert Success')} - ${newModelPath}`, { type: 'success' }); toast(`${t('Convert Success')} - ${newModelPath}`, { type: 'success' });
} }