custom models path
This commit is contained in:
parent
cf16e54463
commit
b49968c145
@ -129,5 +129,8 @@
|
|||||||
"Reset All Configs": "重置所有配置",
|
"Reset All Configs": "重置所有配置",
|
||||||
"Cancel": "取消",
|
"Cancel": "取消",
|
||||||
"Confirm": "确认",
|
"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": "自定义模型路径"
|
||||||
}
|
}
|
@ -12,7 +12,6 @@ import { Button } from '@fluentui/react-components';
|
|||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { exit, getStatus, readRoot, switchModel, updateConfig } from '../apis';
|
import { exit, getStatus, readRoot, switchModel, updateConfig } from '../apis';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import manifest from '../../../manifest.json';
|
|
||||||
import { getStrategy, getSupportedCustomCudaFile, saveCache, toastWithButton } from '../utils';
|
import { getStrategy, getSupportedCustomCudaFile, saveCache, toastWithButton } from '../utils';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { ToolTipButton } from './ToolTipButton';
|
import { ToolTipButton } from './ToolTipButton';
|
||||||
@ -51,7 +50,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
let modelPath = '';
|
let modelPath = '';
|
||||||
if (modelConfig && modelConfig.modelParameters) {
|
if (modelConfig && modelConfig.modelParameters) {
|
||||||
modelName = modelConfig.modelParameters.modelName;
|
modelName = modelConfig.modelParameters.modelName;
|
||||||
modelPath = `./${manifest.localModelDir}/${modelName}`;
|
modelPath = `${commonStore.settings.customModelsPath}/${modelName}`;
|
||||||
} else {
|
} else {
|
||||||
toast(t('Model Config Exception'), { type: 'error' });
|
toast(t('Model Config Exception'), { type: 'error' });
|
||||||
commonStore.setStatus({ status: ModelStatus.Offline });
|
commonStore.setStatus({ status: ModelStatus.Offline });
|
||||||
@ -156,7 +155,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
}
|
}
|
||||||
|
|
||||||
switchModel({
|
switchModel({
|
||||||
model: `${manifest.localModelDir}/${modelConfig.modelParameters.modelName}`,
|
model: modelPath,
|
||||||
strategy: getStrategy(modelConfig),
|
strategy: getStrategy(modelConfig),
|
||||||
customCuda: customCudaFile !== ''
|
customCuda: customCudaFile !== ''
|
||||||
}).then((r) => {
|
}).then((r) => {
|
||||||
|
@ -35,7 +35,6 @@ import { useNavigate } from 'react-router';
|
|||||||
import { RunButton } from '../components/RunButton';
|
import { RunButton } from '../components/RunButton';
|
||||||
import { updateConfig } from '../apis';
|
import { updateConfig } from '../apis';
|
||||||
import { ConvertModel, FileExists } from '../../wailsjs/go/backend_golang/App';
|
import { ConvertModel, FileExists } from '../../wailsjs/go/backend_golang/App';
|
||||||
import manifest from '../../../manifest.json';
|
|
||||||
import { getStrategy, refreshLocalModels } from '../utils';
|
import { getStrategy, refreshLocalModels } from '../utils';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { WindowShow } from '../../wailsjs/runtime/runtime';
|
import { WindowShow } from '../../wailsjs/runtime/runtime';
|
||||||
@ -836,7 +835,7 @@ export const Configs: FC = observer(() => {
|
|||||||
</div>
|
</div>
|
||||||
} />
|
} />
|
||||||
<ToolTipButton text={t('Convert')} desc={t('Convert model with these configs')} onClick={async () => {
|
<ToolTipButton text={t('Convert')} desc={t('Convert model with these configs')} onClick={async () => {
|
||||||
const modelPath = `${manifest.localModelDir}/${selectedConfig.modelParameters.modelName}`;
|
const modelPath = `${commonStore.settings.customModelsPath}/${selectedConfig.modelParameters.modelName}`;
|
||||||
if (await FileExists(modelPath)) {
|
if (await FileExists(modelPath)) {
|
||||||
const strategy = getStrategy(selectedConfig);
|
const strategy = getStrategy(selectedConfig);
|
||||||
const newModelPath = modelPath + '-' + strategy.replace(/[:> *+]/g, '-');
|
const newModelPath = modelPath + '-' + strategy.replace(/[:> *+]/g, '-');
|
||||||
|
@ -18,7 +18,6 @@ import { observer } from 'mobx-react-lite';
|
|||||||
import commonStore from '../stores/commonStore';
|
import commonStore from '../stores/commonStore';
|
||||||
import { BrowserOpenURL } from '../../wailsjs/runtime';
|
import { BrowserOpenURL } from '../../wailsjs/runtime';
|
||||||
import { AddToDownloadList, OpenFileFolder } from '../../wailsjs/go/backend_golang/App';
|
import { AddToDownloadList, OpenFileFolder } from '../../wailsjs/go/backend_golang/App';
|
||||||
import manifest from '../../../manifest.json';
|
|
||||||
import { Page } from '../components/Page';
|
import { Page } from '../components/Page';
|
||||||
import { bytesToGb, refreshModels, saveConfigs, toastWithButton } from '../utils';
|
import { bytesToGb, refreshModels, saveConfigs, toastWithButton } from '../utils';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@ -143,7 +142,7 @@ const columns: TableColumnDefinition<ModelSourceItem>[] = [
|
|||||||
{
|
{
|
||||||
item.isLocal &&
|
item.isLocal &&
|
||||||
<ToolTipButton desc={t('Open Folder')} icon={<Folder20Regular />} onClick={() => {
|
<ToolTipButton desc={t('Open Folder')} icon={<Folder20Regular />} onClick={() => {
|
||||||
OpenFileFolder(`./${manifest.localModelDir}/${item.name}`);
|
OpenFileFolder(`${commonStore.settings.customModelsPath}/${item.name}`);
|
||||||
}} />
|
}} />
|
||||||
}
|
}
|
||||||
{item.downloadUrl && !item.isLocal &&
|
{item.downloadUrl && !item.isLocal &&
|
||||||
@ -152,7 +151,7 @@ const columns: TableColumnDefinition<ModelSourceItem>[] = [
|
|||||||
navigate({ pathname: '/downloads' });
|
navigate({ pathname: '/downloads' });
|
||||||
},
|
},
|
||||||
{ autoClose: 3000 });
|
{ autoClose: 3000 });
|
||||||
AddToDownloadList(`./${manifest.localModelDir}/${item.name}`, item.downloadUrl!);
|
AddToDownloadList(`${commonStore.settings.customModelsPath}/${item.name}`, item.downloadUrl!);
|
||||||
}} />}
|
}} />}
|
||||||
{item.url && <ToolTipButton desc={t('Open Url')} icon={<Open20Regular />} onClick={() => {
|
{item.url && <ToolTipButton desc={t('Open Url')} icon={<Open20Regular />} onClick={() => {
|
||||||
BrowserOpenURL(item.url!);
|
BrowserOpenURL(item.url!);
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
import React, { FC } from 'react';
|
import React, { FC, useEffect, useRef } from 'react';
|
||||||
import { Page } from '../components/Page';
|
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 { Labeled } from '../components/Labeled';
|
||||||
import commonStore from '../stores/commonStore';
|
import commonStore from '../stores/commonStore';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
@ -15,16 +24,24 @@ export const Languages = {
|
|||||||
export type Language = keyof typeof Languages;
|
export type Language = keyof typeof Languages;
|
||||||
|
|
||||||
export type SettingsType = {
|
export type SettingsType = {
|
||||||
language: Language,
|
language: Language
|
||||||
darkMode: boolean
|
darkMode: boolean
|
||||||
autoUpdatesCheck: boolean
|
autoUpdatesCheck: boolean
|
||||||
giteeUpdatesSource: boolean
|
giteeUpdatesSource: boolean
|
||||||
cnMirror: boolean
|
cnMirror: boolean
|
||||||
host: string
|
host: string
|
||||||
|
customModelsPath: string
|
||||||
|
customPythonPath: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Settings: FC = observer(() => {
|
export const Settings: FC = observer(() => {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
|
const advancedHeaderRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (advancedHeaderRef.current)
|
||||||
|
(advancedHeaderRef.current.firstElementChild as HTMLElement).style.padding = '0';
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page title={t('Settings')} content={
|
<Page title={t('Settings')} content={
|
||||||
@ -96,6 +113,33 @@ export const Settings: FC = observer(() => {
|
|||||||
});
|
});
|
||||||
}} />
|
}} />
|
||||||
} />
|
} />
|
||||||
|
<Accordion collapsible>
|
||||||
|
<AccordionItem value="1">
|
||||||
|
<AccordionHeader ref={advancedHeaderRef} size="large">{t('Advanced')}</AccordionHeader>
|
||||||
|
<AccordionPanel>
|
||||||
|
<div className="flex flex-col gap-2 overflow-hidden">
|
||||||
|
<Labeled label={t('Custom Models Path')}
|
||||||
|
content={
|
||||||
|
<Input className="grow" placeholder="./models" value={commonStore.settings.customModelsPath}
|
||||||
|
onChange={(e, data) => {
|
||||||
|
commonStore.setSettings({
|
||||||
|
customModelsPath: data.value
|
||||||
|
});
|
||||||
|
}} />
|
||||||
|
} />
|
||||||
|
<Labeled label={t('Custom Python Path')}
|
||||||
|
content={
|
||||||
|
<Input className="grow" placeholder="./py310/python" value={commonStore.settings.customPythonPath}
|
||||||
|
onChange={(e, data) => {
|
||||||
|
commonStore.setSettings({
|
||||||
|
customPythonPath: data.value
|
||||||
|
});
|
||||||
|
}} />
|
||||||
|
} />
|
||||||
|
</div>
|
||||||
|
</AccordionPanel>
|
||||||
|
</AccordionItem>
|
||||||
|
</Accordion>
|
||||||
</div>
|
</div>
|
||||||
} />
|
} />
|
||||||
);
|
);
|
||||||
|
@ -13,11 +13,11 @@ export async function startup() {
|
|||||||
commonStore.setDownloadList(data);
|
commonStore.setDownloadList(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
initCache().then(initRemoteText);
|
|
||||||
|
|
||||||
await GetPlatform().then(p => commonStore.setPlatform(p as Platform));
|
await GetPlatform().then(p => commonStore.setPlatform(p as Platform));
|
||||||
await initConfig();
|
await initConfig();
|
||||||
|
|
||||||
|
initCache().then(initRemoteText); // depends on config customModelsPath
|
||||||
|
|
||||||
if (commonStore.settings.autoUpdatesCheck) // depends on config settings
|
if (commonStore.settings.autoUpdatesCheck) // depends on config settings
|
||||||
checkUpdate();
|
checkUpdate();
|
||||||
|
|
||||||
|
@ -59,7 +59,9 @@ class CommonStore {
|
|||||||
autoUpdatesCheck: true,
|
autoUpdatesCheck: true,
|
||||||
giteeUpdatesSource: getUserLanguage() === 'zh',
|
giteeUpdatesSource: getUserLanguage() === 'zh',
|
||||||
cnMirror: getUserLanguage() === 'zh',
|
cnMirror: getUserLanguage() === 'zh',
|
||||||
host: '127.0.0.1'
|
host: '127.0.0.1',
|
||||||
|
customModelsPath: './models',
|
||||||
|
customPythonPath: ''
|
||||||
};
|
};
|
||||||
// about
|
// about
|
||||||
about: AboutContent = manifest.about;
|
about: AboutContent = manifest.about;
|
||||||
|
@ -51,7 +51,7 @@ export async function refreshLocalModels(cache: { models: ModelSourceItem[] }, f
|
|||||||
if (filter)
|
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
|
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 => {
|
cache.models.push(...data.flatMap(d => {
|
||||||
if (!d.isDir && d.name.endsWith('.pth'))
|
if (!d.isDir && d.name.endsWith('.pth'))
|
||||||
return [{
|
return [{
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
"en": "<div align=\"center\">\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</div>",
|
"en": "<div align=\"center\">\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</div>",
|
||||||
"zh": "<div align=\"center\">\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</div>"
|
"zh": "<div align=\"center\">\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</div>"
|
||||||
},
|
},
|
||||||
"localModelDir": "models",
|
|
||||||
"programFiles": [
|
"programFiles": [
|
||||||
{
|
{
|
||||||
"url": "",
|
"url": "",
|
||||||
|
Loading…
Reference in New Issue
Block a user