feat: add autoGenerateTitle option

(cherry picked from commit 656ab94a9c4edfee820616b8cfc39f5ee9952a3a)
This commit is contained in:
imldy
2023-07-15 02:13:39 +08:00
parent d45c61109f
commit 20a508e2d6
5 changed files with 34 additions and 1 deletions

View File

@@ -479,6 +479,7 @@ export const useChatStore = create<ChatStore>()(
},
summarizeSession() {
const config = useAppConfig.getState();
const session = get().currentSession();
// remove error messages if any
@@ -487,6 +488,7 @@ export const useChatStore = create<ChatStore>()(
// 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
) {