fix: add grok2 llm model tab and add-provider dialog option
Some checks failed
Build & Push Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
shiyue
2026-03-11 14:57:37 +00:00
parent 7f916b96d2
commit 428ec2dd61
5 changed files with 9 additions and 4 deletions

View File

@@ -111,6 +111,7 @@
"apiType": "API Type", "apiType": "API Type",
"apiTypeGeminiCompatible": "Gemini Compatible", "apiTypeGeminiCompatible": "Gemini Compatible",
"apiTypeOpenAICompatible": "OpenAI Compatible", "apiTypeOpenAICompatible": "OpenAI Compatible",
"apiTypeGrok2": "Grok2 API",
"apiTypeGeminiHint": "Uses Google SDK", "apiTypeGeminiHint": "Uses Google SDK",
"otherProviders": "Other Settings", "otherProviders": "Other Settings",
"audioCategory": "Audio", "audioCategory": "Audio",

View File

@@ -111,6 +111,7 @@
"apiType": "API 类型", "apiType": "API 类型",
"apiTypeGeminiCompatible": "Gemini 兼容", "apiTypeGeminiCompatible": "Gemini 兼容",
"apiTypeOpenAICompatible": "OpenAI 兼容", "apiTypeOpenAICompatible": "OpenAI 兼容",
"apiTypeGrok2": "Grok2 API",
"apiTypeGeminiHint": "使用 Google SDK", "apiTypeGeminiHint": "使用 Google SDK",
"otherProviders": "其他配置", "otherProviders": "其他配置",
"audioCategory": "音频", "audioCategory": "音频",

View File

@@ -28,7 +28,7 @@ interface TestStep {
} }
type TestStatus = 'idle' | 'testing' | 'passed' | 'failed' type TestStatus = 'idle' | 'testing' | 'passed' | 'failed'
type CustomProviderType = 'gemini-compatible' | 'openai-compatible' type CustomProviderType = 'gemini-compatible' | 'openai-compatible' | 'grok2'
const Icons = { const Icons = {
settings: () => ( settings: () => (
@@ -168,7 +168,7 @@ export function ApiConfigTabContainer() {
name, name,
baseUrl, baseUrl,
apiKey, 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' }) setNewGeminiProvider({ name: '', baseUrl: '', apiKey: '', apiType: 'gemini-compatible' })
@@ -372,6 +372,7 @@ export function ApiConfigTabContainer() {
> >
<option value="gemini-compatible">{t('apiTypeGeminiCompatible')}</option> <option value="gemini-compatible">{t('apiTypeGeminiCompatible')}</option>
<option value="openai-compatible">{t('apiTypeOpenAICompatible')}</option> <option value="openai-compatible">{t('apiTypeOpenAICompatible')}</option>
<option value="grok2">{t('apiTypeGrok2')}</option>
</select> </select>
<div className="pointer-events-none absolute right-3 top-3 text-[var(--glass-text-tertiary)]"> <div className="pointer-events-none absolute right-3 top-3 text-[var(--glass-text-tertiary)]">
<Icons.chevronDown /> <Icons.chevronDown />

View File

@@ -13,7 +13,7 @@ interface EnabledModelOption extends CustomModel {
providerName: string providerName: string
} }
const DYNAMIC_PROVIDER_PREFIXES = ['gemini-compatible', 'openai-compatible'] const DYNAMIC_PROVIDER_PREFIXES = ['gemini-compatible', 'openai-compatible', 'grok2']
const ALWAYS_SHOW_PROVIDERS: string[] = [] const ALWAYS_SHOW_PROVIDERS: string[] = []
/** 完全不在 UI 中展示的 provider既不在主列表也不在折叠区 */ /** 完全不在 UI 中展示的 provider既不在主列表也不在折叠区 */
const HIDDEN_PROVIDER_KEYS = new Set(['siliconflow']) const HIDDEN_PROVIDER_KEYS = new Set(['siliconflow'])
@@ -31,6 +31,7 @@ const MODEL_PROVIDER_KEYS = [
'fal', 'fal',
'gemini-compatible', 'gemini-compatible',
'openai-compatible', 'openai-compatible',
'grok2',
] ]
function isProviderModelType(type: CustomModel['type']): type is 'llm' | 'image' | 'video' | 'audio' | 'lipsync' { function isProviderModelType(type: CustomModel['type']): type is 'llm' | 'image' | 'video' | 'audio' | 'lipsync' {

View File

@@ -64,7 +64,8 @@ const MODEL_TYPES: readonly ProviderCardModelType[] = ['llm', 'image', 'video',
export function getAddableModelTypesForProvider(providerId: string): ProviderCardModelType[] { export function getAddableModelTypesForProvider(providerId: string): ProviderCardModelType[] {
const providerKey = getProviderKey(providerId) 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'] return ['llm', 'image', 'video', 'audio']
} }