Fix blocking

This commit is contained in:
MrLetsplay 2024-02-07 22:05:44 +01:00
parent 47e17e4d42
commit c16db22728
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg

View File

@ -110,12 +110,16 @@ impl OllamaChat {
pub async fn complete(
chat: Arc<RwLock<OllamaChat>>,
) -> anyhow::Result<impl Stream<Item = anyhow::Result<String>>> {
{
let mut chat = chat.write().await;
let body = serde_json::to_string(chat.deref())?;
println!("Sending: {}", body);
let msg = Arc::new(RwLock::new(String::from("")));
chat.current_message = Some(msg.clone());
}
let chat = chat.read().await;
let request = chat
.client