diff --git a/src/renderer/src/services/AssistantService.ts b/src/renderer/src/services/AssistantService.ts index 311b1d1528..f11dba8ec4 100644 --- a/src/renderer/src/services/AssistantService.ts +++ b/src/renderer/src/services/AssistantService.ts @@ -24,6 +24,19 @@ import { uuid } from '@renderer/utils' const logger = loggerService.withContext('AssistantService') +export const DEFAULT_ASSISTANT_SETTINGS: AssistantSettings = { + temperature: DEFAULT_TEMPERATURE, + enableTemperature: true, + contextCount: DEFAULT_CONTEXTCOUNT, + enableMaxTokens: false, + maxTokens: 0, + streamOutput: true, + topP: 1, + enableTopP: true, + toolUseMode: 'prompt', + customParameters: [] +} + export function getDefaultAssistant(): Assistant { return { id: 'default', @@ -34,18 +47,7 @@ export function getDefaultAssistant(): Assistant { messages: [], type: 'assistant', regularPhrases: [], // Added regularPhrases - settings: { - temperature: DEFAULT_TEMPERATURE, - enableTemperature: true, - contextCount: DEFAULT_CONTEXTCOUNT, - enableMaxTokens: false, - maxTokens: 0, - streamOutput: true, - topP: 1, - enableTopP: true, - toolUseMode: 'prompt', - customParameters: [] - } + settings: DEFAULT_ASSISTANT_SETTINGS } } @@ -171,18 +173,7 @@ export async function createAssistantFromAgent(agent: Agent) { model: agent.defaultModel, type: 'assistant', regularPhrases: agent.regularPhrases || [], // Ensured regularPhrases - settings: agent.settings || { - temperature: DEFAULT_TEMPERATURE, - enableTemperature: true, - contextCount: DEFAULT_CONTEXTCOUNT, - enableMaxTokens: false, - maxTokens: 0, - streamOutput: true, - topP: 1, - enableTopP: true, - toolUseMode: 'prompt', - customParameters: [] - } + settings: agent.settings || DEFAULT_ASSISTANT_SETTINGS } store.dispatch(addAssistant(assistant)) diff --git a/src/renderer/src/store/index.ts b/src/renderer/src/store/index.ts index aa58b36931..d90ee7282d 100644 --- a/src/renderer/src/store/index.ts +++ b/src/renderer/src/store/index.ts @@ -62,7 +62,7 @@ const persistedReducer = persistReducer( { key: 'cherry-studio', storage, - version: 135, + version: 136, blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs'], migrate }, diff --git a/src/renderer/src/store/migrate.ts b/src/renderer/src/store/migrate.ts index f83a384a46..ee677ead39 100644 --- a/src/renderer/src/store/migrate.ts +++ b/src/renderer/src/store/migrate.ts @@ -4,15 +4,16 @@ import { DEFAULT_CONTEXTCOUNT, DEFAULT_TEMPERATURE, isMac } from '@renderer/conf import { DEFAULT_MIN_APPS } from '@renderer/config/minapps' import { isFunctionCallingModel, isNotSupportedTextDelta, SYSTEM_MODELS } from '@renderer/config/models' import { TRANSLATE_PROMPT } from '@renderer/config/prompts' -import { DEFAULT_SIDEBAR_ICONS } from '@renderer/config/sidebar' import { isSupportArrayContentProvider, isSupportDeveloperRoleProvider, isSupportStreamOptionsProvider, SYSTEM_PROVIDERS } from '@renderer/config/providers' +import { DEFAULT_SIDEBAR_ICONS } from '@renderer/config/sidebar' import db from '@renderer/databases' import i18n from '@renderer/i18n' +import { DEFAULT_ASSISTANT_SETTINGS } from '@renderer/services/AssistantService' import { Assistant, isSystemProvider, @@ -2150,24 +2151,27 @@ const migrateConfig = { '135': (state: RootState) => { try { if (!state.assistants.defaultAssistant.settings) { - state.assistants.defaultAssistant.settings = { - temperature: DEFAULT_TEMPERATURE, - enableTemperature: true, - contextCount: DEFAULT_CONTEXTCOUNT, - enableMaxTokens: false, - maxTokens: 0, - streamOutput: true, - topP: 1, - enableTopP: true, - toolUseMode: 'prompt', - customParameters: [] - } + state.assistants.defaultAssistant.settings = DEFAULT_ASSISTANT_SETTINGS } else if (!state.assistants.defaultAssistant.settings.toolUseMode) { state.assistants.defaultAssistant.settings.toolUseMode = 'prompt' } return state } catch (error) { - logger.error('migrate 134 error', error as Error) + logger.error('migrate 135 error', error as Error) + return state + } + }, + '136': (state: RootState) => { + try { + state.settings.sidebarIcons.visible = [...new Set(state.settings.sidebarIcons.visible)].filter((icon) => + DEFAULT_SIDEBAR_ICONS.includes(icon) + ) + state.settings.sidebarIcons.disabled = [...new Set(state.settings.sidebarIcons.disabled)].filter((icon) => + DEFAULT_SIDEBAR_ICONS.includes(icon) + ) + return state + } catch (error) { + logger.error('migrate 136 error', error as Error) return state } } diff --git a/src/renderer/src/types/index.ts b/src/renderer/src/types/index.ts index f889056ab1..147408d83c 100644 --- a/src/renderer/src/types/index.ts +++ b/src/renderer/src/types/index.ts @@ -692,7 +692,15 @@ export const isAutoDetectionMethod = (method: string): method is AutoDetectionMe return Object.hasOwn(AutoDetectionMethods, method) } -export type SidebarIcon = 'assistants' | 'agents' | 'paintings' | 'translate' | 'minapp' | 'knowledge' | 'files' | 'code_tools' +export type SidebarIcon = + | 'assistants' + | 'agents' + | 'paintings' + | 'translate' + | 'minapp' + | 'knowledge' + | 'files' + | 'code_tools' export type ExternalToolResult = { mcpTools?: MCPTool[]