-
Models
-
-
- Model Source Manifest List
- }/>
-
-
Provide JSON file URLs for the models manifest. Separate URLs with semicolons. The "models"
- field in JSON files will be parsed into the following table.
-
-
-
-
-
- {({renderHeaderCell}) => (
- {renderHeaderCell()}
- )}
-
-
-
-
>
- {({item, rowId}) => (
- key={rowId}>
- {({renderCell}) => (
- {renderCell(item)}
- )}
-
- )}
-
+
+
+
+ Model Source Manifest List
+ }/>
-
+
+ Provide JSON file URLs for the models manifest. Separate URLs with semicolons. The "models"
+ field in JSON files will be parsed into the following table.
+
+
+
+
+
+
+ {({renderHeaderCell}) => (
+ {renderHeaderCell()}
+ )}
+
+
+
+ >
+ {({item, rowId}) => (
+ key={rowId}>
+ {({renderCell}) => (
+ {renderCell(item)}
+ )}
+
+ )}
+
+
+
+
-
+ }/>
);
});
diff --git a/frontend/src/startup.ts b/frontend/src/startup.ts
index 2f68856..9f8d13a 100644
--- a/frontend/src/startup.ts
+++ b/frontend/src/startup.ts
@@ -1,9 +1,10 @@
-import commonStore, {ModelSourceItem} from './stores/commonStore';
+import commonStore, {defaultModelConfigs, ModelSourceItem} from './stores/commonStore';
import {ListDirFiles, ReadJson, SaveJson} from '../wailsjs/go/backend_golang/App';
import manifest from '../../manifest.json';
export async function startup() {
- initConfig();
+ initCache();
+ await initConfig();
}
type Cache = {
@@ -11,6 +12,21 @@ type Cache = {
}
async function initConfig() {
+ await ReadJson('config.json').then((configData) => {
+ if (configData.modelSourceManifestList)
+ commonStore.setModelSourceManifestList(configData.modelSourceManifestList);
+ if (configData.modelConfigs && Array.isArray(configData.modelConfigs))
+ commonStore.setModelConfigs(configData.modelConfigs, false);
+ else throw new Error('Invalid config.json');
+ if (configData.currentModelConfigIndex &&
+ configData.currentModelConfigIndex >= 0 && configData.currentModelConfigIndex < configData.modelConfigs.length)
+ commonStore.setCurrentConfigIndex(configData.currentModelConfigIndex, false);
+ }).catch(() => {
+ commonStore.setModelConfigs(defaultModelConfigs, true);
+ });
+}
+
+async function initCache() {
let cache: Cache = {models: []};
await ReadJson('cache.json').then((cacheData: Cache) => {
cache = cacheData;
diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts
index d1596d2..c6d4787 100644
--- a/frontend/src/stores/commonStore.ts
+++ b/frontend/src/stores/commonStore.ts
@@ -1,4 +1,5 @@
import {makeAutoObservable} from 'mobx';
+import {SaveJson} from '../../wailsjs/go/backend_golang/App';
export enum ModelStatus {
Offline,
@@ -38,17 +39,17 @@ export type ModelParameters = {
}
export type ModelConfig = {
- configName: string;
+ name: string;
apiParameters: ApiParameters
modelParameters: ModelParameters
}
-const defaultModelConfigs: ModelConfig[] = [
+export const defaultModelConfigs: ModelConfig[] = [
{
- configName: 'Default',
+ name: 'Default',
apiParameters: {
apiPort: 8000,
- maxResponseToken: 1000,
+ maxResponseToken: 4100,
temperature: 1,
topP: 1,
presencePenalty: 0,
@@ -71,28 +72,61 @@ class CommonStore {
modelStatus: ModelStatus = ModelStatus.Offline;
currentModelConfigIndex: number = 0;
- modelConfigs: ModelConfig[] = defaultModelConfigs;
+ modelConfigs: ModelConfig[] = [];
modelSourceManifestList: string = 'https://cdn.jsdelivr.net/gh/josstorer/RWKV-Runner/manifest.json;';
modelSourceList: ModelSourceItem[] = [];
+ async saveConfigs() {
+ await SaveJson('config.json', {
+ modelSourceManifestList: this.modelSourceManifestList,
+ currentModelConfigIndex: this.currentModelConfigIndex,
+ modelConfigs: this.modelConfigs
+ });
+ }
+
setModelStatus = (status: ModelStatus) => {
this.modelStatus = status;
};
- setCurrentConfigIndex = (index: number) => {
+ setCurrentConfigIndex = (index: number, saveConfig: boolean = true) => {
this.currentModelConfigIndex = index;
+ if (saveConfig)
+ this.saveConfigs();
};
- setModelConfig = (index: number, config: ModelConfig) => {
+ setModelConfig = (index: number, config: ModelConfig, saveConfig: boolean = true) => {
this.modelConfigs[index] = config;
+ if (saveConfig)
+ this.saveConfigs();
};
- createModelConfig = (config: ModelConfig = defaultModelConfigs[0]) => {
+ setModelConfigs = (configs: ModelConfig[], saveConfig: boolean = true) => {
+ this.modelConfigs = configs;
+ if (saveConfig)
+ this.saveConfigs();
+ };
+
+ createModelConfig = (config: ModelConfig = defaultModelConfigs[0], saveConfig: boolean = true) => {
+ if (config.name === defaultModelConfigs[0].name)
+ config.name = new Date().toLocaleString();
this.modelConfigs.push(config);
+ if (saveConfig)
+ this.saveConfigs();
};
- deleteModelConfig = (index: number) => {
+ deleteModelConfig = (index: number, saveConfig: boolean = true) => {
this.modelConfigs.splice(index, 1);
+ if (index < this.currentModelConfigIndex) {
+ this.setCurrentConfigIndex(this.currentModelConfigIndex - 1);
+ }
+ if (this.modelConfigs.length === 0) {
+ this.createModelConfig();
+ }
+ if (this.currentModelConfigIndex >= this.modelConfigs.length) {
+ this.setCurrentConfigIndex(this.modelConfigs.length - 1);
+ }
+ if (saveConfig)
+ this.saveConfigs();
};
setModelSourceManifestList = (value: string) => {