Skip to content

[AI] Introduce OnDeviceExtension for GenerativeModel#8086

Merged
rlazo merged 6 commits intomainfrom
rl.ondevice.take2
May 4, 2026
Merged

[AI] Introduce OnDeviceExtension for GenerativeModel#8086
rlazo merged 6 commits intomainfrom
rl.ondevice.take2

Conversation

@rlazo
Copy link
Copy Markdown
Contributor

@rlazo rlazo commented May 4, 2026

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.

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.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

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 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

📝 PRs merging into main branch

Our 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.

@rlazo
Copy link
Copy Markdown
Contributor Author

rlazo commented May 4, 2026

/gemini review

@google-oss-bot
Copy link
Copy Markdown
Collaborator

1 Warning
⚠️ Did you forget to add a changelog entry? (Add the 'no-changelog' label to the PR to silence this warning.)

Generated by 🚫 Danger

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a 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 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.

Comment thread ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt Outdated
Comment thread ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt Outdated
@google-oss-bot
Copy link
Copy Markdown
Collaborator

The public api surface has changed for the subproject ai-logic_firebase-ai-ondevice-interop:
error: Constructor com.google.firebase.ai.ondevice.interop.DownloadStatusInterop has removed 'final' qualifier [RemovedFinalStrict]

The public api surface has changed for the subproject ai-logic_firebase-ai:
error: Added constructor com.google.firebase.ai.DownloadStatus() [AddedMethod]

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
@google-oss-bot
Copy link
Copy Markdown
Collaborator

The public api surface has changed for the subproject ai-logic_firebase-ai-ondevice-interop:
error: Constructor com.google.firebase.ai.ondevice.interop.DownloadStatusInterop has removed 'final' qualifier [RemovedFinalStrict]

The public api surface has changed for the subproject ai-logic_firebase-ai:
error: Added constructor com.google.firebase.ai.DownloadStatus() [AddedMethod]

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.

rlazo and others added 3 commits May 4, 2026 15:54
…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>
@google-oss-bot
Copy link
Copy Markdown
Collaborator

The public api surface has changed for the subproject ai-logic_firebase-ai-ondevice-interop:
error: Constructor com.google.firebase.ai.ondevice.interop.DownloadStatusInterop has removed 'final' qualifier [RemovedFinalStrict]

The public api surface has changed for the subproject ai-logic_firebase-ai:
error: Added constructor com.google.firebase.ai.DownloadStatus() [AddedMethod]

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
@google-oss-bot
Copy link
Copy Markdown
Collaborator

The public api surface has changed for the subproject ai-logic_firebase-ai-ondevice-interop:
error: Constructor com.google.firebase.ai.ondevice.interop.DownloadStatusInterop has removed 'final' qualifier [RemovedFinalStrict]

The public api surface has changed for the subproject ai-logic_firebase-ai:
error: Added constructor com.google.firebase.ai.DownloadStatus() [AddedMethod]

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.

@rlazo
Copy link
Copy Markdown
Contributor Author

rlazo commented May 4, 2026

Semver is failing because it assumes firebase-ai-ondevice is a patch release, but it's the second beta.

Copy link
Copy Markdown
Contributor

@emilypgoogle emilypgoogle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rlazo rlazo merged commit 840b3f2 into main May 4, 2026
34 of 35 checks passed
@rlazo rlazo deleted the rl.ondevice.take2 branch May 4, 2026 21:24
rlazo added a commit that referenced this pull request May 4, 2026
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>
@github-actions github-actions Bot mentioned this pull request May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants