Abrarul8541 commited on
Commit
6e1d6ab
·
verified ·
1 Parent(s): 528d09a

Shared process state: engine, locale, endpoints

Browse files
app/src/main/java/io/github/abrarul/modularai/AppRuntime.kt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package io.github.abrarul.modularai
2
+
3
+ import android.content.Context
4
+ import io.github.abrarul.modularai.engine.LlamaEngine
5
+ import io.github.abrarul.modularai.i18n.LocaleManager
6
+
7
+ object Config {
8
+ const val LOCALES_URL = "https://huggingface.co/Abrarul8541/ModularAI-Terminal/resolve/main/locales"
9
+ const val UPDATE_URL = "https://huggingface.co/Abrarul8541/ModularAI-Terminal/resolve/main/update.json"
10
+ }
11
+
12
+ /** Process-wide state so a loaded model and the chosen language survive screen changes. */
13
+ object AppRuntime {
14
+ val engine by lazy { LlamaEngine() }
15
+
16
+ @Volatile private var loc: LocaleManager? = null
17
+ fun locale(ctx: Context): LocaleManager =
18
+ loc ?: synchronized(this) {
19
+ loc ?: LocaleManager(ctx.applicationContext, Config.LOCALES_URL).also { loc = it }
20
+ }
21
+ }