-
Notifications
You must be signed in to change notification settings - Fork 683
[AI] Add configurable model generation for AI On-Device #8043
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
Draft
rlazo
wants to merge
10
commits into
main
Choose a base branch
from
rl.select.model
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c863547
[AI] Add configurable model generation for AI On-Device
rlazo b507cc1
Fix compile issue
rlazo 1680931
Merge branch 'main' into rl.select.model
rlazo 61c8e20
Update api.txt
rlazo 388058b
Update deprecation message
rlazo 01019a0
Merge branch 'main' into rl.select.model
rlazo 23a8abb
Update ai-logic/firebase-ai-ondevice-interop/src/main/kotlin/com/goog…
rlazo ac6bb98
Update ai-logic/firebase-ai-ondevice/src/main/kotlin/com/google/fireb…
rlazo d906a02
Update ai-logic/firebase-ai-ondevice-interop/src/main/kotlin/com/goog…
rlazo d415b85
Add changelog entries
rlazo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...evice-interop/src/main/kotlin/com/google/firebase/ai/ondevice/interop/GenerationConfig.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.google.firebase.ai.ondevice.interop | ||
|
|
||
| public class GenerationConfig(public val modelConfig: ModelConfig? = null) { | ||
| override fun toString(): String = "GenerationConfig(modelConfig=$modelConfig)" | ||
|
|
||
| override fun equals(other: Any?): Boolean = | ||
| other is GenerationConfig && modelConfig == other.modelConfig | ||
|
|
||
| override fun hashCode(): Int = modelConfig?.hashCode() ?: 0 | ||
| } | ||
|
|
||
| /** | ||
| * Configuration parameters for model selection. | ||
| * | ||
| * @property releaseStage The release stage of the model to use. | ||
| * @property preference The performance preference for the model. | ||
| */ | ||
| public class ModelConfig( | ||
| public val releaseStage: ModelReleaseStage = ModelReleaseStage.STABLE, | ||
| public val preference: ModelPreference = ModelPreference.FULL, | ||
| ) { | ||
| override fun equals(other: Any?): Boolean = | ||
| other is ModelConfig && releaseStage == other.releaseStage && preference == other.preference | ||
|
|
||
| override fun hashCode(): Int { | ||
| var result = releaseStage.hashCode() | ||
| result = 31 * result + preference.hashCode() | ||
| return result | ||
| } | ||
|
|
||
| override fun toString(): String { | ||
| return "ModelConfig(releaseStage=$releaseStage, preference=$preference)" | ||
| } | ||
| } | ||
| /** Defines the release stage of the model. */ | ||
| public enum class ModelReleaseStage { | ||
| /** | ||
| * Selects the latest model version that is fully tested and on consumer devices. This is the | ||
| * default setting. | ||
| */ | ||
| STABLE, | ||
|
|
||
| /** | ||
| * Selects the latest model version in the preview stage. This stage lets you test beta features | ||
| * or newer model architectures before they are widely deployed. | ||
| */ | ||
| PREVIEW, | ||
| } | ||
|
|
||
| /** Defines the performance preference for the model. */ | ||
| public enum class ModelPreference { | ||
| /** Recommended when model accuracy and full capabilities are prioritized over speed. */ | ||
| FULL, | ||
|
|
||
| /** Recommended for latency-sensitive apps that require minimal response times. */ | ||
| FAST, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.