UI: fix the breaking build
This commit is contained in:
parent
b92c6dc2f6
commit
98016791a6
|
|
@ -122,12 +122,7 @@ fun ConversationBottomBar(
|
||||||
},
|
},
|
||||||
floatingActionButton = {
|
floatingActionButton = {
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
onClick = {
|
onClick = { if (isReady) { onSendClick() } },
|
||||||
if (isReady) {
|
|
||||||
onSendClick()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
containerColor = MaterialTheme.colorScheme.primary
|
|
||||||
) {
|
) {
|
||||||
if (isReady) {
|
if (isReady) {
|
||||||
Icon(
|
Icon(
|
||||||
|
|
@ -138,7 +133,6 @@ fun ConversationBottomBar(
|
||||||
CircularProgressIndicator(
|
CircularProgressIndicator(
|
||||||
modifier = Modifier.size(24.dp),
|
modifier = Modifier.size(24.dp),
|
||||||
strokeCap = StrokeCap.Round,
|
strokeCap = StrokeCap.Round,
|
||||||
color = MaterialTheme.colorScheme.onPrimary,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ fun BenchmarkScreen(
|
||||||
val benchmarkResults by viewModel.benchmarkResults.collectAsState()
|
val benchmarkResults by viewModel.benchmarkResults.collectAsState()
|
||||||
|
|
||||||
// UI states
|
// UI states
|
||||||
var isModelCardExpanded by remember { mutableStateOf(false) }
|
var isModelCardExpanded by remember { mutableStateOf(true) }
|
||||||
var isInitialBenchmarkRun by rememberSaveable { mutableStateOf(false) }
|
var isInitialBenchmarkRun by rememberSaveable { mutableStateOf(false) }
|
||||||
|
|
||||||
// Run benchmark when entering the screen
|
// Run benchmark when entering the screen
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,21 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.outlined.HelpOutline
|
import androidx.compose.material.icons.automirrored.outlined.HelpOutline
|
||||||
import androidx.compose.material.icons.filled.Timer
|
import androidx.compose.material.icons.filled.Timer
|
||||||
|
import androidx.compose.material3.AssistChip
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.ButtonColors
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
import androidx.compose.material3.FilledTonalButton
|
||||||
|
import androidx.compose.material3.FilledTonalIconToggleButton
|
||||||
|
import androidx.compose.material3.FilterChip
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.IconButtonDefaults
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TonalToggleButton
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
|
@ -72,6 +78,7 @@ import com.example.llama.ui.components.ModelCardContentContextRow
|
||||||
import com.example.llama.ui.components.ModelCardContentField
|
import com.example.llama.ui.components.ModelCardContentField
|
||||||
import com.example.llama.ui.components.ModelCardCoreExpandable
|
import com.example.llama.ui.components.ModelCardCoreExpandable
|
||||||
import com.example.llama.ui.components.ModelUnloadDialogHandler
|
import com.example.llama.ui.components.ModelUnloadDialogHandler
|
||||||
|
import com.example.llama.ui.theme.ButtonShape
|
||||||
import com.example.llama.util.formatMilliSeconds
|
import com.example.llama.util.formatMilliSeconds
|
||||||
import com.example.llama.util.formatMilliSecondstructured
|
import com.example.llama.util.formatMilliSecondstructured
|
||||||
import com.example.llama.util.toEnglishName
|
import com.example.llama.util.toEnglishName
|
||||||
|
|
@ -204,7 +211,10 @@ fun ConversationScreen(
|
||||||
if (showModelCard) {
|
if (showModelCard) {
|
||||||
selectedModel?.let {
|
selectedModel?.let {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.fillMaxWidth().padding(16.dp).align(Alignment.TopCenter)
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp)
|
||||||
|
.align(Alignment.TopCenter)
|
||||||
) {
|
) {
|
||||||
ModelCardWithSystemPrompt(
|
ModelCardWithSystemPrompt(
|
||||||
model = it,
|
model = it,
|
||||||
|
|
@ -338,7 +348,9 @@ private fun ConversationMessageList(
|
||||||
@Composable
|
@Composable
|
||||||
private fun UserMessageBubble(content: String, formattedTime: String) {
|
private fun UserMessageBubble(content: String, formattedTime: String) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp),
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(vertical = 8.dp),
|
||||||
horizontalAlignment = Alignment.End
|
horizontalAlignment = Alignment.End
|
||||||
) {
|
) {
|
||||||
// Timestamp above bubble
|
// Timestamp above bubble
|
||||||
|
|
@ -494,7 +506,6 @@ private fun PulsatingDots(small: Boolean = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ExpandableTokenMetricsBubble(
|
private fun ExpandableTokenMetricsBubble(
|
||||||
metrics: TokenMetrics,
|
metrics: TokenMetrics,
|
||||||
|
|
@ -503,21 +514,24 @@ private fun ExpandableTokenMetricsBubble(
|
||||||
var showMetrics by remember { mutableStateOf(false) }
|
var showMetrics by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Column(Modifier.fillMaxWidth(0.9f)) {
|
Column(Modifier.fillMaxWidth(0.9f)) {
|
||||||
TonalToggleButton(
|
FilterChip(
|
||||||
checked = showMetrics,
|
selected = showMetrics,
|
||||||
onCheckedChange = { showMetrics = !showMetrics }
|
onClick = { showMetrics = !showMetrics },
|
||||||
) {
|
label = {
|
||||||
Icon(
|
|
||||||
modifier = Modifier.size(16.dp),
|
|
||||||
imageVector = Icons.Default.Timer,
|
|
||||||
contentDescription = "${if (showMetrics) "Hide" else "Show"} token metrics of this assistant message"
|
|
||||||
)
|
|
||||||
Text(
|
Text(
|
||||||
text = "${if (showMetrics) "Hide" else "Show"} stats",
|
text = "${if (showMetrics) "Hide" else "Show"} stats",
|
||||||
modifier = Modifier.padding(start = 8.dp),
|
modifier = Modifier.padding(start = 8.dp),
|
||||||
style = MaterialTheme.typography.labelMedium,
|
style = MaterialTheme.typography.labelMedium,
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
|
leadingIcon = {
|
||||||
|
Icon(
|
||||||
|
modifier = Modifier.size(16.dp),
|
||||||
|
imageVector = Icons.Default.Timer,
|
||||||
|
contentDescription = "${if (showMetrics) "Hide" else "Show"} token metrics of this assistant message"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
if (showMetrics) {
|
if (showMetrics) {
|
||||||
Card(
|
Card(
|
||||||
|
|
|
||||||
|
|
@ -518,7 +518,7 @@ private fun PromptList(
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.animateItemPlacement()
|
.animateItem()
|
||||||
.selectable(
|
.selectable(
|
||||||
selected = isSelected,
|
selected = isSelected,
|
||||||
onClick = {
|
onClick = {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import kotlinx.coroutines.flow.onCompletion
|
import kotlinx.coroutines.flow.onCompletion
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.internal.toImmutableList
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
@ -108,7 +107,7 @@ class ConversationViewModel @Inject constructor(
|
||||||
_messages.value.toMutableList().apply {
|
_messages.value.toMutableList().apply {
|
||||||
(removeLastOrNull() as? Message.Assistant.Stopped)?.let {
|
(removeLastOrNull() as? Message.Assistant.Stopped)?.let {
|
||||||
add(it.copy(content = it.content + SUFFIX_GENERATION_STOPPED))
|
add(it.copy(content = it.content + SUFFIX_GENERATION_STOPPED))
|
||||||
_messages.value = toImmutableList()
|
_messages.value = toList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +118,7 @@ class ConversationViewModel @Inject constructor(
|
||||||
_messages.value.toMutableList().apply {
|
_messages.value.toMutableList().apply {
|
||||||
(removeLastOrNull() as? Message.Assistant.Stopped)?.let {
|
(removeLastOrNull() as? Message.Assistant.Stopped)?.let {
|
||||||
add(it.copy(content = it.content + SUFFIX_GENERATION_ERROR.format(e.message)))
|
add(it.copy(content = it.content + SUFFIX_GENERATION_ERROR.format(e.message)))
|
||||||
_messages.value = toImmutableList()
|
_messages.value = this.toList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,7 +142,7 @@ class ConversationViewModel @Inject constructor(
|
||||||
timestamp = it.timestamp
|
timestamp = it.timestamp
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
_messages.value = toImmutableList()
|
_messages.value = toList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue