fix: provider-aware model selection to prevent cross-provider conflicts

When multiple providers share the same model name, the selector now
uses both model ID and provider as the unique identifier instead of
model name alone. Backend returns default_provider alongside default
model, and model switching sends provider to the config.

Fixes #52

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ekko
2026-04-19 15:05:05 +08:00
parent b4f809d8b5
commit 8a4ab2d69d
4 changed files with 13 additions and 6 deletions
@@ -466,8 +466,10 @@ fsRoutes.get('/api/hermes/available-models', async (ctx) => {
const config = await readConfigYaml()
const modelSection = config.model
let currentDefault = ''
let currentDefaultProvider = ''
if (typeof modelSection === 'object' && modelSection !== null) {
currentDefault = String(modelSection.default || '').trim()
currentDefaultProvider = String(modelSection.provider || '').trim()
} else if (typeof modelSection === 'string') {
currentDefault = modelSection.trim()
}
@@ -592,7 +594,7 @@ fsRoutes.get('/api/hermes/available-models', async (ctx) => {
return
}
ctx.body = { default: currentDefault, groups: dedupedGroups }
ctx.body = { default: currentDefault, default_provider: currentDefaultProvider, groups: dedupedGroups }
} catch (err: any) {
ctx.status = 500
ctx.body = { error: err.message }