From 801dc412f99937dfd64a895309d9304429d94cac Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Thu, 24 Oct 2024 15:28:05 +0800 Subject: [PATCH 1/4] add claude-3.5-haiku --- app/constant.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/constant.ts b/app/constant.ts index 9774bb594dd..00b8d9dae95 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -319,6 +319,7 @@ const anthropicModels = [ "claude-3-opus-20240229", "claude-3-haiku-20240307", "claude-3-5-sonnet-20240620", + "claude-3-5-haiku-latest", ]; const baiduModels = [ From e49466fa054c702898780967812abe2dabd4ba6b Mon Sep 17 00:00:00 2001 From: Dogtiti <499960698@qq.com> Date: Mon, 4 Nov 2024 21:25:56 +0800 Subject: [PATCH 2/4] feat: update real 'currentSession' --- app/components/chat.tsx | 2 +- app/store/chat.ts | 31 ++++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 3d5b6a4f2c4..a62021db3d2 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -1607,7 +1607,7 @@ function _Chat() { title={Locale.Chat.Actions.RefreshTitle} onClick={() => { showToast(Locale.Chat.Actions.RefreshToast); - chatStore.summarizeSession(true); + chatStore.summarizeSession(true, session); }} /> diff --git a/app/store/chat.ts b/app/store/chat.ts index 1bf2e13677b..4208692e270 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -352,13 +352,13 @@ export const useChatStore = createPersistStore( return session; }, - onNewMessage(message: ChatMessage) { - get().updateCurrentSession((session) => { + onNewMessage(message: ChatMessage, targetSession: ChatSession) { + get().updateTargetSession(targetSession, (session) => { session.messages = session.messages.concat(); session.lastUpdate = Date.now(); }); get().updateStat(message); - get().summarizeSession(); + get().summarizeSession(false, targetSession); }, async onUserInput(content: string, attachImages?: string[]) { @@ -428,7 +428,7 @@ export const useChatStore = createPersistStore( botMessage.streaming = false; if (message) { botMessage.content = message; - get().onNewMessage(botMessage); + get().onNewMessage(botMessage, session); } ChatControllerPool.remove(session.id, botMessage.id); }, @@ -598,9 +598,12 @@ export const useChatStore = createPersistStore( }); }, - summarizeSession(refreshTitle: boolean = false) { + summarizeSession( + refreshTitle: boolean = false, + targetSession: ChatSession, + ) { const config = useAppConfig.getState(); - const session = get().currentSession(); + const session = targetSession; const modelConfig = session.mask.modelConfig; // skip summarize when using dalle3? if (isDalle3(modelConfig.model)) { @@ -651,7 +654,8 @@ export const useChatStore = createPersistStore( }, onFinish(message, responseRes) { if (responseRes?.status === 200) { - get().updateCurrentSession( + get().updateTargetSession( + session, (session) => (session.topic = message.length > 0 ? trimTopic(message) : DEFAULT_TOPIC), @@ -719,7 +723,7 @@ export const useChatStore = createPersistStore( onFinish(message, responseRes) { if (responseRes?.status === 200) { console.log("[Memory] ", message); - get().updateCurrentSession((session) => { + get().updateTargetSession(session, (session) => { session.lastSummarizeIndex = lastSummarizeIndex; session.memoryPrompt = message; // Update the memory prompt for stored it in local storage }); @@ -745,7 +749,16 @@ export const useChatStore = createPersistStore( updater(sessions[index]); set(() => ({ sessions })); }, - + updateTargetSession( + targetSession: ChatSession, + updater: (session: ChatSession) => void, + ) { + const sessions = get().sessions; + const index = sessions.findIndex((s) => s.id === targetSession.id); + if (index < 0) return; + updater(sessions[index]); + set(() => ({ sessions })); + }, async clearAllData() { await indexedDBStorage.clear(); localStorage.clear(); From 0ec423389fa08e4e4b046db5ad147194622b6218 Mon Sep 17 00:00:00 2001 From: DDMeaqua Date: Tue, 5 Nov 2024 11:06:20 +0800 Subject: [PATCH 3/4] chore: update readme --- README.md | 8 ++++++++ README_CN.md | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index dd2c5b1eedc..fce62ba3750 100644 --- a/README.md +++ b/README.md @@ -301,6 +301,14 @@ iflytek Api Key. iflytek Api Secret. +### `CHATGLM_API_KEY` (optional) + +ChatGLM Api Key. + +### `CHATGLM_URL` (optional) + +ChatGLM Api Url. + ### `HIDE_USER_API_KEY` (optional) > Default: Empty diff --git a/README_CN.md b/README_CN.md index ccdcf28ffe9..d4da8b9da13 100644 --- a/README_CN.md +++ b/README_CN.md @@ -184,6 +184,13 @@ ByteDance Api Url. 讯飞星火Api Secret. +### `CHATGLM_API_KEY` (可选) + +ChatGLM Api Key. + +### `CHATGLM_URL` (可选) + +ChatGLM Api Url. ### `HIDE_USER_API_KEY` (可选) From 00d6cb27f719caffd24518db3dd656b7380a9062 Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Tue, 5 Nov 2024 17:42:55 +0800 Subject: [PATCH 4/4] update version --- src-tauri/tauri.conf.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 415825b13f2..7e08d9070e5 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -9,7 +9,7 @@ }, "package": { "productName": "NextChat", - "version": "2.15.6" + "version": "2.15.7" }, "tauri": { "allowlist": {