fix(vertexai): compact for gemini-3.1-flash-lite in non-stream mode#1204
fix(vertexai): compact for gemini-3.1-flash-lite in non-stream mode#1204
Conversation
…ew in non-stream mode Fix a bug where the gemini-3.1-flash-lite-preview model in non-stream mode requires non-user messages to have the "model" role instead of their original roles
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a specific compatibility bug within the Vertex AI provider, ensuring that the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1204 +/- ##
==========================================
+ Coverage 48.09% 48.42% +0.33%
==========================================
Files 93 93
Lines 5510 5507 -3
==========================================
+ Hits 2650 2667 +17
+ Misses 2664 2640 -24
- Partials 196 200 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request introduces a workaround for a bug in the gemini-3.1-flash-lite-preview model when used in non-streaming mode, by ensuring non-user messages have the model role. The change is specific and seems correct. My review includes a suggestion to improve code maintainability by replacing hardcoded strings with constants.
| if req.Model == "google/gemini-3.1-flash-lite-preview" && req.Stream == false { | ||
| if msg.Role != openai.ChatMessageRoleUser { | ||
| msg.Role = "model" | ||
| } | ||
| } |
There was a problem hiding this comment.
To improve readability and maintainability, it's a good practice to avoid magic strings. The model name "google/gemini-3.1-flash-lite-preview" and the role "model" should be extracted into package-level constants.
For example:
const (
modelGeminiFlashLitePreview = "google/gemini-3.1-flash-lite-preview"
roleModel = "model"
)Then you can use these constants in the if condition. Also, req.Stream == false can be simplified to !req.Stream, which is more idiomatic in Go.
Fix a bug where the gemini-3.1-flash-lite-preview model in non-stream mode requires non-user messages to have the "model" role instead of their original roles