Skip to content

Commit d93f21c

Browse files
committed
udpdate error msg
1 parent ebb1fff commit d93f21c

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

crates/chat-cli/src/api_client/clients/streaming_client.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,18 @@ impl StreamingClient {
175175
&& e.raw_response().is_some_and(|resp| resp.status().as_u16() == 500)
176176
&& e.as_service_error().is_some_and(|err| {
177177
err.meta().message()
178-
== Some("Encountered unexpectedly high load when processing the request, please try again.")
178+
== Some("Encountered unexpectedly high load when processing the request, please try again.")
179179
});
180180
if is_quota_breach {
181181
Err(ApiClientError::QuotaBreach("quota has reached its limit"))
182182
} else if is_context_window_overflow {
183183
Err(ApiClientError::ContextWindowOverflow)
184184
} else if is_model_unavailable {
185-
Err(ApiClientError::ModelOverloadedError())
185+
let request_id = e
186+
.as_service_error()
187+
.and_then(|err| err.meta().request_id())
188+
.map(|s| s.to_string());
189+
Err(ApiClientError::ModelOverloadedError(request_id))
186190
} else {
187191
Err(e.into())
188192
}

crates/chat-cli/src/api_client/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub enum ApiClientError {
6969
#[error(
7070
"The model you've selected is temporarily unavailable. Please use '/model' to select a different model and try again."
7171
)]
72-
ModelOverloadedError(),
72+
ModelOverloadedError(Option<String>),
7373
}
7474

7575
#[cfg(test)]

crates/chat-cli/src/cli/chat/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,23 @@ impl ChatContext {
10861086
crate::api_client::ApiClientError::QuotaBreach(msg) => {
10871087
print_err!(msg, err);
10881088
},
1089+
crate::api_client::ApiClientError::ModelOverloadedError(request_id) => {
1090+
queue!(
1091+
self.output,
1092+
style::SetAttribute(Attribute::Bold),
1093+
style::SetForegroundColor(Color::Red),
1094+
)?;
1095+
let message = "The model you've selected is temporarily unavailable. Please use '/model' to select a different model and try again.";
1096+
queue!(
1097+
self.output,
1098+
style::Print(&format!("{}\nRequest ID: {}", message, request_id))
1099+
)?;
1100+
execute!(
1101+
self.output,
1102+
style::SetAttribute(Attribute::Reset),
1103+
style::SetForegroundColor(Color::Reset),
1104+
)?;
1105+
},
10891106
_ => {
10901107
print_default_error!(err);
10911108
},

0 commit comments

Comments
 (0)