mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 05:11:24 +08:00
refactor(aiCore): streamline provider options and enhance OpenAI handling
- Simplified the OpenAI mode handling in the provider configuration. - Added service tier settings to provider-specific options for better configuration management. - Refactored the `buildOpenAIProviderOptions` function to remove redundant parameters and improve clarity.
This commit is contained in:
parent
efeada281a
commit
2ca5116769
@ -85,7 +85,7 @@ export function providerToAiSdkConfig(
|
||||
baseURL: actualProvider.apiHost,
|
||||
apiKey: actualProvider.apiKey
|
||||
}
|
||||
// 处理OpenAI模式(简化逻辑)
|
||||
// 处理OpenAI模式
|
||||
const extraOptions: any = {}
|
||||
if (actualProvider.type === 'openai-response' && !isOpenAIChatCompletionOnlyModel(model)) {
|
||||
extraOptions.mode = 'responses'
|
||||
|
||||
@ -70,13 +70,15 @@ export function buildProviderOptions(
|
||||
const providerId = getAiSdkProviderId(actualProvider)
|
||||
// 构建 provider 特定的选项
|
||||
let providerSpecificOptions: Record<string, any> = {}
|
||||
|
||||
const serviceTierSetting = getServiceTier(model, actualProvider)
|
||||
providerSpecificOptions.serviceTier = serviceTierSetting
|
||||
// 根据 provider 类型分离构建逻辑
|
||||
switch (providerId) {
|
||||
case 'openai':
|
||||
case 'azure':
|
||||
providerSpecificOptions = {
|
||||
...buildOpenAIProviderOptions(assistant, model, capabilities, actualProvider)
|
||||
...buildOpenAIProviderOptions(assistant, model, capabilities),
|
||||
serviceTier: serviceTierSetting
|
||||
}
|
||||
break
|
||||
|
||||
@ -95,7 +97,10 @@ export function buildProviderOptions(
|
||||
|
||||
default:
|
||||
// 对于其他 provider,使用通用的构建逻辑
|
||||
providerSpecificOptions = buildGenericProviderOptions(assistant, model, capabilities)
|
||||
providerSpecificOptions = {
|
||||
...buildGenericProviderOptions(assistant, model, capabilities),
|
||||
serviceTier: serviceTierSetting
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
@ -121,19 +126,16 @@ function buildOpenAIProviderOptions(
|
||||
enableReasoning: boolean
|
||||
enableWebSearch: boolean
|
||||
enableGenerateImage: boolean
|
||||
},
|
||||
actualProvider: Provider
|
||||
}
|
||||
): Record<string, any> {
|
||||
const { enableReasoning } = capabilities
|
||||
let providerOptions: Record<string, any> = {}
|
||||
const serviceTierSetting = getServiceTier(model, actualProvider)
|
||||
// OpenAI 推理参数
|
||||
if (enableReasoning) {
|
||||
const reasoningParams = getOpenAIReasoningParams(assistant, model)
|
||||
providerOptions = {
|
||||
...providerOptions,
|
||||
...reasoningParams,
|
||||
serviceTier: serviceTierSetting
|
||||
...reasoningParams
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user