Skip to content

Commit

Permalink
fix: error Message start with "Some("")" #1294 (#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikbry authored Sep 25, 2024
1 parent 594bd68 commit 2fed740
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion webapp/native/src/providers/llama_cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl HttpError for LlamaCppCompletionResponse {
fn to_error(&self, status: String) -> Box<dyn std::error::Error> {
let error = LlmError {
message: format!("HTTP error {} : {}", status, self.content.to_string()),
status: Some("http_error".to_string()),
status: "http_error".to_string(),
};
Box::new(error)
}
Expand Down
8 changes: 4 additions & 4 deletions webapp/native/src/providers/llm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ use super::{ services::HttpService, ProviderAdapter, ServerParameters };
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct LlmError {
pub message: String,
pub status: Option<String>,
pub status: String,
}

impl LlmError {
pub fn new(msg: &str, status: &str) -> LlmError {
LlmError { message: msg.to_string(), status: Some(status.to_string()) }
LlmError { message: msg.to_string(), status: status.to_string() }
}

pub fn to_string(&self) -> String {
Expand All @@ -42,7 +42,7 @@ impl LlmError {

impl NewHttpError for LlmError {
fn new(msg: &str, status: &str) -> Self {
LlmError { message: msg.to_string(), status: Some(status.to_string()) }
LlmError { message: msg.to_string(), status: status.to_string() }
}
}

Expand All @@ -62,7 +62,7 @@ impl HttpError for LlmError {
fn to_error(&self, status: String) -> Box<dyn std::error::Error> {
let error = LlmError {
message: format!("HTTP error {} : {}", status, self.message.to_string()),
status: Some("http_error".to_string()),
status: "http_error".to_string(),
};
Box::new(error)
}
Expand Down
8 changes: 4 additions & 4 deletions webapp/native/src/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl ProviderAdapter {
{
match self.interface.deserialize_response(&full) {
Ok(response) => Ok(D::completion_to(response)),
Err(err) => Err(E::new(&err.message, &err.status.unwrap_or_default())),
Err(err) => Err(E::new(&err.message, &err.status)),
}
}

Expand All @@ -100,8 +100,8 @@ impl ProviderAdapter {
match response {
Ok(full) => {
match self.interface.deserialize_response_error(&full) {
Ok(err) => E::new(&err.error.message, &err.error.status.unwrap_or_default()),
Err(err) => E::new(&err.message, &err.status.unwrap_or_default()),
Ok(err) => E::new(&err.error.message, &err.error.status),
Err(err) => E::new(&err.message, &err.status),
}
}
Err(err) => err,
Expand All @@ -113,7 +113,7 @@ impl ProviderAdapter {
{
self.interface
.build_stream_chunk(data, self.created)
.map_err(|e| E::new(&e.message, &e.status.unwrap_or_default()))
.map_err(|e| E::new(&e.message, &e.status))
}

pub fn handle_input_response(&mut self) {}
Expand Down

0 comments on commit 2fed740

Please sign in to comment.