feat: Add thought content auto-collapse setting

This commit is contained in:
ousugo 2025-02-19 23:22:54 +08:00 committed by 亢奋猫
parent bf51a0b5c6
commit 32da853f27
8 changed files with 39 additions and 7 deletions

View File

@ -121,6 +121,8 @@
"settings.top_p.tip": "Default value is 1, the smaller the value, the less variety in the answers, the easier to understand, the larger the value, the larger the range of the AI's vocabulary, the more diverse",
"settings.max_tokens.confirm": "Enable max tokens limit",
"settings.max_tokens.confirm_content": "Enable max tokens limit, affects the length of the result. Need to consider the context limit of the model, otherwise an error will be reported",
"settings.thought_auto_collapse": "Automatically Collapse Thought Content",
"settings.thought_auto_collapse.tip": "Automatically collapse thought content after thinking ends",
"suggestions.title": "Suggested Questions",
"thinking": "Thinking",
"topics.auto_rename": "Auto Rename",

View File

@ -121,6 +121,8 @@
"settings.top_p.tip": "デフォルト値は1で、値が小さいほど回答の多様性が減り、理解しやすくなります。値が大きいほど、AIの語彙範囲が広がり、多様性が増します",
"settings.max_tokens.confirm": "最大トークン制限を有効にする",
"settings.max_tokens.confirm_content": "最大トークン制限を有効にすると、モデルが生成できる最大トークン数が制限されます。これにより、返される結果の長さに影響が出る可能性があります。モデルのコンテキスト制限に基づいて設定する必要があります。そうしないとエラーが発生します",
"settings.thought_auto_collapse": "思考内容を自動的に折りたたむ",
"settings.thought_auto_collapse.tip": "思考が終了したら思考内容を自動的に折りたたみます",
"suggestions.title": "提案された質問",
"thinking": "思考中...",
"topics.auto_rename": "自動リネーム",

View File

@ -121,6 +121,8 @@
"settings.top_p.tip": "Значение по умолчанию 1, чем меньше значение, тем меньше вариативности в ответах, тем проще понять, чем больше значение, тем больше вариативности в ответах, тем больше разнообразие",
"settings.max_tokens.confirm": "Включить лимит максимальных токенов",
"settings.max_tokens.confirm_content": "Включить лимит максимальных токенов, влияет на длину результата. Нужно учитывать контекст модели, иначе будет ошибка",
"settings.thought_auto_collapse": "Автоматически сворачивать содержание мыслей",
"settings.thought_auto_collapse.tip": "Автоматически сворачивать содержание мыслей после завершения размышления",
"suggestions.title": "Предложенные вопросы",
"thinking": "Мыслим",
"topics.auto_rename": "Автопереименование",

View File

@ -123,6 +123,8 @@
"settings.top_p.tip": "默认值为 1值越小AI 生成的内容越单调也越容易理解值越大AI 回复的词汇围越大,越多样化",
"settings.max_tokens.confirm": "开启消息长度限制",
"settings.max_tokens.confirm_content": "开启消息长度限制后,单次交互所用的最大 Token 数, 会影响返回结果的长度。要根据模型上下文限制来设置,否则会报错",
"settings.thought_auto_collapse": "思考内容自动折叠",
"settings.thought_auto_collapse.tip": "思考结束后思考内容自动折叠",
"suggestions.title": "建议的问题",
"thinking": "思考中",
"topics.auto_rename": "生成话题名",

View File

@ -121,6 +121,8 @@
"settings.top_p.tip": "模型生成文本的隨機程度。值越小AI 生成的內容越單調也越容易理解值越大AI 回覆的詞彙範圍越大,越多樣化",
"settings.max_tokens.confirm": "啟用消息長度限制",
"settings.max_tokens.confirm_content": "啟用消息長度限制後,單次交互所用的最大 Token 數, 會影響返回結果的長度。要根據模型上下文限制來設置,否則會報錯",
"settings.thought_auto_collapse": "思考內容自動折疊",
"settings.thought_auto_collapse.tip": "思考結束後思考內容自動折疊",
"suggestions.title": "建議的問題",
"thinking": "思考中",
"topics.auto_rename": "自動重新命名",

View File

@ -18,7 +18,7 @@ const MessageThought: FC<Props> = ({ message }) => {
const [copied, setCopied] = useState(false)
const isThinking = !message.content
const { t } = useTranslation()
const { messageFont, fontSize } = useSettings()
const { messageFont, fontSize, thoughtAutoCollapse } = useSettings()
const fontFamily = useMemo(() => {
return messageFont === 'serif'
? 'serif'
@ -26,8 +26,8 @@ const MessageThought: FC<Props> = ({ message }) => {
}, [messageFont])
useEffect(() => {
if (!isThinking) setActiveKey('')
}, [isThinking])
if (!isThinking && thoughtAutoCollapse) setActiveKey('')
}, [isThinking, thoughtAutoCollapse])
if (!message.reasoning_content) {
return null

View File

@ -27,7 +27,8 @@ import {
setPasteLongTextThreshold,
setRenderInputMessageAsMarkdown,
setShowInputEstimatedTokens,
setShowMessageDivider
setShowMessageDivider,
setThoughtAutoCollapse
} from '@renderer/store/settings'
import { Assistant, AssistantSettings, ThemeMode, TranslateLanguageVarious } from '@renderer/types'
import { modalConfirm } from '@renderer/utils'
@ -69,7 +70,8 @@ const SettingsTab: FC<Props> = (props) => {
mathEngine,
autoTranslateWithSpace,
pasteLongTextThreshold,
multiModelMessageStyle
multiModelMessageStyle,
thoughtAutoCollapse
} = useSettings()
const onUpdateAssistantSettings = (settings: Partial<AssistantSettings>) => {
@ -261,6 +263,20 @@ const SettingsTab: FC<Props> = (props) => {
/>
</SettingRow>
<SettingDivider />
<SettingRow>
<SettingRowTitleSmall>
{t('chat.settings.thought_auto_collapse')}
<Tooltip title={t('chat.settings.thought_auto_collapse.tip')}>
<QuestionIcon style={{ marginLeft: 4 }} />
</Tooltip>
</SettingRowTitleSmall>
<Switch
size="small"
checked={thoughtAutoCollapse}
onChange={(checked) => dispatch(setThoughtAutoCollapse(checked))}
/>
</SettingRow>
<SettingDivider />
<SettingRow>
<SettingRowTitleSmall>{t('message.message.style')}</SettingRowTitleSmall>
<Select

View File

@ -70,6 +70,7 @@ export interface SettingsState {
notionDatabaseID: string | null
notionApiKey: string | null
notionPageNameKey: string | null
thoughtAutoCollapse: boolean
}
export type MultiModelMessageStyle = 'horizontal' | 'vertical' | 'fold' | 'grid'
@ -125,7 +126,8 @@ const initialState: SettingsState = {
multiModelMessageStyle: 'fold',
notionDatabaseID: '',
notionApiKey: '',
notionPageNameKey: 'Name'
notionPageNameKey: 'Name',
thoughtAutoCollapse: true
}
const settingsSlice = createSlice({
@ -288,6 +290,9 @@ const settingsSlice = createSlice({
},
setNotionPageNameKey: (state, action: PayloadAction<string>) => {
state.notionPageNameKey = action.payload
},
setThoughtAutoCollapse: (state, action: PayloadAction<boolean>) => {
state.thoughtAutoCollapse = action.payload
}
}
})
@ -342,7 +347,8 @@ export const {
setMultiModelMessageStyle,
setNotionDatabaseID,
setNotionApiKey,
setNotionPageNameKey
setNotionPageNameKey,
setThoughtAutoCollapse
} = settingsSlice.actions
export default settingsSlice.reducer