diff --git a/backend-golang/file.go b/backend-golang/file.go index 02ebe34..104f830 100644 --- a/backend-golang/file.go +++ b/backend-golang/file.go @@ -106,7 +106,7 @@ func (a *App) CopyFile(src string, dst string) error { } defer destFile.Close() - _, err = io.Copy(sourceFile, destFile) + _, err = io.Copy(destFile, sourceFile) if err != nil { return err } diff --git a/frontend/src/components/RunButton.tsx b/frontend/src/components/RunButton.tsx index 07d5474..8daaa8b 100644 --- a/frontend/src/components/RunButton.tsx +++ b/frontend/src/components/RunButton.tsx @@ -138,12 +138,16 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean let customCudaFile = ''; if (modelConfig.modelParameters.useCustomCuda) { customCudaFile = getSupportedCustomCudaFile(); - if (customCudaFile) + if (customCudaFile) { + FileExists('./py310/Lib/site-packages/rwkv/model.py').then((exist) => { + // defensive measure. As Python has already been launched, will only take effect the next time it runs. + if (!exist) CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py'); + }); await CopyFile(customCudaFile, './py310/Lib/site-packages/rwkv/wkv_cuda.pyd').catch(() => { customCudaFile = ''; toast(t('Failed to copy custom cuda file'), { type: 'error' }); }); - else + } else toast(t('Supported custom cuda file not found'), { type: 'warning' }); }