diff --git a/examples/llama.android/app/build.gradle.kts b/examples/llama.android/app/build.gradle.kts index e272fd15de..ec88cc93d6 100644 --- a/examples/llama.android/app/build.gradle.kts +++ b/examples/llama.android/app/build.gradle.kts @@ -70,7 +70,7 @@ dependencies { implementation(libs.accompanist.systemuicontroller) // Subproject - implementation(project(":llama")) + implementation(project(":lib")) debugImplementation(libs.bundles.debug) testImplementation(libs.junit) diff --git a/examples/llama.android/app/src/main/java/com/example/llama/MainActivity.kt b/examples/llama.android/app/src/main/java/com/example/llama/MainActivity.kt index cf2d1fd8a1..4c708ead01 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/MainActivity.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/MainActivity.kt @@ -3,8 +3,6 @@ package com.example.llama import android.app.Activity import android.content.ActivityNotFoundException import android.content.Intent -import android.llama.cpp.InferenceEngine.State -import android.llama.cpp.isUninterruptible import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.rememberLauncherForActivityResult @@ -32,6 +30,8 @@ import androidx.navigation.compose.composable import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import androidx.navigation.navArgument +import com.arm.aichat.InferenceEngine.State +import com.arm.aichat.isUninterruptible import com.example.llama.engine.ModelLoadingMetrics import com.example.llama.navigation.AppDestinations import com.example.llama.navigation.NavigationActions diff --git a/examples/llama.android/app/src/main/java/com/example/llama/data/model/GgufMetadata.kt b/examples/llama.android/app/src/main/java/com/example/llama/data/model/GgufMetadata.kt index 249a63b1a0..ce89dc37f0 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/data/model/GgufMetadata.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/data/model/GgufMetadata.kt @@ -1,11 +1,11 @@ package com.example.llama.data.model import kotlinx.serialization.Serializable -import android.llama.cpp.gguf.GgufMetadata as Domain +import com.arm.aichat.gguf.GgufMetadata as Domain /** - * A local serializable domain replicate of [android.llama.cpp.gguf.GgufMetadata] + * A local serializable domain replicate of [com.arm.aichat.gguf.GgufMetadata] */ @Serializable data class GgufMetadata( diff --git a/examples/llama.android/app/src/main/java/com/example/llama/data/model/ModelInfo.kt b/examples/llama.android/app/src/main/java/com/example/llama/data/model/ModelInfo.kt index 919816a68a..7e546ea326 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/data/model/ModelInfo.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/data/model/ModelInfo.kt @@ -1,6 +1,6 @@ package com.example.llama.data.model -import android.llama.cpp.gguf.FileType +import com.arm.aichat.gguf.FileType import com.example.llama.util.formatContextLength import com.example.llama.util.formatFileByteSize diff --git a/examples/llama.android/app/src/main/java/com/example/llama/data/repo/ModelRepository.kt b/examples/llama.android/app/src/main/java/com/example/llama/data/repo/ModelRepository.kt index 6008d5cbec..71fa48a94c 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/data/repo/ModelRepository.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/data/repo/ModelRepository.kt @@ -1,11 +1,11 @@ package com.example.llama.data.repo import android.content.Context -import android.llama.cpp.gguf.GgufMetadataReader -import android.llama.cpp.gguf.InvalidFileFormatException import android.net.Uri import android.os.StatFs import android.util.Log +import com.arm.aichat.gguf.GgufMetadataReader +import com.arm.aichat.gguf.InvalidFileFormatException import com.example.llama.data.db.dao.ModelDao import com.example.llama.data.db.entity.ModelEntity import com.example.llama.data.model.GgufMetadata diff --git a/examples/llama.android/app/src/main/java/com/example/llama/di/AppModule.kt b/examples/llama.android/app/src/main/java/com/example/llama/di/AppModule.kt index 469b966de1..ba30a779ce 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/di/AppModule.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/di/AppModule.kt @@ -1,10 +1,10 @@ package com.example.llama.di import android.content.Context -import android.llama.cpp.InferenceEngine -import android.llama.cpp.AiChat -import android.llama.cpp.TierDetection -import android.llama.cpp.gguf.GgufMetadataReader +import com.arm.aichat.AiChat +import com.arm.aichat.InferenceEngine +import com.arm.aichat.TierDetection +import com.arm.aichat.gguf.GgufMetadataReader import com.example.llama.data.db.AppDatabase import com.example.llama.data.repo.ModelRepository import com.example.llama.data.repo.ModelRepositoryImpl diff --git a/examples/llama.android/app/src/main/java/com/example/llama/engine/InferenceServices.kt b/examples/llama.android/app/src/main/java/com/example/llama/engine/InferenceServices.kt index 4bff08b751..2e287c13bf 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/engine/InferenceServices.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/engine/InferenceServices.kt @@ -1,8 +1,8 @@ package com.example.llama.engine -import android.llama.cpp.InferenceEngine -import android.llama.cpp.InferenceEngine.State import android.util.Log +import com.arm.aichat.InferenceEngine +import com.arm.aichat.InferenceEngine.State import com.example.llama.data.model.ModelInfo import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow diff --git a/examples/llama.android/app/src/main/java/com/example/llama/engine/StubInferenceEngine.kt b/examples/llama.android/app/src/main/java/com/example/llama/engine/StubInferenceEngine.kt index 936f43b891..8a5615dc0e 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/engine/StubInferenceEngine.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/engine/StubInferenceEngine.kt @@ -1,8 +1,8 @@ package com.example.llama.engine -import android.llama.cpp.InferenceEngine -import android.llama.cpp.InferenceEngine.State import android.util.Log +import com.arm.aichat.InferenceEngine +import com.arm.aichat.InferenceEngine.State import com.example.llama.APP_NAME import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope diff --git a/examples/llama.android/app/src/main/java/com/example/llama/engine/StubTierDetection.kt b/examples/llama.android/app/src/main/java/com/example/llama/engine/StubTierDetection.kt index c27050027b..27fcc19e49 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/engine/StubTierDetection.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/engine/StubTierDetection.kt @@ -1,7 +1,7 @@ package com.example.llama.engine -import android.llama.cpp.LLamaTier -import android.llama.cpp.TierDetection +import com.arm.aichat.LLamaTier +import com.arm.aichat.TierDetection import android.util.Log /** diff --git a/examples/llama.android/app/src/main/java/com/example/llama/ui/components/ArmFeaturesVisualizer.kt b/examples/llama.android/app/src/main/java/com/example/llama/ui/components/ArmFeaturesVisualizer.kt index b9e227c7df..641447be7f 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/ui/components/ArmFeaturesVisualizer.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/ui/components/ArmFeaturesVisualizer.kt @@ -1,7 +1,5 @@ package com.example.llama.ui.components -import android.llama.cpp.ArmFeature -import android.llama.cpp.ArmFeaturesMapper.DisplayItem import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.text.TextAutoSize import androidx.compose.material3.MaterialTheme @@ -12,6 +10,8 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight +import com.arm.aichat.ArmFeature +import com.arm.aichat.ArmFeaturesMapper.DisplayItem import kotlin.math.sqrt /** diff --git a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/BenchmarkScreen.kt b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/BenchmarkScreen.kt index 3fd5768486..bf1335e638 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/BenchmarkScreen.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/BenchmarkScreen.kt @@ -1,7 +1,6 @@ package com.example.llama.ui.screens import android.content.Intent -import android.llama.cpp.InferenceEngine.State import android.widget.Toast import androidx.activity.compose.BackHandler import androidx.compose.foundation.background @@ -50,6 +49,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.core.net.toUri +import com.arm.aichat.InferenceEngine.State import com.example.llama.data.model.ModelInfo import com.example.llama.engine.ModelLoadingMetrics import com.example.llama.ui.components.ModelCardContentArchitectureRow diff --git a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ConversationScreen.kt b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ConversationScreen.kt index d5044d9488..e976194dd0 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ConversationScreen.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ConversationScreen.kt @@ -1,7 +1,6 @@ package com.example.llama.ui.screens import android.content.Intent -import android.llama.cpp.InferenceEngine.State import android.widget.Toast import androidx.activity.compose.BackHandler import androidx.compose.animation.core.LinearEasing @@ -63,6 +62,7 @@ import androidx.core.net.toUri import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.compose.LocalLifecycleOwner +import com.arm.aichat.InferenceEngine.State import com.example.llama.data.model.ModelInfo import com.example.llama.engine.ModelLoadingMetrics import com.example.llama.engine.TokenMetrics diff --git a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelDetailsScreen.kt b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelDetailsScreen.kt index e3cdf4cbe1..24a3d6370e 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelDetailsScreen.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelDetailsScreen.kt @@ -1,6 +1,5 @@ package com.example.llama.ui.screens -import android.llama.cpp.gguf.FileType import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ExperimentalLayoutApi @@ -22,6 +21,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import com.arm.aichat.gguf.FileType import com.example.llama.data.model.ModelInfo import com.example.llama.ui.components.ModelCardContentArchitectureRow import com.example.llama.ui.components.ModelCardContentContextRow diff --git a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelLoadingScreen.kt b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelLoadingScreen.kt index c3be3b674f..eab2eb9f5b 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelLoadingScreen.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelLoadingScreen.kt @@ -1,8 +1,6 @@ package com.example.llama.ui.screens import android.content.Intent -import android.llama.cpp.InferenceEngine.State -import android.llama.cpp.UnsupportedArchitectureException import android.widget.Toast import androidx.activity.compose.BackHandler import androidx.compose.animation.AnimatedVisibility @@ -60,6 +58,8 @@ import androidx.compose.ui.semantics.Role import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.core.net.toUri +import com.arm.aichat.InferenceEngine.State +import com.arm.aichat.UnsupportedArchitectureException import com.example.llama.data.model.SystemPrompt import com.example.llama.engine.ModelLoadingMetrics import com.example.llama.ui.components.ModelCardCoreExpandable diff --git a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/SettingsGeneralScreen.kt b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/SettingsGeneralScreen.kt index 9ab75e942f..b645c9249e 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/SettingsGeneralScreen.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/SettingsGeneralScreen.kt @@ -1,8 +1,6 @@ package com.example.llama.ui.screens import android.content.Intent -import android.llama.cpp.ArmFeaturesMapper -import android.llama.cpp.ArmFeaturesMapper.DisplayItem import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -30,6 +28,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import androidx.core.net.toUri +import com.arm.aichat.ArmFeaturesMapper +import com.arm.aichat.ArmFeaturesMapper.DisplayItem import com.example.llama.APP_NAME import com.example.llama.BuildConfig import com.example.llama.data.source.prefs.ColorThemeMode diff --git a/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/BenchmarkViewModel.kt b/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/BenchmarkViewModel.kt index 826fee57f4..5ada670909 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/BenchmarkViewModel.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/BenchmarkViewModel.kt @@ -1,7 +1,7 @@ package com.example.llama.viewmodel -import android.llama.cpp.isUninterruptible import androidx.lifecycle.viewModelScope +import com.arm.aichat.isUninterruptible import com.example.llama.data.model.ModelInfo import com.example.llama.engine.BenchmarkService import com.example.llama.ui.scaffold.ScaffoldEvent diff --git a/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelUnloadingViewModel.kt b/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelUnloadingViewModel.kt index 0a93a9851d..e629f2759e 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelUnloadingViewModel.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelUnloadingViewModel.kt @@ -1,11 +1,11 @@ package com.example.llama.viewmodel -import android.llama.cpp.InferenceEngine -import android.llama.cpp.InferenceEngine.State -import android.llama.cpp.isModelLoaded -import android.llama.cpp.isUninterruptible import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.arm.aichat.InferenceEngine +import com.arm.aichat.InferenceEngine.State +import com.arm.aichat.isModelLoaded +import com.arm.aichat.isUninterruptible import com.example.llama.engine.InferenceService import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow diff --git a/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelsManagementViewModel.kt b/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelsManagementViewModel.kt index fe372eda7f..06e66e04c4 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelsManagementViewModel.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelsManagementViewModel.kt @@ -6,11 +6,11 @@ import android.content.Context import android.content.Context.RECEIVER_EXPORTED import android.content.Intent import android.content.IntentFilter -import android.llama.cpp.gguf.InvalidFileFormatException import android.net.Uri import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.arm.aichat.gguf.InvalidFileFormatException import com.example.llama.data.model.ModelInfo import com.example.llama.data.repo.InsufficientStorageException import com.example.llama.data.repo.ModelRepository diff --git a/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/SettingsViewModel.kt b/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/SettingsViewModel.kt index d8e025a05e..4cea012328 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/SettingsViewModel.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/SettingsViewModel.kt @@ -1,9 +1,9 @@ package com.example.llama.viewmodel -import android.llama.cpp.LLamaTier -import android.llama.cpp.TierDetection import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.arm.aichat.LLamaTier +import com.arm.aichat.TierDetection import com.example.llama.data.repo.ModelRepository import com.example.llama.data.source.prefs.ColorThemeMode import com.example.llama.data.source.prefs.DarkThemeMode diff --git a/examples/llama.android/gradle/libs.versions.toml b/examples/llama.android/gradle/libs.versions.toml index de2357a718..162a3fd61f 100644 --- a/examples/llama.android/gradle/libs.versions.toml +++ b/examples/llama.android/gradle/libs.versions.toml @@ -1,19 +1,19 @@ [versions] # Plugins -agp = "8.12.2" +agp = "8.13.0" ksp = "2.2.10-2.0.2" -kotlin = "2.2.10" +kotlin = "2.2.20" dagger-hilt = "2.57.1" # AndroidX -activity = "1.10.1" +activity = "1.11.0" core-ktx = "1.17.0" datastore-preferences = "1.1.7" -lifecycle = "2.9.3" -navigation = "2.9.3" -room = "2.7.2" -hilt = "1.2.0" +lifecycle = "2.9.4" +navigation = "2.9.4" +room = "2.8.0" +hilt = "1.3.0" retrofit2 = "3.0.0" okhttp3 = "5.1.0" @@ -22,11 +22,11 @@ coroutines = "1.10.2" serialization = "1.9.0" # Compose -compose-bom = "2025.08.01" -compose-foundation = "1.9.0" +compose-bom = "2025.09.00" +compose-foundation = "1.9.1" compose-material-icons = "1.7.8" -compose-material3 = "1.4.0-beta03" -compose-ui = "1.9.0" +compose-material3 = "1.4.0-rc01" +compose-ui = "1.9.1" # Accompanist accompanist = "0.36.0" diff --git a/examples/llama.android/llama/.gitignore b/examples/llama.android/lib/.gitignore similarity index 100% rename from examples/llama.android/llama/.gitignore rename to examples/llama.android/lib/.gitignore diff --git a/examples/llama.android/llama/build.gradle.kts b/examples/llama.android/lib/build.gradle.kts similarity index 96% rename from examples/llama.android/llama/build.gradle.kts rename to examples/llama.android/lib/build.gradle.kts index f8dcddbe25..eec80d1f88 100644 --- a/examples/llama.android/llama/build.gradle.kts +++ b/examples/llama.android/lib/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } android { - namespace = "android.llama.cpp" + namespace = "com.arm.aichat" compileSdk = 36 ndkVersion = "29.0.13113456" @@ -84,8 +84,8 @@ publishing { publications { register("release") { groupId = "com.arm" - artifactId = "kleidi-llama" - version = "1.0.0" + artifactId = "ai-chat" + version = "0.1.0" afterEvaluate { from(components["release"]) diff --git a/examples/llama.android/llama/consumer-rules.pro b/examples/llama.android/lib/consumer-rules.pro similarity index 100% rename from examples/llama.android/llama/consumer-rules.pro rename to examples/llama.android/lib/consumer-rules.pro diff --git a/examples/llama.android/llama/proguard-rules.pro b/examples/llama.android/lib/proguard-rules.pro similarity index 100% rename from examples/llama.android/llama/proguard-rules.pro rename to examples/llama.android/lib/proguard-rules.pro diff --git a/examples/llama.android/llama/src/androidTest/java/android/llama/cpp/ExampleInstrumentedTest.kt b/examples/llama.android/lib/src/androidTest/java/android/llama/cpp/ExampleInstrumentedTest.kt similarity index 100% rename from examples/llama.android/llama/src/androidTest/java/android/llama/cpp/ExampleInstrumentedTest.kt rename to examples/llama.android/lib/src/androidTest/java/android/llama/cpp/ExampleInstrumentedTest.kt diff --git a/examples/llama.android/llama/src/main/AndroidManifest.xml b/examples/llama.android/lib/src/main/AndroidManifest.xml similarity index 100% rename from examples/llama.android/llama/src/main/AndroidManifest.xml rename to examples/llama.android/lib/src/main/AndroidManifest.xml diff --git a/examples/llama.android/llama/src/main/cpp/CMakeLists.txt b/examples/llama.android/lib/src/main/cpp/CMakeLists.txt similarity index 100% rename from examples/llama.android/llama/src/main/cpp/CMakeLists.txt rename to examples/llama.android/lib/src/main/cpp/CMakeLists.txt diff --git a/examples/llama.android/llama/src/main/cpp/cpu_detector.cpp b/examples/llama.android/lib/src/main/cpp/cpu_detector.cpp similarity index 93% rename from examples/llama.android/llama/src/main/cpp/cpu_detector.cpp rename to examples/llama.android/lib/src/main/cpp/cpu_detector.cpp index 85826754a1..05bc238056 100644 --- a/examples/llama.android/llama/src/main/cpp/cpu_detector.cpp +++ b/examples/llama.android/lib/src/main/cpp/cpu_detector.cpp @@ -13,7 +13,7 @@ static const Aarch64Features features = info.features; #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) extern "C" JNIEXPORT jint JNICALL -Java_android_llama_cpp_internal_TierDetectionImpl_getOptimalTier( +Java_com_arm_aichat_internal_TierDetectionImpl_getOptimalTier( JNIEnv* /*env*/, jobject /*clazz*/) { int tier = 0; // Default to T0 (baseline) @@ -54,7 +54,7 @@ Java_android_llama_cpp_internal_TierDetectionImpl_getOptimalTier( // Optional: Keep a feature string function for debugging extern "C" JNIEXPORT jstring JNICALL -Java_android_llama_cpp_internal_TierDetectionImpl_getCpuFeaturesString( +Java_com_arm_aichat_internal_TierDetectionImpl_getCpuFeaturesString( JNIEnv* env, jobject /*clazz*/) { std::string text; diff --git a/examples/llama.android/llama/src/main/cpp/kleidi_llama.cpp b/examples/llama.android/lib/src/main/cpp/kleidi_llama.cpp similarity index 95% rename from examples/llama.android/llama/src/main/cpp/kleidi_llama.cpp rename to examples/llama.android/lib/src/main/cpp/kleidi_llama.cpp index da585ebc06..94ea076df2 100644 --- a/examples/llama.android/llama/src/main/cpp/kleidi_llama.cpp +++ b/examples/llama.android/lib/src/main/cpp/kleidi_llama.cpp @@ -72,7 +72,7 @@ static void log_callback(ggml_log_level level, const char *fmt, void *data) { extern "C" JNIEXPORT void JNICALL -Java_android_llama_cpp_internal_InferenceEngineImpl_init(JNIEnv *env, jobject /*unused*/, jstring nativeLibDir) { +Java_com_arm_aichat_internal_InferenceEngineImpl_init(JNIEnv *env, jobject /*unused*/, jstring nativeLibDir) { // Set llama log handler to Android llama_log_set(log_callback, nullptr); @@ -89,7 +89,7 @@ Java_android_llama_cpp_internal_InferenceEngineImpl_init(JNIEnv *env, jobject /* extern "C" JNIEXPORT jint JNICALL -Java_android_llama_cpp_internal_InferenceEngineImpl_load(JNIEnv *env, jobject, jstring jmodel_path) { +Java_com_arm_aichat_internal_InferenceEngineImpl_load(JNIEnv *env, jobject, jstring jmodel_path) { llama_model_params model_params = llama_model_default_params(); const auto *model_path = env->GetStringUTFChars(jmodel_path, 0); @@ -143,7 +143,7 @@ static common_sampler *new_sampler(float temp) { extern "C" JNIEXPORT jint JNICALL -Java_android_llama_cpp_internal_InferenceEngineImpl_prepare(JNIEnv * /*env*/, jobject /*unused*/) { +Java_com_arm_aichat_internal_InferenceEngineImpl_prepare(JNIEnv * /*env*/, jobject /*unused*/) { auto *context = init_context(g_model); if (!context) { return 1; } g_context = context; @@ -167,13 +167,13 @@ static std::string get_backend() { extern "C" JNIEXPORT jstring JNICALL -Java_android_llama_cpp_internal_InferenceEngineImpl_systemInfo(JNIEnv *env, jobject /*unused*/) { +Java_com_arm_aichat_internal_InferenceEngineImpl_systemInfo(JNIEnv *env, jobject /*unused*/) { return env->NewStringUTF(llama_print_system_info()); } extern "C" JNIEXPORT jstring JNICALL -Java_android_llama_cpp_internal_InferenceEngineImpl_benchModel(JNIEnv *env, jobject /*unused*/, jint pp, jint tg, +Java_com_arm_aichat_internal_InferenceEngineImpl_benchModel(JNIEnv *env, jobject /*unused*/, jint pp, jint tg, jint pl, jint nr) { auto *context = init_context(g_model, pp); if (!context) { @@ -383,7 +383,7 @@ static int decode_tokens_in_batches( extern "C" JNIEXPORT jint JNICALL -Java_android_llama_cpp_internal_InferenceEngineImpl_processSystemPrompt( +Java_com_arm_aichat_internal_InferenceEngineImpl_processSystemPrompt( JNIEnv *env, jobject /*unused*/, jstring jsystem_prompt @@ -432,7 +432,7 @@ Java_android_llama_cpp_internal_InferenceEngineImpl_processSystemPrompt( extern "C" JNIEXPORT jint JNICALL -Java_android_llama_cpp_internal_InferenceEngineImpl_processUserPrompt( +Java_com_arm_aichat_internal_InferenceEngineImpl_processUserPrompt( JNIEnv *env, jobject /*unused*/, jstring juser_prompt, @@ -516,7 +516,7 @@ static bool is_valid_utf8(const char *string) { extern "C" JNIEXPORT jstring JNICALL -Java_android_llama_cpp_internal_InferenceEngineImpl_generateNextToken( +Java_com_arm_aichat_internal_InferenceEngineImpl_generateNextToken( JNIEnv *env, jobject /*unused*/ ) { @@ -576,7 +576,7 @@ Java_android_llama_cpp_internal_InferenceEngineImpl_generateNextToken( extern "C" JNIEXPORT void JNICALL -Java_android_llama_cpp_internal_InferenceEngineImpl_unload(JNIEnv * /*unused*/, jobject /*unused*/) { +Java_com_arm_aichat_internal_InferenceEngineImpl_unload(JNIEnv * /*unused*/, jobject /*unused*/) { // Reset long-term & short-term states reset_long_term_states(); reset_short_term_states(); @@ -591,6 +591,6 @@ Java_android_llama_cpp_internal_InferenceEngineImpl_unload(JNIEnv * /*unused*/, extern "C" JNIEXPORT void JNICALL -Java_android_llama_cpp_internal_InferenceEngineImpl_shutdown(JNIEnv *env, jobject /*unused*/) { +Java_com_arm_aichat_internal_InferenceEngineImpl_shutdown(JNIEnv *env, jobject /*unused*/) { llama_backend_free(); } diff --git a/examples/llama.android/llama/src/main/java/android/llama/cpp/AiChat.kt b/examples/llama.android/lib/src/main/java/com/arm/aichat/AiChat.kt similarity index 60% rename from examples/llama.android/llama/src/main/java/android/llama/cpp/AiChat.kt rename to examples/llama.android/lib/src/main/java/com/arm/aichat/AiChat.kt index 9f36c54397..151b2fbfa2 100644 --- a/examples/llama.android/llama/src/main/java/android/llama/cpp/AiChat.kt +++ b/examples/llama.android/lib/src/main/java/com/arm/aichat/AiChat.kt @@ -1,12 +1,11 @@ -package android.llama.cpp +package com.arm.aichat import android.content.Context -import android.llama.cpp.internal.InferenceEngineImpl -import android.llama.cpp.internal.TierDetectionImpl +import com.arm.aichat.internal.InferenceEngineImpl +import com.arm.aichat.internal.TierDetectionImpl /** - * Main entry point for the Ai Chat library. - * This is the only class that should be used by library consumers. + * Main entry point for Arm's AI Chat library. */ object AiChat { /** diff --git a/examples/llama.android/llama/src/main/java/android/llama/cpp/ArmFeatures.kt b/examples/llama.android/lib/src/main/java/com/arm/aichat/ArmFeatures.kt similarity index 99% rename from examples/llama.android/llama/src/main/java/android/llama/cpp/ArmFeatures.kt rename to examples/llama.android/lib/src/main/java/com/arm/aichat/ArmFeatures.kt index d3b1f668b0..6ddca0d70b 100644 --- a/examples/llama.android/llama/src/main/java/android/llama/cpp/ArmFeatures.kt +++ b/examples/llama.android/lib/src/main/java/com/arm/aichat/ArmFeatures.kt @@ -1,4 +1,4 @@ -package android.llama.cpp +package com.arm.aichat /** * Represents an ArmĀ® CPU feature with its metadata. diff --git a/examples/llama.android/llama/src/main/java/android/llama/cpp/InferenceEngine.kt b/examples/llama.android/lib/src/main/java/com/arm/aichat/InferenceEngine.kt similarity index 96% rename from examples/llama.android/llama/src/main/java/android/llama/cpp/InferenceEngine.kt rename to examples/llama.android/lib/src/main/java/com/arm/aichat/InferenceEngine.kt index 62ae87af12..a40b584362 100644 --- a/examples/llama.android/llama/src/main/java/android/llama/cpp/InferenceEngine.kt +++ b/examples/llama.android/lib/src/main/java/com/arm/aichat/InferenceEngine.kt @@ -1,6 +1,6 @@ -package android.llama.cpp +package com.arm.aichat -import android.llama.cpp.InferenceEngine.State +import com.arm.aichat.InferenceEngine.State import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow diff --git a/examples/llama.android/llama/src/main/java/android/llama/cpp/TierDetection.kt b/examples/llama.android/lib/src/main/java/com/arm/aichat/TierDetection.kt similarity index 96% rename from examples/llama.android/llama/src/main/java/android/llama/cpp/TierDetection.kt rename to examples/llama.android/lib/src/main/java/com/arm/aichat/TierDetection.kt index 395ca9a7f8..3799346359 100644 --- a/examples/llama.android/llama/src/main/java/android/llama/cpp/TierDetection.kt +++ b/examples/llama.android/lib/src/main/java/com/arm/aichat/TierDetection.kt @@ -1,4 +1,4 @@ -package android.llama.cpp +package com.arm.aichat /** * Public interface for [LLamaTier] detection information. diff --git a/examples/llama.android/llama/src/main/java/android/llama/cpp/gguf/FileType.kt b/examples/llama.android/lib/src/main/java/com/arm/aichat/gguf/FileType.kt similarity index 97% rename from examples/llama.android/llama/src/main/java/android/llama/cpp/gguf/FileType.kt rename to examples/llama.android/lib/src/main/java/com/arm/aichat/gguf/FileType.kt index ea694814ac..2f15eef077 100644 --- a/examples/llama.android/llama/src/main/java/android/llama/cpp/gguf/FileType.kt +++ b/examples/llama.android/lib/src/main/java/com/arm/aichat/gguf/FileType.kt @@ -1,4 +1,6 @@ -package android.llama.cpp.gguf +package com.arm.aichat.gguf + +import kotlin.collections.get /** diff --git a/examples/llama.android/llama/src/main/java/android/llama/cpp/gguf/GgufMetadata.kt b/examples/llama.android/lib/src/main/java/com/arm/aichat/gguf/GgufMetadata.kt similarity index 99% rename from examples/llama.android/llama/src/main/java/android/llama/cpp/gguf/GgufMetadata.kt rename to examples/llama.android/lib/src/main/java/com/arm/aichat/gguf/GgufMetadata.kt index 1e48773037..5e1971ae2f 100644 --- a/examples/llama.android/llama/src/main/java/android/llama/cpp/gguf/GgufMetadata.kt +++ b/examples/llama.android/lib/src/main/java/com/arm/aichat/gguf/GgufMetadata.kt @@ -1,4 +1,4 @@ -package android.llama.cpp.gguf +package com.arm.aichat.gguf import java.io.IOException diff --git a/examples/llama.android/llama/src/main/java/android/llama/cpp/gguf/GgufMetadataReader.kt b/examples/llama.android/lib/src/main/java/com/arm/aichat/gguf/GgufMetadataReader.kt similarity index 96% rename from examples/llama.android/llama/src/main/java/android/llama/cpp/gguf/GgufMetadataReader.kt rename to examples/llama.android/lib/src/main/java/com/arm/aichat/gguf/GgufMetadataReader.kt index c22f6d7a14..4d5ff25783 100644 --- a/examples/llama.android/llama/src/main/java/android/llama/cpp/gguf/GgufMetadataReader.kt +++ b/examples/llama.android/lib/src/main/java/com/arm/aichat/gguf/GgufMetadataReader.kt @@ -1,8 +1,8 @@ -package android.llama.cpp.gguf +package com.arm.aichat.gguf import android.content.Context -import android.llama.cpp.internal.gguf.GgufMetadataReaderImpl import android.net.Uri +import com.arm.aichat.internal.gguf.GgufMetadataReaderImpl import java.io.IOException import java.io.InputStream diff --git a/examples/llama.android/llama/src/main/java/android/llama/cpp/internal/InferenceEngineImpl.kt b/examples/llama.android/lib/src/main/java/com/arm/aichat/internal/InferenceEngineImpl.kt similarity index 98% rename from examples/llama.android/llama/src/main/java/android/llama/cpp/internal/InferenceEngineImpl.kt rename to examples/llama.android/lib/src/main/java/com/arm/aichat/internal/InferenceEngineImpl.kt index c5d8eccbf0..a22c5b7620 100644 --- a/examples/llama.android/llama/src/main/java/android/llama/cpp/internal/InferenceEngineImpl.kt +++ b/examples/llama.android/lib/src/main/java/com/arm/aichat/internal/InferenceEngineImpl.kt @@ -1,9 +1,10 @@ -package android.llama.cpp.internal +package com.arm.aichat.internal import android.content.Context -import android.llama.cpp.InferenceEngine -import android.llama.cpp.UnsupportedArchitectureException import android.util.Log +import com.arm.aichat.InferenceEngine +import com.arm.aichat.UnsupportedArchitectureException +import com.arm.aichat.internal.InferenceEngineImpl.Companion.getInstance import dalvik.annotation.optimization.FastNative import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope @@ -205,7 +206,7 @@ internal class InferenceEngineImpl private constructor( } /** - * Send plain text user prompt to LLM, which starts generating tokens in a [kotlinx.coroutines.flow.Flow] + * Send plain text user prompt to LLM, which starts generating tokens in a [Flow] */ override fun sendUserPrompt( message: String, diff --git a/examples/llama.android/llama/src/main/java/android/llama/cpp/internal/TierDetectionImpl.kt b/examples/llama.android/lib/src/main/java/com/arm/aichat/internal/TierDetectionImpl.kt similarity index 97% rename from examples/llama.android/llama/src/main/java/android/llama/cpp/internal/TierDetectionImpl.kt rename to examples/llama.android/lib/src/main/java/com/arm/aichat/internal/TierDetectionImpl.kt index feadb9aa8c..70c8d00356 100644 --- a/examples/llama.android/llama/src/main/java/android/llama/cpp/internal/TierDetectionImpl.kt +++ b/examples/llama.android/lib/src/main/java/com/arm/aichat/internal/TierDetectionImpl.kt @@ -1,14 +1,14 @@ -package android.llama.cpp.internal +package com.arm.aichat.internal import android.content.Context -import android.llama.cpp.LLamaTier -import android.llama.cpp.TierDetection import android.util.Log import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.intPreferencesKey import androidx.datastore.preferences.preferencesDataStore +import com.arm.aichat.LLamaTier +import com.arm.aichat.TierDetection import kotlinx.coroutines.flow.first import kotlinx.coroutines.runBlocking diff --git a/examples/llama.android/llama/src/main/java/android/llama/cpp/internal/gguf/GgufMetadataReaderImpl.kt b/examples/llama.android/lib/src/main/java/com/arm/aichat/internal/gguf/GgufMetadataReaderImpl.kt similarity index 99% rename from examples/llama.android/llama/src/main/java/android/llama/cpp/internal/gguf/GgufMetadataReaderImpl.kt rename to examples/llama.android/lib/src/main/java/com/arm/aichat/internal/gguf/GgufMetadataReaderImpl.kt index e052a106c9..d8b95aff37 100644 --- a/examples/llama.android/llama/src/main/java/android/llama/cpp/internal/gguf/GgufMetadataReaderImpl.kt +++ b/examples/llama.android/lib/src/main/java/com/arm/aichat/internal/gguf/GgufMetadataReaderImpl.kt @@ -1,10 +1,10 @@ -package android.llama.cpp.internal.gguf +package com.arm.aichat.internal.gguf import android.content.Context -import android.llama.cpp.gguf.GgufMetadata -import android.llama.cpp.gguf.GgufMetadataReader -import android.llama.cpp.gguf.InvalidFileFormatException import android.net.Uri +import com.arm.aichat.gguf.GgufMetadata +import com.arm.aichat.gguf.GgufMetadataReader +import com.arm.aichat.gguf.InvalidFileFormatException import java.io.IOException import java.io.InputStream diff --git a/examples/llama.android/llama/src/test/java/android/llama/cpp/ExampleUnitTest.kt b/examples/llama.android/lib/src/test/java/android/llama/cpp/ExampleUnitTest.kt similarity index 100% rename from examples/llama.android/llama/src/test/java/android/llama/cpp/ExampleUnitTest.kt rename to examples/llama.android/lib/src/test/java/android/llama/cpp/ExampleUnitTest.kt diff --git a/examples/llama.android/settings.gradle.kts b/examples/llama.android/settings.gradle.kts index 7ad9f5cc08..74f4eb3e46 100644 --- a/examples/llama.android/settings.gradle.kts +++ b/examples/llama.android/settings.gradle.kts @@ -13,6 +13,6 @@ dependencyResolutionManagement { } } -rootProject.name = "LlamaAndroid" +rootProject.name = "AiChat" include(":app") -include(":llama") +include(":lib")