This commit is contained in:
josc146
2023-05-17 21:20:41 +08:00
parent 11813454de
commit df8eef5f64
14 changed files with 438 additions and 121 deletions

View File

@@ -13,6 +13,9 @@ import {Page} from '../components/Page';
import {useNavigate} from 'react-router';
import {RunButton} from '../components/RunButton';
import {updateConfig} from '../apis';
import {ConvertModel} from '../../wailsjs/go/backend_golang/App';
import manifest from '../../../manifest.json';
import {getStrategy, refreshLocalModels} from '../utils';
export const Configs: FC = observer(() => {
const [selectedIndex, setSelectedIndex] = React.useState(commonStore.currentModelConfigIndex);
@@ -173,7 +176,18 @@ export const Configs: FC = observer(() => {
}}/>
</div>
}/>
<ToolTipButton text="Convert" desc="Convert model with these configs"/>
<ToolTipButton text="Convert" desc="Convert model with these configs" onClick={() => {
const modelPath = `${manifest.localModelDir}/${selectedConfig.modelParameters.modelName}`;
const strategy = getStrategy(selectedConfig);
const newModelPath = modelPath + '-' + strategy.replace(/[> *+]/g, '-');
toast('Start Converting', {autoClose: 1000, type: 'info'});
ConvertModel(modelPath, strategy, newModelPath).then(() => {
toast(`Convert Success - ${newModelPath}`, {type: 'success'});
refreshLocalModels({models: commonStore.modelSourceList});
}).catch(e => {
toast(`Convert Failed - ${e}`, {type: 'error'});
});
}}/>
<Labeled label="Device" content={
<Dropdown style={{minWidth: 0}} className="grow" value={selectedConfig.modelParameters.device}
selectedOptions={[selectedConfig.modelParameters.device]}

View File

@@ -21,6 +21,7 @@ import {DownloadFile, OpenFileFolder} from '../../wailsjs/go/backend_golang/App'
import manifest from '../../../manifest.json';
import {toast} from 'react-toastify';
import {Page} from '../components/Page';
import {refreshModels} from '../utils';
const columns: TableColumnDefinition<ModelSourceItem>[] = [
createTableColumn<ModelSourceItem>({
@@ -106,13 +107,13 @@ const columns: TableColumnDefinition<ModelSourceItem>[] = [
{
item.isLocal &&
<ToolTipButton desc="Open Folder" icon={<Folder20Regular/>} onClick={() => {
OpenFileFolder(`.\\${manifest.localModelPath}\\${item.name}`);
OpenFileFolder(`./${manifest.localModelDir}/${item.name}`);
}}/>
}
{item.downloadUrl && !item.isLocal &&
<ToolTipButton desc="Download" icon={<ArrowDownload20Regular/>} onClick={() => {
toast(`Downloading ${item.name}`);
DownloadFile(`./${manifest.localModelPath}/${item.name}`, item.downloadUrl!);
DownloadFile(`./${manifest.localModelDir}/${item.name}`, item.downloadUrl!);
}}/>}
{item.url && <ToolTipButton desc="Open Url" icon={<Open20Regular/>} onClick={() => {
BrowserOpenURL(item.url!);
@@ -131,7 +132,9 @@ export const Models: FC = observer(() => {
<div className="flex flex-col gap-1">
<div className="flex justify-between">
<Text weight="medium">Model Source Manifest List</Text>
<ToolTipButton desc="Refresh" icon={<ArrowClockwise20Regular/>}/>
<ToolTipButton desc="Refresh" icon={<ArrowClockwise20Regular/>} onClick={() => {
refreshModels(false);
}}/>
</div>
<Text size={100}>
Provide JSON file URLs for the models manifest. Separate URLs with semicolons. The "models"
@@ -146,6 +149,7 @@ export const Models: FC = observer(() => {
items={commonStore.modelSourceList}
columns={columns}
sortable={true}
defaultSortState={{sortColumn: 'actions', sortDirection: 'ascending'}}
style={{display: 'flex'}}
className="flex-col w-full"
>