Skip to content

fix: correct Outlines multimodal input format (list not dict)#205

Merged
abrichr merged 1 commit into
mainfrom
fix/outlines-multimodal-input-format
Mar 28, 2026
Merged

fix: correct Outlines multimodal input format (list not dict)#205
abrichr merged 1 commit into
mainfrom
fix/outlines-multimodal-input-format

Conversation

@abrichr
Copy link
Copy Markdown
Member

@abrichr abrichr commented Mar 28, 2026

Summary

Two bugs in the Outlines constrained generation call:

  1. Input format: TransformersMultiModal.format_input is a singledispatch that only accepts list and Chat types. We passed a dictTypeError. Fixed: [text_input, outlines.Image(image)]

  2. PIL format lost: .convert("RGB") drops .format attribute. outlines.Image requires .format to be set. Fixed: restore .format = "PNG" after conversion.

New test

test_outlines_multimodal_input_format verifies:

  • list is registered in the singledispatch, dict is NOT
  • outlines.Image wraps PIL images with .format set

This test would have caught both bugs immediately.

36/36 tests pass in 0.10s

🤖 Generated with Claude Code

TransformersMultiModal.format_input is a singledispatch that only
accepts `list` and `Chat` types. A `dict` raises TypeError.

Correct format: [prompt_text, outlines.Image(pil_image)]
Wrong format:   {"text": prompt, "images": [image]}

Also fixes PIL .format being dropped by .convert("RGB") — outlines.Image
requires .format to be set. Restored after conversion.

New test: test_outlines_multimodal_input_format verifies:
- list is a registered dispatch type (dict is NOT)
- outlines.Image wraps PIL images correctly
- This test would have caught both the dict and format bugs

36/36 tests pass in 0.10s.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@abrichr abrichr force-pushed the fix/outlines-multimodal-input-format branch from 3fde55b to cefcbe2 Compare March 28, 2026 20:05
@abrichr abrichr merged commit 9c91a54 into main Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant