-
Notifications
You must be signed in to change notification settings - Fork 46
[VertexAI] Add new Schema options #1242
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
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 @a-maurice, 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 new schema options to enhance the functionality of the VertexAI integration. Specifically, it adds support for Title
, MinItems
, MaxItems
, Minimum
, Maximum
, PropertyOrdering
, and AnyOf
schema properties. These additions provide more control and flexibility when defining data schemas for generative models. The changes include modifications to the Schema.cs
file to incorporate these new properties and their corresponding logic for serialization. Additionally, a new test case, TestAnyOfSchemaResponse
, has been added to UIHandlerAutomated.cs
to validate the functionality of the AnyOf
schema option.
Highlights
- Schema Enhancements: The pull request introduces several new schema options, including
Title
,MinItems
,MaxItems
,Minimum
,Maximum
,PropertyOrdering
, andAnyOf
, to provide more control over data generation. - Nullable SchemaType: The
Type
property in theSchema
class is now nullable (SchemaType?
) to accommodate theAnyOf
schema, which doesn't have a specific schema type. - New Test Case: A new test case,
TestAnyOfSchemaResponse
, has been added to verify the functionality of theAnyOf
schema option. - Numeric Schema Constraints: The
Int
,Long
,Double
, andFloat
schema types now supportminimum
andmaximum
constraints to guide the model in generating values within a specific range. - Object Schema Ordering: The
Object
schema now supportspropertyOrdering
, allowing developers to suggest the order of keys in the generated JSON string.
Changelog
Click here to see the changelog
- vertexai/src/Schema.cs
- Added
null
case to SchemaType enum conversion to string. - Made the
Type
property nullable (SchemaType?
). - Added
Title
property to theSchema
class. - Added
MinItems
andMaxItems
properties for array schemas. - Added
Minimum
andMaximum
properties for numeric schemas. - Added
PropertyOrdering
property for object schemas. - Added
AnyOfSchemas
property to support multiple schema types for a single field. - Modified the Schema constructor to accept new parameters.
- Updated the
Int
,Long
,Double
, andFloat
methods to acceptminimum
andmaximum
parameters. - Updated the
Object
method to acceptpropertyOrdering
andtitle
parameters. - Updated the
Array
method to acceptminItems
andmaxItems
parameters. - Added the
AnyOf
method to create a schema that conforms to any of the provided sub-schemas. - Updated the
ToJson
method to include the new properties in the JSON serialization.
- Added
- vertexai/testapp/Assets/Firebase/Sample/VertexAI/UIHandlerAutomated.cs
- Added
TestAnyOfSchemaResponse
to the list of automated tests. - Added
minimum
constraint tobasicParameterIntName
inCreateGenerativeModelWithBasicFunctionCall
. - Added
maximum
constraint tobasicParameterObjectFloat
inCreateGenerativeModelWithBasicFunctionCall
. - Added a new test case
TestAnyOfSchemaResponse
to test the AnyOf schema response.
- Added
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.
A schema's tale,
New options now prevail,
Data's form refined,
With constraints aligned,
A model's output, no longer frail.
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
This pull request introduces new schema options for VertexAI, enhancing the flexibility and expressiveness of the schema definitions. The changes include adding support for Title, MinItems, MaxItems, Minimum, Maximum, PropertyOrdering, and AnyOf. The addition of new test cases is also a good practice. Overall, the changes look good, but there are a few areas that could be improved.
Summary of Findings
- Nullable SchemaType: Changing
SchemaType Type
toSchemaType? Type
allows for a null SchemaType, which is used in theAnyOf
schema. This is a good approach to handle the absence of a specific type forAnyOf
. - ReadOnlyCollection Initialization: Using
?.ToList().AsReadOnly()
for initializingReadOnlyCollection
is a concise way to handle nullIEnumerable
values. However, consider usingCollectionExtensions.AsReadOnlySafe()
to avoid creating a new list when the input is already aReadOnlyCollection
. - Minimum and Maximum Parameters: The addition of
minimum
andmaximum
parameters to theInt
,Long
,Double
, andFloat
schema types enhances the ability to specify constraints on numeric values. Ensure that these parameters are correctly handled and validated in the backend. - AnyOf Schema: The implementation of the
AnyOf
schema allows for specifying multiple possible structures or types for a single field. This is a powerful feature that can improve the flexibility of schema definitions.
Merge Readiness
The pull request introduces valuable new features and schema options. However, addressing the identified issues, particularly the potential for code duplication and the handling of nullable types, would further enhance the quality and maintainability of the code. I am unable to approve this pull request, and recommend that another reviewer approves this code before merging. I recommend that the pull request not be merged until the high severity issues are addressed.
Description
Add Schema support for: Title, MinItems, MaxItems, Minimum, Maximum, PropertyOrdering, AnyOf
Testing
Added some new test cases
Type of Change
Place an
x
the applicable box: