feat(py): add Gemini 3.1 preview support to python #5032
feat(py): add Gemini 3.1 preview support to python #5032cabljac wants to merge 2 commits intogenkit-ai:mainfrom
Conversation
Construct Google GenAI clients with explicit typed keyword arguments instead of unpacked kwargs maps, and apply Ruff formatting to plugin tests. Made-with: Cursor
There was a problem hiding this comment.
Code Review
This pull request introduces support for Gemini 3.1 preview models (Flash Lite, Pro, and Pro with Custom Tools) across the Google AI and Vertex AI plugins. A key architectural change includes a routing mechanism in the Vertex AI plugin to ensure Gemini 3.1 preview models use the 'global' location, while maintaining configured locations for other models. The PR also updates documentation, enums, and samples to reflect these additions. Feedback was provided regarding the newly defined ModelInfo constants, which are currently not registered in the SUPPORTED_MODELS dictionary, potentially causing them to fall back to generic metadata in the UI.
| GEMINI_3_1_FLASH_LITE_PREVIEW = ModelInfo( | ||
| label='Google AI - Gemini 3.1 Flash Lite Preview', | ||
| supports=Supports( | ||
| multiturn=True, | ||
| media=True, | ||
| tools=True, | ||
| tool_choice=True, | ||
| system_role=True, | ||
| constrained=Constrained.NO_TOOLS, | ||
| output=['text', 'json'], | ||
| ), | ||
| ) | ||
|
|
||
| GEMINI_3_1_PRO_PREVIEW_CUSTOMTOOLS = ModelInfo( | ||
| label='Google AI - Gemini 3.1 Pro Preview Custom Tools', | ||
| supports=Supports( | ||
| multiturn=True, | ||
| media=True, | ||
| tools=True, | ||
| tool_choice=True, | ||
| system_role=True, | ||
| constrained=Constrained.NO_TOOLS, | ||
| output=['text', 'json'], | ||
| ), | ||
| ) | ||
|
|
||
| GEMINI_3_1_PRO_PREVIEW = ModelInfo( | ||
| label='Google AI - Gemini 3.1 Pro Preview', | ||
| supports=Supports( | ||
| multiturn=True, | ||
| media=True, | ||
| tools=True, | ||
| tool_choice=True, | ||
| system_role=True, | ||
| constrained=Constrained.NO_TOOLS, | ||
| output=['text', 'json'], | ||
| ), | ||
| ) |
There was a problem hiding this comment.
While these ModelInfo constants are correctly defined, they are currently not being used for model lookup because they aren't added to the SUPPORTED_MODELS dictionary. This means that when these models are resolved, they will fall back to a generic ModelInfo with a default label and support flags, rather than using the specific metadata defined here.
Consider populating the SUPPORTED_MODELS dictionary with these constants (and existing ones) to ensure the correct metadata is surfaced in the Genkit UI and used during execution.
Summary
Adds Python support for new Gemini 3.1 preview models:
Updates Vertex plugin routing so Gemini 3.1 preview models default to global location (while non-3.1-preview models keep configured region).
Updates samples/Dev UI flows so all 5 models can be exercised directly:
Adds/updates tests for enum support and Vertex global-routing behavior.
Issue
Checklist: