feat: enhance model capabilities with endpoint type validation and add 'gemini' to supported providers

This commit is contained in:
kangfenmao 2025-10-23 16:57:06 +08:00
parent c10f6c029c
commit 2fa2e98a02

View File

@ -5,7 +5,7 @@
import { isVisionModel } from '@renderer/config/models' import { isVisionModel } from '@renderer/config/models'
import { getProviderByModel } from '@renderer/services/AssistantService' import { getProviderByModel } from '@renderer/services/AssistantService'
import type { Model } from '@renderer/types' import type { EndpointType, Model } from '@renderer/types'
import { FileTypes } from '@renderer/types' import { FileTypes } from '@renderer/types'
import { getAiSdkProviderId } from '../provider/factory' import { getAiSdkProviderId } from '../provider/factory'
@ -17,12 +17,14 @@ function modelSupportValidator(
supportedModels = [], supportedModels = [],
unsupportedModels = [], unsupportedModels = [],
supportedProviders = [], supportedProviders = [],
unsupportedProviders = [] unsupportedProviders = [],
supportedEndpointTypes = []
}: { }: {
supportedModels?: string[] supportedModels?: string[]
unsupportedModels?: string[] unsupportedModels?: string[]
supportedProviders?: string[] supportedProviders?: string[]
unsupportedProviders?: string[] unsupportedProviders?: string[]
supportedEndpointTypes?: EndpointType[]
} }
): boolean { ): boolean {
const provider = getProviderByModel(model) const provider = getProviderByModel(model)
@ -43,6 +45,11 @@ function modelSupportValidator(
return true return true
} }
// 根据 EndpointType 进行判断
if (model.endpoint_type && supportedEndpointTypes.includes(model.endpoint_type)) {
return true
}
// 回退到提供商判断 // 回退到提供商判断
return supportedProviders.includes(aiSdkId) return supportedProviders.includes(aiSdkId)
} }
@ -54,6 +61,7 @@ export function supportsPdfInput(model: Model): boolean {
// 基于AI SDK文档以下模型或提供商支持PDF输入 // 基于AI SDK文档以下模型或提供商支持PDF输入
return modelSupportValidator(model, { return modelSupportValidator(model, {
supportedModels: ['qwen-long', 'qwen-doc'], supportedModels: ['qwen-long', 'qwen-doc'],
supportedEndpointTypes: ['anthropic', 'gemini'],
supportedProviders: [ supportedProviders: [
'openai', 'openai',
'azure-openai', 'azure-openai',