From 08cd0de89b1439cfe2efcec8cfd8c828e43b2c18 Mon Sep 17 00:00:00 2001 From: thzxx Date: Sun, 5 Apr 2026 00:01:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=BB=BA=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E6=97=B6=E8=87=AA=E5=8A=A8=E9=87=8A=E6=94=BE=E6=98=BE=E5=AD=98?= =?UTF-8?q?=EF=BC=8C=E6=B8=85=E7=90=86=E6=A8=A1=E5=9E=8B=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/app.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/app.js b/js/app.js index eba04ab..2416db5 100644 --- a/js/app.js +++ b/js/app.js @@ -59,6 +59,17 @@ async function startNewSession() { await db.saveSession(currentSession); } + // 释放显存,清理模型上下文 + const api = state.get(KEYS.API); + const model = currentSession?.model || state.get('_defaultModel', ''); + if (api && model) { + try { + await api.chat({ model, messages: [], keep_alive: 0 }); + } catch (e) { + console.warn('[App] 释放显存失败:', e); + } + } + const session = createNewSession(); state.set(KEYS.CURRENT_SESSION, session); state.set(KEYS.IS_HISTORY_VIEW, false);