mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 14:29:15 +08:00
fix: conditionally enable reasoning middleware for OpenAI and Azure providers
- Added a check to enable the 'thinking-tag-extraction' middleware only if reasoning is enabled in the configuration for OpenAI and Azure providers. - Commented out the provider type check in `getAiSdkProviderId` to prevent issues with retrieving provider options.
This commit is contained in:
parent
786bc8dca9
commit
61e3309cd2
@ -146,11 +146,13 @@ function addProviderSpecificMiddlewares(builder: AiSdkMiddlewareBuilder, config:
|
|||||||
break
|
break
|
||||||
case 'openai':
|
case 'openai':
|
||||||
case 'azure-openai': {
|
case 'azure-openai': {
|
||||||
const tagName = config.model?.id.includes('gemini') ? tagNameArray[1] : tagNameArray[0]
|
if (config.enableReasoning) {
|
||||||
builder.add({
|
const tagName = config.model?.id.includes('gemini') ? tagNameArray[1] : tagNameArray[0]
|
||||||
name: 'thinking-tag-extraction',
|
builder.add({
|
||||||
middleware: extractReasoningMiddleware({ tagName })
|
name: 'thinking-tag-extraction',
|
||||||
})
|
middleware: extractReasoningMiddleware({ tagName })
|
||||||
|
})
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'gemini':
|
case 'gemini':
|
||||||
|
|||||||
@ -26,9 +26,10 @@ export function getAiSdkProviderId(provider: Provider): ProviderId | 'openai-com
|
|||||||
if (AiCore.isSupported(provider.id)) {
|
if (AiCore.isSupported(provider.id)) {
|
||||||
return provider.id as ProviderId
|
return provider.id as ProviderId
|
||||||
}
|
}
|
||||||
if (AiCore.isSupported(provider.type)) {
|
// 先注释掉,会影响获取providerOptions
|
||||||
return provider.type as ProviderId
|
// if (AiCore.isSupported(provider.type)) {
|
||||||
}
|
// return provider.type as ProviderId
|
||||||
|
// }
|
||||||
|
|
||||||
return provider.id as ProviderId
|
return provider.id as ProviderId
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user