fix(models): fix builtin provider detection and model matching (#120)
- Add glm-coding-plan to PROVIDER_ENV_MAP for proper env mapping - Rename GLMCodingPlan value from 'glm' to 'glm-coding-plan' (kebab-case) - Match custom providers against PROVIDER_PRESETS to reuse builtin models - Fix provider key matching in create/update (use entry.name consistently) - Clear stale base_url/api_key from config on provider create - Clear model config when all providers are removed - Add gateway restart on provider remove Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -72,11 +72,15 @@ export async function getAvailable(ctx: any) {
|
||||
if (!cp.base_url) return null
|
||||
const providerKey = `custom:${cp.name.trim().toLowerCase().replace(/ /g, '-')}`
|
||||
const baseUrl = cp.base_url.replace(/\/+$/, '')
|
||||
let models = [cp.model]
|
||||
const bareKey = cp.name.trim().toLowerCase().replace(/ /g, '-')
|
||||
const builtinPreset = PROVIDER_PRESETS.find(p => p.value === bareKey)
|
||||
let models = builtinPreset?.models?.length ? [...builtinPreset.models] : [cp.model]
|
||||
if (cp.api_key) {
|
||||
try { const fetched = await fetchProviderModels(baseUrl, cp.api_key); if (fetched.length > 0) models = fetched } catch { }
|
||||
}
|
||||
return { providerKey, label: cp.name, base_url: baseUrl, models, api_key: cp.api_key || '' }
|
||||
const label = builtinPreset?.label || cp.name
|
||||
const presetBaseUrl = builtinPreset?.base_url || ''
|
||||
return { providerKey, label, base_url: presetBaseUrl || baseUrl, models, api_key: cp.api_key || '' }
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user