From 7ca44ef5e23cc268a27b9dbbfce39447217a497b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Fri, 13 Nov 2026 14:17:27 +0000 Subject: [PATCH] Settings: the assistant's model, and it holds for every new chat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Settings › Assistant › Assistant model: "Instance default" or one of the instance's models, saved as the existing assistantModel preference. The controller keeps the model for new chats apart from the model of the chat the sheet is in: New chat after "Continue the last chat" goes back to it, a change in Settings reaches a sheet that is still alive, and a question asked before the model list was read waits for it (and falls back to the saved choice, not to the instance's default, when the list cannot be read). Co-Authored-By: Claude Fable 5.2 --- CHANGELOG.md | 13 ++++ .../android/assist/AssistController.kt | 49 ++++++++++-- .../android/ui/settings/SettingsScreen.kt | 75 +++++++++++++++++++ app/src/main/res/values-cs/strings.xml | 3 + app/src/main/res/values-de/strings.xml | 3 + app/src/main/res/values-es/strings.xml | 3 + app/src/main/res/values-fr/strings.xml | 3 + app/src/main/res/values-hu/strings.xml | 3 + app/src/main/res/values-it/strings.xml | 3 + app/src/main/res/values-pl/strings.xml | 3 + app/src/main/res/values-sk/strings.xml | 3 + app/src/main/res/values/strings.xml | 3 + .../java/eu/llembas/android/AssistTest.kt | 17 +++++ .../java/eu/llembas/android/shots/Fakes.kt | 1 + .../eu/llembas/android/shots/ScreenShots.kt | 9 +++ scripts/strings.py | 3 + scripts/strings_own.json | 24 ++++++ 17 files changed, 212 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b153e5..a803dfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,21 @@ is in alpha and releases come off `main`. ## [Unreleased] +### Added + +- **Assistant model** in Settings › Assistant: the model the assistant's new chats start on -- + *Instance default* (your account's default, as before) or any model of the instance. A large + default model is slow to answer a spoken question; a quick one can be chosen for the assistant + alone. It holds for every way in: the sheet, the wake word, Share. Picking a model in the + sheet still changes it too. + ### Fixed +- **A new assistant chat could start on the wrong model.** After *Continue the last chat*, *New + chat* kept that chat's model instead of going back to the assistant's own; and a question + sent the moment the sheet opened, before the instance had said which models it has, went to + the instance's default whatever was chosen. + - **Listening went on and on in a quiet room.** With the instance's speech-to-text the sheet decided "somebody is speaking" and "it is quiet again" by two fixed loudness levels. A phone whose room noise sat above the quiet level never heard a pause, so it listened until the diff --git a/app/src/main/java/eu/llembas/android/assist/AssistController.kt b/app/src/main/java/eu/llembas/android/assist/AssistController.kt index a74f850..fee0a4b 100644 --- a/app/src/main/java/eu/llembas/android/assist/AssistController.kt +++ b/app/src/main/java/eu/llembas/android/assist/AssistController.kt @@ -28,7 +28,10 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.transformWhile import kotlinx.coroutines.flow.update import kotlinx.coroutines.isActive @@ -142,11 +145,29 @@ class AssistController(private val context: Context, private val scope: Coroutin private var usingPhone = false private var screenText: String? = null private var stt: Boolean? = null + + /** The account's own default model, as the instance said it: what "Instance default" means. */ + private var accountDefault: String? = null + + /** + * The model a new chat starts on (Settings › Assistant › Assistant model). The sheet's + * [AssistUiState.modelId] is the model of the chat it is in, which for a continued chat is + * that chat's own; a new chat goes back to this one. + */ + private var newChatModel: String? = null private val ready: Job init { ready = scope.launch { load() } scope.launch { speaker.playing.collect { on -> _state.update { it.copy(speaking = on) } } } + // Settings changed the assistant's model while this sheet lives: the next new chat has it. + scope.launch { + context.lembas.instances.prefs.map { it.assistantModel }.distinctUntilChanged().drop(1).collect { chosen -> + ready.join() + newChatModel = assistantModelFor(chosen, accountDefault, _state.value.models) ?: chosen.ifBlank { null } + _state.update { if (it.chatId == null) it.copy(modelId = newChatModel) else it } + } + } } /** The instance, its models and what it offers this account; the choices kept in Settings. */ @@ -164,15 +185,17 @@ class AssistController(private val context: Context, private val scope: Coroutin ?.let { id -> LastAssist(id, prefs.lastAssistTitle, prefs.lastAssistAt) }, ) } + // Until the instance has said what it has, the choice in Settings stands as it is: a + // question asked while the list could not be read still goes to the chosen model. + newChatModel = prefs.assistantModel.ifBlank { null } val api = instance?.let { store.clientFor(it) } ?: return try { val me = api.me() val models = api.models() stt = me.speechToText - val chosen = prefs.assistantModel.takeIf { id -> models.any { it.id == id } } - ?: me.defaultModel?.takeIf { id -> models.any { it.id == id } } - ?: models.firstOrNull { it.default }?.id - ?: models.firstOrNull()?.id + accountDefault = me.defaultModel + val chosen = assistantModelFor(prefs.assistantModel, me.defaultModel, models) + newChatModel = chosen _state.update { it.copy( connection = Connection.Online, @@ -428,6 +451,8 @@ class AssistController(private val context: Context, private val scope: Coroutin val store = context.lembas.instances val api = store.client() ?: throw ApiException(401, "Not signed in.") val prefs = store.prefs.first() + // A question typed the moment the sheet opened: the model is known first. + ready.join() val now = _state.value val withScreen = now.includeScreen val attachments = buildList { @@ -456,7 +481,7 @@ class AssistController(private val context: Context, private val scope: Coroutin inChat = chatId replyId = sent.reply?.id ?: return@launch } else { - val made = api.createChat(text, attachments, model = now.modelId, temporary = prefs.assistantTemporary) + val made = api.createChat(text, attachments, model = now.modelId ?: newChatModel, temporary = prefs.assistantTemporary) inChat = made.chat.id replyId = made.reply?.id ?: return@launch _state.update { it.copy(chatId = inChat) } @@ -560,11 +585,13 @@ class AssistController(private val context: Context, private val scope: Coroutin override fun newChat() { following?.cancel() speaker.stop() - _state.update { it.copy(chatId = null, turns = emptyList(), error = null, busy = false, conversation = false) } + // And on the assistant's own model again, not the one of the chat that was continued. + _state.update { it.copy(chatId = null, turns = emptyList(), error = null, busy = false, conversation = false, modelId = newChatModel ?: it.modelId) } } /** The model: for the chat this sheet is in, changed at once; for a new one, kept for next time. */ override fun pickModel(id: String) { + newChatModel = id _state.update { it.copy(modelId = id) } scope.launch { context.lembas.instances.savePrefs { it.copy(assistantModel = id) } @@ -637,6 +664,16 @@ class AssistController(private val context: Context, private val scope: Coroutin private const val TICK_MS = EndOfSpeech.TICK_MS private const val PARTIAL_EVERY_MS = 1_200L + /** + * The model a new assistant chat starts on: the one [chosen] in Settings while the + * instance still has it; else ("Instance default", or a model that is gone) the + * account's default, the instance's, or its first. + */ + fun assistantModelFor(chosen: String, accountDefault: String?, models: List): String? { + val has = { id: String? -> !id.isNullOrBlank() && models.any { it.id == id } } + return chosen.takeIf(has) ?: accountDefault?.takeIf(has) ?: models.firstOrNull { it.default }?.id ?: models.firstOrNull()?.id + } + /** A reply's words, for a voice: its text steps, without the markup. */ fun spokenWords(steps: List): String = plain(steps.filter { it.kind == "text" }.joinToString("\n\n") { it.markdown.orEmpty() }) diff --git a/app/src/main/java/eu/llembas/android/ui/settings/SettingsScreen.kt b/app/src/main/java/eu/llembas/android/ui/settings/SettingsScreen.kt index 4e49659..e511deb 100644 --- a/app/src/main/java/eu/llembas/android/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/eu/llembas/android/ui/settings/SettingsScreen.kt @@ -48,6 +48,7 @@ import androidx.compose.material.icons.filled.Notifications import androidx.compose.material.icons.filled.NotificationsActive import androidx.compose.material.icons.filled.Palette import androidx.compose.material.icons.filled.PhoneAndroid +import androidx.compose.material.icons.filled.Psychology import androidx.compose.material.icons.filled.RecordVoiceOver import androidx.compose.material.icons.filled.Science import androidx.compose.material.icons.filled.ScreenLockPortrait @@ -93,6 +94,7 @@ import eu.llembas.android.AppLanguage import eu.llembas.android.BuildConfig import eu.llembas.android.R import eu.llembas.android.actions.NavApp +import eu.llembas.android.api.ModelInfo import eu.llembas.android.assist.LembasAssistService import eu.llembas.android.assist.PhoneRecognizer import eu.llembas.android.auth.Instance @@ -122,6 +124,7 @@ import eu.llembas.android.wake.WakeWordService import eu.llembas.android.wake.WakeWords import eu.llembas.android.wake.wakeAttemptWords import eu.llembas.android.wake.wakeTitle +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -136,6 +139,7 @@ interface SettingsActions { fun notificationSettings() {} fun assistantSettings() {} fun assistantTemporary(on: Boolean) {} + fun assistantModel(id: String) {} fun voiceInput(value: String) {} fun assistantListens(on: Boolean) {} fun assistantConversation(on: Boolean) {} @@ -195,6 +199,8 @@ data class SettingsState( val notificationsBuild: Boolean = false, /** The navigation apps installed: NavApp ids. */ val navApps: List = emptyList(), + /** The instance's models, for Settings › Assistant › Assistant model; empty until (or unless) it said them. */ + val assistantModels: List = emptyList(), ) @Composable @@ -218,6 +224,18 @@ fun SettingsScreen(onBack: () -> Unit, onAddInstance: () -> Unit) { } clock = SystemClock.elapsedRealtime() } + // The instance's models, for the assistant's: asked for each time Settings opens on an instance. + var models by remember { mutableStateOf(emptyList()) } + LaunchedEffect(active?.id) { + models = try { + store.client()?.models().orEmpty() + } catch (e: CancellationException) { + throw e + } catch (e: Exception) { + // Not reachable now: the row keeps what was chosen and offers the instance's default. + emptyList() + } + } var pushNote by remember { mutableStateOf(null) } var updateNote by remember { mutableStateOf(null) } var updateFound by remember { mutableStateOf(null) } @@ -279,6 +297,10 @@ fun SettingsScreen(onBack: () -> Unit, onAddInstance: () -> Unit) { scope.launch { store.savePrefs { it.copy(assistantTemporary = on) } } } + override fun assistantModel(id: String) { + scope.launch { store.savePrefs { it.copy(assistantModel = id) } } + } + override fun voiceInput(value: String) { scope.launch { store.savePrefs { it.copy(voiceInput = value) } } } @@ -420,6 +442,7 @@ fun SettingsScreen(onBack: () -> Unit, onAddInstance: () -> Unit) { notificationAccess = NotificationAccess.granted(context), notificationsBuild = NotificationAccess.AVAILABLE, navApps = remember { NavApp.installedApps(context).map { it.id } }, + assistantModels = models, ), actions, onBack, @@ -444,6 +467,15 @@ fun SettingsContent(state: SettingsState, actions: SettingsActions, onBack: () - }) } } + var choosingModel by remember { mutableStateOf(false) } + if (choosingModel) { + ModalBottomSheet(onDismissRequest = { choosingModel = false }, sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)) { + AssistantModelChoices(state, onPick = { + choosingModel = false + actions.assistantModel(it) + }) + } + } if (choosingLanguage) { ModalBottomSheet(onDismissRequest = { choosingLanguage = false }, sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)) { LanguageChoices(state.prefs, onPick = { @@ -567,6 +599,15 @@ fun SettingsContent(state: SettingsState, actions: SettingsActions, onBack: () - onClick = actions::assistantSettings, ) Rule() + // The model the assistant's new chats start on: the instance's default may be + // a large one, and a spoken question wants a quick answer. + SettingRow( + Icons.Filled.Psychology, + stringResource(R.string.assistant_model), + subtitle = assistantModelLabel(state), + onClick = { choosingModel = true }, + ) + Rule() SettingRow( Icons.Filled.Timer, stringResource(R.string.assistant_temporary), @@ -1109,6 +1150,40 @@ fun WakeChoices(which: WakeChoice, prefs: Prefs, onPick: ((SettingsActions) -> U } } +/** + * What the assistant's model row says: the chosen model by its name, or "Instance default" -- + * also for a model the instance no longer has, since that is what the assistant then uses. + */ +@Composable +private fun assistantModelLabel(state: SettingsState): String { + val chosen = state.prefs.assistantModel + val model = state.assistantModels.firstOrNull { it.id == chosen } + // While the list is not read yet, or could not be: the choice as it was saved. + return when { + chosen.isBlank() -> stringResource(R.string.assistant_model_default) + model != null -> model.name.ifBlank { model.id } + state.assistantModels.isEmpty() -> chosen + else -> stringResource(R.string.assistant_model_default) + } +} + +/** + * Settings › Assistant › Assistant model, as a sheet: "Instance default" (the account's default + * model, as in a new chat in the app), then the instance's models. The choice is the model a new + * assistant chat starts on, from every way in -- the sheet, the wake word, Share. + */ +@Composable +fun AssistantModelChoices(state: SettingsState, onPick: (String) -> Unit) { + val chosen = state.prefs.assistantModel.takeIf { id -> state.assistantModels.any { it.id == id } }.orEmpty() + val choices = listOf( + Choice(INSTANCE_DEFAULT, stringResource(R.string.assistant_model_default), stringResource(R.string.assistant_model_default_line), chosen.isEmpty()), + ) + state.assistantModels.map { Choice(it.id, it.name.ifBlank { it.id }, null, it.id == chosen) } + ChoiceList(stringResource(R.string.assistant_model), choices) { id -> onPick(if (id == INSTANCE_DEFAULT) "" else id) } +} + +/** The list's key for "Instance default": a key cannot be empty, and no model is named so. */ +private const val INSTANCE_DEFAULT = " default" + private data class Choice(val id: String, val title: String, val subtitle: String?, val chosen: Boolean) /** A sheet's list of choices: a title, then rows of words that give and a radio button that keeps its size. */ diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index ac2ca02..b872af1 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -372,6 +372,9 @@ Asistent Nastavte LLeMbas jako digitálního asistenta telefonu: zvolte ho v Výchozí aplikace › Digitální asistent. Podržení tlačítka napájení, gesto asistenta nebo zkratka na zamykací obrazovce ho pak otevře přes to, co je právě na obrazovce. Otevřít nastavení asistenta + Model asistenta + Výchozí model instance + Model, se kterým začínají vaše nové konverzace. Je-li na mluvenou otázku příliš pomalý, vyberte níže rychlejší. Na telefonech Samsung: Nastavení › Pokročilé funkce › Boční tlačítko › Stisknutí a podržení › Digitální asistent. Konverzace s asistentem jsou dočasné Přečíst odpověď nahlas, když se zeptáte hlasem diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 385ead2..aa62dd5 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -372,6 +372,9 @@ Assistent Machen Sie LLeMbas zum digitalen Assistenten des Telefons: Wählen Sie ihn unter Standard-Apps › Digitaler Assistent. Das Halten der Einschalttaste, die Assistenzgeste oder die Verknüpfung auf dem Sperrbildschirm öffnet ihn dann über allem, was gerade angezeigt wird. Assistenten-Einstellungen öffnen + Modell des Assistenten + Standard der Instanz + Das Modell, mit dem deine neuen Chats beginnen. Ist es für eine gesprochene Frage zu langsam, wähle unten ein schnelleres. Auf Samsung-Telefonen: Einstellungen › Erweiterte Funktionen › Seitentaste › Gedrückt halten › Digitaler Assistent. Assistenten-Chats sind temporär Antwort vorlesen, wenn per Sprache gefragt wurde diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 36673fa..546b794 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -372,6 +372,9 @@ Asistente Convierta LLeMbas en el asistente digital del teléfono: elíjalo en Aplicaciones predeterminadas › App de asistencia digital. Mantener pulsado el botón de encendido, el gesto de asistencia o el acceso directo de la pantalla de bloqueo lo abrirá entonces sobre lo que haya en pantalla. Abrir los ajustes del asistente + Modelo del asistente + Predeterminado de la instancia + El modelo con el que empiezan tus chats nuevos. Si es demasiado lento para una pregunta hablada, elige abajo uno más rápido. En los teléfonos Samsung: Ajustes › Funciones avanzadas › Botón lateral › Mantener pulsado › Asistente digital. Los chats del asistente son temporales Leer la respuesta en voz alta cuando se pregunte por voz diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 33604ad..988724a 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -372,6 +372,9 @@ Assistant Faites de LLeMbas l\'assistant numérique du téléphone : choisissez-le dans Applications par défaut › Application d\'assistance numérique. Maintenir le bouton d\'alimentation, le geste d\'assistance ou le raccourci de l\'écran de verrouillage l\'ouvrira alors par-dessus ce qui est affiché. Ouvrir les paramètres de l\'assistant + Modèle de l’assistant + Modèle par défaut de l’instance + Le modèle avec lequel commencent vos nouvelles discussions. S’il est trop lent pour une question orale, choisissez-en un plus rapide ci-dessous. Sur les téléphones Samsung : Paramètres › Fonctions avancées › Bouton latéral › Maintenir enfoncé › Assistant numérique. Les conversations de l\'assistant sont temporaires Lire la réponse à voix haute en cas de question orale diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index fa943d0..bfdd0b5 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -372,6 +372,9 @@ Asszisztens Tegye az LLeMbas-t a telefon digitális asszisztensévé: válassza ki az Alapértelmezett alkalmazások › Digitális asszisztens alkalmazás alatt. A bekapcsológomb lenyomva tartása, az asszisztens-gesztus vagy a lezárási képernyő parancsikonja ezután a képernyőn lévő tartalom felett nyitja meg. Asszisztens beállításainak megnyitása + Az asszisztens modellje + A példány alapértelmezése + Az a modell, amellyel az új csevegéseid indulnak. Ha egy kimondott kérdéshez túl lassú, válassz lent gyorsabbat. Samsung telefonokon: Beállítások › Speciális funkciók › Oldalgomb › Nyomva tartás › Digitális asszisztens. Az asszisztenses csevegések ideiglenesek Olvassa fel a választ, ha hangos kérdés érkezett diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 403dad2..68c3ae1 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -372,6 +372,9 @@ Assistente Rendi LLeMbas l\'assistente digitale del telefono: selezionalo in App predefinite › App di assistenza digitale. Tenendo premuto il tasto di accensione, il gesto di assistenza o la scorciatoia della schermata di blocco lo apre quindi sopra qualsiasi cosa sia a schermo. Apri le impostazioni dell\'assistente + Modello dell’assistente + Predefinito dell’istanza + Il modello con cui iniziano le tue nuove chat. Se è troppo lento per una domanda a voce, scegline sotto uno più rapido. Sui telefoni Samsung: Impostazioni › Funzioni avanzate › Tasto laterale › Pressione prolungata › Assistente digitale. Le chat dell\'assistente sono temporanee Leggi la risposta ad alta voce quando la domanda è vocale diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index a2cea20..1be330d 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -372,6 +372,9 @@ Asystent Ustaw LLeMbas jako cyfrowego asystenta telefonu: wybierz go w Domyślne aplikacje › Aplikacja asystenta cyfrowego. Przytrzymanie przycisku zasilania, gest asystenta lub skrót z ekranu blokady otwiera go wtedy nad tym, co jest na ekranie. Otwórz ustawienia asystenta + Model asystenta + Domyślny model instancji + Model, od którego zaczynają się Twoje nowe czaty. Jeśli jest za wolny na pytanie zadane głosem, wybierz poniżej szybszy. W telefonach Samsung: Ustawienia › Funkcje zaawansowane › Przycisk boczny › Naciśnięcie i przytrzymanie › Asystent cyfrowy. Czaty asystenta są tymczasowe Odczytaj odpowiedź na głos, gdy pytanie było głosowe diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index ebfbc55..713fbba 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -372,6 +372,9 @@ Asistent Nastavte LLeMbas ako digitálneho asistenta telefónu: zvoľte ho v Predvolené aplikácie › Digitálny asistent. Podržanie tlačidla napájania, gesto asistenta alebo skratka na uzamknutej obrazovke ho potom otvorí nad tým, čo je práve na obrazovke. Otvoriť nastavenia asistenta + Model asistenta + Predvolený model inštancie + Model, s ktorým sa začínajú vaše nové konverzácie. Ak je na hovorenú otázku príliš pomalý, vyberte nižšie rýchlejší. Na telefónoch Samsung: Nastavenia › Rozšírené funkcie › Tlačidlo na boku › Stlačenie a podržanie › Digitálny asistent. Konverzácie s asistentom sú dočasné Prečítať odpoveď nahlas, keď sa spýtate hlasom diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f133afd..702a952 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -374,6 +374,9 @@ Assistant Make LLeMbas the phone\'s digital assistant: choose it under Default apps › Digital assistant app. Then holding the power button, the assist gesture or the lock screen\'s shortcut opens it over whatever is on screen. Open the assistant settings + Assistant model + Instance default + The model your new chats start on. Choose a quick one below if it is too slow for a spoken question. On Samsung phones: Settings › Advanced features › Side button › Press and hold › Digital assistant. Assistant chats are temporary Read the answer aloud when asked by voice diff --git a/app/src/test/java/eu/llembas/android/AssistTest.kt b/app/src/test/java/eu/llembas/android/AssistTest.kt index 0021a20..cf85424 100644 --- a/app/src/test/java/eu/llembas/android/AssistTest.kt +++ b/app/src/test/java/eu/llembas/android/AssistTest.kt @@ -1,6 +1,7 @@ package eu.llembas.android import eu.llembas.android.api.LiveReply +import eu.llembas.android.api.ModelInfo import eu.llembas.android.api.Step import eu.llembas.android.api.Tail import eu.llembas.android.assist.AssistController @@ -53,6 +54,22 @@ class AssistTest { assertEquals("Because.", earlier.steps.single().markdown) } + @Test + fun theAssistantsModelIsTheOneChosenInSettings() { + val models = listOf(ModelInfo("large"), ModelInfo("standard", default = true), ModelInfo("quick")) + // The choice, whatever the account's and the instance's defaults are. + assertEquals("quick", AssistController.assistantModelFor("quick", "large", models)) + // "Instance default": the account's default, as a new chat in the app starts. + assertEquals("large", AssistController.assistantModelFor("", "large", models)) + // No account default (or one that is gone): the instance's, then its first. + assertEquals("standard", AssistController.assistantModelFor("", null, models)) + assertEquals("standard", AssistController.assistantModelFor("", "retired", models)) + assertEquals("large", AssistController.assistantModelFor("", null, models.map { it.copy(default = false) })) + // A chosen model the instance no longer has falls back the same way, and none is none. + assertEquals("large", AssistController.assistantModelFor("retired", "large", models)) + assertEquals(null, AssistController.assistantModelFor("quick", null, emptyList())) + } + @Test fun aVoiceReadsOnlyTheWords() { val steps = listOf( diff --git a/app/src/test/java/eu/llembas/android/shots/Fakes.kt b/app/src/test/java/eu/llembas/android/shots/Fakes.kt index 69c0009..e809a1e 100644 --- a/app/src/test/java/eu/llembas/android/shots/Fakes.kt +++ b/app/src/test/java/eu/llembas/android/shots/Fakes.kt @@ -375,6 +375,7 @@ object Fakes { wakeState = WakeState.Listening("OK Google"), notificationsBuild = true, navApps = listOf("google", "osmand"), + assistantModels = models, ) /** The wake word in trouble, and its test having heard the phrase: what the rows say then. */ diff --git a/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt b/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt index 40177c8..0a3b1f1 100644 --- a/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt +++ b/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt @@ -63,6 +63,7 @@ import eu.llembas.android.ui.scheduled.ScheduleContent import eu.llembas.android.ui.scheduled.ScheduleEditContent import eu.llembas.android.ui.scheduled.ScheduledContent import eu.llembas.android.ui.scheduled.SchedulingModelsContent +import eu.llembas.android.ui.settings.AssistantModelChoices import eu.llembas.android.ui.settings.LanguageChoices import eu.llembas.android.ui.settings.NotificationSummaryGroup import eu.llembas.android.ui.settings.SettingsActions @@ -233,6 +234,14 @@ class ScreenShots { shoot("08-wake-sensitivity", Phone.Small, fontScale = 1.5f) { SheetOver { WakeChoices(WakeChoice.Sensitivity, Fakes.settings.prefs, onPick = {}) } } } + @Test + fun assistantModel() { + // "Instance default" chosen, then one of the instance's models. + shoot("08-assistant-model", Phone.Scroll) { SheetOver { AssistantModelChoices(Fakes.settings, onPick = {}) } } + val picked = Fakes.settings.copy(prefs = Fakes.settings.prefs.copy(assistantModel = Fakes.models.last().id)) + shoot("08-assistant-model-chosen", Phone.Small, fontScale = 1.5f) { SheetOver { AssistantModelChoices(picked, onPick = {}) } } + } + @Test fun language() { shoot("17-language", Phone.Scroll) { SheetOver { LanguageChoices(Fakes.settings.prefs, onPick = {}) } } diff --git a/scripts/strings.py b/scripts/strings.py index a27d2e3..7452e37 100755 --- a/scripts/strings.py +++ b/scripts/strings.py @@ -398,6 +398,9 @@ STRINGS: dict[str, str] = { "settings_assistant": "Assistant", "assistant_explained": "Make LLeMbas the phone's digital assistant: choose it under Default apps › Digital assistant app. Then holding the power button, the assist gesture or the lock screen's shortcut opens it over whatever is on screen.", "assistant_open_settings": "Open the assistant settings", + "assistant_model": "Assistant model", + "assistant_model_default": "Instance default", + "assistant_model_default_line": "The model your new chats start on. Choose a quick one below if it is too slow for a spoken question.", "assistant_samsung": "On Samsung phones: Settings › Advanced features › Side button › Press and hold › Digital assistant.", "assistant_temporary": "Assistant chats are temporary", "assistant_read_aloud": "Read the answer aloud when asked by voice", diff --git a/scripts/strings_own.json b/scripts/strings_own.json index e924e9f..06158bb 100644 --- a/scripts/strings_own.json +++ b/scripts/strings_own.json @@ -75,6 +75,9 @@ "assistant_conversation_line": "Po přečtení mluvené odpovědi asistent znovu poslouchá — dokud neřeknete „stop“, neklepnete na Ukončit nebo pár sekund nic neřeknete. Funguje i se sluchátky.", "assistant_explained": "Nastavte LLeMbas jako digitálního asistenta telefonu: zvolte ho v Výchozí aplikace › Digitální asistent. Podržení tlačítka napájení, gesto asistenta nebo zkratka na zamykací obrazovce ho pak otevře přes to, co je právě na obrazovce.", "assistant_listens": "Začít poslouchat, když se asistent otevře", + "assistant_model": "Model asistenta", + "assistant_model_default": "Výchozí model instance", + "assistant_model_default_line": "Model, se kterým začínají vaše nové konverzace. Je-li na mluvenou otázku příliš pomalý, vyberte níže rychlejší.", "assistant_open_settings": "Otevřít nastavení asistenta", "assistant_read_aloud": "Přečíst odpověď nahlas, když se zeptáte hlasem", "assistant_samsung": "Na telefonech Samsung: Nastavení › Pokročilé funkce › Boční tlačítko › Stisknutí a podržení › Digitální asistent.", @@ -457,6 +460,9 @@ "assistant_conversation_line": "Nachdem eine gesprochene Antwort vorgelesen wurde, hört der Assistent wieder zu — bis du „Stopp“ sagst, auf Beenden tippst oder ein paar Sekunden nichts sagst. Funktioniert mit einem Headset.", "assistant_explained": "Machen Sie LLeMbas zum digitalen Assistenten des Telefons: Wählen Sie ihn unter Standard-Apps › Digitaler Assistent. Das Halten der Einschalttaste, die Assistenzgeste oder die Verknüpfung auf dem Sperrbildschirm öffnet ihn dann über allem, was gerade angezeigt wird.", "assistant_listens": "Beim Öffnen des Assistenten zuhören", + "assistant_model": "Modell des Assistenten", + "assistant_model_default": "Standard der Instanz", + "assistant_model_default_line": "Das Modell, mit dem deine neuen Chats beginnen. Ist es für eine gesprochene Frage zu langsam, wähle unten ein schnelleres.", "assistant_open_settings": "Assistenten-Einstellungen öffnen", "assistant_read_aloud": "Antwort vorlesen, wenn per Sprache gefragt wurde", "assistant_samsung": "Auf Samsung-Telefonen: Einstellungen › Erweiterte Funktionen › Seitentaste › Gedrückt halten › Digitaler Assistent.", @@ -840,6 +846,9 @@ "assistant_conversation_line": "Después de leer en voz alta una respuesta hablada, el asistente vuelve a escuchar, hasta que digas «para», toques Terminar o no digas nada durante unos segundos. Funciona con auriculares.", "assistant_explained": "Convierta LLeMbas en el asistente digital del teléfono: elíjalo en Aplicaciones predeterminadas › App de asistencia digital. Mantener pulsado el botón de encendido, el gesto de asistencia o el acceso directo de la pantalla de bloqueo lo abrirá entonces sobre lo que haya en pantalla.", "assistant_listens": "Empezar a escuchar al abrir el asistente", + "assistant_model": "Modelo del asistente", + "assistant_model_default": "Predeterminado de la instancia", + "assistant_model_default_line": "El modelo con el que empiezan tus chats nuevos. Si es demasiado lento para una pregunta hablada, elige abajo uno más rápido.", "assistant_open_settings": "Abrir los ajustes del asistente", "assistant_read_aloud": "Leer la respuesta en voz alta cuando se pregunte por voz", "assistant_samsung": "En los teléfonos Samsung: Ajustes › Funciones avanzadas › Botón lateral › Mantener pulsado › Asistente digital.", @@ -1222,6 +1231,9 @@ "assistant_conversation_line": "Après la lecture d’une réponse orale, l’assistant écoute à nouveau — jusqu’à ce que vous disiez « stop », touchiez Terminer ou ne disiez rien pendant quelques secondes. Fonctionne avec un casque.", "assistant_explained": "Faites de LLeMbas l'assistant numérique du téléphone : choisissez-le dans Applications par défaut › Application d'assistance numérique. Maintenir le bouton d'alimentation, le geste d'assistance ou le raccourci de l'écran de verrouillage l'ouvrira alors par-dessus ce qui est affiché.", "assistant_listens": "Écouter dès l’ouverture de l’assistant", + "assistant_model": "Modèle de l’assistant", + "assistant_model_default": "Modèle par défaut de l’instance", + "assistant_model_default_line": "Le modèle avec lequel commencent vos nouvelles discussions. S’il est trop lent pour une question orale, choisissez-en un plus rapide ci-dessous.", "assistant_open_settings": "Ouvrir les paramètres de l'assistant", "assistant_read_aloud": "Lire la réponse à voix haute en cas de question orale", "assistant_samsung": "Sur les téléphones Samsung : Paramètres › Fonctions avancées › Bouton latéral › Maintenir enfoncé › Assistant numérique.", @@ -1605,6 +1617,9 @@ "assistant_conversation_line": "Egy szóbeli válasz felolvasása után az asszisztens újra figyel — amíg nem mondod, hogy „állj”, nem koppintasz a Befejezésre, vagy néhány másodpercig nem szólsz. Headsettel is működik.", "assistant_explained": "Tegye az LLeMbas-t a telefon digitális asszisztensévé: válassza ki az Alapértelmezett alkalmazások › Digitális asszisztens alkalmazás alatt. A bekapcsológomb lenyomva tartása, az asszisztens-gesztus vagy a lezárási képernyő parancsikonja ezután a képernyőn lévő tartalom felett nyitja meg.", "assistant_listens": "Hallgatás indítása az asszisztens megnyitásakor", + "assistant_model": "Az asszisztens modellje", + "assistant_model_default": "A példány alapértelmezése", + "assistant_model_default_line": "Az a modell, amellyel az új csevegéseid indulnak. Ha egy kimondott kérdéshez túl lassú, válassz lent gyorsabbat.", "assistant_open_settings": "Asszisztens beállításainak megnyitása", "assistant_read_aloud": "Olvassa fel a választ, ha hangos kérdés érkezett", "assistant_samsung": "Samsung telefonokon: Beállítások › Speciális funkciók › Oldalgomb › Nyomva tartás › Digitális asszisztens.", @@ -1988,6 +2003,9 @@ "assistant_conversation_line": "Dopo aver letto ad alta voce una risposta a voce, l’assistente ascolta di nuovo, finché non dici «basta», tocchi Termina o non dici nulla per qualche secondo. Funziona con le cuffie.", "assistant_explained": "Rendi LLeMbas l'assistente digitale del telefono: selezionalo in App predefinite › App di assistenza digitale. Tenendo premuto il tasto di accensione, il gesto di assistenza o la scorciatoia della schermata di blocco lo apre quindi sopra qualsiasi cosa sia a schermo.", "assistant_listens": "Inizia ad ascoltare all’apertura dell’assistente", + "assistant_model": "Modello dell’assistente", + "assistant_model_default": "Predefinito dell’istanza", + "assistant_model_default_line": "Il modello con cui iniziano le tue nuove chat. Se è troppo lento per una domanda a voce, scegline sotto uno più rapido.", "assistant_open_settings": "Apri le impostazioni dell'assistente", "assistant_read_aloud": "Leggi la risposta ad alta voce quando la domanda è vocale", "assistant_samsung": "Sui telefoni Samsung: Impostazioni › Funzioni avanzate › Tasto laterale › Pressione prolungata › Assistente digitale.", @@ -2370,6 +2388,9 @@ "assistant_conversation_line": "Po odczytaniu odpowiedzi na głos asystent znów słucha — dopóki nie powiesz „stop”, nie dotkniesz Zakończ albo nie będziesz milczeć przez kilka sekund. Działa ze słuchawkami.", "assistant_explained": "Ustaw LLeMbas jako cyfrowego asystenta telefonu: wybierz go w Domyślne aplikacje › Aplikacja asystenta cyfrowego. Przytrzymanie przycisku zasilania, gest asystenta lub skrót z ekranu blokady otwiera go wtedy nad tym, co jest na ekranie.", "assistant_listens": "Zacznij słuchać po otwarciu asystenta", + "assistant_model": "Model asystenta", + "assistant_model_default": "Domyślny model instancji", + "assistant_model_default_line": "Model, od którego zaczynają się Twoje nowe czaty. Jeśli jest za wolny na pytanie zadane głosem, wybierz poniżej szybszy.", "assistant_open_settings": "Otwórz ustawienia asystenta", "assistant_read_aloud": "Odczytaj odpowiedź na głos, gdy pytanie było głosowe", "assistant_samsung": "W telefonach Samsung: Ustawienia › Funkcje zaawansowane › Przycisk boczny › Naciśnięcie i przytrzymanie › Asystent cyfrowy.", @@ -2752,6 +2773,9 @@ "assistant_conversation_line": "Po prečítaní hovorenej odpovede asistent znova počúva — kým nepoviete „stop“, neťuknete na Ukončiť alebo pár sekúnd nič nepoviete. Funguje aj so slúchadlami.", "assistant_explained": "Nastavte LLeMbas ako digitálneho asistenta telefónu: zvoľte ho v Predvolené aplikácie › Digitálny asistent. Podržanie tlačidla napájania, gesto asistenta alebo skratka na uzamknutej obrazovke ho potom otvorí nad tým, čo je práve na obrazovke.", "assistant_listens": "Začať počúvať, keď sa asistent otvorí", + "assistant_model": "Model asistenta", + "assistant_model_default": "Predvolený model inštancie", + "assistant_model_default_line": "Model, s ktorým sa začínajú vaše nové konverzácie. Ak je na hovorenú otázku príliš pomalý, vyberte nižšie rýchlejší.", "assistant_open_settings": "Otvoriť nastavenia asistenta", "assistant_read_aloud": "Prečítať odpoveď nahlas, keď sa spýtate hlasom", "assistant_samsung": "Na telefónoch Samsung: Nastavenia › Rozšírené funkcie › Tlačidlo na boku › Stlačenie a podržanie › Digitálny asistent.",