fix: revert person_generation auto-routing to warn-only (#14) - #15
Merged
Conversation
Removed GEMINI_TO_IMAGEN_MAP, IMAGEN_ASPECT_RATIOS, and the entire auto-routing block from generate(). The auto-routing silently swapped Gemini models for Imagen when person_generation was set, degrading quality (especially Arabic/RTL text rendering) without user consent. Updated the warning message to accurately explain that Gemini blocks photorealistic identifiable people by default but still generates fictional/illustrated people, and suggests Imagen models for strict API-level enforcement.
Removed auto_routed propagation from format_image_result() since the field no longer exists in generation results. Updated the generate_image docstring and server_info to reflect the warn-only behavior for person_generation on Gemini models. Updated the person_generation field description in validation.py to clarify enforcement scope.
Replaced TestPersonGenerationAutoRouting class (10 tests) with TestPersonGenerationWarnOnly class (2 focused tests) that verify: - person_generation on Gemini stays on Gemini (no silent model swap) - person_generation on Gemini produces a warning pointing to Imagen Removed auto_routed propagation test from test_server.py since the field is no longer present in generation responses. All 242 unit tests passing.
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
Reverts the smart auto-routing introduced in #14. Auto-routing silently swapped Gemini models for Imagen when
person_generationwas set, degrading quality (especially text rendering for Arabic/RTL) without user consent.The problem:
quality="quality"resolves togemini-3-pro-image-preview(~94% text accuracy). When the calling LLM defensively addsperson_generation="block", auto-routing swapped toimagen-4.0-ultrawhich has worse text rendering → garbled Arabic text.The fix: Warn-only approach — always preserve the user's chosen model. Skip
person_generationfor Gemini with a clear warning explaining that Gemini blocks photorealistic identifiable people by default but still generates fictional/illustrated people, and suggesting Imagen models for strict API-level enforcement.What changed
GEMINI_TO_IMAGEN_MAP,IMAGEN_ASPECT_RATIOS, and auto-routing logic fromgenerate()auto_routedresponse field fromformat_image_result()What stays from v0.5.1/v0.5.2
"block"→"DONT_ALLOW"(correct PersonGeneration member)person_generation: False, Imagen:TrueTest plan
generate_image(quality="quality", person_generation="block")generates on gemini-3-pro with warning (NOT Imagen)