Skip to content

Commit

Permalink
chore: add log messages for deserialization failures
Browse files Browse the repository at this point in the history
Signed-off-by: Xin Liu <[email protected]>
  • Loading branch information
apepkuss committed Sep 27, 2024
1 parent 3e6f568 commit 583ee07
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/backend/ggml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ pub(crate) async fn embeddings_handler(mut req: Request<Body>) -> Response<Body>
let mut embedding_request: EmbeddingRequest = match serde_json::from_slice(&body_bytes) {
Ok(embedding_request) => embedding_request,
Err(e) => {
if let Ok(json_value) = serde_json::from_slice::<serde_json::Value>(&body_bytes) {
error!(target: "stdout", "json_value: {}", json_value);
}

let err_msg = format!("Fail to deserialize embedding request: {msg}", msg = e);

// log
Expand Down Expand Up @@ -226,6 +230,10 @@ pub(crate) async fn rag_query_handler(mut req: Request<Body>) -> Response<Body>
let mut chat_request: ChatCompletionRequest = match serde_json::from_slice(&body_bytes) {
Ok(chat_request) => chat_request,
Err(e) => {
if let Ok(json_value) = serde_json::from_slice::<serde_json::Value>(&body_bytes) {
error!(target: "stdout", "json_value: {}", json_value);
}

let err_msg = format!("Fail to deserialize chat completion request: {}", e);

// log
Expand Down Expand Up @@ -1162,6 +1170,10 @@ pub(crate) async fn chunks_handler(mut req: Request<Body>) -> Response<Body> {
let chunks_request: ChunksRequest = match serde_json::from_slice(&body_bytes) {
Ok(chunks_request) => chunks_request,
Err(e) => {
if let Ok(json_value) = serde_json::from_slice::<serde_json::Value>(&body_bytes) {
error!(target: "stdout", "json_value: {}", json_value);
}

let err_msg = format!("Fail to deserialize chunks request: {msg}", msg = e);

// log
Expand Down Expand Up @@ -1768,6 +1780,10 @@ pub(crate) async fn retrieve_handler(mut req: Request<Body>) -> Response<Body> {
let mut chat_request: ChatCompletionRequest = match serde_json::from_slice(&body_bytes) {
Ok(chat_request) => chat_request,
Err(e) => {
if let Ok(json_value) = serde_json::from_slice::<serde_json::Value>(&body_bytes) {
error!(target: "stdout", "json_value: {}", json_value);
}

let err_msg = format!(
"Fail to deserialize chat completion request: {msg}",
msg = e
Expand Down

0 comments on commit 583ee07

Please sign in to comment.