Skip to content

Commit 195a1a2

Browse files
Merge pull request #432 from RunanywhereAI/smonga/android_fixes
[Kotlin-SDK] [Kotlin-Example] minor fixes
2 parents 61f6f1a + 03d6416 commit 195a1a2

21 files changed

Lines changed: 1126 additions & 944 deletions

File tree

examples/android/RunAnywhereAI/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<activity
4141
android:name=".MainActivity"
4242
android:exported="true"
43-
android:windowSoftInputMode="adjustResize"
43+
android:windowSoftInputMode="adjustNothing"
4444
android:theme="@style/Theme.RunAnywhereAI">
4545
<intent-filter>
4646
<action android:name="android.intent.action.MAIN" />

examples/android/RunAnywhereAI/app/src/main/java/com/runanywhere/runanywhereai/data/ConversationStore.kt

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ import timber.log.Timber
66
import com.runanywhere.runanywhereai.domain.models.ChatMessage
77
import com.runanywhere.runanywhereai.domain.models.Conversation
88
import com.runanywhere.runanywhereai.domain.models.MessageRole
9+
import kotlinx.coroutines.CoroutineScope
10+
import kotlinx.coroutines.Dispatchers
11+
import kotlinx.coroutines.SupervisorJob
912
import kotlinx.coroutines.flow.MutableStateFlow
1013
import kotlinx.coroutines.flow.StateFlow
1114
import kotlinx.coroutines.flow.asStateFlow
15+
import kotlinx.coroutines.launch
1216
import kotlinx.serialization.decodeFromString
1317
import kotlinx.serialization.encodeToString
1418
import kotlinx.serialization.json.Json
@@ -42,6 +46,7 @@ class ConversationStore private constructor(context: Context) {
4246
val currentConversation: StateFlow<Conversation?> = _currentConversation.asStateFlow()
4347

4448
private val conversationsDirectory: File
49+
private val ioScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
4550
private val json =
4651
Json {
4752
prettyPrint = true
@@ -53,7 +58,7 @@ class ConversationStore private constructor(context: Context) {
5358
if (!conversationsDirectory.exists()) {
5459
conversationsDirectory.mkdirs()
5560
}
56-
loadConversations()
61+
ioScope.launch { loadConversations() }
5762
}
5863

5964
// MARK: - Public Methods
@@ -127,10 +132,12 @@ class ConversationStore private constructor(context: Context) {
127132
_currentConversation.value = _conversations.value.firstOrNull()
128133
}
129134

130-
// Delete file
131-
val file = conversationFileURL(conversation.id)
132-
if (file.exists()) {
133-
file.delete()
135+
// Delete file off main thread
136+
ioScope.launch {
137+
val file = conversationFileURL(conversation.id)
138+
if (file.exists()) {
139+
file.delete()
140+
}
134141
}
135142
}
136143

@@ -246,12 +253,14 @@ class ConversationStore private constructor(context: Context) {
246253
* Save a conversation to disk
247254
*/
248255
private fun saveConversation(conversation: Conversation) {
249-
try {
250-
val file = conversationFileURL(conversation.id)
251-
val jsonString = json.encodeToString(conversation)
252-
file.writeText(jsonString)
253-
} catch (e: Exception) {
254-
Timber.e(e, "Failed to save conversation")
256+
ioScope.launch {
257+
try {
258+
val file = conversationFileURL(conversation.id)
259+
val jsonString = json.encodeToString(conversation)
260+
file.writeText(jsonString)
261+
} catch (e: Exception) {
262+
Timber.e(e, "Failed to save conversation")
263+
}
255264
}
256265
}
257266

examples/android/RunAnywhereAI/app/src/main/java/com/runanywhere/runanywhereai/data/ModelList.kt

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ object ModelList {
3232
AppModel(id = "qwen2.5-0.5b-instruct-q6_k", name = "Qwen 2.5 0.5B Instruct Q6_K",
3333
url = "https://huggingface.co/Triangle104/Qwen2.5-0.5B-Instruct-Q6_K-GGUF/resolve/main/qwen2.5-0.5b-instruct-q6_k.gguf",
3434
framework = InferenceFramework.LLAMA_CPP, category = ModelCategory.LANGUAGE,
35-
memoryRequirement = 600_000_000),
35+
memoryRequirement = 600_000_000, supportsLoraAdapters = true),
3636
AppModel(id = "lfm2-350m-q4_k_m", name = "LiquidAI LFM2 350M Q4_K_M",
3737
url = "https://huggingface.co/LiquidAI/LFM2-350M-GGUF/resolve/main/LFM2-350M-Q4_K_M.gguf",
3838
framework = InferenceFramework.LLAMA_CPP, category = ModelCategory.LANGUAGE,
39-
memoryRequirement = 250_000_000, supportsLoraAdapters = true),
39+
memoryRequirement = 250_000_000),
4040
AppModel(id = "lfm2-350m-q8_0", name = "LiquidAI LFM2 350M Q8_0",
4141
url = "https://huggingface.co/LiquidAI/LFM2-350M-GGUF/resolve/main/LFM2-350M-Q8_0.gguf",
4242
framework = InferenceFramework.LLAMA_CPP, category = ModelCategory.LANGUAGE,
43-
memoryRequirement = 400_000_000, supportsLoraAdapters = true),
43+
memoryRequirement = 400_000_000),
4444
AppModel(id = "lfm2-1.2b-tool-q4_k_m", name = "LiquidAI LFM2 1.2B Tool Q4_K_M",
4545
url = "https://huggingface.co/LiquidAI/LFM2-1.2B-Tool-GGUF/resolve/main/LFM2-1.2B-Tool-Q4_K_M.gguf",
4646
framework = InferenceFramework.LLAMA_CPP, category = ModelCategory.LANGUAGE,
@@ -81,46 +81,46 @@ object ModelList {
8181
)),
8282
)
8383

84-
// LoRA Adapters (from Void2377/Qwen on HuggingFace — real standalone LoRA GGUF files)
84+
// LoRA Adapters
8585
private val loraAdapters = listOf(
8686
LoraAdapterCatalogEntry(
87-
id = "chat-assistant-lora",
88-
name = "Chat Assistant",
89-
description = "Enhances conversational chat ability",
90-
downloadUrl = "https://huggingface.co/Void2377/Qwen/resolve/main/lora/chat_assistant-lora-Q8_0.gguf",
91-
filename = "chat_assistant-lora-Q8_0.gguf",
92-
compatibleModelIds = listOf("lfm2-350m-q4_k_m", "lfm2-350m-q8_0"),
93-
fileSize = 690_176,
87+
id = "code-assistant-lora",
88+
name = "Code Assistant",
89+
description = "Enhances code generation and programming assistance",
90+
downloadUrl = "https://huggingface.co/Void2377/Qwen/resolve/main/lora/code-assistant-Q8_0.gguf",
91+
filename = "code-assistant-Q8_0.gguf",
92+
compatibleModelIds = listOf("qwen2.5-0.5b-instruct-q6_k"),
93+
fileSize = 765_952,
9494
defaultScale = 1.0f,
9595
),
9696
LoraAdapterCatalogEntry(
97-
id = "summarizer-lora",
98-
name = "Summarizer",
99-
description = "Specialized for text summarization tasks",
100-
downloadUrl = "https://huggingface.co/Void2377/Qwen/resolve/main/lora/summarizer-lora-Q8_0.gguf",
101-
filename = "summarizer-lora-Q8_0.gguf",
102-
compatibleModelIds = listOf("lfm2-350m-q4_k_m", "lfm2-350m-q8_0"),
103-
fileSize = 690_176,
97+
id = "reasoning-logic-lora",
98+
name = "Reasoning Logic",
99+
description = "Improves logical reasoning and step-by-step problem solving",
100+
downloadUrl = "https://huggingface.co/Void2377/Qwen/resolve/main/lora/reasoning-logic-Q8_0.gguf",
101+
filename = "reasoning-logic-Q8_0.gguf",
102+
compatibleModelIds = listOf("qwen2.5-0.5b-instruct-q6_k"),
103+
fileSize = 765_952,
104104
defaultScale = 1.0f,
105105
),
106106
LoraAdapterCatalogEntry(
107-
id = "translator-lora",
108-
name = "Translator",
109-
description = "Improves translation between languages",
110-
downloadUrl = "https://huggingface.co/Void2377/Qwen/resolve/main/lora/translator-lora-Q8_0.gguf",
111-
filename = "translator-lora-Q8_0.gguf",
112-
compatibleModelIds = listOf("lfm2-350m-q4_k_m", "lfm2-350m-q8_0"),
113-
fileSize = 690_176,
107+
id = "medical-qa-lora",
108+
name = "Medical QA",
109+
description = "Enhances medical question answering and health-related responses",
110+
downloadUrl = "https://huggingface.co/Void2377/Qwen/resolve/main/lora/medical-qa-Q8_0.gguf",
111+
filename = "medical-qa-Q8_0.gguf",
112+
compatibleModelIds = listOf("qwen2.5-0.5b-instruct-q6_k"),
113+
fileSize = 765_952,
114114
defaultScale = 1.0f,
115115
),
116116
LoraAdapterCatalogEntry(
117-
id = "sentiment-lora",
118-
name = "Sentiment Analysis",
119-
description = "Fine-tuned for sentiment analysis tasks",
120-
downloadUrl = "https://huggingface.co/Void2377/Qwen/resolve/main/lora/sentiment-lora-Q8_0.gguf",
121-
filename = "sentiment-lora-Q8_0.gguf",
122-
compatibleModelIds = listOf("lfm2-350m-q4_k_m", "lfm2-350m-q8_0"),
123-
fileSize = 690_176,
117+
id = "creative-writing-lora",
118+
name = "Creative Writing",
119+
description = "Improves creative writing, storytelling, and literary style",
120+
downloadUrl = "https://huggingface.co/Void2377/Qwen/resolve/main/lora/creative-writing-Q8_0.gguf",
121+
filename = "creative-writing-Q8_0.gguf",
122+
compatibleModelIds = listOf("qwen2.5-0.5b-instruct-q6_k"),
123+
fileSize = 765_952,
124124
defaultScale = 1.0f,
125125
),
126126
)

0 commit comments

Comments
 (0)