From 9fe5fb9a91dfa18bd09be578bf09f2465dfcca7d Mon Sep 17 00:00:00 2001 From: SuYao Date: Wed, 25 Jun 2025 12:49:00 +0800 Subject: [PATCH] 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 --- src/renderer/src/store/index.ts | 2 +- src/renderer/src/store/migrate.ts | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/store/index.ts b/src/renderer/src/store/index.ts index 81b547eed1..ae5c52a9fb 100644 --- a/src/renderer/src/store/index.ts +++ b/src/renderer/src/store/index.ts @@ -50,7 +50,7 @@ const persistedReducer = persistReducer( { key: 'cherry-studio', storage, - version: 114, + version: 115, blacklist: ['runtime', 'messages', 'messageBlocks'], migrate }, diff --git a/src/renderer/src/store/migrate.ts b/src/renderer/src/store/migrate.ts index ece6204f66..df89be66b8 100644 --- a/src/renderer/src/store/migrate.ts +++ b/src/renderer/src/store/migrate.ts @@ -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 + } } }