UI: show a Snack bar to warn user that system prompt is not always supported
This commit is contained in:
parent
56a7272858
commit
d1b018e375
|
|
@ -306,6 +306,7 @@ fun AppContent(
|
||||||
// Mode Selection Screen
|
// Mode Selection Screen
|
||||||
composable(AppDestinations.MODEL_LOADING_ROUTE) {
|
composable(AppDestinations.MODEL_LOADING_ROUTE) {
|
||||||
ModelLoadingScreen(
|
ModelLoadingScreen(
|
||||||
|
onScaffoldEvent = handleScaffoldEvent,
|
||||||
onNavigateBack = { navigationActions.navigateUp() },
|
onNavigateBack = { navigationActions.navigateUp() },
|
||||||
onNavigateToBenchmark = { navigationActions.navigateToBenchmark(it) },
|
onNavigateToBenchmark = { navigationActions.navigateToBenchmark(it) },
|
||||||
onNavigateToConversation = { navigationActions.navigateToConversation(it) },
|
onNavigateToConversation = { navigationActions.navigateToConversation(it) },
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ import com.example.llama.revamp.data.model.SystemPrompt
|
||||||
import com.example.llama.revamp.engine.ModelLoadingMetrics
|
import com.example.llama.revamp.engine.ModelLoadingMetrics
|
||||||
import com.example.llama.revamp.ui.components.ModelCardCoreExpandable
|
import com.example.llama.revamp.ui.components.ModelCardCoreExpandable
|
||||||
import com.example.llama.revamp.ui.components.ModelUnloadDialogHandler
|
import com.example.llama.revamp.ui.components.ModelUnloadDialogHandler
|
||||||
|
import com.example.llama.revamp.ui.components.ScaffoldEvent
|
||||||
import com.example.llama.revamp.viewmodel.ModelLoadingViewModel
|
import com.example.llama.revamp.viewmodel.ModelLoadingViewModel
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -67,6 +68,7 @@ enum class SystemPromptTab(val label: String) {
|
||||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun ModelLoadingScreen(
|
fun ModelLoadingScreen(
|
||||||
|
onScaffoldEvent: (ScaffoldEvent) -> Unit,
|
||||||
onNavigateBack: () -> Unit,
|
onNavigateBack: () -> Unit,
|
||||||
onNavigateToBenchmark: (ModelLoadingMetrics) -> Unit,
|
onNavigateToBenchmark: (ModelLoadingMetrics) -> Unit,
|
||||||
onNavigateToConversation: (ModelLoadingMetrics) -> Unit,
|
onNavigateToConversation: (ModelLoadingMetrics) -> Unit,
|
||||||
|
|
@ -83,6 +85,7 @@ fun ModelLoadingScreen(
|
||||||
var isModelCardExpanded by remember { mutableStateOf(false) }
|
var isModelCardExpanded by remember { mutableStateOf(false) }
|
||||||
var selectedMode by remember { mutableStateOf<Mode?>(null) }
|
var selectedMode by remember { mutableStateOf<Mode?>(null) }
|
||||||
var useSystemPrompt by remember { mutableStateOf(false) }
|
var useSystemPrompt by remember { mutableStateOf(false) }
|
||||||
|
var showedSystemPromptWarning by remember { mutableStateOf(false) }
|
||||||
var selectedPrompt by remember { mutableStateOf<SystemPrompt?>(null) }
|
var selectedPrompt by remember { mutableStateOf<SystemPrompt?>(null) }
|
||||||
var selectedTab by remember { mutableStateOf(SystemPromptTab.PRESETS) }
|
var selectedTab by remember { mutableStateOf(SystemPromptTab.PRESETS) }
|
||||||
var customPromptText by remember { mutableStateOf("") }
|
var customPromptText by remember { mutableStateOf("") }
|
||||||
|
|
@ -216,6 +219,15 @@ fun ModelLoadingScreen(
|
||||||
Switch(
|
Switch(
|
||||||
checked = useSystemPrompt,
|
checked = useSystemPrompt,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
|
// First show a warning message if not yet
|
||||||
|
if (!showedSystemPromptWarning) {
|
||||||
|
onScaffoldEvent(ScaffoldEvent.ShowSnackbar(
|
||||||
|
message = "Model may not support system prompt!\nProceed with caution.",
|
||||||
|
))
|
||||||
|
showedSystemPromptWarning = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then update states
|
||||||
useSystemPrompt = it
|
useSystemPrompt = it
|
||||||
if (it && selectedMode != Mode.CONVERSATION) {
|
if (it && selectedMode != Mode.CONVERSATION) {
|
||||||
selectedMode = Mode.CONVERSATION
|
selectedMode = Mode.CONVERSATION
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,8 @@ class LLamaAndroid private constructor() : InferenceEngine {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the plain text system prompt
|
* Process the plain text system prompt
|
||||||
|
*
|
||||||
|
* TODO-han.yin: return error code if system prompt not correct processed?
|
||||||
*/
|
*/
|
||||||
override suspend fun setSystemPrompt(prompt: String) =
|
override suspend fun setSystemPrompt(prompt: String) =
|
||||||
withContext(llamaDispatcher) {
|
withContext(llamaDispatcher) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue