Skip to content

add quick start app for system isntructions - #2846

Open
VinayGuthal wants to merge 5 commits into
masterfrom
system_instruction
Open

VinayGuthal wants to merge 5 commits into
masterfrom
system_instruction

Conversation

@VinayGuthal

@VinayGuthal VinayGuthal commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Add support for system instructions in quickstart application.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 adds a new 'Hybrid System Instructions' test screen and view model to the Firebase AI Quickstart app, integrating it into the main navigation and updating Firebase dependency versions. Feedback on these changes highlights a compilation error in SystemInstructionViewModel where update is called on a read-only StateFlow, which should be resolved using a private backing property. Other recommendations include managing coroutine jobs to prevent race conditions, decoupling the ViewModel from MainActivity's static image reference, using rememberSaveable to preserve UI state during configuration changes, avoiding double-bang (!!) operators, and ensuring fallback error messages are provided.

VinayGuthal and others added 4 commits October 6, 2026 11:18
…i/feature/hybrid/SystemInstructionViewModel.kt

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…i/feature/hybrid/SystemInstructionViewModel.kt

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…i/ui/SystemInstructionScreen.kt

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
VinayGuthal added a commit to firebase/firebase-android-sdk that referenced this pull request Oct 6, 2026
Adds support for `systemInstruction` when generating content using
on-device and hybrid inference modes.

### Summary of Changes
- **`firebase-ai-ondevice-interop`**: Added an optional
`systemInstruction: TextPart?` property to `GenerateContentRequest` and
updated `api.txt`.
- **`firebase-ai-ondevice`**: Updated `GenerateContentRequest.toMlKit()`
in `Converters.kt` to convert the interop `TextPart` into an ML Kit
`SystemInstruction`.
- **`firebase-ai`**:
- Passed `systemInstruction` from `GenerativeModel.Builder` to
`OnDeviceGenerativeModelProvider`.
- Updated `OnDeviceGenerativeModelProvider` to validate that
`systemInstruction` contains only text parts (throwing
`FirebaseAIOnDeviceInvalidRequestException` for non-text parts),
concatenate multiple `TextPart` instances with a newline, and attach it
to the on-device request.
- **Tests & Changelogs**: Added unit tests in `ConvertersTest`,
`GenerativeModelBuilderTests`, and
`OnDeviceGenerativeModelProviderTests`, and updated `CHANGELOG.md`
across all three modules.


Tested updating the quickstart app to add testing functionality for
system instruction at
firebase/quickstart-android#2846

@rlazo rlazo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved.

Hold submitting it until the SDK 06 is out

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.

2 participants