Skip to content

Commit 995344d

Browse files
committed
Technical review of Android AI Chat LP
1 parent 8284635 commit 995344d

5 files changed

Lines changed: 14 additions & 5 deletions

File tree

content/learning-paths/mobile-graphics-and-gaming/android-ai-chat-lib/_index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ title: Add an LLM to your Android app with Arm's AI Chat library
33

44
minutes_to_complete: 15
55

6-
who_is_this_for: Android App Developers who wish to add LLM capabilities to an app.
6+
who_is_this_for: This is an introductory topic for developers who want to add a local, on-device LLM chat experience using Arm's AI Chat library, Kotlin, and Android Studio.
77

88
learning_objectives:
9-
- Easily add an on-device LLM to any Android app
9+
- Create a simple Android chatbot app scaffold in Android Studio
10+
- Load a mobile-friendly GGUF model on-device and run streamed chat inference
1011

1112
prerequisites:
1213
- Android Studio

content/learning-paths/mobile-graphics-and-gaming/android-ai-chat-lib/add-ai-chat-lib-2.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ This adds the library to your project, and all the LLM functionality. Also in th
2121
- the Java version in `compileOptions` is `JavaVersion.VERSION_17`
2222
- the `jvmTarget` in `kotlinOptions` is 17
2323

24-
In `libs.version.toml` we need to change the `kotlin` version to `2.2.20`, as the library requires a more recent version than the default.
24+
In `libs.version.toml`, check that:
25+
- `kotlin` version is `2.2.20`
2526

2627
Finally, there will be a banner at the top of these settings files saying the "Gradle files have changed since last project sync." Choose the option to "Sync Now", and let the project update.
2728

content/learning-paths/mobile-graphics-and-gaming/android-ai-chat-lib/add-layouts-adapter-3.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ layout: learningpathall
77
---
88

99
## Add Layouts
10-
Currently the `activity_main.xml` layout file in your `app\src\res\layout` directory is nearly empty, containing just a "Hello World!" piece of text that we wish to remove. Instead, replace it with the following, which will create a status area at the top, a place for messages in the middle, and a place for you to type at the bottom with a button to send:
10+
Currently the `activity_main.xml` layout file in your `app\src\main\res\layout` directory is nearly empty, containing just a "Hello World!" piece of text that we wish to remove. Instead, replace it with the following, which will create a status area at the top, a place for messages in the middle, and a place for you to type at the bottom with a button to send:
1111
```xml
1212
<?xml version="1.0" encoding="utf-8"?>
1313
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -117,7 +117,12 @@ Then create `item_message_assistant.xml` and put the following as its contents:
117117
## Add the MessageAdaptor class
118118
As a final bit of UI code, we add a `MessageAdapter.kt` code file to put our messages into the correct bit of layout. The file should sit alongside the `MainActivity` class that is auto-created with the project.
119119

120+
{{% notice Package name %}}
121+
The `package` name below has to match that of your project name. If you named your project `simpleaichat`, you can copy the block without changes. If you named your project differently as you started out this Learning Path, make sure you update it after populating the file.
122+
{{% /notice %}}
123+
120124
The file contents of `MessageAdapter.kt` are:
125+
121126
```kotlin
122127
package com.example.simpleaichat
123128

content/learning-paths/mobile-graphics-and-gaming/android-ai-chat-lib/setup-1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ For other examples of chatbots using this library you can use:
1616
- the [AI Chat library GitHub example](https://github.com/arm/ai-chat/tree/use-maven-library/examples/llama.android), which is only slightly more complicated than this Learning Path.
1717

1818
## Project Setup
19-
Open Android Studio and create a new project of the type "Empty Views Activity". Name it however you like, and leave other options on default - for instance Minimum SDK will be 33.
19+
Open Android Studio and create a new project of the type "Empty Views Activity". Name it `simpleaichat`, and set the Minimum SDK to 33.
2020

content/learning-paths/mobile-graphics-and-gaming/android-ai-chat-lib/use-lib-in-code-4.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import java.io.File
3535
import java.io.IOException
3636
import java.util.UUID
3737
import kotlin.math.max
38+
import com.example.simpleaichat.Message
39+
import com.example.simpleaichat.MessageAdapter
3840
```
3941

4042
Next, within the MainActivity class, we need to set all the class variables we'll need:

0 commit comments

Comments
 (0)