expo-ai-kit 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
On-device AI for Expo apps. Run language models locally—no API keys, no cloud, just native intelligence.
|
|
4
4
|
|
|
5
|
-
**Now with Gemma 4 support** — Download and run Google's [Gemma 4](https://blog.google/technology/developers/gemma-4/) E2B (2.3B) and E4B (4.5B) models directly on Android devices via [LiteRT-LM](https://ai.google.dev/edge/litert-lm). Full on-device inference with GPU acceleration, streaming, and zero cloud dependency.
|
|
5
|
+
**Now with Gemma 4 support** — Download and run Google's [Gemma 4](https://blog.google/innovation-and-ai/technology/developers-tools/gemma-4/) E2B (2.3B) and E4B (4.5B) models directly on Android devices via [LiteRT-LM](https://ai.google.dev/edge/litert-lm). Full on-device inference with GPU acceleration, streaming, and zero cloud dependency.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/expo-ai-kit)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
package/android/build.gradle
CHANGED
|
@@ -208,7 +208,7 @@ class ExpoAiKitModule : Module() {
|
|
|
208
208
|
activeModelId
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
AsyncFunction("unloadModel") Coroutine {
|
|
211
|
+
AsyncFunction("unloadModel") Coroutine { ->
|
|
212
212
|
if (activeModelId != "mlkit" && gemmaClient.isModelLoaded()) {
|
|
213
213
|
val previousId = activeModelId
|
|
214
214
|
gemmaClient.unloadModel()
|
|
@@ -5,6 +5,7 @@ import com.google.ai.edge.litertlm.Engine
|
|
|
5
5
|
import com.google.ai.edge.litertlm.EngineConfig
|
|
6
6
|
import com.google.ai.edge.litertlm.Conversation
|
|
7
7
|
import com.google.ai.edge.litertlm.Backend
|
|
8
|
+
import com.google.ai.edge.litertlm.Message
|
|
8
9
|
import kotlinx.coroutines.Dispatchers
|
|
9
10
|
import kotlinx.coroutines.sync.Mutex
|
|
10
11
|
import kotlinx.coroutines.sync.withLock
|
|
@@ -64,7 +65,7 @@ class GemmaInferenceClient(private val context: Context) {
|
|
|
64
65
|
withContext(Dispatchers.IO) {
|
|
65
66
|
val engineConfig = EngineConfig(
|
|
66
67
|
modelPath = modelPath,
|
|
67
|
-
backend = Backend.GPU
|
|
68
|
+
backend = Backend.GPU
|
|
68
69
|
)
|
|
69
70
|
val newEngine = Engine(engineConfig)
|
|
70
71
|
newEngine.initialize()
|
|
@@ -122,7 +123,7 @@ class GemmaInferenceClient(private val context: Context) {
|
|
|
122
123
|
|
|
123
124
|
try {
|
|
124
125
|
withContext(Dispatchers.IO) {
|
|
125
|
-
conv.sendMessage(
|
|
126
|
+
conv.sendMessage(Message.of(fullPrompt)).toString()
|
|
126
127
|
}
|
|
127
128
|
} catch (e: OutOfMemoryError) {
|
|
128
129
|
throw RuntimeException("INFERENCE_OOM:${loadedModelId ?: "unknown"}:Out of memory during inference")
|
|
@@ -153,7 +154,7 @@ class GemmaInferenceClient(private val context: Context) {
|
|
|
153
154
|
withContext(Dispatchers.IO) {
|
|
154
155
|
var previousText = ""
|
|
155
156
|
|
|
156
|
-
conv.sendMessageAsync(
|
|
157
|
+
conv.sendMessageAsync(Message.of(fullPrompt)).collect { message ->
|
|
157
158
|
val accumulated = message.toString()
|
|
158
159
|
val token = if (accumulated.length > previousText.length) {
|
|
159
160
|
accumulated.substring(previousText.length)
|
package/package.json
CHANGED