Skip to content

Add Gemma 4 E4B offline model and generalize offline-model handling#75

Closed
Android-PowerUser wants to merge 1 commit intoadd-mistral-medium-latest-with-retry-logicfrom
add-gemma-4-e4b-it-integration
Closed

Add Gemma 4 E4B offline model and generalize offline-model handling#75
Android-PowerUser wants to merge 1 commit intoadd-mistral-medium-latest-with-retry-logicfrom
add-gemma-4-e4b-it-integration

Conversation

@Android-PowerUser
Copy link
Copy Markdown
Owner

Motivation

  • Nutzeranforderung: Gemma 4 E4B (offline) wie Gemma 3n integrieren und den angegebenen HuggingFace-Downloadlink verwenden.
  • Vermeidung harter Kodierungen für ein einzelnes Offline-Modell, damit mehrere LiteRT-Modelle (z. B. Gemma 3n + Gemma 4) gleichermaßen unterstützt werden.
  • Hinweis aus dem Rollout: Laufzeitfehler (Unknown model type: tf_lite_end_of_vision) kann bei bestimmten LiteRT-Modellen auftreten und ist zur Laufzeit relevant, löst aber hier keine Kompilationsänderung aus.

Description

  • Neue ModelOption GEMMA_4_E4B_IT hinzugefügt und ModelOption um Felder isOfflineModel und offlineModelFilename erweitert, damit Offline-Modelle dateigenspezifisch konfiguriert werden (GenerativeAiViewModelFactory.kt).
  • Offline-Handling verallgemeinert: API-Key-Logik, Auswahl/Anzeige, CPU/GPU-Optionen und UI-Flags wurden auf isOfflineModel umgestellt (Änderungen in MenuScreen.kt, PhotoReasoningScreen.kt, PhotoReasoningViewModel.kt und ScreenOperatorAccessibilityService.kt).
  • ModelDownloadManager refactored, um modellabhängige Dateinamen, Temp-Dateien und download/resume/cancel APIs zu unterstützen (ModelDownloadManager.kt), inklusive Benachrichtigungs-/Fortschrittslogik.
  • Download-Dialog und Model-Auswahl-Flow im Menü dynamisch an das ausgewählte Offline-Modell angepasst; Auswahl initialisiert oder reinitialisiert das Offline-Modell wie bei Gemma 3n (keine Änderung am Laufzeit-LLM-Codepfad außer Pfad- und Auswahllogik).

Testing

  • SDK- und Build-Tools installiert und Lizenzen akzeptiert mit sdkmanager (Android SDK cmdline tools, platform-tools, platforms;android-35, build-tools;35.0.0) um lokale Kompilationsprüfung zu ermöglichen.
  • Lokale Konfigurationen für Build: local.properties mit sdk.dir=/opt/android-sdk und eine minimal ersetzende app/google-services.json angelegt, damit Gradle-Tasks laufen.
  • Kotlin-Kompilations-Check erfolgreich ausgeführt mit ./gradlew :app:compileDebugKotlin und die Aufgabe lief bis zu BUILD SUCCESSFUL durch (nur Compiler-Warnungen, keine Fehler).
  • Hinweis: Der zuvor genannte laufzeitbezogene LiteRT-Fehler (Unknown model type: tf_lite_end_of_vision) wurde nicht zur Laufzeit reproduziert oder gelöst, da er ein Modell-/Runtime-Kompatibilitätsproblem ist und nicht Teil der Kompilations-/Integrationsarbeiten war.

Codex Task

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

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

This PR successfully refactors the codebase to support multiple offline models by introducing the isOfflineModel property to the ModelOption enum. The changes are well-structured and maintain consistency across all affected files. The refactoring properly abstracts offline model handling and adds support for a new GEMMA_4_E4B_IT model alongside the existing GEMMA_3N_E4B_IT.

Key improvements:

  • Added isOfflineModel and offlineModelFilename properties to ModelOption enum
  • Replaced all hardcoded model name checks with the generic isOfflineModel property check
  • Updated ModelDownloadManager API to accept ModelOption parameter for better flexibility
  • Added proper size information for the new GEMMA 4 model

The changes follow clean code principles and maintain backward compatibility. No blocking issues found.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@Android-PowerUser Android-PowerUser deleted the branch add-mistral-medium-latest-with-retry-logic April 9, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant