-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Google Gemini Support and Disable Auto PR Title Updates #7
Conversation
📖 WalkthroughIntegrated Google's Gemini AI models by adding the Google AI SDK and introducing two new models: Changes
autogenerated by presubmit.ai |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review submitted
name: "gemini-1.5-flash", | ||
createAi: createGoogleGenerativeAI, | ||
}, | ||
{ | ||
name: "gemini-1.5-flash-latest", | ||
createAi: createGoogleGenerativeAI, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding model version validation or constants for the Gemini model names to prevent typos and ensure consistency. You could create an enum or constant object like:
const GEMINI_MODELS = {
FLASH: 'gemini-1.5-flash',
FLASH_LATEST: 'gemini-1.5-flash-latest'
} as const;
@@ -20,6 +20,7 @@ | |||
"@actions/core": "^1.11.1", | |||
"@actions/github": "^6.0.0", | |||
"@ai-sdk/anthropic": "^0.0.56", | |||
"@ai-sdk/google": "^0.0.55", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a new integration with Google's AI SDK which is likely in early versions (0.0.x), consider pinning to an exact version number instead of using the caret (^) to prevent potential breaking changes. Early versions may have more frequent breaking changes.
// await octokit.rest.pulls.update({ | ||
// ...context.repo, | ||
// pull_number: pull_request.number, | ||
// title: summary.title, | ||
// body: summary.description, | ||
// }); | ||
// info(`updated pull request title and description`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of keeping commented code, consider removing it entirely and tracking the change in version control history. If this is a temporary change or needs to be documented, add a comment explaining why the PR title/description updates are disabled rather than keeping the commented implementation.
// title: summary.title, | ||
// body: summary.description, | ||
// }); | ||
// info(`updated pull request title and description`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR disables automatic updates for PR titles and descriptions, but it's unclear why. Is there a specific reason for this change? If so, please add a comment explaining the rationale.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review submitted
name: "gemini-1.5-flash", | ||
createAi: createGoogleGenerativeAI, | ||
}, | ||
{ | ||
name: "gemini-1.5-flash-latest", | ||
createAi: createGoogleGenerativeAI, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding version validation or error handling for the Gemini models. Since there are two versions (regular and 'latest'), it would be helpful to:
- Add comments explaining the difference between these versions
- Implement version checking to ensure compatibility
- Consider adding fallback logic if a specific version is not available
@@ -20,6 +20,7 @@ | |||
"@actions/core": "^1.11.1", | |||
"@actions/github": "^6.0.0", | |||
"@ai-sdk/anthropic": "^0.0.56", | |||
"@ai-sdk/google": "^0.0.55", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @ai-sdk/google
package is using a caret version range (^0.0.55
). For a new integration, especially with an AI service, it's recommended to pin to an exact version (0.0.55
) to ensure consistent behavior. This is particularly important since the package is still in early versions (0.x.x) where breaking changes are more likely.
// await octokit.rest.pulls.update({ | ||
// ...context.repo, | ||
// pull_number: pull_request.number, | ||
// title: summary.title, | ||
// body: summary.description, | ||
// }); | ||
// info(`updated pull request title and description`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of leaving commented-out code, consider either:
- Removing it completely and tracking the change in version control history
- Adding a comment explaining why this functionality is disabled and under what conditions it might be re-enabled
- Moving this to a feature flag if there's a possibility of re-enabling it in the future
Commented-out code can lead to maintenance confusion and code clutter.
// title: summary.title, | ||
// body: summary.description, | ||
// }); | ||
// info(`updated pull request title and description`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR disables automatic PR title and description updates, but it's unclear why. Is there a specific reason for this change? If so, please add a comment explaining the rationale.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review submitted
name: "gemini-1.5-flash", | ||
createAi: createGoogleGenerativeAI, | ||
}, | ||
{ | ||
name: "gemini-1.5-flash-latest", | ||
createAi: createGoogleGenerativeAI, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding version validation or error handling for the Gemini models. Since these are new models, it would be beneficial to:
- Add version checks to ensure compatibility with the Google AI SDK version being used (
@ai-sdk/[email protected]
) - Include error handling for cases where the model might not be available
- Consider adding comments documenting any specific requirements or limitations of these models
@@ -20,6 +20,7 @@ | |||
"@actions/core": "^1.11.1", | |||
"@actions/github": "^6.0.0", | |||
"@ai-sdk/anthropic": "^0.0.56", | |||
"@ai-sdk/google": "^0.0.55", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @ai-sdk/google
package is using a caret version range (^0.0.55
). For a new integration, especially with an SDK version below 1.0.0, it's recommended to pin the exact version (0.0.55
) to avoid potential breaking changes in patch updates. This is particularly important since 0.x versions don't follow semantic versioning strictly.
// await octokit.rest.pulls.update({ | ||
// ...context.repo, | ||
// pull_number: pull_request.number, | ||
// title: summary.title, | ||
// body: summary.description, | ||
// }); | ||
// info(`updated pull request title and description`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of leaving commented-out code, consider either:
- Removing it completely and tracking the change in version control history
- Adding a clear comment explaining why this functionality is disabled and under what conditions it might be re-enabled
- Moving this configuration to a feature flag if it might be re-enabled in the future
Commented-out code can lead to maintenance confusion and code clutter over time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review submitted
console.log("Review: ", review.review); | ||
console.log("Comments: ", review.comments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing or replacing console.log
statements with proper logging using @actions/core
info/debug methods, which are already being used elsewhere in the code. This maintains consistency in logging and better integrates with GitHub Actions logging system.
const comments = review.comments.filter( | ||
(c) => c.content.trim() !== "" && files.some((f) => f.filename === c.file) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a brief comment explaining why this filtering is necessary. The logic filters out empty comments and ensures comments only reference existing files, but this isn't immediately obvious from the code alone.
{ | ||
name: "gemini-1.5-flash", | ||
createAi: createGoogleGenerativeAI, | ||
}, | ||
{ | ||
name: "gemini-1.5-flash-latest", | ||
createAi: createGoogleGenerativeAI, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding documentation comments for the new Gemini models explaining their specific use cases, capabilities, or any configuration requirements. This would help other developers understand when to use each model variant, particularly the difference between 'flash' and 'flash-latest'.
// await octokit.rest.pulls.update({ | ||
// ...context.repo, | ||
// pull_number: pull_request.number, | ||
// title: summary.title, | ||
// body: summary.description, | ||
// }); | ||
// info(`updated pull request title and description`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of keeping commented-out code, consider removing it entirely and tracking these changes in version control. If this code needs to be referenced later, it can be found in the git history. If the code is kept for documentation purposes, consider adding a clear comment explaining why it's disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review submitted
@@ -20,6 +20,7 @@ | |||
"@actions/core": "^1.11.1", | |||
"@actions/github": "^6.0.0", | |||
"@ai-sdk/anthropic": "^0.0.56", | |||
"@ai-sdk/google": "^0.0.55", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that the version of the Google AI SDK (@ai-sdk/google
) is compatible with the other SDKs in your project. Consider checking the documentation for any breaking changes or required configurations.
@@ -1,6 +1,7 @@ | |||
import { generateObject } from "ai"; | |||
import { createAnthropic } from "@ai-sdk/anthropic"; | |||
import { createOpenAI } from "@ai-sdk/openai"; | |||
import { createGoogleGenerativeAI } from "@ai-sdk/google"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling for the createGoogleGenerativeAI
function to ensure that any issues during the instantiation of the model are properly managed.
- Return a summary for each single affected file or if there is nothing to summarize simply use the status of the change (ie. "New file"). | ||
- Start the overview with a verb at past tense like "Started", "Commented", "Generated" etc... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The instructions for generating summaries could be clearer. Consider specifying what kind of summaries are expected for different types of changes (e.g., new files, modified files).
console.log("Comments: ", review.comments); | ||
info(`reviewed pull request`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing or commenting out the console logs before merging to keep the production code clean. If logging is necessary for debugging, consider using a logging library instead.
Integrated Google's Gemini AI models by adding the Google AI SDK and introducing two new models: 'gemini-1.5-flash' and 'gemini-1.5-flash-latest'. The PR also disables automatic updates to PR titles and descriptions while maintaining comment updates. Additionally, improved prompts and review comment handling.