mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-09-11 20:34:54 +00:00
fix: propagate completions error events to stream
This commit is contained in:
parent
84cd8434b0
commit
0ae84e5473
@ -866,7 +866,14 @@ pub(crate) async fn completions(
|
|||||||
|
|
||||||
yield Ok(event);
|
yield Ok(event);
|
||||||
}
|
}
|
||||||
Err(err) => yield Ok(Event::from(err)),
|
Err(err) => {
|
||||||
|
let error_event: ErrorEvent = err.into();
|
||||||
|
let event = Event::default().json_data(error_event).unwrap_or_else(|e| {
|
||||||
|
InferError::StreamSerializationError(e.to_string()).into()
|
||||||
|
});
|
||||||
|
yield Ok::<Event, Infallible>(event);
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -2527,20 +2534,22 @@ impl From<InferError> for Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
pub struct ErrorWithMessage {
|
pub struct APIError {
|
||||||
message: String,
|
message: String,
|
||||||
|
http_status_code: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
pub struct ErrorEvent {
|
pub struct ErrorEvent {
|
||||||
error: ErrorWithMessage,
|
error: APIError,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<InferError> for ErrorEvent {
|
impl From<InferError> for ErrorEvent {
|
||||||
fn from(err: InferError) -> Self {
|
fn from(err: InferError) -> Self {
|
||||||
ErrorEvent {
|
ErrorEvent {
|
||||||
error: ErrorWithMessage {
|
error: APIError {
|
||||||
message: err.to_string(),
|
message: err.to_string(),
|
||||||
|
http_status_code: 500,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user