Repository navigation
add quick start app for system isntructions - #2846
VinayGuthal wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
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.
…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>
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
left a comment
There was a problem hiding this comment.
Approved.
Hold submitting it until the SDK 06 is out
Add support for system instructions in quickstart application.