mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-12 00:49:14 +08:00
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.
This commit is contained in:
parent
f6c3794ac9
commit
f08c444ffb
@ -11,6 +11,12 @@ const PROVIDER_MAPPING: Record<string, ProviderId> = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getAiSdkProviderId(provider: Provider): ProviderId | 'openai-compatible' {
|
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]
|
const providerId = PROVIDER_MAPPING[provider.id]
|
||||||
|
|
||||||
if (providerId) {
|
if (providerId) {
|
||||||
@ -18,7 +24,7 @@ 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 as ProviderId
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'openai-compatible'
|
return 'openai-compatible'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user