From 0a4876a5649130b28f4c4a2ea3fcd6e87ed0bc23 Mon Sep 17 00:00:00 2001 From: josc146 Date: Thu, 9 Nov 2023 22:07:01 +0800 Subject: [PATCH] improve user guide --- frontend/src/_locales/ja/main.json | 5 +++-- frontend/src/_locales/zh-hans/main.json | 3 ++- frontend/src/components/RunButton.tsx | 6 ++++++ frontend/src/startup.ts | 17 +++++------------ frontend/src/stores/commonStore.ts | 18 +++++++++++++----- frontend/src/types/chat.ts | 5 +++++ 6 files changed, 34 insertions(+), 20 deletions(-) diff --git a/frontend/src/_locales/ja/main.json b/frontend/src/_locales/ja/main.json index 5eb8790..16014b2 100644 --- a/frontend/src/_locales/ja/main.json +++ b/frontend/src/_locales/ja/main.json @@ -13,7 +13,7 @@ "Working": "動作中", "Stop": "停止", "Enable High Precision For Last Layer": "最後の層で高精度を有効にする", - "Stored Layers": "メモリ層読み込み", + "Stored Layers": "保存されるレイヤー", "Precision": "精度", "Device": "デバイス", "Convert model with these configs. Using a converted model will greatly improve the loading speed, but model parameters of the converted model cannot be modified.": "これらの設定でモデルを変換します。変換されたモデルを使用すると、読み込み速度が大幅に向上しますが、変換したモデルのパラメータを変更することはできません。", @@ -267,5 +267,6 @@ "Hello, what can I do for you?": "こんにちは、何かお手伝いできますか?", "Enable WebUI": "WebUIを有効化", "Server is working on deployment mode, please close the terminal window manually": "サーバーはデプロイモードで動作しています、ターミナルウィンドウを手動で閉じてください", - "Server is working on deployment mode, please exit the program manually to stop the server": "サーバーはデプロイモードで動作しています、サーバーを停止するにはプログラムを手動で終了してください" + "Server is working on deployment mode, please exit the program manually to stop the server": "サーバーはデプロイモードで動作しています、サーバーを停止するにはプログラムを手動で終了してください", + "You can increase the number of stored layers in Configs page to improve performance": "パフォーマンスを向上させるために、保存されるレイヤーの数を設定ページで増やすことができます" } \ 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 01434c6..92eda02 100644 --- a/frontend/src/_locales/zh-hans/main.json +++ b/frontend/src/_locales/zh-hans/main.json @@ -267,5 +267,6 @@ "Hello, what can I do for you?": "你好,有什么要我帮忙的吗?", "Enable WebUI": "启用WebUI", "Server is working on deployment mode, please close the terminal window manually": "服务器正在部署模式下运行,请手动关闭终端窗口", - "Server is working on deployment mode, please exit the program manually to stop the server": "服务器正在部署模式下运行,请手动退出程序以停止服务器" + "Server is working on deployment mode, please exit the program manually to stop the server": "服务器正在部署模式下运行,请手动退出程序以停止服务器", + "You can increase the number of stored layers in Configs page to improve performance": "你可以在配置页面增加载入显存层数以提升性能" } \ No newline at end of file diff --git a/frontend/src/components/RunButton.tsx b/frontend/src/components/RunButton.tsx index 0dd5851..fdb1629 100644 --- a/frontend/src/components/RunButton.tsx +++ b/frontend/src/components/RunButton.tsx @@ -213,6 +213,12 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean const buttonFn = () => { navigate({ pathname: '/' + buttonName.toLowerCase() }); }; + + if ((modelConfig.modelParameters.device === 'CUDA' || modelConfig.modelParameters.device === 'CUDA-Beta') && + modelConfig.modelParameters.storedLayers < modelConfig.modelParameters.maxStoredLayers && + commonStore.monitorData && commonStore.monitorData.totalVram !== 0 && + (commonStore.monitorData.usedVram / commonStore.monitorData.totalVram) < 0.85) + toast(t('You can increase the number of stored layers in Configs page to improve performance'), { type: 'info' }); toastWithButton(t('Startup Completed'), t(buttonName), buttonFn, { type: 'success', autoClose: 3000 }); } else if (r.status === 304) { toast(t('Loading Model'), { type: 'info' }); diff --git a/frontend/src/startup.ts b/frontend/src/startup.ts index 63415a6..32b871b 100644 --- a/frontend/src/startup.ts +++ b/frontend/src/startup.ts @@ -1,4 +1,4 @@ -import commonStore, { Platform } from './stores/commonStore'; +import commonStore, { MonitorData, Platform } from './stores/commonStore'; import { GetPlatform, ListDirFiles, ReadJson } from '../wailsjs/go/backend_golang/App'; import { Cache, checkUpdate, downloadProgramFiles, LocalConfig, refreshLocalModels, refreshModels } from './utils'; import { getStatus } from './apis'; @@ -125,19 +125,12 @@ async function initLocalModelsNotify() { }); } -type monitorData = { - usedMemory: number; - totalMemory: number; - gpuUsage: number; - gpuPower: number; - usedVram: number; - totalVram: number; -} - async function initHardwareMonitor() { EventsOn('monitor', (data: string) => { - const results: monitorData = JSON.parse(data); - if (results) + const results: MonitorData = JSON.parse(data); + if (results) { + commonStore.setMonitorData(results); WindowSetTitle(`RWKV-Runner (${t('RAM')}: ${results.usedMemory.toFixed(1)}/${results.totalMemory.toFixed(1)} GB, ${t('VRAM')}: ${(results.usedVram / 1024).toFixed(1)}/${(results.totalVram / 1024).toFixed(1)} GB, ${t('GPU Usage')}: ${results.gpuUsage}%)`); + } }); } diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts index 08bf0c1..7dc5e9a 100644 --- a/frontend/src/stores/commonStore.ts +++ b/frontend/src/stores/commonStore.ts @@ -7,7 +7,7 @@ import { defaultCompositionPrompt, defaultModelConfigs, defaultModelConfigsMac } import { ChartData } from 'chart.js'; import { Preset } from '../types/presets'; import { AboutContent } from '../types/about'; -import { Conversation } from '../types/chat'; +import { Attachment, Conversation } from '../types/chat'; import { CompletionPreset } from '../types/completion'; import { CompositionParams } from '../types/composition'; import { ModelConfig } from '../types/configs'; @@ -30,10 +30,13 @@ export type Status = { device_name: string; } -export type Attachment = { - name: string; - size: number; - content: string; +export type MonitorData = { + usedMemory: number; + totalMemory: number; + gpuUsage: number; + gpuPower: number; + usedVram: number; + totalVram: number; } export type Platform = 'windows' | 'darwin' | 'linux' | 'web'; @@ -45,6 +48,7 @@ class CommonStore { pid: 0, device_name: 'CPU' }; + monitorData: MonitorData | null = null; depComplete: boolean = false; platform: Platform = 'windows'; // presets manager @@ -254,6 +258,10 @@ class CommonStore { this.completionGenerating = value; } + setMonitorData(value: MonitorData) { + this.monitorData = value; + } + setPlatform(value: Platform) { this.platform = value; } diff --git a/frontend/src/types/chat.ts b/frontend/src/types/chat.ts index 1ac9885..083cecd 100644 --- a/frontend/src/types/chat.ts +++ b/frontend/src/types/chat.ts @@ -26,4 +26,9 @@ export type Role = 'assistant' | 'user' | 'system'; export type ConversationMessage = { role: Role; content: string; +} +export type Attachment = { + name: string; + size: number; + content: string; } \ No newline at end of file