-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[Vertex AI] Parameterize integration tests for Vertex and Dev API #14540
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # 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 @andrewheard, 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 a new integration test suite, GenerateContentIntegrationTests
, to verify the generateContent
functionality against Vertex AI (v1 and v1beta) and the Developer API (v1beta). It also refactors the VertexAI
component to consolidate the initialization logic into a single static method, vertexAI(app:location:)
, reducing code duplication. The internal VertexAI.developer(...)
API has been removed in favor of directly calling VertexAI.vertexAI(app:location:apiConfig:)
in the integration tests.
Highlights
- Integration Tests: Added a new
GenerateContentIntegrationTests
suite to testgenerateContent
against Vertex AI and Developer APIs. - Refactoring: Refactored the
VertexAI
component to use a single static methodvertexAI(app:location:)
for initialization. - API Simplification: Removed the internal
VertexAI.developer(...)
API, usingVertexAI.vertexAI(app:location:apiConfig:)
directly in tests.
Changelog
Click here to see the changelog
- FirebaseVertexAI/Sources/VertexAI.swift
- Consolidated the
vertexAI
initialization logic into a single static methodvertexAI(app:location:)
. - Removed the separate
developerAPI
methods. - Modified the
vertexAI
method to accept an optionalFirebaseApp
instance.
- Consolidated the
- FirebaseVertexAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift
- Introduced a new test suite
GenerateContentIntegrationTests
. - Added a
generateContent
test case that runs against Vertex AI and Developer APIs. - Included helper methods for creating
GenerativeModel
instances with specific configurations.
- Introduced a new test suite
- FirebaseVertexAI/Tests/TestApp/Tests/Integration/IntegrationTests.swift
- Removed the
testGenerateContent
method, as its functionality is now covered by the new integration test suite.
- Removed the
- FirebaseVertexAI/Tests/TestApp/VertexAITestApp.xcodeproj/project.pbxproj
- Added the
GenerateContentIntegrationTests.swift
file to the project. - Updated the project file to include the new test file in the build process.
- Added the
- FirebaseVertexAI/Tests/Unit/VertexComponentTests.swift
- Updated
testVertexInstanceCreation_defaultApp
to assert default values. - Added
testVertexInstanceCreation_defaultApp_customLocation
to test custom locations. - Modified
testSameAppAndDifferentAPI_newInstanceCreated
to usevertexAI
with differentAPIConfig
values. - Updated
testModelResourceName_developerAPI_generativeLanguage
andtestGenerativeModel_developerAPI
to use the newvertexAI
method withAPIConfig
.
- Updated
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.
Did you know?
The first version of Swift was released in 2014.
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 a new integration test suite for the generateContent
method, covering Vertex AI and Developer APIs. It also refactors the VertexAI
component to reduce code duplication. The changes seem well-structured and aim to improve test coverage and code maintainability.
Summary of Findings
- Fatal error in VertexAI initialization: The
vertexAI
method inVertexAI.swift
usesfatalError
if no default Firebase app is found. This could crash the app in unexpected scenarios. Consider using a more graceful error handling mechanism, especially in a public API. - TODO comments in integration tests: The integration tests contain
TODO
comments indicating potential areas for improvement, such as moving helper functions to a utilities folder. Addressing these would improve code organization and reusability. - Token count accuracy in integration tests: The integration tests use a
tokenCountAccuracy
variable to account for slight variations in token counts. While this addresses potential flakiness, it might mask underlying issues with tokenization. Consider investigating the source of these variations and addressing them directly.
Merge Readiness
The pull request introduces valuable integration tests and refactors existing code. However, the potential for app crashes due to fatalError
in VertexAI.swift
should be addressed before merging. Additionally, addressing the TODO
comments and investigating token count variations would further improve the quality of the code. I am unable to approve this pull request, and other reviewers should approve this code before merging.
generateContent
test against the Vertex AI (v1
andv1beta
) API, as well as the Developer API (v1beta
).VertexAI
component to use one static methodvertexAI(app:location:)
, whereapp
is optional, to reduce code and documentation duplication.VertexAI.developer(...)
API in favour of callingVertexAI.vertexAI(app:location:apiConfig:)
(also internal -- I think we should consider renaming to differentiate it from the public API) directly in the integration tests.#no-changelog