feat(image-gen): support Codex image inputs (salvage #55828) - #824
Merged
Conversation
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
The
openai-codex(Codex OAuth) image-gen backend can now do image-to-image / reference-image editing — it previously hard-rejected anyimage_url/reference_image_urlsand advertised text-only.Salvage of @CrazyBoyM's NousResearch#55828 onto current
main, with one follow-up commit that reuses the shared magic-byte sniffer and gates it to the raster formats gpt-image-2 actually accepts.Changes
plugins/image_gen/openai-codex/__init__.py:image_url+reference_image_urls; attach them as Responsesinput_imagecontent parts alongside the prompt.normalize_reference_images(...), clamp to 16 (same cap as the API-key OpenAI path).agent.file_safetyread guard before inlining.modalities: ["text","image"]/max_reference_images: 16only now that the path is wired.agent.image_routing._sniff_mime_from_bytes(drops a duplicated format table) and gate the result topng/jpeg/gif/webp— the raster set gpt-image-2'sinput_imageaccepts — so SVG/TIFF/ICO fail locally with a clearinvalid_image_inputerror instead of an opaque server-side 400.tests/plugins/image_gen/test_openai_codex_provider.py: payload shape with source+reference images, capability metadata, non-image + SVG rejection, 16-image clamp.Validation
tests/plugins/image_gen/test_openai_codex_provider.py+ dispatchtests/plugins/image_gen/.txt/nonexistent/fake-magic-byte/SVG/TIFF rejectedinvalid_image_input; refs clamp 20→16; text-to-image regression clean;.env/auth.jsonblocked by read guard (no credential exfil)Fixes NousResearch#21661.
Fixes NousResearch#36737.
Closes NousResearch#55828. Commits cherry-picked from @CrazyBoyM with authorship preserved.
Mirror-of: NousResearch#57017
NousResearch#57017