Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#2627 from imldy/dev_title-generatio…
Browse files Browse the repository at this point in the history
…n-checkbox
  • Loading branch information
Yidadaa authored Aug 14, 2023
2 parents 25ada1e + 803b66a commit 9d3dff4
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
16 changes: 16 additions & 0 deletions app/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 4 additions & 0 deletions app/locales/cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ const cn = {
Title: "预览气泡",
SubTitle: "在预览气泡中预览 Markdown 内容",
},
AutoGenerateTitle: {
Title: "自动生成标题",
SubTitle: "根据对话内容生成合适的标题",
},
Mask: {
Splash: {
Title: "面具启动页",
Expand Down
4 changes: 4 additions & 0 deletions app/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions app/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ export const useChatStore = create<ChatStore>()(
},

summarizeSession() {
const config = useAppConfig.getState();
const session = get().currentSession();

// remove error messages if any
Expand All @@ -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
) {
Expand Down
7 changes: 6 additions & 1 deletion app/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const DEFAULT_CONFIG = {
theme: Theme.Auto as Theme,
tightBorder: !!getClientConfig()?.isApp,
sendPreviewBubble: true,
enableAutoGenerateTitle: true,
sidebarWidth: 300,

disablePromptHint: false,
Expand Down Expand Up @@ -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;

Expand All @@ -170,6 +171,10 @@ export const useAppConfig = create<ChatConfigStore>()(
state.modelConfig.enableInjectSystemPrompts = true;
}

if (version < 3.7) {
state.enableAutoGenerateTitle = true;
}

return state as any;
},
},
Expand Down

0 comments on commit 9d3dff4

Please sign in to comment.