feat: better chat support for thinking
This commit is contained in:
@@ -234,16 +234,50 @@ impl App {
|
||||
.spacing(8),
|
||||
);
|
||||
} else {
|
||||
for message in &self.conversation {
|
||||
for (index, message) in self.conversation.iter().enumerate() {
|
||||
let label = if message.user { "You" } else { "DS4" };
|
||||
let content = if !message.user && message.content.is_empty() && self.generating
|
||||
{
|
||||
"Loading model…"
|
||||
} else {
|
||||
&message.content
|
||||
};
|
||||
let active = self.generating && index + 1 == self.conversation.len();
|
||||
let mut body = column![text(label).size(11)].spacing(5);
|
||||
if let Some(reasoning) = &message.reasoning {
|
||||
let reasoning_label =
|
||||
match (message.reasoning_open, message.reasoning_complete, active) {
|
||||
(true, false, true) => "▾ Thinking",
|
||||
(false, false, true) => "› Thinking",
|
||||
(true, false, false) => "▾ Reasoning (stopped)",
|
||||
(false, false, false) => "› Reasoning (stopped)",
|
||||
(true, true, _) => "▾ Reasoning",
|
||||
(false, true, _) => "› Reasoning",
|
||||
};
|
||||
body = body.push(
|
||||
button(text(reasoning_label).size(12))
|
||||
.padding(0)
|
||||
.style(button::text)
|
||||
.on_press(Message::ToggleReasoning(index)),
|
||||
);
|
||||
if message.reasoning_open {
|
||||
body = body.push(
|
||||
text(if reasoning.is_empty() && active {
|
||||
"Thinking…"
|
||||
} else {
|
||||
reasoning
|
||||
})
|
||||
.size(13)
|
||||
.color(muted_text()),
|
||||
);
|
||||
}
|
||||
}
|
||||
if !message.content.is_empty() {
|
||||
let content = if message.reasoning.is_some() {
|
||||
message.content.trim_start()
|
||||
} else {
|
||||
&message.content
|
||||
};
|
||||
body = body.push(text(content).size(14));
|
||||
} else if active && message.reasoning.is_none() {
|
||||
body = body.push(text("Loading model…").size(14));
|
||||
}
|
||||
messages = messages.push(
|
||||
container(column![text(label).size(11), text(content).size(14)].spacing(5))
|
||||
container(body)
|
||||
.padding(14)
|
||||
.width(Length::Fill)
|
||||
.style(overview_style),
|
||||
|
||||
Reference in New Issue
Block a user