openassistant: drop litertlm
- Commit
40c4f7f7fa0ff62c2bc5d30cefe550300116353b- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-26 21:49 UTC (1 month ago)
- Parents
7298e6c
Diff
gradle/libs.versions.toml
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex e7015e4861..203489de82 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -107,7 +107,6 @@ javaxAnnotation = "1.3.2" jsr305 = "3.0.2" zxing = "3.5.4" libphonenumber = "9.0.41"-litertlmAndroid = "0.18.0" brotli = "0.1.2" # Pooled HTTP for :library:network's range-fetch path (issue 815): connection # reuse + HTTP/2 multiplexing at MapLibre's 20/host concurrency, which per-request@@ -129,7 +128,7 @@ chicory = "1.4.0" # Git jgit = "7.8.0.202609011348-r" -# On-device AI (openassistant: LiteRT-LM chat + SigLIP2 ONNX embeddings)+# On-device AI (openassistant: SigLIP2 ONNX embeddings) onnxruntimeAndroid = "1.31.0" # Crypto, security & credential storage@@ -322,7 +321,6 @@ javax-annotation-api = { module = "javax.annotation:javax.annotation-api", versi google-jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "jsr305" } zxing-core = { module = "com.google.zxing:core", version.ref = "zxing" } libphonenumber = { module = "com.googlecode.libphonenumber:libphonenumber", version.ref = "libphonenumber" }-litertlm-android = { module = "com.google.ai.edge.litertlm:litertlm-android", version.ref = "litertlmAndroid" } brotli-dec = { module = "org.brotli:dec", version.ref = "brotli" } okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } apksig = { module = "com.android.tools.build:apksig", version.ref = "apksig" }@@ -339,7 +337,7 @@ chicory-runtime = { module = "com.dylibso.chicory:runtime", version.ref = "chico # Git jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version.ref = "jgit" } -# On-device AI (openassistant: LiteRT-LM chat + SigLIP2 ONNX embeddings)+# On-device AI (openassistant: SigLIP2 ONNX embeddings) onnxruntime-android = { module = "com.microsoft.onnxruntime:onnxruntime-android", version.ref = "onnxruntimeAndroid" } # Crypto, security & credential storage
openassistant/AGENTS.md
diff --git a/openassistant/AGENTS.md b/openassistant/AGENTS.mdindex a9780d0630..5a8e5071ab 100644--- a/openassistant/AGENTS.md+++ b/openassistant/AGENTS.md@@ -5,7 +5,7 @@ _Install: ./install openassistant (dev by default)._ <!-- last-reviewed: 2026-10-16 --> - Gradle: :openassistant / dir: openassistant/-- Package roots present: ui, data+- Package roots present: ui, data, domain, platform - Entry files: MainActivity.kt (no Route.kt — `Route` + `Navigation` are inline) - Deps: :library:room, :library:image, :library:ml, :library:downloadservice - Metadata: metadata_data/openassistant.md (present)@@ -18,12 +18,14 @@ _Install: ./install openassistant (dev by default)._ - Multimodal input: photo upload (SigLIP embeddings) and audio recording - Tool calling into other Modern Apps over local IPC, with JSON-schema validation - A model-managed memory plus an editable system prompt; can be set as the device's default digital assistant (Assist API + voice interaction service)-**Architecture / data-flow:** `ui/LiteRTChatUi` → `util/AssistantViewModel` → `data/OpenAssistantRepository` (Room) + `util/InferenceService` (LiteRT/Gemma engine) with `util/AssistantToolSet` dispatching IPC tool calls. `onCreateBeforeContent` only wires the `IntentLauncher` and picks up Assist-API screen context; `Content()` gates on the initial model download before the chat renders.-**Entry points + reading order:** `Route` (`ConversationPage(id)` / `SettingsPage`, inline) → `MainActivity.kt` → `ui/LiteRTChatUi.kt` → `util/AssistantViewModel.kt` → `util/InferenceService.kt` → `data/OpenAssistantRepository.kt`.+**Architecture / data-flow:** `ui/LiteRTChatUi` → `util/AssistantViewModel` → `data/OpenAssistantRepository` (Room) + `util/InferenceService` → `platform/MamlChatEngine` (Gemma 4 on `:library:ml`'s `Gemma4Handle`; own tool loop, max 6 rounds) with `platform/AssistantTools` (explicit registry over `domain/AssistantToolSpecs`) dispatching IPC tool calls. Pure logic (tool-call parsing/markup stripping, tool loop, WAV decode, history fitting) lives in `domain/` with unit tests. `onCreateBeforeContent` only wires the `IntentLauncher` and picks up Assist-API screen context; `Content()` gates on the initial model download before the chat renders.+**Entry points + reading order:** `Route` (`ConversationPage(id)` / `SettingsPage`, inline) → `MainActivity.kt` → `ui/LiteRTChatUi.kt` → `util/AssistantViewModel.kt` → `util/InferenceService.kt` → `platform/MamlChatEngine.kt` → `data/OpenAssistantRepository.kt`. **Gotchas:** - Card drift fixed: `ui/` files were renamed `Assistant*` → `LiteRT*` and `util/` gained `AssistantDeviceTools`, `AssistantToolIntents`, `InferenceEmbeddingHandler`, `JsonSchemaValidator`, `SentencePieceTokenizer`, `SiglipEmbedder`; `Gemma4Engine`/`Gemma4EtEngine` no longer exist - `MainActivity.intentLauncher` is a shared static other apps mirror (maps/taxi pattern) — keep it initialized in `onCreateBeforeContent` - `StubRecognitionService` is a placeholder voice-recognition hook, not a real recognizer+- Tool names are snake_case (`get_notes`, `add_to_memory`), matching what LiteRT-LM exposed; the system prompt references them. Add a tool in `domain/AssistantToolSpecs.kt` AND `platform/AssistantTools.kt` (an init check fails if they disagree)+- Model files live in `getExternalFilesDir(null)/gemma4/` (text, embed, head, vision, audio, tokenizer); the vision/audio towers load lazily and unload after 3 idle minutes - Extra non-conforming dirs (`assist/`, `util/`) hold real code — closed-roots migration pending ## Key files@@ -43,6 +45,15 @@ _Install: ./install openassistant (dev by default)._ - com/vayunmathur/openassistant/ui/LiteRTChatBubble.kt - com/vayunmathur/openassistant/ui/LiteRTChatInput.kt - com/vayunmathur/openassistant/ui/SettingsPage.kt+### domain/ — pure, unit-tested+- com/vayunmathur/openassistant/domain/AssistantToolSpecs.kt — tool names/descriptions/params+- com/vayunmathur/openassistant/domain/ToolCalls.kt — call parsing, markup stripping, arg coercion+- com/vayunmathur/openassistant/domain/ToolLoop.kt — generate/call/respond loop+- com/vayunmathur/openassistant/domain/WavDecoder.kt+- com/vayunmathur/openassistant/domain/HistoryFit.kt+### platform/ — engine + tool registry+- com/vayunmathur/openassistant/platform/MamlChatEngine.kt+- com/vayunmathur/openassistant/platform/AssistantTools.kt ### util/ — ViewModel, inference, tools, audio (migration pending) - com/vayunmathur/openassistant/util/AssistantViewModel.kt - com/vayunmathur/openassistant/util/AssistantUiContract.kt@@ -50,7 +61,6 @@ _Install: ./install openassistant (dev by default)._ - com/vayunmathur/openassistant/util/InferenceEmbeddingHandler.kt - com/vayunmathur/openassistant/util/SentencePieceTokenizer.kt - com/vayunmathur/openassistant/util/SiglipEmbedder.kt-- com/vayunmathur/openassistant/util/AssistantToolSet.kt - com/vayunmathur/openassistant/util/AssistantToolIntents.kt - com/vayunmathur/openassistant/util/AssistantDeviceTools.kt - com/vayunmathur/openassistant/util/JsonSchemaValidator.kt@@ -60,6 +70,7 @@ _Install: ./install openassistant (dev by default)._ ## Verify (this module only) ``` ./gradlew :openassistant:compileDevKotlin+./gradlew :openassistant:testDevUnitTest ./gradlew :openassistant:lint ./gradlew :openassistant:checkMetadata ```
openassistant/build.gradle.kts
diff --git a/openassistant/build.gradle.kts b/openassistant/build.gradle.ktsindex 68abaf8613..bfd7f17caf 100644--- a/openassistant/build.gradle.kts+++ b/openassistant/build.gradle.kts@@ -24,7 +24,6 @@ android { packaging { jniLibs {- pickFirsts.add("**/libLiteRtTopKOpenClSampler.so") pickFirsts.add("**/libc++_shared.so") } }@@ -45,12 +44,9 @@ dependencies { // ai // Gemma 4 chat runs on `:library:ml`'s Vulkan runtime (Gemma4Handle). implementation(project(":library:ml"))- implementation(libs.litertlm.android)- // litertlm 0.14.0 needs kotlinx-coroutines 1.11.0 (close$default on the- // SendChannel interface); requesting it directly wins over the transitive 1.9.0. implementation(libs.kotlinx.coroutines.android) // SigLIP2 image/text embedding (semantic photo search served to the photos- // app) runs on ONNX Runtime; litertlm stays for the chat LLM.+ // app) runs on ONNX Runtime. implementation(libs.onnxruntime.android) implementation(project(":library:downloadservice"))
openassistant/proguard-rules.pro
diff --git a/openassistant/proguard-rules.pro b/openassistant/proguard-rules.prodeleted file mode 100644index 4cb72a7126..0000000000--- a/openassistant/proguard-rules.pro+++ /dev/null@@ -1,24 +0,0 @@-# LiteRT LM / Gemma 4. Only this app depends on litertlm, so these keeps live-# here rather than in the shared root file.--keep class com.google.ai.edge.litertlm.** { *; }--# LiteRT Core - prevent R8 from deleting LiteRT classes used via reflection--keep class com.google.ai.edge.litert.** { *; }--# OpenAssistant tools: the @Tool/@ToolParam-annotated methods in the ToolSet are-# never called from Kotlin directly — litertlm discovers and invokes them via-# reflection (using method + parameter names to build the function schema). R8's-# shrinker would treat them as unused and remove them, silently breaking every-# assistant tool. Keep the ToolSet implementation (all members + names) and any-# @Tool method, plus the attributes reflection relies on.-#-# MethodParameters is what makes the parameter names survive. It is scoped to this-# app because it costs a name string for every parameter of every method, and the-# other 57 apps reflect on nothing. Once the runtime moves to :library:ml with-# explicit tool descriptors, this whole file goes away.--keepattributes MethodParameters--keep class com.vayunmathur.openassistant.util.AssistantToolSet { *; }--keep class * implements com.google.ai.edge.litertlm.ToolSet { *; }--keepclassmembers class * {- @com.google.ai.edge.litertlm.Tool <methods>;-}
openassistant/src/main/AndroidManifest.xml
diff --git a/openassistant/src/main/AndroidManifest.xml b/openassistant/src/main/AndroidManifest.xmlindex 93fc7c0bbd..7267e19abf 100644--- a/openassistant/src/main/AndroidManifest.xml+++ b/openassistant/src/main/AndroidManifest.xml@@ -54,11 +54,6 @@ android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" android:theme="@style/Theme.General">-- <uses-native-library android:name="libvndksupport.so" android:required="false"/>- <uses-native-library android:name="libOpenCL.so" android:required="false"/>- <uses-native-library android:name="libcdsprpc.so" android:required="false"/>- <activity android:configChanges="mcc|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|keyboardHidden|layoutDirection|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:name=".MainActivity"
openassistant/src/main/java/com/vayunmathur/openassistant/util/SentencePieceTokenizer.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/util/SentencePieceTokenizer.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/util/SentencePieceTokenizer.ktindex 877fc366eb..bcab56ed90 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/util/SentencePieceTokenizer.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/util/SentencePieceTokenizer.kt@@ -12,8 +12,8 @@ import kotlin.math.min * SentencePiece model (`tokenizer.model`, ~4 MB, 256k vocab) that SigLIP2 uses * for its text tower. *- * We need raw token ids to feed SigLIP2's text ONNX model, and litertlm's Gemma- * engine does not expose them, so this is a standalone re-implementation of the+ * We need raw token ids to feed SigLIP2's text ONNX model with SigLIP2's own+ * vocabulary, so this is a standalone re-implementation of the * two pieces we actually need: * * 1. **Model parsing** ([load]): the `.model` file is a serialized
openassistant/src/main/res/xml/data_extraction_rules.xml
diff --git a/openassistant/src/main/res/xml/data_extraction_rules.xml b/openassistant/src/main/res/xml/data_extraction_rules.xmlindex 27cada0283..32ff184ff4 100644--- a/openassistant/src/main/res/xml/data_extraction_rules.xml+++ b/openassistant/src/main/res/xml/data_extraction_rules.xml@@ -6,7 +6,7 @@ conversation history plus remembered facts. Free-form user text, so it can contain anything. external/ on-demand model downloads in getExternalFilesDir(null):- gemma4-2b.litertlm, the SigLIP2 ONNX encoders and+ the gemma4/ maml model files, the SigLIP2 ONNX encoders and tokenizer.model. Gigabytes, and re-downloadable. file/datastore_default.preferences_pb model download progress and version markers (progress_*, dlid_*, siglip_model_version). Meaningless once
openassistant/src/test/java/com/vayunmathur/openassistant/util/ToolCallParseTest.kt
diff --git a/openassistant/src/test/java/com/vayunmathur/openassistant/util/ToolCallParseTest.kt b/openassistant/src/test/java/com/vayunmathur/openassistant/util/ToolCallParseTest.ktindex ea3cb1089e..b93b527574 100644--- a/openassistant/src/test/java/com/vayunmathur/openassistant/util/ToolCallParseTest.kt+++ b/openassistant/src/test/java/com/vayunmathur/openassistant/util/ToolCallParseTest.kt@@ -11,7 +11,7 @@ import kotlin.test.assertTrue * Model output arrives as streaming text with an embedded JSON call, so the * host must extract the largest balanced object, reject malformed payloads * without throwing, and dispatch only allowlisted tools. Mirrors the- *(JsonExtractor plus runTool gating) contract without litertlm or intents.+ *(JsonExtractor plus runTool gating) contract without the model or intents. */ class ToolCallParseTest {
proguard-rules.pro
diff --git a/proguard-rules.pro b/proguard-rules.proindex 34a7193eaf..9d65e82f09 100644--- a/proguard-rules.pro+++ b/proguard-rules.pro@@ -5,8 +5,7 @@ # Annotation metadata is read reflectively by Room, kotlinx.serialization and # protobuf-lite, so these stay repo-wide. MethodParameters is deliberately NOT # here: it stores a name string for every parameter of every method in the app,-# and only :openassistant reflects on parameter names. It lives in-# openassistant/proguard-rules.pro alongside the rest of the LiteRT keeps.+# and no app reflects on parameter names. -keepattributes RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,AnnotationDefault,Signature # Protobuf Lite - the generated runtime schema accesses message fields (e.g.