fix: correct Outlines multimodal input format (list not dict)#205
Merged
Conversation
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>
3fde55b to
cefcbe2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two bugs in the Outlines constrained generation call:
Input format:
TransformersMultiModal.format_inputis asingledispatchthat only acceptslistandChattypes. We passed adict→TypeError. Fixed:[text_input, outlines.Image(image)]PIL format lost:
.convert("RGB")drops.formatattribute.outlines.Imagerequires.formatto be set. Fixed: restore.format = "PNG"after conversion.New test
test_outlines_multimodal_input_formatverifies:listis registered in the singledispatch,dictis NOToutlines.Imagewraps PIL images with.formatsetThis test would have caught both bugs immediately.
36/36 tests pass in 0.10s
🤖 Generated with Claude Code