mirror of
https://github.com/katanemo/plano.git
synced 2026-06-20 15:28:07 +02:00
fix tracing
This commit is contained in:
parent
35065e2e41
commit
9570b167db
2 changed files with 13 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use log::debug;
|
use log::trace;
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug, PartialEq, Eq)]
|
#[derive(thiserror::Error, Debug, PartialEq, Eq)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
@ -9,7 +9,7 @@ pub enum Error {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn token_count(model_name: &str, text: &str) -> Result<usize, Error> {
|
pub fn token_count(model_name: &str, text: &str) -> Result<usize, Error> {
|
||||||
debug!("getting token count model={}", model_name);
|
trace!("getting token count model={}", model_name);
|
||||||
// Consideration: is it more expensive to instantiate the BPE object every time, or to contend the singleton?
|
// 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 {
|
let bpe = tiktoken_rs::get_bpe_from_model(model_name).map_err(|_| Error::UnknownModel {
|
||||||
model_name: model_name.to_string(),
|
model_name: model_name.to_string(),
|
||||||
|
|
|
||||||
|
|
@ -312,9 +312,11 @@ impl HttpContext for StreamContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_http_response_body(&mut self, body_size: usize, end_of_stream: bool) -> Action {
|
fn on_http_response_body(&mut self, body_size: usize, end_of_stream: bool) -> Action {
|
||||||
debug!(
|
trace!(
|
||||||
"on_http_response_body [S={}] bytes={} end_stream={}",
|
"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 {
|
if !self.is_chat_completions_request {
|
||||||
|
|
@ -398,9 +400,10 @@ impl HttpContext for StreamContext {
|
||||||
let body = if self.streaming_response {
|
let body = if self.streaming_response {
|
||||||
let chunk_start = 0;
|
let chunk_start = 0;
|
||||||
let chunk_size = body_size;
|
let chunk_size = body_size;
|
||||||
debug!(
|
trace!(
|
||||||
"streaming response reading, {}..{}",
|
"streaming response reading, {}..{}",
|
||||||
chunk_start, chunk_size
|
chunk_start,
|
||||||
|
chunk_size
|
||||||
);
|
);
|
||||||
let streaming_chunk = match self.get_http_response_body(0, chunk_size) {
|
let streaming_chunk = match self.get_http_response_body(0, chunk_size) {
|
||||||
Some(chunk) => chunk,
|
Some(chunk) => chunk,
|
||||||
|
|
@ -520,9 +523,11 @@ impl HttpContext for StreamContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!(
|
trace!(
|
||||||
"recv [S={}] total_tokens={} end_stream={}",
|
"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
|
Action::Continue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue