feat: enhance Anthropic API support for compatible providers

- Add support for anthropicApiHost configuration in providers
- Improve model filtering for Anthropic-compatible providers
- Add isAnthropicModel function to validate Anthropic models
- Update ClaudeCode service to support compatible providers
- Enhance logging and error handling in API routes
- Fix model transformation and validation logic
This commit is contained in:
Vaayne
2025-09-27 14:06:46 +08:00
parent 35b885798b
commit 4d133d59ea
10 changed files with 61 additions and 62 deletions
@@ -20,7 +20,7 @@ export const ApiModelLabel: React.FC<ModelLabelProps> = ({ model, className, cla
<Avatar src={model ? getModelLogo(model.id) : undefined} className={cn('h-4 w-4', classNames?.avatar)} />
<span className={classNames?.modelName}>{model?.name}</span>
<span className={classNames?.divider}> | </span>
<span className={classNames?.providerName}>{model?.provider_name}</span>
<span className={classNames?.providerName}>{model?.provider}</span>
</div>
)
}
+2
View File
@@ -56,6 +56,7 @@ import ZhipuProviderLogo from '@renderer/assets/images/providers/zhipu.png'
import {
AtLeast,
isSystemProvider,
Model,
OpenAIServiceTiers,
Provider,
ProviderType,
@@ -105,6 +106,7 @@ export const SYSTEM_PROVIDERS_CONFIG: Record<SystemProviderId, SystemProvider> =
apiKey: '',
apiHost: 'https://aihubmix.com',
anthropicApiHost: 'https://aihubmix.com/anthropic',
isAnthropicModel: (m: Model) => m.id.includes('claude'),
models: SYSTEM_MODELS.aihubmix,
isSystem: true,
enabled: false
+1
View File
@@ -2618,6 +2618,7 @@ const migrateConfig = {
break
case 'aihubmix':
provider.anthropicApiHost = 'https://aihubmix.com/anthropic'
provider.isAnthropicModel = (m: Model) => m.id.includes('claude')
break
}
})
+1
View File
@@ -253,6 +253,7 @@ export type Provider = {
apiKey: string
apiHost: string
anthropicApiHost?: string
isAnthropicModel?: (m: Model) => boolean
apiVersion?: string
models: Model[]
enabled?: boolean