diff --git a/src/renderer/src/pages/settings/ProviderSettings/ProviderSetting.tsx b/src/renderer/src/pages/settings/ProviderSettings/ProviderSetting.tsx index be5dc6a4d0..208716edd9 100644 --- a/src/renderer/src/pages/settings/ProviderSettings/ProviderSetting.tsx +++ b/src/renderer/src/pages/settings/ProviderSettings/ProviderSetting.tsx @@ -14,7 +14,7 @@ import { checkApi } from '@renderer/services/ApiService' import { isProviderSupportAuth } from '@renderer/services/ProviderService' import { useAppDispatch } from '@renderer/store' import { updateWebSearchProvider } from '@renderer/store/websearch' -import { isSystemProvider } from '@renderer/types' +import { isSystemProvider, isSystemProviderId, SystemProviderIds } from '@renderer/types' import { ApiKeyConnectivity, HealthStatus } from '@renderer/types/healthCheck' import { formatApiHost, @@ -56,7 +56,21 @@ interface Props { providerId: string } -const ANTHROPIC_COMPATIBLE_PROVIDER_IDS = ['deepseek', 'moonshot', 'zhipu', 'dashscope', 'modelscope', 'aihubmix'] +const ANTHROPIC_COMPATIBLE_PROVIDER_IDS = [ + SystemProviderIds.deepseek, + SystemProviderIds.moonshot, + SystemProviderIds.zhipu, + SystemProviderIds.dashscope, + SystemProviderIds.modelscope, + SystemProviderIds.aihubmix, + SystemProviderIds.grok +] as const +type AnthropicCompatibleProviderId = (typeof ANTHROPIC_COMPATIBLE_PROVIDER_IDS)[number] + +const ANTHROPIC_COMPATIBLE_PROVIDER_ID_SET = new Set(ANTHROPIC_COMPATIBLE_PROVIDER_IDS) +const isAnthropicCompatibleProviderId = (id: string): id is AnthropicCompatibleProviderId => { + return ANTHROPIC_COMPATIBLE_PROVIDER_ID_SET.has(id) +} const ProviderSetting: FC = ({ providerId }) => { const { provider, updateProvider, models } = useProvider(providerId) @@ -265,7 +279,9 @@ const ProviderSetting: FC = ({ providerId }) => { }, [provider.anthropicApiHost]) const canConfigureAnthropicHost = useMemo(() => { - return provider.type !== 'anthropic' && ANTHROPIC_COMPATIBLE_PROVIDER_IDS.includes(provider.id) + return ( + provider.type !== 'anthropic' && isSystemProviderId(provider.id) && isAnthropicCompatibleProviderId(provider.id) + ) }, [provider]) const anthropicHostPreview = useMemo(() => { @@ -396,7 +412,7 @@ const ProviderSetting: FC = ({ providerId }) => { <> - {t('settings.provider.api_host')} + {t('settings.provider.api_host')}