From 89a63dbf33576f4b79e48e088ce34fe0e87e8c0e Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Sun, 29 Oct 2023 23:27:09 -0700 Subject: [PATCH] fix: when send failed, treat the request as stopped (#673) --- crates/llama-cpp-bindings/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/llama-cpp-bindings/src/lib.rs b/crates/llama-cpp-bindings/src/lib.rs index 00e5879..1e0ad2a 100644 --- a/crates/llama-cpp-bindings/src/lib.rs +++ b/crates/llama-cpp-bindings/src/lib.rs @@ -90,7 +90,10 @@ impl AsyncTextInferenceEngine { // Cancelled by client side or hit eos. stopped = true; } else if let Some(new_text) = decoding.next_token(token_id) { - tx.send(new_text).await.expect("send failed"); + match tx.send(new_text).await { + Ok(_) => (), + Err(_) => stopped = true, + } } else { // Stoop words stopped stopped = true;