Modern Apps git

← Modern-Apps.git

openassistant: start engine as soon as app opens

Commit
5de18798d11ad7708b3293e23bab2324568ee3da
Author
Vayun Mathur <[email protected]>
When
2026-05-06 21:56 UTC (7 months ago)
Parents
edb5baa

Diff

openassistant/src/main/java/com/vayunmathur/openassistant/MainActivity.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/MainActivity.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/MainActivity.ktindex ecf81c5db0..7308e78f19 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/MainActivity.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/MainActivity.kt@@ -1,6 +1,8 @@ package com.vayunmathur.openassistant +import android.content.Intent import android.os.Bundle+import com.vayunmathur.openassistant.util.InferenceService import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge@@ -54,7 +56,8 @@ class MainActivity : ComponentActivity() {                 InitialDownloadChecker(ds, listOf(                     Triple("https://huggingface.co/litert-community/gemma-4-E4B-it-litert-lm/resolve/main/gemma-4-E4B-it.litertlm", "gemma4-4b.litertlm", "Model"),                 )) {-                    // Once downloads are complete, find the file in internal storage+                    // Start the inference service immediately to pre-warm the model+                    startService(Intent(this, InferenceService::class.java))                     Navigation(viewModel)                 }             }
openassistant/src/main/java/com/vayunmathur/openassistant/util/InferenceService.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/util/InferenceService.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/util/InferenceService.ktindex 44ca66a6d6..85ba622dd1 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/util/InferenceService.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/util/InferenceService.kt@@ -69,6 +69,13 @@ class InferenceService : Service() {     override fun onCreate() {         super.onCreate()         startForegroundTask()+        serviceScope.launch {+            try {+                ensureEngineInitialized()+            } catch (e: Exception) {+                Log.e("InferenceService", "Error pre-warming engine", e)+            }+        }         serviceScope.launch {             Log.d("InferenceService", "Starting job queue processor loop")             while (isActive) {