mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-02 18:39:06 +08:00
fix: set developer role and service tier to default not supported (#9245)
* refactor(api): 将 isNotSupportDeveloperRole 替换为 isSupportDeveloperRole 重构开发者角色支持逻辑,使用正向命名的 isSupportDeveloperRole 替代反向命名的 isNotSupportDeveloperRole 更新相关迁移逻辑和配置检查逻辑 * refactor(api): 替换 isNotSupportServiceTier 为 isSupportServiceTier 将服务层级支持的否定式参数改为肯定式参数,修改默认行为为不支持
This commit is contained in:
parent
aed9566409
commit
e652c1d783
@ -52,7 +52,14 @@ import VoyageAIProviderLogo from '@renderer/assets/images/providers/voyageai.png
|
|||||||
import XirangProviderLogo from '@renderer/assets/images/providers/xirang.png'
|
import XirangProviderLogo from '@renderer/assets/images/providers/xirang.png'
|
||||||
import ZeroOneProviderLogo from '@renderer/assets/images/providers/zero-one.png'
|
import ZeroOneProviderLogo from '@renderer/assets/images/providers/zero-one.png'
|
||||||
import ZhipuProviderLogo from '@renderer/assets/images/providers/zhipu.png'
|
import ZhipuProviderLogo from '@renderer/assets/images/providers/zhipu.png'
|
||||||
import { AtLeast, OpenAIServiceTiers, Provider, SystemProvider, SystemProviderId } from '@renderer/types'
|
import {
|
||||||
|
AtLeast,
|
||||||
|
isSystemProvider,
|
||||||
|
OpenAIServiceTiers,
|
||||||
|
Provider,
|
||||||
|
SystemProvider,
|
||||||
|
SystemProviderId
|
||||||
|
} from '@renderer/types'
|
||||||
|
|
||||||
import { TOKENFLUX_HOST } from './constant'
|
import { TOKENFLUX_HOST } from './constant'
|
||||||
import { SYSTEM_MODELS } from './models'
|
import { SYSTEM_MODELS } from './models'
|
||||||
@ -1253,8 +1260,8 @@ const NOT_SUPPORT_DEVELOPER_ROLE_PROVIDERS = ['poe', 'qiniu'] as const satisfies
|
|||||||
*/
|
*/
|
||||||
export const isSupportDeveloperRoleProvider = (provider: Provider) => {
|
export const isSupportDeveloperRoleProvider = (provider: Provider) => {
|
||||||
return (
|
return (
|
||||||
provider.apiOptions?.isNotSupportDeveloperRole !== true &&
|
provider.apiOptions?.isSupportDeveloperRole === true ||
|
||||||
!NOT_SUPPORT_DEVELOPER_ROLE_PROVIDERS.some((pid) => pid === provider.id)
|
(isSystemProvider(provider) && !NOT_SUPPORT_DEVELOPER_ROLE_PROVIDERS.some((pid) => pid === provider.id))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1289,7 +1296,7 @@ const NOT_SUPPORT_SERVICE_TIER_PROVIDERS = ['github', 'copilot'] as const satisf
|
|||||||
*/
|
*/
|
||||||
export const isSupportServiceTierProvider = (provider: Provider) => {
|
export const isSupportServiceTierProvider = (provider: Provider) => {
|
||||||
return (
|
return (
|
||||||
provider.apiOptions?.isNotSupportServiceTier !== true &&
|
provider.apiOptions?.isSupportServiceTier === true ||
|
||||||
!NOT_SUPPORT_SERVICE_TIER_PROVIDERS.some((pid) => pid === provider.id)
|
(isSystemProvider(provider) && !NOT_SUPPORT_SERVICE_TIER_PROVIDERS.some((pid) => pid === provider.id))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,10 +39,10 @@ const ApiOptionsSettings = ({ providerId }: Props) => {
|
|||||||
tip: t('settings.provider.api.options.developer_role.help'),
|
tip: t('settings.provider.api.options.developer_role.help'),
|
||||||
onChange: (checked: boolean) => {
|
onChange: (checked: boolean) => {
|
||||||
updateProviderTransition({
|
updateProviderTransition({
|
||||||
apiOptions: { ...provider.apiOptions, isNotSupportDeveloperRole: !checked }
|
apiOptions: { ...provider.apiOptions, isSupportDeveloperRole: checked }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
checked: !provider.apiOptions?.isNotSupportDeveloperRole
|
checked: !!provider.apiOptions?.isSupportDeveloperRole
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'openai_stream_options',
|
key: 'openai_stream_options',
|
||||||
@ -61,10 +61,10 @@ const ApiOptionsSettings = ({ providerId }: Props) => {
|
|||||||
tip: t('settings.provider.api.options.service_tier.help'),
|
tip: t('settings.provider.api.options.service_tier.help'),
|
||||||
onChange: (checked: boolean) => {
|
onChange: (checked: boolean) => {
|
||||||
updateProviderTransition({
|
updateProviderTransition({
|
||||||
apiOptions: { ...provider.apiOptions, isNotSupportServiceTier: !checked }
|
apiOptions: { ...provider.apiOptions, isSupportServiceTier: checked }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
checked: !provider.apiOptions?.isNotSupportServiceTier
|
checked: !!provider.apiOptions?.isSupportServiceTier
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'openai_enable_thinking',
|
key: 'openai_enable_thinking',
|
||||||
|
|||||||
@ -62,7 +62,7 @@ const persistedReducer = persistReducer(
|
|||||||
{
|
{
|
||||||
key: 'cherry-studio',
|
key: 'cherry-studio',
|
||||||
storage,
|
storage,
|
||||||
version: 131,
|
version: 132,
|
||||||
blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs'],
|
blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs'],
|
||||||
migrate
|
migrate
|
||||||
},
|
},
|
||||||
|
|||||||
@ -2103,6 +2103,23 @@ const migrateConfig = {
|
|||||||
logger.error('migrate 131 error', error as Error)
|
logger.error('migrate 131 error', error as Error)
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'132': (state: RootState) => {
|
||||||
|
try {
|
||||||
|
state.llm.providers.forEach((p) => {
|
||||||
|
// 如果原本是undefined则不做改动,静默从默认支持改为默认不支持
|
||||||
|
if (p.apiOptions?.isNotSupportDeveloperRole) {
|
||||||
|
p.apiOptions.isSupportDeveloperRole = !p.apiOptions.isNotSupportDeveloperRole
|
||||||
|
}
|
||||||
|
if (p.apiOptions?.isNotSupportServiceTier) {
|
||||||
|
p.apiOptions.isSupportServiceTier = !p.apiOptions.isNotSupportServiceTier
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return state
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('migrate 132 error', error as Error)
|
||||||
|
return state
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -192,10 +192,18 @@ export type ProviderApiOptions = {
|
|||||||
isNotSupportArrayContent?: boolean
|
isNotSupportArrayContent?: boolean
|
||||||
/** 是否不支持 stream_options 参数 */
|
/** 是否不支持 stream_options 参数 */
|
||||||
isNotSupportStreamOptions?: boolean
|
isNotSupportStreamOptions?: boolean
|
||||||
/** 是否不支持 message 的 role 为 developer */
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* 是否不支持 message 的 role 为 developer */
|
||||||
isNotSupportDeveloperRole?: boolean
|
isNotSupportDeveloperRole?: boolean
|
||||||
/** 是否不支持 service_tier 参数. Only for OpenAI Models. */
|
/* 是否支持 message 的 role 为 developer */
|
||||||
|
isSupportDeveloperRole?: boolean
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* 是否不支持 service_tier 参数. Only for OpenAI Models. */
|
||||||
isNotSupportServiceTier?: boolean
|
isNotSupportServiceTier?: boolean
|
||||||
|
/* 是否支持 service_tier 参数. Only for OpenAI Models. */
|
||||||
|
isSupportServiceTier?: boolean
|
||||||
/** 是否不支持 enable_thinking 参数 */
|
/** 是否不支持 enable_thinking 参数 */
|
||||||
isNotSupportEnableThinking?: boolean
|
isNotSupportEnableThinking?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user