chore(go/samples): use gemini-flash-latest as the model#5329
Conversation
Updates Go samples to use gemini-flash-latest. Specialized models are kept where the sample demonstrates them on purpose: image generation (gemini-2.5-flash-image, gemini-3.1-flash-image-preview), TTS (gemini-2.5-flash-preview-tts), Fallback middleware demos (gemini-3.1-flash-preview, gemini-3.1-pro-preview), the gemini-3.1 preview flows in imagen-gemini, and the SimplePrompt "Override the default model" demo in samples/prompts/main.go.
There was a problem hiding this comment.
Code Review
This pull request updates model references across numerous Go samples to use gemini-flash-latest. Review feedback highlights that this alias is not currently supported by the googlegenai plugin, which will cause runtime failures. Additionally, the alias is inappropriate for Vertex AI samples, where gemini-1.5-flash should be used instead. Finally, one instance requires the addition of the googleai/ provider prefix for consistency.
| // Define a flow to demonstrate code execution | ||
| genkit.DefineFlow(g, "codeExecutionFlow", func(ctx context.Context, _ any) (string, error) { | ||
| m := googlegenai.GoogleAIModel(g, "gemini-2.5-flash") | ||
| m := googlegenai.GoogleAIModel(g, "gemini-flash-latest") |
There was a problem hiding this comment.
The model gemini-flash-latest is not currently registered in the googlegenai plugin's supported models list (see go/plugins/googlegenai/models.go). As a result, googlegenai.GoogleAIModel will return nil, causing the flow to fail at the check on line 39. Please ensure the model name is correct (e.g., gemini-1.5-flash-latest) or update the plugin to support this alias. Additionally, ensure that any error returned from this check is wrapped with contextual information (like the model name) to improve diagnosability.
References
- Wrap generic errors with contextual information (such as resource names or IDs) when the underlying function's error message lacks specific context, particularly when multiple instances of the same operation are performed in a single scope.
| g := genkit.Init(ctx, genkit.WithPlugins(&googlegenai.VertexAI{})) | ||
|
|
||
| model := googlegenai.VertexAIModel(g, "gemini-2.5-flash") | ||
| model := googlegenai.VertexAIModel(g, "gemini-flash-latest") |
There was a problem hiding this comment.
Vertex AI does not support the gemini-flash-latest alias; this naming convention is specific to the Google AI (AI Studio) API. For Vertex AI, you should use gemini-1.5-flash or a specific versioned model like gemini-1.5-flash-002.
| model := googlegenai.VertexAIModel(g, "gemini-flash-latest") | |
| model := googlegenai.VertexAIModel(g, "gemini-1.5-flash") |
| Location: vectorsearchPlugin.Location, | ||
| }, vectorsearchPlugin)) | ||
|
|
||
| model := googlegenai.VertexAIModel(g, "gemini-2.5-flash") | ||
| model := googlegenai.VertexAIModel(g, "gemini-flash-latest") |
There was a problem hiding this comment.
Vertex AI does not support the gemini-flash-latest alias. Please use a valid Vertex AI model name such as gemini-1.5-flash.
| Location: vectorsearchPlugin.Location, | |
| }, vectorsearchPlugin)) | |
| model := googlegenai.VertexAIModel(g, "gemini-2.5-flash") | |
| model := googlegenai.VertexAIModel(g, "gemini-flash-latest") | |
| Location: vectorsearchPlugin.Location, | |
| }, vectorsearchPlugin)) | |
| model := googlegenai.VertexAIModel(g, "gemini-1.5-flash") |
| Location: vectorsearchPlugin.Location, | ||
| }, vectorsearchPlugin)) | ||
|
|
||
| model := googlegenai.VertexAIModel(g, "gemini-2.5-flash") | ||
| model := googlegenai.VertexAIModel(g, "gemini-flash-latest") |
There was a problem hiding this comment.
Vertex AI does not support the gemini-flash-latest alias. Please use a valid Vertex AI model name such as gemini-1.5-flash.
| Location: vectorsearchPlugin.Location, | |
| }, vectorsearchPlugin)) | |
| model := googlegenai.VertexAIModel(g, "gemini-2.5-flash") | |
| model := googlegenai.VertexAIModel(g, "gemini-flash-latest") | |
| Location: vectorsearchPlugin.Location, | |
| }, vectorsearchPlugin)) | |
| model := googlegenai.VertexAIModel(g, "gemini-1.5-flash") |
|
|
||
| return genkit.GenerateText(ctx, g, | ||
| ai.WithModel(googlegenai.ModelRef("gemini-2.5-flash", &genai.GenerateContentConfig{ | ||
| ai.WithModel(googlegenai.ModelRef("gemini-flash-latest", &genai.GenerateContentConfig{ |
There was a problem hiding this comment.
The model reference is missing the googleai/ provider prefix. For consistency with other samples in this pull request and to ensure the model is correctly resolved by Genkit, it should be googleai/gemini-flash-latest.
| ai.WithModel(googlegenai.ModelRef("gemini-flash-latest", &genai.GenerateContentConfig{ | |
| ai.WithModel(googlegenai.ModelRef("googleai/gemini-flash-latest", &genai.GenerateContentConfig{ |
No description provided.