Skip to content

Commit

Permalink
Reworked the implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Narsil committed Nov 15, 2024
1 parent de735e3 commit 7c3f297
Show file tree
Hide file tree
Showing 2 changed files with 270 additions and 268 deletions.
22 changes: 22 additions & 0 deletions router/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use chat_template::ChatTemplate;
use futures::future::try_join_all;
use futures::Stream;
use minijinja::ErrorKind;
use serde::{Deserialize, Serialize};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use thiserror::Error;
Expand Down Expand Up @@ -373,4 +374,25 @@ impl InferError {
InferError::StreamSerializationError(_) => "stream_serialization_error",
}
}

pub(crate) fn into_openai_event(self) -> Event {
let message = self.to_string();
Event::default().json_data(OpenaiErrorEvent {
error: APIError {
message,
http_status_code: 422,
},
})
}
}

#[derive(Serialize)]
pub struct APIError {
message: String,
http_status_code: usize,
}

#[derive(Serialize)]
pub struct OpenaiErrorEvent {
error: APIError,
}
Loading

0 comments on commit 7c3f297

Please sign in to comment.