Merge pull request #2627 from imldy/dev_title-generation-checkbox

This commit is contained in:
Yifei Zhang 2023-08-14 22:12:26 +08:00 committed by GitHub
commit 9d3dff47d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 1 deletions

View File

@ -529,6 +529,22 @@ export function Settings() {
></InputRange>
</ListItem>
<ListItem
title={Locale.Settings.AutoGenerateTitle.Title}
subTitle={Locale.Settings.AutoGenerateTitle.SubTitle}
>
<input
type="checkbox"
checked={config.enableAutoGenerateTitle}
onChange={(e) =>
updateConfig(
(config) =>
(config.enableAutoGenerateTitle = e.currentTarget.checked),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.SendPreviewBubble.Title}
subTitle={Locale.Settings.SendPreviewBubble.SubTitle}

View File

@ -170,6 +170,10 @@ const cn = {
Title: "预览气泡",
SubTitle: "在预览气泡中预览 Markdown 内容",
},
AutoGenerateTitle: {
Title: "自动生成标题",
SubTitle: "根据对话内容生成合适的标题",
},
Mask: {
Splash: {
Title: "面具启动页",

View File

@ -172,6 +172,10 @@ const en: LocaleType = {
Title: "Send Preview Bubble",
SubTitle: "Preview markdown in bubble",
},
AutoGenerateTitle: {
Title: "Auto Generate Title",
SubTitle: "Generate a suitable title based on the conversation content",
},
Mask: {
Splash: {
Title: "Mask Splash Screen",

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
) {

View File

@ -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<ChatConfigStore>()(
}),
{
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<ChatConfigStore>()(
state.modelConfig.enableInjectSystemPrompts = true;
}
if (version < 3.7) {
state.enableAutoGenerateTitle = true;
}
return state as any;
},
},