Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request removes the deprecated gemini-2.5-flash-image-preview model, introduces a mechanism to track and return the effective configuration (normalized to snake_case and including injected modalities) on the response's request copy, and improves handling of empty or blocked image generation responses by mapping new finish reasons (NO_IMAGE, IMAGE_OTHER) and providing descriptive finish messages. The reviewer suggests fully removing the unused GEMINI_2_5_FLASH_IMAGE_PREVIEW enum members and constants, which were left behind after removing the model from docstrings and registration.
| | `gemini-3-pro-image-preview` | Gemini 3 Pro Image Preview | Supported | | ||
| | `gemini-2.5-flash-image-preview` | Gemini 2.5 Flash Image Preview | Supported | | ||
| | `gemini-2.5-flash-image` | Gemini 2.5 Flash Image | Supported | |
There was a problem hiding this comment.
While the docstrings for VertexAIGeminiVersion and GoogleAIGeminiVersion have been updated to remove gemini-2.5-flash-image-preview, the actual enum members GEMINI_2_5_FLASH_IMAGE_PREVIEW are still defined in both enum classes, and the constant GEMINI_2_5_FLASH_IMAGE_PREVIEW remains defined in the file. To fully retire this model version, please remove these unused enum members and constants.
9a2c0ba to
0f97e7b
Compare
c0b14c3 to
2a2ad94
Compare
0f97e7b to
c9df52c
Compare
…l refs Core plumbing extracted from #5806: FinishReason.ABORTED (schema + typing), cancel-operation action kind and registry lookup, background operation lifecycle updates in _background.py, generate_operation/check_operation plumbing in _ai, and a config_schema parameter on model_ref. Co-authored-by: Jeff Huang <huangjeff@google.com>
genkit-schema.json is generated from this zod enum by export:schemas; adding aborted only to the generated JSON left CI's clean-working-tree check failing once the build regenerated the schema. Co-authored-by: Jeff Huang <huangjeff@google.com>
…nishReason Regenerates go/ai/gen.go from genkit-schema.json (FinishReasonAborted) and narrows the runtime-parameterized ModelRequest cast to type[BaseModel] to match _override_input_schema's signature. Co-authored-by: Jeff Huang <huangjeff@google.com>
c0440db to
395d4d6
Compare
mode='plain' replaced the field's core schema, so the config JSON schema collapsed to an empty object, every traced dump warned, and mismatched config instances passed validation. The field is now a left-to-right union (dict | SerializeAsAny[ConfigT] | None) with a before-validator coercing dicts into the bound schema; type checkers see ConfigT | None with a shadow __init__ that accepts dicts. Validation also unnests the wire output key so model_dump round-trips keep output config, which the action input retry relies on when re-validating cross-schema configs.
Hardcoded googleai/vertexai suggestions misdirect users of other plugins; build the hint from the registry's plugin names instead.
…fective config echo Gemini slice extracted from #5806: normalizes finish reasons (NO_IMAGE, IMAGE_OTHER), synthesizes finish_message when image models return no media so empty results are not silent successes, propagates finish_message onto candidates, echoes the normalized effective config on response.request for debugging, and drops the retired gemini-2.5-flash-image-preview registration. Co-authored-by: Jeff Huang <huangjeff@google.com>
c9df52c to
9d401da
Compare
| if _content_has_media(content): | ||
| return None | ||
| if fr_name == 'IMAGE_SAFETY': | ||
| return 'Image blocked by safety filters.' | ||
| if fr_name == 'IMAGE_OTHER': | ||
| return 'Image generation stopped (IMAGE_OTHER). Try revising the prompt.' | ||
| if fr_name == 'NO_IMAGE': | ||
| return 'No image was returned. Try a clearer image prompt (for example, "draw a red circle on white").' | ||
| # Ambiguous prompts sometimes come back as STOP/OTHER/UNKNOWN with empty parts. | ||
| return 'No image was returned. Try a clearer image prompt (for example, "draw a red circle on white").' |
There was a problem hiding this comment.
I think this guard is broader than the comment on the fallback intends. The comment says these come back with empty parts, but the check is not _content_has_media(content), which is also true of a non-empty text-only reply. GEMINI_IMAGE_SUPPORTS marks these models multiturn=True with TEXT, IMAGE modalities, so a text-only turn (the model asking a clarifying question, for example) is a normal outcome, and it now comes back carrying finish_message="No image was returned. Try a clearer image prompt...".
The new test_generate_echoes_normalized_effective_config actually constructs this exact case (image model, finish_reason='STOP', a single text part) but only asserts on response.request.config, so it passes without noticing. The empty-candidates path (prompt-level block) reaches the same fallback.
Could we gate the synthesized message on the reasons that actually mean no image was produced, and leave STOP with text content alone?
| 'NO_IMAGE', | ||
| 'IMAGE_OTHER', |
There was a problem hiding this comment.
IMAGE_PROHIBITED_CONTENT and IMAGE_RECITATION are left unmapped, so they fall through to FinishReason.UNKNOWN and then pick up the generic "try a clearer image prompt" text, even though the non-image PROHIBITED_CONTENT and RECITATION both map to BLOCKED in the tuple above.
Both members exist as far back as the declared floor (google-genai>=1.63.0), so this is not a new-SDK concern. The practical effect is that a genuine content-policy block on an image model never surfaces as blocked, and the caller gets prompt-quality advice instead of a policy explanation.
Could we add both to the blocked tuple?
| elif is_tts_model(model_name): | ||
| effective['response_modalities'] = ['AUDIO'] | ||
| elif is_image_model(model_name): | ||
| effective['response_modalities'] = ['TEXT', 'IMAGE'] |
There was a problem hiding this comment.
These two fallbacks look unreachable from the only caller. generate() already sets request_cfg.response_modalities unconditionally for TTS and image models before dispatching, so the first branch always wins by the time effective_config runs. test_generate_echoes_injected_modalities_when_config_omitted passes through that first branch too.
bb8be01 to
fb3cbf1
Compare
…empty image replies Ports the still-applicable part of genkit-ai/genkit#5859 (9d401da1d). - The candidate's finish_message now reaches ModelResponse.finish_message in both generate and streaming, matching the JS plugin. - Gemini native image models that return no media get a finish_message saying why, so an empty reply is not a silent success. Blocked reasons name the reason; MAX_TOKENS gets none, since finish_reason=length already says it. Not ported: the core background-model changes (superseded upstream and already here), the effective-config echo on response.request, and dropping gemini-2.5-flash-image-preview (this repo keeps retired models registered but hidden from autocomplete). Co-authored-by: Jacob Cable <jacobcable94@gmail.com> Upstream-Commit: genkit-ai/genkit@9d401da1d Upstream-PR: genkit-ai/genkit#5859
Parallel slice of the #5806 split (based on #5854, independent of the Interactions chain): normalizes finish reasons (NO_IMAGE, IMAGE_OTHER), synthesizes finish_message when image models return no media so empty results are not silent successes, propagates finish_message onto candidates, echoes the normalized effective config on response.request, and drops the retired gemini-2.5-flash-image-preview registration.
Part of the stack splitting #5806; recombined it reproduces that PR byte-for-byte. Co-authored with @huangjeff5.
Breaking changes
gemini-2.5-flash-image-previewis no longer registered as a model (theGEMINI_2_5_FLASH_IMAGE_PREVIEWenum members remain, but the model name stops resolving). Usegemini-2.5-flash-image.