diff --git a/frontend/src/_locales/zh-hans/main.json b/frontend/src/_locales/zh-hans/main.json index df9eb06..902d22e 100644 --- a/frontend/src/_locales/zh-hans/main.json +++ b/frontend/src/_locales/zh-hans/main.json @@ -129,5 +129,8 @@ "Reset All Configs": "重置所有配置", "Cancel": "取消", "Confirm": "确认", - "Are you sure you want to reset all configs? This will obtain the latest preset configs, but will override your custom configs and cannot be undone.": "你确定要重置所有配置吗?这会获取最新的预设配置,但会覆盖你的自定义配置,并且无法撤销" + "Are you sure you want to reset all configs? This will obtain the latest preset configs, but will override your custom configs and cannot be undone.": "你确定要重置所有配置吗?这会获取最新的预设配置,但会覆盖你的自定义配置,并且无法撤销", + "Advanced": "高级", + "Custom Python Path": "自定义Python路径", + "Custom Models Path": "自定义模型路径" } \ No newline at end of file diff --git a/frontend/src/components/RunButton.tsx b/frontend/src/components/RunButton.tsx index 76383f8..ffc835c 100644 --- a/frontend/src/components/RunButton.tsx +++ b/frontend/src/components/RunButton.tsx @@ -12,7 +12,6 @@ import { Button } from '@fluentui/react-components'; import { observer } from 'mobx-react-lite'; import { exit, getStatus, readRoot, switchModel, updateConfig } from '../apis'; import { toast } from 'react-toastify'; -import manifest from '../../../manifest.json'; import { getStrategy, getSupportedCustomCudaFile, saveCache, toastWithButton } from '../utils'; import { useTranslation } from 'react-i18next'; import { ToolTipButton } from './ToolTipButton'; @@ -51,7 +50,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean let modelPath = ''; if (modelConfig && modelConfig.modelParameters) { modelName = modelConfig.modelParameters.modelName; - modelPath = `./${manifest.localModelDir}/${modelName}`; + modelPath = `${commonStore.settings.customModelsPath}/${modelName}`; } else { toast(t('Model Config Exception'), { type: 'error' }); commonStore.setStatus({ status: ModelStatus.Offline }); @@ -156,7 +155,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean } switchModel({ - model: `${manifest.localModelDir}/${modelConfig.modelParameters.modelName}`, + model: modelPath, strategy: getStrategy(modelConfig), customCuda: customCudaFile !== '' }).then((r) => { diff --git a/frontend/src/pages/Configs.tsx b/frontend/src/pages/Configs.tsx index 1684bc4..6e80e91 100644 --- a/frontend/src/pages/Configs.tsx +++ b/frontend/src/pages/Configs.tsx @@ -35,7 +35,6 @@ import { useNavigate } from 'react-router'; import { RunButton } from '../components/RunButton'; import { updateConfig } from '../apis'; import { ConvertModel, FileExists } from '../../wailsjs/go/backend_golang/App'; -import manifest from '../../../manifest.json'; import { getStrategy, refreshLocalModels } from '../utils'; import { useTranslation } from 'react-i18next'; import { WindowShow } from '../../wailsjs/runtime/runtime'; @@ -836,7 +835,7 @@ export const Configs: FC = observer(() => { } /> { - const modelPath = `${manifest.localModelDir}/${selectedConfig.modelParameters.modelName}`; + const modelPath = `${commonStore.settings.customModelsPath}/${selectedConfig.modelParameters.modelName}`; if (await FileExists(modelPath)) { const strategy = getStrategy(selectedConfig); const newModelPath = modelPath + '-' + strategy.replace(/[:> *+]/g, '-'); diff --git a/frontend/src/pages/Models.tsx b/frontend/src/pages/Models.tsx index 0794d2b..d094570 100644 --- a/frontend/src/pages/Models.tsx +++ b/frontend/src/pages/Models.tsx @@ -18,7 +18,6 @@ import { observer } from 'mobx-react-lite'; import commonStore from '../stores/commonStore'; import { BrowserOpenURL } from '../../wailsjs/runtime'; import { AddToDownloadList, OpenFileFolder } from '../../wailsjs/go/backend_golang/App'; -import manifest from '../../../manifest.json'; import { Page } from '../components/Page'; import { bytesToGb, refreshModels, saveConfigs, toastWithButton } from '../utils'; import { useTranslation } from 'react-i18next'; @@ -143,7 +142,7 @@ const columns: TableColumnDefinition[] = [ { item.isLocal && } onClick={() => { - OpenFileFolder(`./${manifest.localModelDir}/${item.name}`); + OpenFileFolder(`${commonStore.settings.customModelsPath}/${item.name}`); }} /> } {item.downloadUrl && !item.isLocal && @@ -152,7 +151,7 @@ const columns: TableColumnDefinition[] = [ navigate({ pathname: '/downloads' }); }, { autoClose: 3000 }); - AddToDownloadList(`./${manifest.localModelDir}/${item.name}`, item.downloadUrl!); + AddToDownloadList(`${commonStore.settings.customModelsPath}/${item.name}`, item.downloadUrl!); }} />} {item.url && } onClick={() => { BrowserOpenURL(item.url!); diff --git a/frontend/src/pages/Settings.tsx b/frontend/src/pages/Settings.tsx index dd396bc..3e09c77 100644 --- a/frontend/src/pages/Settings.tsx +++ b/frontend/src/pages/Settings.tsx @@ -1,6 +1,15 @@ -import React, { FC } from 'react'; +import React, { FC, useEffect, useRef } from 'react'; import { Page } from '../components/Page'; -import { Dropdown, Option, Switch } from '@fluentui/react-components'; +import { + Accordion, + AccordionHeader, + AccordionItem, + AccordionPanel, + Dropdown, + Input, + Option, + Switch +} from '@fluentui/react-components'; import { Labeled } from '../components/Labeled'; import commonStore from '../stores/commonStore'; import { observer } from 'mobx-react-lite'; @@ -15,16 +24,24 @@ export const Languages = { export type Language = keyof typeof Languages; export type SettingsType = { - language: Language, + language: Language darkMode: boolean autoUpdatesCheck: boolean giteeUpdatesSource: boolean cnMirror: boolean host: string + customModelsPath: string + customPythonPath: string } export const Settings: FC = observer(() => { const { t, i18n } = useTranslation(); + const advancedHeaderRef = useRef(null); + + useEffect(() => { + if (advancedHeaderRef.current) + (advancedHeaderRef.current.firstElementChild as HTMLElement).style.padding = '0'; + }, []); return ( { }); }} /> } /> + + + {t('Advanced')} + +
+ { + commonStore.setSettings({ + customModelsPath: data.value + }); + }} /> + } /> + { + commonStore.setSettings({ + customPythonPath: data.value + }); + }} /> + } /> +
+
+
+
} /> ); diff --git a/frontend/src/startup.ts b/frontend/src/startup.ts index a602afb..6c72df4 100644 --- a/frontend/src/startup.ts +++ b/frontend/src/startup.ts @@ -13,11 +13,11 @@ export async function startup() { commonStore.setDownloadList(data); }); - initCache().then(initRemoteText); - await GetPlatform().then(p => commonStore.setPlatform(p as Platform)); await initConfig(); + initCache().then(initRemoteText); // depends on config customModelsPath + if (commonStore.settings.autoUpdatesCheck) // depends on config settings checkUpdate(); diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts index 75b5945..9a0b88f 100644 --- a/frontend/src/stores/commonStore.ts +++ b/frontend/src/stores/commonStore.ts @@ -59,7 +59,9 @@ class CommonStore { autoUpdatesCheck: true, giteeUpdatesSource: getUserLanguage() === 'zh', cnMirror: getUserLanguage() === 'zh', - host: '127.0.0.1' + host: '127.0.0.1', + customModelsPath: './models', + customPythonPath: '' }; // about about: AboutContent = manifest.about; diff --git a/frontend/src/utils/index.tsx b/frontend/src/utils/index.tsx index 14e1267..d7c9602 100644 --- a/frontend/src/utils/index.tsx +++ b/frontend/src/utils/index.tsx @@ -51,7 +51,7 @@ export async function refreshLocalModels(cache: { models: ModelSourceItem[] }, f if (filter) cache.models = cache.models.filter(m => !m.isLocal); //TODO BUG cause local but in manifest files to be removed, so currently cache is disabled - await ListDirFiles(manifest.localModelDir).then((data) => { + await ListDirFiles(commonStore.settings.customModelsPath).then((data) => { cache.models.push(...data.flatMap(d => { if (!d.isDir && d.name.endsWith('.pth')) return [{ diff --git a/manifest.json b/manifest.json index 53a1679..180628e 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,6 @@ "en": "
\n\nProject Source Code:\nhttps://github.com/josStorer/RWKV-Runner\nAuthor: [@josStorer](https://github.com/josStorer)\nFAQs: https://github.com/josStorer/RWKV-Runner/wiki/FAQs\n\nRelated Repositories:\nRWKV-4-Raven: https://huggingface.co/BlinkDL/rwkv-4-raven/tree/main\nChatRWKV: https://github.com/BlinkDL/ChatRWKV\nRWKV-LM: https://github.com/BlinkDL/RWKV-LM\n\n
", "zh": "
\n\n本项目源码:\nhttps://github.com/josStorer/RWKV-Runner\n作者: [@josStorer](https://github.com/josStorer)\n演示与常见问题说明视频: https://www.bilibili.com/video/BV1hM4y1v76R\n疑难解答: https://www.bilibili.com/read/cv23921171\n\n相关仓库:\nRWKV-4-Raven: https://huggingface.co/BlinkDL/rwkv-4-raven/tree/main\nChatRWKV: https://github.com/BlinkDL/ChatRWKV\nRWKV-LM: https://github.com/BlinkDL/RWKV-LM\n\n
" }, - "localModelDir": "models", "programFiles": [ { "url": "",