From 428ec2dd61ebc7235143099d25907e938308ac15 Mon Sep 17 00:00:00 2001 From: shiyue Date: Wed, 11 Mar 2026 14:57:37 +0000 Subject: [PATCH] fix: add grok2 llm model tab and add-provider dialog option --- messages/en/apiConfig.json | 1 + messages/zh/apiConfig.json | 1 + .../components/api-config-tab/ApiConfigTabContainer.tsx | 5 +++-- .../components/api-config-tab/hooks/useApiConfigFilters.ts | 3 ++- .../api-config/provider-card/ProviderAdvancedFields.tsx | 3 ++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/messages/en/apiConfig.json b/messages/en/apiConfig.json index 535cb7a..4f23e29 100644 --- a/messages/en/apiConfig.json +++ b/messages/en/apiConfig.json @@ -111,6 +111,7 @@ "apiType": "API Type", "apiTypeGeminiCompatible": "Gemini Compatible", "apiTypeOpenAICompatible": "OpenAI Compatible", + "apiTypeGrok2": "Grok2 API", "apiTypeGeminiHint": "Uses Google SDK", "otherProviders": "Other Settings", "audioCategory": "Audio", diff --git a/messages/zh/apiConfig.json b/messages/zh/apiConfig.json index a0379b5..52e434c 100644 --- a/messages/zh/apiConfig.json +++ b/messages/zh/apiConfig.json @@ -111,6 +111,7 @@ "apiType": "API 类型", "apiTypeGeminiCompatible": "Gemini 兼容", "apiTypeOpenAICompatible": "OpenAI 兼容", + "apiTypeGrok2": "Grok2 API", "apiTypeGeminiHint": "使用 Google SDK", "otherProviders": "其他配置", "audioCategory": "音频", diff --git a/src/app/[locale]/profile/components/api-config-tab/ApiConfigTabContainer.tsx b/src/app/[locale]/profile/components/api-config-tab/ApiConfigTabContainer.tsx index 376f84b..5efd278 100644 --- a/src/app/[locale]/profile/components/api-config-tab/ApiConfigTabContainer.tsx +++ b/src/app/[locale]/profile/components/api-config-tab/ApiConfigTabContainer.tsx @@ -28,7 +28,7 @@ interface TestStep { } type TestStatus = 'idle' | 'testing' | 'passed' | 'failed' -type CustomProviderType = 'gemini-compatible' | 'openai-compatible' +type CustomProviderType = 'gemini-compatible' | 'openai-compatible' | 'grok2' const Icons = { settings: () => ( @@ -168,7 +168,7 @@ export function ApiConfigTabContainer() { name, baseUrl, apiKey, - apiMode: newGeminiProvider.apiType === 'openai-compatible' ? 'openai-official' : 'gemini-sdk', + apiMode: newGeminiProvider.apiType === 'gemini-compatible' ? 'gemini-sdk' : 'openai-official', }) setNewGeminiProvider({ name: '', baseUrl: '', apiKey: '', apiType: 'gemini-compatible' }) @@ -372,6 +372,7 @@ export function ApiConfigTabContainer() { > +
diff --git a/src/app/[locale]/profile/components/api-config-tab/hooks/useApiConfigFilters.ts b/src/app/[locale]/profile/components/api-config-tab/hooks/useApiConfigFilters.ts index 10c1a1e..6dcb755 100644 --- a/src/app/[locale]/profile/components/api-config-tab/hooks/useApiConfigFilters.ts +++ b/src/app/[locale]/profile/components/api-config-tab/hooks/useApiConfigFilters.ts @@ -13,7 +13,7 @@ interface EnabledModelOption extends CustomModel { providerName: string } -const DYNAMIC_PROVIDER_PREFIXES = ['gemini-compatible', 'openai-compatible'] +const DYNAMIC_PROVIDER_PREFIXES = ['gemini-compatible', 'openai-compatible', 'grok2'] const ALWAYS_SHOW_PROVIDERS: string[] = [] /** 完全不在 UI 中展示的 provider(既不在主列表,也不在折叠区) */ const HIDDEN_PROVIDER_KEYS = new Set(['siliconflow']) @@ -31,6 +31,7 @@ const MODEL_PROVIDER_KEYS = [ 'fal', 'gemini-compatible', 'openai-compatible', + 'grok2', ] function isProviderModelType(type: CustomModel['type']): type is 'llm' | 'image' | 'video' | 'audio' | 'lipsync' { diff --git a/src/app/[locale]/profile/components/api-config/provider-card/ProviderAdvancedFields.tsx b/src/app/[locale]/profile/components/api-config/provider-card/ProviderAdvancedFields.tsx index 19bcca6..26a33ff 100644 --- a/src/app/[locale]/profile/components/api-config/provider-card/ProviderAdvancedFields.tsx +++ b/src/app/[locale]/profile/components/api-config/provider-card/ProviderAdvancedFields.tsx @@ -64,7 +64,8 @@ const MODEL_TYPES: readonly ProviderCardModelType[] = ['llm', 'image', 'video', export function getAddableModelTypesForProvider(providerId: string): ProviderCardModelType[] { const providerKey = getProviderKey(providerId) - if (providerKey === 'openai-compatible' || providerKey === 'grok2') return ['image', 'video'] + if (providerKey === 'openai-compatible') return ['image', 'video'] + if (providerKey === 'grok2') return ['llm', 'image', 'video'] return ['llm', 'image', 'video', 'audio'] }