fix: non streamoutput sometimes (#7512)

* feat(migrate): add default settings for assistants during migration

- Introduced a new migration step to assign default settings for assistants that lack configuration.
- Default settings include temperature, context count, and other parameters to ensure consistent behavior across the application.

* chore(store): increment version number to 115 for persisted reducer
This commit is contained in:
SuYao 2025-06-25 12:49:00 +08:00 committed by GitHub
parent 17951ad157
commit 9fe5fb9a91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 2 deletions

View File

@ -50,7 +50,7 @@ const persistedReducer = persistReducer(
{
key: 'cherry-studio',
storage,
version: 114,
version: 115,
blacklist: ['runtime', 'messages', 'messageBlocks'],
migrate
},

View File

@ -1,5 +1,5 @@
import { nanoid } from '@reduxjs/toolkit'
import { isMac } from '@renderer/config/constant'
import { DEFAULT_CONTEXTCOUNT, DEFAULT_TEMPERATURE, isMac } from '@renderer/config/constant'
import { DEFAULT_MIN_APPS } from '@renderer/config/minapps'
import { SYSTEM_MODELS } from '@renderer/config/models'
import { TRANSLATE_PROMPT } from '@renderer/config/prompts'
@ -1611,6 +1611,26 @@ const migrateConfig = {
} catch (error) {
return state
}
},
'115': (state: RootState) => {
try {
state.assistants.assistants.forEach((assistant) => {
if (!assistant.settings) {
assistant.settings = {
temperature: DEFAULT_TEMPERATURE,
contextCount: DEFAULT_CONTEXTCOUNT,
topP: 1,
toolUseMode: 'prompt',
customParameters: [],
streamOutput: true,
enableMaxTokens: false
}
}
})
return state
} catch (error) {
return state
}
}
}