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:
suyao 2025-07-21 14:20:33 +08:00
parent 786bc8dca9
commit 61e3309cd2
No known key found for this signature in database
2 changed files with 11 additions and 8 deletions

View File

@ -146,11 +146,13 @@ function addProviderSpecificMiddlewares(builder: AiSdkMiddlewareBuilder, config:
break
case 'openai':
case 'azure-openai': {
const tagName = config.model?.id.includes('gemini') ? tagNameArray[1] : tagNameArray[0]
builder.add({
name: 'thinking-tag-extraction',
middleware: extractReasoningMiddleware({ tagName })
})
if (config.enableReasoning) {
const tagName = config.model?.id.includes('gemini') ? tagNameArray[1] : tagNameArray[0]
builder.add({
name: 'thinking-tag-extraction',
middleware: extractReasoningMiddleware({ tagName })
})
}
break
}
case 'gemini':

View File

@ -26,9 +26,10 @@ export function getAiSdkProviderId(provider: Provider): ProviderId | 'openai-com
if (AiCore.isSupported(provider.id)) {
return provider.id as ProviderId
}
if (AiCore.isSupported(provider.type)) {
return provider.type as ProviderId
}
// 先注释掉会影响获取providerOptions
// if (AiCore.isSupported(provider.type)) {
// return provider.type as ProviderId
// }
return provider.id as ProviderId
}