-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(modelarmor): Added create template samples for modelarmor #10068
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
base: main
Are you sure you want to change the base?
feat(modelarmor): Added create template samples for modelarmor #10068
Conversation
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.
Hello @rudrakhsha-crest, 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!
Summary of Changes
This pull request introduces sample code snippets for the Model Armor API using the Google Java API Client Libraries. It includes examples for creating templates with different configurations, such as basic SDP, labels, and metadata. The PR also includes a README file with instructions on how to enable the API, grant permissions, and set environment variables, as well as integration tests for the new samples.
Highlights
- New samples: Added four new Java samples demonstrating how to create Model Armor templates with different configurations: basic, with SDP, with labels, and with metadata.
- README update: The README.md file was updated with instructions on how to enable the Model Armor API, grant necessary permissions, and set the required environment variables.
- Integration tests: Added integration tests to verify the functionality of the new sample code snippets.
Changelog
Click here to see the changelog
- modelarmor/README.md
- Added a README file with prerequisites and instructions for using the Model Armor samples, including enabling the API, granting permissions, and setting environment variables (lines 1-29).
- modelarmor/pom.xml
- Added dependencies for google-cloud-modelarmor, google-cloud-dlp, protobuf-java-util, and lombok (lines 53-74).
- Added test dependencies for junit and truth (lines 77-88).
- Configured the maven-compiler-plugin to use Java 11 and enable annotation processing for Lombok (lines 91-108).
- modelarmor/src/main/java/modelarmor/CreateTemplate.java
- Created a sample for creating a basic Model Armor template with a dangerous RAI filter and high confidence level (lines 1-80).
- modelarmor/src/main/java/modelarmor/CreateTemplateWithBasicSdp.java
- Created a sample for creating a Model Armor template with basic SDP settings, including a dangerous RAI filter with high confidence (lines 1-81).
- modelarmor/src/main/java/modelarmor/CreateTemplateWithLabels.java
- Created a sample for creating a Model Armor template with labels (key1=value1, key2=value2) and a dangerous RAI filter with high confidence (lines 1-87).
- modelarmor/src/main/java/modelarmor/CreateTemplateWithMetadata.java
- Created a sample for creating a Model Armor template with metadata (ignorePartialInvocationFailures=true, logSanitizeOperations=true) and a dangerous RAI filter with high confidence (lines 1-85).
- modelarmor/src/test/java/modelarmor/SnippetsIT.java
- Added integration tests for the new create template samples, verifying that they create templates successfully and that the output contains the expected messages (lines 1-108).
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and 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 to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Model Armor stands,
A shield for language models,
Protecting AI.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
The pull request introduces new samples for creating Model Armor templates with different configurations. The code is generally well-structured and easy to follow. However, there are a few areas that could be improved for clarity and maintainability.
Summary of Findings
- Missing DeleteTemplate Samples: The pull request adds samples for creating Model Armor templates but lacks corresponding samples for deleting them. This could lead to resource accumulation and make it difficult for users to clean up their test environments. It would be helpful to add samples for deleting the created templates.
- Duplicated Code: The code for creating templates is very similar across the different samples (basic, with labels, with metadata). Consider refactoring the common parts into a shared utility function to reduce code duplication and improve maintainability.
- Hardcoded Location: The location is hardcoded as
us-central1
in the test file. It would be better to use an environment variable or a configuration parameter to allow users to test in different regions.
Merge Readiness
The pull request is almost ready for merging. Before merging, I recommend adding samples for deleting the created templates and addressing the code duplication issue. The hardcoded location in the test file should also be addressed. I am unable to approve this pull request, and recommend that others review and approve this code before merging.
Here is the summary of changes. You are about to add 5 region tags.
This comment is generated by snippet-bot.
|
@telpirion Thanks for the review! All the comments have been addressed. Please review and let us know your feedback. |
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.
Approved on behalf of the Model Armor team.
Description
Added code samples for creating Model Armor templates.
Checklist
pom.xml
parent set to latestshared-configuration
mvn clean verify
requiredmvn -P lint checkstyle:check
requiredmvn -P lint clean compile pmd:cpd-check spotbugs:check
advisory only