zot/internal/provider
patriceckhart ef7327ca7d anthropic: downscale oversized images on outbound requests
Anthropic returns 'At least one of the image dimensions exceed max
allowed size for many-image requests' when a request contains more
than one image and any of them is larger than 2000 px on the
longest side. Single-image requests get a more lenient 8000 px
cap. OpenAI has no such limit, so a session that worked fine on
gpt-* breaks the moment /model swaps to a Claude family while the
transcript still holds high-res screenshots.

Add anthShrinkImageBytesIfTooBig that decodes any outbound image
exceeding 2000 px on the longest side, resamples it with Catmull-
Rom from golang.org/x/image/draw, and re-encodes in the same
format. JPEG stays JPEG, PNG stays PNG, GIF gets re-encoded as
PNG (we'd otherwise need to compose a single-frame gif by hand).
Decode/encode failures fall back to the original bytes so the
caller's flow is untouched and Anthropic's own error message
surfaces if the image is genuinely unusable.

Both Anthropic encode sites \u2014 the top-level message converter
and the tool-result inner converter \u2014 run every image through
the helper, so screenshots from earlier turns also get resized
on subsequent requests instead of failing forever once the
transcript captured them at full size.

Adds golang.org/x/image v0.18.0 (compatible with go 1.22).
2026-04-28 12:48:13 +02:00
..
anthropic.go anthropic: downscale oversized images on outbound requests 2026-04-28 12:48:13 +02:00
anthropic_image.go anthropic: downscale oversized images on outbound requests 2026-04-28 12:48:13 +02:00
anthropic_image_test.go anthropic: downscale oversized images on outbound requests 2026-04-28 12:48:13 +02:00
cache.go initial commit 2026-04-17 20:36:38 +02:00
discover.go initial commit 2026-04-17 20:36:38 +02:00
merge.go initial commit 2026-04-17 20:36:38 +02:00
models.go feat: custom models with baseUrl + domain migration to www.zot.sh 2026-04-24 14:00:31 +02:00
openai.go feat: add ollama as first-class provider 2026-04-24 19:13:45 +02:00
openai_codex.go fix ci: portable syscall.Select via x/sys/unix; gofmt pass 2026-04-18 10:55:42 +02:00
provider.go feat(compact): silent compaction with status line and orphan repair 2026-04-23 14:20:15 +02:00
provider_test.go initial commit 2026-04-17 20:36:38 +02:00
refreshing.go feat: auto-refresh OAuth tokens before each API call 2026-04-24 19:37:44 +02:00
sse.go initial commit 2026-04-17 20:36:38 +02:00
usermodels.go feat: custom models with baseUrl + domain migration to www.zot.sh 2026-04-24 14:00:31 +02:00