fix builtin provider flags (#1125)

This commit is contained in:
ekko
2026-05-29 19:18:40 +08:00
committed by GitHub
parent 285f623d6f
commit 9838173365
3 changed files with 53 additions and 4 deletions
@@ -99,6 +99,7 @@ function providerPresetToGroup(p: any, models?: string[]): AvailableGroup {
base_url: p.base_url,
models: models || p.models,
api_key: '',
...(p.builtin ? { builtin: true } : {}),
...(envMapping?.base_url_env ? { base_url_env: envMapping.base_url_env } : {}),
}
}
@@ -181,6 +182,15 @@ function providerKeyForCustom(name: string): string {
return `custom:${name.trim().toLowerCase().replace(/ /g, '-')}`
}
function providerKeyWithoutCustomPrefix(providerKey: string): string {
return providerKey.startsWith('custom:') ? providerKey.slice('custom:'.length) : providerKey
}
function isBuiltinProviderKey(providerKey: string): boolean {
const normalized = providerKeyWithoutCustomPrefix(providerKey)
return PROVIDER_PRESETS.some((preset: any) => preset.value === normalized && preset.builtin === true)
}
function providerShouldFetchLiveModels(providerKey: string): boolean {
return providerKey === 'openrouter' ||
providerKey === 'cliproxyapi' ||
@@ -402,13 +412,13 @@ async function buildAvailableForProfile(
const fetched = await cachedProviderModels(fetchCache, baseUrl, cp.api_key)
if (fetched.length > 0) models = [...new Set([...models, ...fetched])]
}
return { providerKey, label: cp.name, base_url: baseUrl, models, api_key: cp.api_key || '' }
return { providerKey, label: cp.name, base_url: baseUrl, models, api_key: cp.api_key || '', builtin: isBuiltinProviderKey(providerKey) }
}),
)
for (const result of customFetches) {
if (result.status === 'fulfilled' && result.value?.models.length) {
const { providerKey, label, base_url, models, api_key } = result.value
addGroup(providerKey, label, base_url, models, api_key)
const { providerKey, label, base_url, models, api_key, builtin } = result.value
addGroup(providerKey, label, base_url, models, api_key, builtin)
}
}
@@ -655,7 +665,7 @@ export async function getAvailable(ctx: any) {
if (cp.api_key) {
try { const fetched = await fetchProviderModels(baseUrl, cp.api_key); if (fetched.length > 0) models = [...new Set([cp.model, ...fetched])] } catch { }
}
return { providerKey, label: cp.name, base_url: baseUrl, models, api_key: cp.api_key || '' }
return { providerKey, label: cp.name, base_url: baseUrl, models, api_key: cp.api_key || '', builtin: isBuiltinProviderKey(providerKey) }
}),
)
+1
View File
@@ -34,6 +34,7 @@ export const PROVIDER_PRESETS: ProviderPreset[] = [
base_url: 'https://api.apikey.fun',
api_mode: "anthropic_messages",
models: [
'claude-opus-4-8',
'claude-opus-4-7',
'claude-opus-4-6',
'claude-sonnet-4-6',