Repository navigation
Add thinking mode view - #2848
Open
VinayGuthal wants to merge 2 commits into
Open
Add thinking mode view #2848VinayGuthal wants to merge 2 commits into
VinayGuthal wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new "Hybrid Thinking Mode" sample feature to test the enableThinking configuration and response.thoughtSummary across On-Device, Hybrid, and Cloud inference modes. It adds ThinkingModeViewModel, ThinkingModeScreen, and associated navigation and UI state classes, alongside updating Firebase AI dependency versions. Feedback on the changes suggests optimizing streaming response accumulation by using StringBuilder instead of string concatenation to reduce memory allocations, and preventing redundant model status checks in the UI when clicking an already selected model option chip.
BeyondYou923383
approved these changes
Oct 12, 2026
VinayGuthal
added a commit
to firebase/firebase-android-sdk
that referenced
this pull request
Oct 14, 2026
Adds support for thinking mode (`enableThinking`) when generating content using on-device and hybrid inference modes. ### Summary of Changes - **`firebase-ai-ondevice-interop`**: - Added `enableThinking: Boolean?` to `GenerateContentRequest`. - Added `thoughtProcess: List<Candidate>` to `GenerateContentResponse`. - Added `isThinkingModeAvailable(): Boolean` to `GenerativeModel`. - Updated `api.txt`. - **`firebase-ai-ondevice`**: - Implemented `GenerativeModelImpl.isThinkingModeAvailable()` delegating to ML Kit's `GenerativeModel.isThinkingModeAvailable()`. - Updated `Converters.kt` to pass `enableThinking` to the ML Kit request and map `thoughtProcess` candidates to the interop `GenerateContentResponse`. - **`firebase-ai`**: - Added `enableThinking: Boolean? = null` to `OnDeviceConfig` and updated `api.txt`. - Updated `OnDeviceGenerativeModelProvider` to check `onDeviceModel.isThinkingModeAvailable()` when `enableThinking == true` (throwing `FirebaseAIOnDeviceNotAvailableException` so `PREFER_ON_DEVICE` falls back to cloud when unsupported) and forward `enableThinking` to the on-device request. - Updated `Candidate` and `OnDeviceGenerativeModelProvider` response mapping to convert interop `thoughtProcess` candidates into `TextPart` entries with `isThought = true` (populating `GenerateContentResponse.thoughtSummary` for both unary and streaming responses). - **Tests & Changelogs**: Added unit tests in `ConvertersTest`, `GenerativeModelImplTest`, and `OnDeviceGenerativeModelProviderTests`, and updated `CHANGELOG.md` across all three modules. Tested at firebase/quickstart-android#2848 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add thinking mode view to test thinking mode.