forked from XiaoMo/ChatGPT-Next-Web
feat: add autoGenerateTitle option
(cherry picked from commit 656ab94a9c4edfee820616b8cfc39f5ee9952a3a)
This commit is contained in:
parent
d45c61109f
commit
20a508e2d6
@ -529,6 +529,22 @@ export function Settings() {
|
|||||||
></InputRange>
|
></InputRange>
|
||||||
</ListItem>
|
</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
|
<ListItem
|
||||||
title={Locale.Settings.SendPreviewBubble.Title}
|
title={Locale.Settings.SendPreviewBubble.Title}
|
||||||
subTitle={Locale.Settings.SendPreviewBubble.SubTitle}
|
subTitle={Locale.Settings.SendPreviewBubble.SubTitle}
|
||||||
|
@ -170,6 +170,11 @@ const cn = {
|
|||||||
Title: "预览气泡",
|
Title: "预览气泡",
|
||||||
SubTitle: "在预览气泡中预览 Markdown 内容",
|
SubTitle: "在预览气泡中预览 Markdown 内容",
|
||||||
},
|
},
|
||||||
|
AutoGenerateTitle: {
|
||||||
|
Title: "自动生成标题",
|
||||||
|
SubTitle:
|
||||||
|
"根据对话内容生成合适的标题(需标题为默认标题,并且内容长度大于设定的最小长度)",
|
||||||
|
},
|
||||||
Mask: {
|
Mask: {
|
||||||
Splash: {
|
Splash: {
|
||||||
Title: "面具启动页",
|
Title: "面具启动页",
|
||||||
|
@ -172,6 +172,11 @@ const en: LocaleType = {
|
|||||||
Title: "Send Preview Bubble",
|
Title: "Send Preview Bubble",
|
||||||
SubTitle: "Preview markdown in bubble",
|
SubTitle: "Preview markdown in bubble",
|
||||||
},
|
},
|
||||||
|
AutoGenerateTitle: {
|
||||||
|
Title: "Auto Generate Title",
|
||||||
|
SubTitle:
|
||||||
|
"Generate a suitable title based on the conversation content (requires default title and content length greater than the set minimum length)",
|
||||||
|
},
|
||||||
Mask: {
|
Mask: {
|
||||||
Splash: {
|
Splash: {
|
||||||
Title: "Mask Splash Screen",
|
Title: "Mask Splash Screen",
|
||||||
|
@ -479,6 +479,7 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
},
|
},
|
||||||
|
|
||||||
summarizeSession() {
|
summarizeSession() {
|
||||||
|
const config = useAppConfig.getState();
|
||||||
const session = get().currentSession();
|
const session = get().currentSession();
|
||||||
|
|
||||||
// remove error messages if any
|
// remove error messages if any
|
||||||
@ -487,6 +488,7 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
// should summarize topic after chating more than 50 words
|
// should summarize topic after chating more than 50 words
|
||||||
const SUMMARIZE_MIN_LEN = 50;
|
const SUMMARIZE_MIN_LEN = 50;
|
||||||
if (
|
if (
|
||||||
|
config.enableAutoGenerateTitle &&
|
||||||
session.topic === DEFAULT_TOPIC &&
|
session.topic === DEFAULT_TOPIC &&
|
||||||
countMessages(messages) >= SUMMARIZE_MIN_LEN
|
countMessages(messages) >= SUMMARIZE_MIN_LEN
|
||||||
) {
|
) {
|
||||||
|
@ -27,6 +27,7 @@ export const DEFAULT_CONFIG = {
|
|||||||
theme: Theme.Auto as Theme,
|
theme: Theme.Auto as Theme,
|
||||||
tightBorder: !!getClientConfig()?.isApp,
|
tightBorder: !!getClientConfig()?.isApp,
|
||||||
sendPreviewBubble: true,
|
sendPreviewBubble: true,
|
||||||
|
enableAutoGenerateTitle: true,
|
||||||
sidebarWidth: 300,
|
sidebarWidth: 300,
|
||||||
|
|
||||||
disablePromptHint: false,
|
disablePromptHint: false,
|
||||||
@ -147,7 +148,7 @@ export const useAppConfig = create<ChatConfigStore>()(
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: StoreKey.Config,
|
name: StoreKey.Config,
|
||||||
version: 3.6,
|
version: 3.7,
|
||||||
migrate(persistedState, version) {
|
migrate(persistedState, version) {
|
||||||
const state = persistedState as ChatConfig;
|
const state = persistedState as ChatConfig;
|
||||||
|
|
||||||
@ -170,6 +171,10 @@ export const useAppConfig = create<ChatConfigStore>()(
|
|||||||
state.modelConfig.enableInjectSystemPrompts = true;
|
state.modelConfig.enableInjectSystemPrompts = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (version < 3.7) {
|
||||||
|
state.enableAutoGenerateTitle = true;
|
||||||
|
}
|
||||||
|
|
||||||
return state as any;
|
return state as any;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user