Improve chat rendering and generation summaries
This commit is contained in:
@@ -180,13 +180,15 @@ impl App {
|
||||
body = body.push(tool_cards(cards));
|
||||
}
|
||||
}
|
||||
let user = message.user;
|
||||
messages = messages.push(
|
||||
container(body)
|
||||
.padding(14)
|
||||
.width(Length::Fill)
|
||||
.style(move |theme| chat_message_style(theme, user)),
|
||||
);
|
||||
let message_body = container(body).padding(14).width(Length::Fill);
|
||||
messages = messages.push(if message.user {
|
||||
message_body.style(chat_message_style)
|
||||
} else {
|
||||
message_body
|
||||
});
|
||||
if let Some(stats) = message.generation_stats {
|
||||
messages = messages.push(generation_summary(stats));
|
||||
}
|
||||
}
|
||||
if let Some(activity) = &self.activity {
|
||||
messages = messages.push(
|
||||
@@ -335,6 +337,26 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
fn generation_summary(stats: crate::app::generation::GenerationStats) -> Element<'static, Message> {
|
||||
column![
|
||||
row![
|
||||
Space::new().width(Length::Fill),
|
||||
text(format!(
|
||||
"{} · {} input · {} cached · {} output",
|
||||
format_duration(stats.duration_ms as f64 / 1_000.0),
|
||||
stats.input_tokens,
|
||||
stats.cached_tokens,
|
||||
stats.output_tokens,
|
||||
))
|
||||
.size(11)
|
||||
.color(muted_text()),
|
||||
],
|
||||
rule::horizontal(1),
|
||||
]
|
||||
.spacing(5)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn tool_cards(cards: Vec<crate::agent::ToolCard>) -> Element<'static, Message> {
|
||||
let mut rows = column![].spacing(0);
|
||||
for (index, card) in cards.into_iter().enumerate() {
|
||||
|
||||
Reference in New Issue
Block a user