Skip to content
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

Merged
merged 2 commits into from
Nov 10, 2024
Merged

Conversation

bstanga
Copy link
Contributor

@bstanga bstanga commented Nov 10, 2024

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.

Copy link

github-actions bot commented Nov 10, 2024

📖 Walkthrough

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. This PR also disables automatic updates to PR titles and descriptions while maintaining comment updates. Additionally, it includes improvements to prompts and review comment handling.

Changes

File Summary
dist/index.js No summary
package.json Added dependency for Google AI SDK (@ai-sdk/google) version 0.0.55 to support Gemini models.
pnpm-lock.yaml Updated lock file to include the new Google AI SDK dependency.
src/ai.ts Introduced support for Google Gemini models by adding gemini-1.5-flash and gemini-1.5-flash-latest to the AI model list.
src/prompts.ts No summary
src/pull_request.ts Disabled automatic updates to PR titles and descriptions while keeping comment updates functional.

autogenerated by presubmit.ai

@github-actions github-actions bot changed the title add support for google gemini API Add Google Gemini API Support and Disable Auto PR Updates Nov 10, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review submitted

Comment on lines +26 to +32
name: "gemini-1.5-flash",
createAi: createGoogleGenerativeAI,
},
{
name: "gemini-1.5-flash-latest",
createAi: createGoogleGenerativeAI,
},

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",

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.

Comment on lines +84 to +90
// 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`);

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`);
Copy link
Contributor Author

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.

Copy link
Contributor Author

@bstanga bstanga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review submitted

Comment on lines +26 to +32
name: "gemini-1.5-flash",
createAi: createGoogleGenerativeAI,
},
{
name: "gemini-1.5-flash-latest",
createAi: createGoogleGenerativeAI,
},
Copy link
Contributor Author

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:

  1. Add comments explaining the difference between these versions
  2. Implement version checking to ensure compatibility
  3. 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",
Copy link
Contributor Author

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.

Comment on lines +84 to +90
// 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`);
Copy link
Contributor Author

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:

  1. Removing it completely and tracking the change in version control history
  2. Adding a comment explaining why this functionality is disabled and under what conditions it might be re-enabled
  3. 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`);
Copy link
Contributor Author

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.

Copy link
Contributor Author

@bstanga bstanga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review submitted

Comment on lines +26 to +32
name: "gemini-1.5-flash",
createAi: createGoogleGenerativeAI,
},
{
name: "gemini-1.5-flash-latest",
createAi: createGoogleGenerativeAI,
},
Copy link
Contributor Author

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:

  1. Add version checks to ensure compatibility with the Google AI SDK version being used (@ai-sdk/[email protected])
  2. Include error handling for cases where the model might not be available
  3. 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",
Copy link
Contributor Author

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.

Comment on lines +84 to +90
// 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`);
Copy link
Contributor Author

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:

  1. Removing it completely and tracking the change in version control history
  2. Adding a clear comment explaining why this functionality is disabled and under what conditions it might be re-enabled
  3. 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.

@github-actions github-actions bot changed the title Add Google Gemini API Support and Disable Auto PR Updates Add Google Gemini Support and Disable Auto PR Title Updates Nov 10, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review submitted

Comment on lines +107 to +108
console.log("Review: ", review.review);
console.log("Comments: ", review.comments);

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.

Comment on lines +112 to +114
const comments = review.comments.filter(
(c) => c.content.trim() !== "" && files.some((f) => f.filename === c.file)
);

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.

Comment on lines +25 to +32
{
name: "gemini-1.5-flash",
createAi: createGoogleGenerativeAI,
},
{
name: "gemini-1.5-flash-latest",
createAi: createGoogleGenerativeAI,
},

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'.

Comment on lines +84 to +90
// 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`);

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.

@bstanga bstanga merged commit 3874841 into main Nov 10, 2024
1 check passed
Copy link
Contributor Author

@bstanga bstanga left a 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",
Copy link
Contributor Author

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";
Copy link
Contributor Author

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.

Comment on lines +34 to +35
- 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...
Copy link
Contributor Author

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).

Comment on lines +108 to 109
console.log("Comments: ", review.comments);
info(`reviewed pull request`);
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant