Per-provider vision blocks; parser repairs local models' almost-JSON

config.toml now carries a [vision.<provider>] block per backend —
model/base_url/key_env — with vision_provider picking the active one,
so the committed file documents every recipe and switching is a
one-line flip. Only the active block applies; typo'd block names and
keys warn like every other config mistake.

First real Ollama run (qwen2.5vl:7b) surfaced what local models emit:
almost-JSON with trailing commas. parse_vision_response now makes one
cheap repair pass before declaring a response unusable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016jXZFSTZQKzAC8fqpWSz9g
This commit is contained in:
Eric Wagoner
2026-08-03 18:39:27 -04:00
co-authored by Claude Fable 5
parent 0358079da4
commit 118503e4e0
6 changed files with 99 additions and 12 deletions
+9
View File
@@ -120,6 +120,15 @@ def test_parse_drops_malformed_entries():
assert len(unidentified) == 1 # empty {} and the bare string are dropped
def test_parse_repairs_trailing_commas():
# the almost-JSON local vision models emit
titles, unidentified, dropped = parse_vision_response(
'{"titles": [{"title_raw": "Catan",},], "unidentified": [],}'
)
assert [t["title_raw"] for t in titles] == ["Catan"]
assert unidentified == [] and dropped == 0
def test_parse_raises_on_garbage():
with pytest.raises(ValueError):
parse_vision_response("I couldn't see any games clearly.")