fix: use provider block's own vision model on legacy fallback

When falling back to a provider block (providerID / legacy ludmila-ai),
prefer the model flagged attachment:true in that block instead of the
Google-default options.model. Prevents sending 'gemini-2.5-flash' to the
ludmila endpoint which expects 'gemini/gemini-2.5-flash'.
This commit is contained in:
Maksim Totmin
2026-08-04 20:44:14 +07:00
parent 04e3eb8dda
commit 338bd80a95
2 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vision-bridge",
"version": "0.2.0",
"version": "0.2.1",
"type": "module",
"description": "Opencode plugin: bridges images to a vision model when the active model cannot see images.",
"main": "src/vision-bridge.ts",
+8 -8
View File
@@ -147,19 +147,19 @@ export const VisionBridge: Plugin = async (_input: any, options: any = {}) => {
const pBase = p?.options?.baseURL
const pKey = p?.options?.apiKey
if (pBase && pKey) {
let pmodel = resolveTemplates(options.model) || ""
if (!pmodel) {
for (const [id, m] of Object.entries<any>(p?.models ?? {})) {
if (m?.attachment === true) {
pmodel = typeof m?.id === "string" && m.id ? m.id : id
break
}
// Prefer the provider block's own vision model (attachment: true).
// options.model only as a last-resort fallback.
let pmodel = ""
for (const [id, m] of Object.entries<any>(p?.models ?? {})) {
if (m?.attachment === true) {
pmodel = typeof m?.id === "string" && m.id ? m.id : id
break
}
}
providerInfo = {
baseURL: String(pBase).replace(/\/$/, ""),
apiKey: pKey,
visionModel: pmodel || DEFAULT_MODEL,
visionModel: pmodel || resolveTemplates(options.model) || DEFAULT_MODEL,
}
return
}