From 20a508e2d6e16252e44f6a9cbb07dd5c195b6fc3 Mon Sep 17 00:00:00 2001 From: imldy Date: Sat, 15 Jul 2023 02:13:39 +0800 Subject: [PATCH] feat: add autoGenerateTitle option (cherry picked from commit 656ab94a9c4edfee820616b8cfc39f5ee9952a3a) --- app/components/settings.tsx | 16 ++++++++++++++++ app/locales/cn.ts | 5 +++++ app/locales/en.ts | 5 +++++ app/store/chat.ts | 2 ++ app/store/config.ts | 7 ++++++- 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/components/settings.tsx b/app/components/settings.tsx index c438f68c..1e6ef713 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -529,6 +529,22 @@ export function Settings() { > + + + updateConfig( + (config) => + (config.enableAutoGenerateTitle = e.currentTarget.checked), + ) + } + > + + ()( }, summarizeSession() { + const config = useAppConfig.getState(); const session = get().currentSession(); // remove error messages if any @@ -487,6 +488,7 @@ export const useChatStore = create()( // should summarize topic after chating more than 50 words const SUMMARIZE_MIN_LEN = 50; if ( + config.enableAutoGenerateTitle && session.topic === DEFAULT_TOPIC && countMessages(messages) >= SUMMARIZE_MIN_LEN ) { diff --git a/app/store/config.ts b/app/store/config.ts index d963d39d..7070ea05 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -27,6 +27,7 @@ export const DEFAULT_CONFIG = { theme: Theme.Auto as Theme, tightBorder: !!getClientConfig()?.isApp, sendPreviewBubble: true, + enableAutoGenerateTitle: true, sidebarWidth: 300, disablePromptHint: false, @@ -147,7 +148,7 @@ export const useAppConfig = create()( }), { name: StoreKey.Config, - version: 3.6, + version: 3.7, migrate(persistedState, version) { const state = persistedState as ChatConfig; @@ -170,6 +171,10 @@ export const useAppConfig = create()( state.modelConfig.enableInjectSystemPrompts = true; } + if (version < 3.7) { + state.enableAutoGenerateTitle = true; + } + return state as any; }, },