-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[AI] Hybrid #15660
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: pb-json-schema-enum-refactor
Are you sure you want to change the base?
[AI] Hybrid #15660
Conversation
Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. |
|
/gemini review |
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 support for on-device generative AI models (Apple Foundation Models) by refactoring the APIConfig from a struct to an enum with .cloud and .onDevice cases. This change necessitated updates across the codebase to handle the new APIConfig structure, including FirebaseAI initialization, model resource name resolution, URL generation, and token counting logic, ensuring that on-device models are handled separately from cloud-based ones. New error codes for unsupported configurations were added, and integration tests were updated and expanded to cover both cloud and on-device scenarios, including a new HybridAIIntegrationTests file. A review comment highlighted the use of iOS 26.0 and macOS 26.0 in an availability check for on-device models, suggesting it's a placeholder for future OS versions and recommending a clarifying comment.
|
/gemini review |
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 support for on-device generative AI models by refactoring the APIConfig from a struct into an enum with .cloud(CloudConfig) and .onDevice cases. This change allows the SDK to differentiate between cloud-based and on-device inference. The core GenerativeModel.generateContent method now includes logic for on-device execution using Apple's Foundation Models, with conditional compilation and OS version checks. Various API request methods (getURL, encode, createWebsocket) and internal functions (modelResourceName, developerModelResourceName) have been updated to handle the new APIConfig enum, explicitly throwing unsupportedConfig errors for operations not supported by on-device models (e.g., URL generation, templates, Imagen, Live API, token counting encoding). A new unsupportedConfig error code was added to AILog.swift. Integration tests were updated to reflect the APIConfig change and a new HybridAIIntegrationTests file was added to test both cloud and on-device model inference. Review comments suggested improving the countTokens implementation for on-device models to explicitly throw an 'unsupported' error instead of attempting a network request, using map instead of compactMap for a non-optional string transformation, and adding an AILog.error call before throwing an NSError for consistency.
Proof of concept of hybrid that successfully runs a hybrid end to end test