Skip to content

Commit

Permalink
refactor(llama): enhance debug messages for llama requests (#1717)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys authored Mar 25, 2024
1 parent 0e01be4 commit 8c2a3b8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion crates/llama-cpp-bindings/src/llama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use tokio::sync::{
mpsc::{channel, unbounded_channel, Receiver, Sender, UnboundedReceiver, UnboundedSender},
RwLock,
};
use tracing::debug;

use crate::ffi;

Expand Down Expand Up @@ -40,7 +41,19 @@ impl LlamaInitRequest {
}

pub(crate) fn step(&self, token: &str) -> bool {
self.tx.send(token.to_owned()).is_err()
match self.tx.send(token.to_owned()) {
Ok(_) => false,
Err(err) => {
debug!("Request <{}> is cancelled: `{}`", self.id, err);
true
}
}
}
}

impl Drop for LlamaInitRequest {
fn drop(&mut self) {
debug!("Request <{}> is done", self.id)
}
}

Expand All @@ -64,9 +77,11 @@ impl LlamaServiceImpl {
} {
// Drop canceled requests.
if req.tx.is_closed() {
debug!("Request <{}> is cancelled before it got started", req.id);
continue;
}

debug!("Request <{}> started", req.id);
self.engine.as_mut().unwrap().add_request(Box::new(req));
}

Expand Down

0 comments on commit 8c2a3b8

Please sign in to comment.