-
Couldn't load subscription status.
- Fork 1.5k
Add VertexAI Sample to repo #1675
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 @paulb777, 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 adds a new VertexAI sample application to the repository. The sample includes several features demonstrating the capabilities of the Vertex AI for Firebase SDK, including text summarization, multi-modal image reasoning, chat conversations, function calling, and image generation using Imagen. It also introduces UI components and view models to support these features.
Highlights
- New VertexAI Sample App: Adds a complete sample application showcasing various Vertex AI functionalities within a Firebase context.
- Feature Implementation: Includes implementations for text summarization, multi-modal image reasoning, chat conversations, function calling with external APIs, and image generation using Imagen.
- UI Components: Introduces reusable UI components in the
GenerativeAIUIComponentspackage, such asInputFieldandMultimodalInputField, to facilitate user interaction. - Workflow Integration: Sets up a new workflow (
vertexai.yml) to automatically build and test the VertexAI sample on pull requests and scheduled runs.
Changelog
Click here to see the changelog
- .github/workflows/vertexai.yml
- Added a new workflow to build and test the VertexAI sample on pull requests and a daily schedule.
- Configured the workflow to run on macOS-15 with Xcode 16.1 and test on iOS, tvOS, and macOS.
- vertexai/ChatSample/Models/ChatMessage.swift
- Defined
ChatMessagemodel withid,message,participant, andpendingproperties. - Added sample messages for testing and previewing the chat functionality.
- Defined
- vertexai/ChatSample/Screens/ConversationScreen.swift
- Implemented the
ConversationScreenview, which displays the chat interface. - Integrated
InputFieldfor user input and aListto display messages. - Added toolbar button for starting a new chat.
- Implemented the
- vertexai/ChatSample/ViewModels/ConversationViewModel.swift
- Implemented the
ConversationViewModelto manage chat messages and interact with the Vertex AI model. - Added methods for sending messages, starting new chats, and handling streaming responses.
- Implemented the
- vertexai/ChatSample/Views/BouncingDots.swift
- Created a
BouncingDotsview to indicate loading or pending states in the UI.
- Created a
- vertexai/ChatSample/Views/ErrorDetailsView.swift
- Implemented
ErrorDetailsViewto display detailed information about errors encountered during Vertex AI operations, including safety ratings and block reasons.
- Implemented
- vertexai/ChatSample/Views/ErrorView.swift
- Created
ErrorViewto display a generic error message with a button to show error details.
- Created
- vertexai/ChatSample/Views/MessageView.swift
- Implemented
MessageViewto display individual chat messages with different styling for user and system participants. - Used
MarkdownUIto render messages with Markdown formatting.
- Implemented
- vertexai/FunctionCallingSample/Screens/FunctionCallingScreen.swift
- Implemented the
FunctionCallingScreenview, which demonstrates function calling with Gemini. - Integrated
InputFieldfor user input and aListto display messages.
- Implemented the
- vertexai/FunctionCallingSample/ViewModels/FunctionCallingViewModel.swift
- Implemented the
FunctionCallingViewModelto manage chat messages and interact with the Vertex AI model for function calling. - Added methods for sending messages, processing function calls, and handling streaming responses.
- Defined a function to get exchange rates between currencies.
- Implemented the
- vertexai/GenerativeAIMultimodalSample/Screens/PhotoReasoningScreen.swift
- Implemented the
PhotoReasoningScreenview, which allows users to upload images and ask questions about them. - Integrated
MultimodalInputFieldfor user input and image selection.
- Implemented the
- vertexai/GenerativeAIMultimodalSample/ViewModels/PhotoReasoningViewModel.swift
- Implemented the
PhotoReasoningViewModelto manage user input, image selection, and interaction with the Vertex AI model for multi-modal reasoning. - Added methods for processing images and generating responses.
- Implemented the
- vertexai/GenerativeAITextSample/Screens/SummarizeScreen.swift
- Implemented the
SummarizeScreenview, which allows users to enter text and summarize it. - Integrated
TextFieldfor user input and aListto display the summarized text.
- Implemented the
- vertexai/GenerativeAITextSample/ViewModels/SummarizeViewModel.swift
- Implemented the
SummarizeViewModelto manage user input and interact with the Vertex AI model for text summarization. - Added methods for processing text and generating summaries.
- Implemented the
- vertexai/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/InputField.swift
- Created a reusable
InputFieldcomponent for text input with a submit button.
- Created a reusable
- vertexai/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/MultimodalInputField.swift
- Created a reusable
MultimodalInputFieldcomponent for text input and image selection.
- Created a reusable
- vertexai/ImagenScreen/ImagenScreen.swift
- Implemented the
ImagenScreenview, which allows users to enter a prompt and generate an image. - Integrated
TextFieldfor user input and a button to generate the image.
- Implemented the
- vertexai/ImagenScreen/ImagenViewModel.swift
- Implemented the
ImagenViewModelto manage user input and interact with the Vertex AI model for image generation. - Added methods for processing prompts and generating images.
- Implemented the
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.
Trivia time!
What is the name of Google's large language model that powers Vertex AI?
Click here for the answer
Gemini
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 adds a VertexAI sample to the repository, migrating code from the Firebase iOS SDK. The changes include workflow configurations, UI components, view models, and assets for various generative AI functionalities like chat, function calling, multimodal interactions, text summarization, and image generation. Overall, the migration seems well-structured, but there are a few areas that could benefit from closer examination and potential improvements.
Summary of Findings
- Missing Error Handling in UI Components: Several UI components lack explicit error handling for Vertex AI API calls, which could lead to unhandled exceptions and a poor user experience. It's crucial to implement robust error handling to gracefully manage potential failures.
- Potential Performance Bottlenecks in Image Handling: The image resizing logic in
PhotoReasoningViewModelmight introduce performance bottlenecks when dealing with large images. Consider optimizing this process to ensure smooth performance, especially on lower-end devices. - Inconsistent Use of Asynchronous Operations: There are inconsistencies in how asynchronous operations are handled across different view models. Standardizing the approach to asynchronous tasks can improve code maintainability and prevent potential race conditions.
- Hardcoded Model Names: The model names are hardcoded in the view models. It would be better to make them configurable to allow for easier experimentation with different models.
Merge Readiness
The pull request introduces significant new functionality to the repository. While the code appears to be well-structured, the identified issues regarding error handling, performance, and asynchronous operations should be addressed before merging. I am unable to approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issues should be addressed before merging.
vertexai/FunctionCallingSample/ViewModels/FunctionCallingViewModel.swift
Show resolved
Hide resolved
vertexai/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/MultimodalInputField.swift
Show resolved
Hide resolved
vertexai/GenerativeAIMultimodalSample/ViewModels/PhotoReasoningViewModel.swift
Show resolved
Hide resolved
vertexai/GenerativeAIMultimodalSample/ViewModels/PhotoReasoningViewModel.swift
Show resolved
Hide resolved
a870da3 to
9c10558
Compare
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.
See individual commits for a summary of the follow up adaptations.
-- @paulb777
Thanks for structuring it this way. Definitely made it easier to review.
Out of scope for this PR which is moving repos for the sample
Migrated from the FirebaseVertexAI/Sample directory at firebase/firebase-ios-sdk@c7ceee4.
See individual commits for a summary of the follow up adaptations.