[AI] Introduce OnDeviceExtension for GenerativeModel#8086
Conversation
Adds `OnDeviceExtension` to `GenerativeModel` in `firebase-ai`, centralizing on-device model management. This extension provides methods for `checkStatus`, `download`, and `warmUp` for on-device models. This removes the need for `firebase-ai-ondevice` SDK to have a public API. Key changes include: * Defining: new `DownloadStatus` and `OnDeviceModelStatus` classes in `firebase-ai` for public consumption, marked as `PublicPreviewAPI`. * Creating: corresponding `DownloadStatusInterop` and `OnDeviceModelStatusInterop` classes in `firebase-ai-ondevice-interop` for internal interop with ML Kit. * Implementing: `checkStatus` and `download` on the `GenerativeModel` interop interface in `firebase-ai-ondevice`, utilizing ML Kit's APIs and new converter functions. * Deprecating: the old `FirebaseAIOnDevice.checkStatus`, `FirebaseAIOnDevice.download`, `DownloadStatus`, `OnDeviceModelStatus`, and `OnDeviceModelOption` in `firebase-ai-ondevice`. * Deprecating: the top-level `GenerativeModel.warmUp()` method in `firebase-ai` in favor of `onDeviceExtension?.warmUp()`. * Adding: new unit tests for the `OnDeviceExtension` functionality.
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. |
📝 PRs merging into main branchOur main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released. |
|
/gemini review |
Generated by 🚫 Danger |
There was a problem hiding this comment.
Code Review
This pull request refactors the on-device AI model status and download functionality by introducing an interop layer and moving the primary API to a new OnDeviceExtension property within GenerativeModel. Existing top-level on-device classes and methods are deprecated in favor of this new structure. The review feedback highlights a mismatch in property names within a deprecation message, a missing sealed modifier on a class to align with the API definition, and a stale documentation tag.
|
The public api surface has changed for the subproject ai-logic_firebase-ai-ondevice-interop: The public api surface has changed for the subproject ai-logic_firebase-ai: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
1 similar comment
|
The public api surface has changed for the subproject ai-logic_firebase-ai-ondevice-interop: The public api surface has changed for the subproject ai-logic_firebase-ai: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
…nerativeModel.kt Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…nerativeModel.kt Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
The public api surface has changed for the subproject ai-logic_firebase-ai-ondevice-interop: The public api surface has changed for the subproject ai-logic_firebase-ai: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
1 similar comment
|
The public api surface has changed for the subproject ai-logic_firebase-ai-ondevice-interop: The public api surface has changed for the subproject ai-logic_firebase-ai: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
|
Semver is failing because it assumes |
emilypgoogle
left a comment
There was a problem hiding this comment.
General nit on the data exposed in API types, would probably be reasonable to expose bytes progress in general (even with failure) and perhaps have some abstract methods, but I imagine the effort required for that exceeds its utility at the moment.
Adds `OnDeviceExtension` to `GenerativeModel` in `firebase-ai`, centralizing on-device model management. This extension provides methods for `checkStatus`, `download`, and `warmUp` for on-device models. This removes the need for `firebase-ai-ondevice` SDK to have a public API. Key changes include: * Defining: new `DownloadStatus` and `OnDeviceModelStatus` classes in `firebase-ai` for public consumption, marked as `PublicPreviewAPI`. * Creating: corresponding `DownloadStatusInterop` and `OnDeviceModelStatusInterop` classes in `firebase-ai-ondevice-interop` for internal interop with ML Kit. * Implementing: `checkStatus` and `download` on the `GenerativeModel` interop interface in `firebase-ai-ondevice`, utilizing ML Kit's APIs and new converter functions. * Deprecating: the old `FirebaseAIOnDevice.checkStatus`, `FirebaseAIOnDevice.download`, `DownloadStatus`, `OnDeviceModelStatus`, and `OnDeviceModelOption` in `firebase-ai-ondevice`. * Deprecating: the top-level `GenerativeModel.warmUp()` method in `firebase-ai` in favor of `onDeviceExtension?.warmUp()`. * Adding: new unit tests for the `OnDeviceExtension` functionality. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Adds
OnDeviceExtensiontoGenerativeModelinfirebase-ai, centralizing on-device model management. This extension provides methods forcheckStatus,download, andwarmUpfor on-device models. This removes the need forfirebase-ai-ondeviceSDK to have a public API.Key changes include:
DownloadStatusandOnDeviceModelStatusclasses infirebase-aifor public consumption, marked asPublicPreviewAPI.DownloadStatusInteropandOnDeviceModelStatusInteropclasses infirebase-ai-ondevice-interopfor internal interop with ML Kit.checkStatusanddownloadon theGenerativeModelinterop interface infirebase-ai-ondevice, utilizing ML Kit's APIs and new converter functions.FirebaseAIOnDevice.checkStatus,FirebaseAIOnDevice.download,DownloadStatus,OnDeviceModelStatus, andOnDeviceModelOptioninfirebase-ai-ondevice.GenerativeModel.warmUp()method infirebase-aiin favor ofonDeviceExtension?.warmUp().OnDeviceExtensionfunctionality.