From f08c444ffbaa131fda097f51bef3ac3bb54ed752 Mon Sep 17 00:00:00 2001 From: suyao Date: Sat, 21 Jun 2025 23:46:06 +0800 Subject: [PATCH] feat: enhance provider ID resolution in AI SDK - Updated getAiSdkProviderId function to include mapping for provider types, improving compatibility with third-party SDKs. - Refined return logic to ensure correct provider ID resolution, enhancing overall functionality and support for various providers. --- src/renderer/src/aiCore/provider/factory.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/aiCore/provider/factory.ts b/src/renderer/src/aiCore/provider/factory.ts index fb52a0ea3b..3ad3684407 100644 --- a/src/renderer/src/aiCore/provider/factory.ts +++ b/src/renderer/src/aiCore/provider/factory.ts @@ -11,6 +11,12 @@ const PROVIDER_MAPPING: Record = { } export function getAiSdkProviderId(provider: Provider): ProviderId | 'openai-compatible' { + const providerType = PROVIDER_MAPPING[provider.type] // 有些第三方需要映射到aicore对应sdk + + if (providerType) { + return providerType + } + const providerId = PROVIDER_MAPPING[provider.id] if (providerId) { @@ -18,7 +24,7 @@ export function getAiSdkProviderId(provider: Provider): ProviderId | 'openai-com } if (AiCore.isSupported(provider.id)) { - return provider.id as ProviderId + return provider.id as ProviderId as ProviderId } return 'openai-compatible'