From 5017e7931ed9b08a23e8cd45b3734c67621acc65 Mon Sep 17 00:00:00 2001 From: Adil Hafeez Date: Thu, 16 Jan 2025 14:37:09 -0800 Subject: [PATCH] fix tracing --- crates/common/src/tokenizer.rs | 4 ++-- crates/llm_gateway/src/stream_context.rs | 17 ++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/crates/common/src/tokenizer.rs b/crates/common/src/tokenizer.rs index c424e344..aa0870f2 100644 --- a/crates/common/src/tokenizer.rs +++ b/crates/common/src/tokenizer.rs @@ -1,4 +1,4 @@ -use log::trace; +use log::debug; #[derive(thiserror::Error, Debug, PartialEq, Eq)] #[allow(dead_code)] @@ -9,7 +9,7 @@ pub enum Error { #[allow(dead_code)] pub fn token_count(model_name: &str, text: &str) -> Result { - trace!("getting token count model={}", model_name); + debug!("getting token count model={}", model_name); // Consideration: is it more expensive to instantiate the BPE object every time, or to contend the singleton? let bpe = tiktoken_rs::get_bpe_from_model(model_name).map_err(|_| Error::UnknownModel { model_name: model_name.to_string(), diff --git a/crates/llm_gateway/src/stream_context.rs b/crates/llm_gateway/src/stream_context.rs index 50f46ac2..4df9779e 100644 --- a/crates/llm_gateway/src/stream_context.rs +++ b/crates/llm_gateway/src/stream_context.rs @@ -315,11 +315,9 @@ impl HttpContext for StreamContext { } fn on_http_response_body(&mut self, body_size: usize, end_of_stream: bool) -> Action { - trace!( + debug!( "on_http_response_body [S={}] bytes={} end_stream={}", - self.context_id, - body_size, - end_of_stream + self.context_id, body_size, end_of_stream ); if !self.is_chat_completions_request { @@ -403,10 +401,9 @@ impl HttpContext for StreamContext { let body = if self.streaming_response { let chunk_start = 0; let chunk_size = body_size; - trace!( + debug!( "streaming response reading, {}..{}", - chunk_start, - chunk_size + chunk_start, chunk_size ); let streaming_chunk = match self.get_http_response_body(0, chunk_size) { Some(chunk) => chunk, @@ -526,11 +523,9 @@ impl HttpContext for StreamContext { } } - trace!( + debug!( "recv [S={}] total_tokens={} end_stream={}", - self.context_id, - self.response_tokens, - end_of_stream + self.context_id, self.response_tokens, end_of_stream ); Action::Continue