feat(ai-logic): add hybrid on-device inference sample#2773
feat(ai-logic): add hybrid on-device inference sample#2773thatfiredev wants to merge 8 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a Hybrid Receipt Scanner feature that utilizes Firebase AI to extract expense data from receipts, preferring on-device inference. The changes include the addition of a new ViewModel for managing model downloads and scanning logic, a Compose-based UI for displaying expenses, and necessary dependency updates. Review feedback highlights the need to handle exceptions in the image picker rather than leaving the catch block empty, improving the robustness of the CSV parsing logic to handle store names containing commas, and removing an unnecessary non-null assertion where Kotlin smart-casting is already available.
firebase-ai/app/src/main/java/com/google/firebase/quickstart/ai/ui/HybridInferenceScreen.kt
Outdated
Show resolved
Hide resolved
...p/src/main/java/com/google/firebase/quickstart/ai/feature/hybrid/HybridInferenceViewModel.kt
Outdated
Show resolved
Hide resolved
firebase-ai/app/src/main/java/com/google/firebase/quickstart/ai/ui/HybridInferenceScreen.kt
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a Hybrid Receipt Scanner feature that utilizes Firebase AI's hybrid inference to extract expense data from receipts, prioritizing on-device processing. The implementation includes a new ViewModel for model management and receipt parsing, a dedicated UI screen, and necessary dependency updates. Feedback focuses on enhancing error handling for parsing failures and image loading issues, as well as improving localization by using standard currency formatting instead of hardcoded symbols.
...p/src/main/java/com/google/firebase/quickstart/ai/feature/hybrid/HybridInferenceViewModel.kt
Outdated
Show resolved
Hide resolved
firebase-ai/app/src/main/java/com/google/firebase/quickstart/ai/ui/HybridInferenceScreen.kt
Outdated
Show resolved
Hide resolved
firebase-ai/app/src/main/java/com/google/firebase/quickstart/ai/ui/HybridInferenceScreen.kt
Show resolved
Hide resolved
| viewModelScope.launch { | ||
| _uiState.update { it.copy(isScanning = true, errorMessage = null) } | ||
| try { | ||
| val prompt = content { |
There was a problem hiding this comment.
Should we add a comment saying something along the lines of "This sample code is just an example. You should not leave your prompt harcoded on the client. Read the Firebase AI Logic documentation to learn how to move your prompts to the server."?
There was a problem hiding this comment.
We have lots of prompts in this quickstart, I think if we do it here we'd have to do for all of them, which then becomes a burden to maintain.
Also: I think not every prompt needs to be on the server. Some of them don't contain anything sensitive and are ok to have on the client.
| @@ -0,0 +1,206 @@ | |||
| package com.google.firebase.quickstart.ai.ui | |||
There was a problem hiding this comment.
Can you add a screenshot of the new screen to the PR description?
marinacoelho
left a comment
There was a problem hiding this comment.
Code looks great - just two minor requests.
Note that this also: