From 3ddcf9f62e02c2dd8e14f3a6f8085989d5d567ba Mon Sep 17 00:00:00 2001 From: josc146 Date: Tue, 7 Nov 2023 22:24:06 +0800 Subject: [PATCH] add webui entry --- backend-golang/rwkv.go | 5 ++++- frontend/src/_locales/ja/main.json | 3 ++- frontend/src/_locales/zh-hans/main.json | 3 ++- frontend/src/components/RunButton.tsx | 2 +- frontend/src/pages/Configs.tsx | 13 ++++++++++++- frontend/src/types/configs.ts | 5 +++-- frontend/wailsjs/go/backend_golang/App.d.ts | 2 +- frontend/wailsjs/go/backend_golang/App.js | 4 ++-- 8 files changed, 27 insertions(+), 10 deletions(-) diff --git a/backend-golang/rwkv.go b/backend-golang/rwkv.go index e4b3d8b..78e0006 100644 --- a/backend-golang/rwkv.go +++ b/backend-golang/rwkv.go @@ -10,7 +10,7 @@ import ( "strings" ) -func (a *App) StartServer(python string, port int, host string, rwkvBeta bool) (string, error) { +func (a *App) StartServer(python string, port int, host string, webui bool, rwkvBeta bool) (string, error) { var err error if python == "" { python, err = GetPython() @@ -19,6 +19,9 @@ func (a *App) StartServer(python string, port int, host string, rwkvBeta bool) ( return "", err } args := []string{python, "./backend-python/main.py"} + if webui { + args = append(args, "--webui") + } if rwkvBeta { args = append(args, "--rwkv-beta") } diff --git a/frontend/src/_locales/ja/main.json b/frontend/src/_locales/ja/main.json index c115727..a989f30 100644 --- a/frontend/src/_locales/ja/main.json +++ b/frontend/src/_locales/ja/main.json @@ -264,5 +264,6 @@ "The file name is: ": "ファイル名は次のとおりです: ", "Port is occupied. Change it in Configs page or close the program that occupies the port.": "ポートが占有されています。設定ページで変更するか、ポートを占有しているプログラムを終了してください。", "Loading...": "読み込み中...", - "Hello, what can I do for you?": "こんにちは、何かお手伝いできますか?" + "Hello, what can I do for you?": "こんにちは、何かお手伝いできますか?", + "Enable WebUI": "WebUIを有効化" } \ No newline at end of file diff --git a/frontend/src/_locales/zh-hans/main.json b/frontend/src/_locales/zh-hans/main.json index 0dac207..569a818 100644 --- a/frontend/src/_locales/zh-hans/main.json +++ b/frontend/src/_locales/zh-hans/main.json @@ -264,5 +264,6 @@ "The file name is: ": "文件名是:", "Port is occupied. Change it in Configs page or close the program that occupies the port.": "端口被占用。请在配置页面更改端口,或关闭占用端口的程序", "Loading...": "加载中...", - "Hello, what can I do for you?": "你好,有什么要我帮忙的吗?" + "Hello, what can I do for you?": "你好,有什么要我帮忙的吗?", + "Enable WebUI": "启用WebUI" } \ No newline at end of file diff --git a/frontend/src/components/RunButton.tsx b/frontend/src/components/RunButton.tsx index e313230..142577d 100644 --- a/frontend/src/components/RunButton.tsx +++ b/frontend/src/components/RunButton.tsx @@ -129,7 +129,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean const isUsingCudaBeta = modelConfig.modelParameters.device === 'CUDA-Beta'; startServer(commonStore.settings.customPythonPath, port, commonStore.settings.host !== '127.0.0.1' ? '0.0.0.0' : '127.0.0.1', - isUsingCudaBeta + !!modelConfig.enableWebUI, isUsingCudaBeta ).catch((e) => { const errMsg = e.message || e; if (errMsg.includes('path contains space')) diff --git a/frontend/src/pages/Configs.tsx b/frontend/src/pages/Configs.tsx index 2960a8c..1f7a0fa 100644 --- a/frontend/src/pages/Configs.tsx +++ b/frontend/src/pages/Configs.tsx @@ -441,7 +441,18 @@ const Configs: FC = observer(() => { />
- +
+ { + setSelectedConfig({ + ...selectedConfig, + enableWebUI: data.checked as boolean + }); + }} /> + +
} /> diff --git a/frontend/src/types/configs.ts b/frontend/src/types/configs.ts index 9385635..a3222cf 100644 --- a/frontend/src/types/configs.ts +++ b/frontend/src/types/configs.ts @@ -23,6 +23,7 @@ export type ModelParameters = { export type ModelConfig = { // different configs can have the same name name: string; - apiParameters: ApiParameters - modelParameters: ModelParameters + apiParameters: ApiParameters; + modelParameters: ModelParameters; + enableWebUI?: boolean; } \ No newline at end of file diff --git a/frontend/wailsjs/go/backend_golang/App.d.ts b/frontend/wailsjs/go/backend_golang/App.d.ts index ec1cdbb..047581e 100755 --- a/frontend/wailsjs/go/backend_golang/App.d.ts +++ b/frontend/wailsjs/go/backend_golang/App.d.ts @@ -52,7 +52,7 @@ export function RestartApp():Promise; export function SaveJson(arg1:string,arg2:any):Promise; -export function StartServer(arg1:string,arg2:number,arg3:string,arg4:boolean):Promise; +export function StartServer(arg1:string,arg2:number,arg3:string,arg4:boolean,arg5:boolean):Promise; export function StartWebGPUServer(arg1:number,arg2:string):Promise; diff --git a/frontend/wailsjs/go/backend_golang/App.js b/frontend/wailsjs/go/backend_golang/App.js index d63c473..a08d64e 100755 --- a/frontend/wailsjs/go/backend_golang/App.js +++ b/frontend/wailsjs/go/backend_golang/App.js @@ -102,8 +102,8 @@ export function SaveJson(arg1, arg2) { return window['go']['backend_golang']['App']['SaveJson'](arg1, arg2); } -export function StartServer(arg1, arg2, arg3, arg4) { - return window['go']['backend_golang']['App']['StartServer'](arg1, arg2, arg3, arg4); +export function StartServer(arg1, arg2, arg3, arg4, arg5) { + return window['go']['backend_golang']['App']['StartServer'](arg1, arg2, arg3, arg4, arg5); } export function StartWebGPUServer(arg1, arg2) {