From 271fbaf57e561b62268b19cd53ec107a71c86afe Mon Sep 17 00:00:00 2001 From: MrLetsplay Date: Fri, 9 Feb 2024 18:27:40 +0100 Subject: [PATCH] Properly handle assistant messages --- src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.rs b/src/main.rs index 6d1fe79..c75e033 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ mod api; use std::{ cell::RefCell, io::{self, Write}, + ops::Deref, sync::{ mpsc::{Receiver, Sender}, Arc, @@ -173,6 +174,14 @@ impl Application for UI { let _ = send.send(UIMessage::Nop); } + + let mut chat = chat.write().await; + let msg = chat.current_message.clone(); + if let Some(msg) = msg { + let msg = msg.write().await; + chat.send_assistant(msg.deref()); + chat.current_message = None; + } } //state.ollama_api.complete(&x); },