Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit dd2b7fc

Browse files
authored
Track LLM gateway errors (#575)
Due to our integration of `sentry_tracing`, `error!` logs are captured as sentry errors. We propagate additional information like message history using breadcrumbs generated by `debug!`.
1 parent 3fcfc90 commit dd2b7fc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

server/bleep/src/webserver/answer/llm_gateway.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use anyhow::{anyhow, bail};
66
use axum::http::StatusCode;
77
use futures::{Stream, StreamExt};
88
use reqwest_eventsource::EventSource;
9-
use tracing::warn;
9+
use tracing::{debug, error, warn};
1010

1111
pub mod api {
1212
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)]
@@ -143,16 +143,22 @@ impl Client {
143143
for _ in 0..self.max_retries {
144144
match self.chat_oneshot(messages).await {
145145
Err(ChatError::TooManyRequests) => {
146-
warn!("LLM request failed, retrying ...");
146+
warn!(?delay, "too many LLM requests, retrying with delay...");
147147
tokio::time::sleep(delay).await;
148148
delay = Duration::from_millis((delay.as_millis() as f32 * SCALE_FACTOR) as u64);
149149
}
150150
Err(ChatError::BadRequest) => {
151-
warn!("LLM request failed, request not eligible for retry");
151+
// We log the messages in a separate `debug!` statement so that they can be
152+
// filtered out, due to their verbosity.
153+
debug!("LLM message list: {messages:?}");
154+
error!("LLM request failed, request not eligible for retry");
152155
bail!("request not eligible for retry");
153156
}
154157
Err(ChatError::Other(e)) => {
155-
warn!("{e}");
158+
// We log the messages in a separate `debug!` statement so that they can be
159+
// filtered out, due to their verbosity.
160+
debug!("LLM message list: {messages:?}");
161+
error!("LLM request failed due to unknown reason: {e}");
156162
return Err(e);
157163
}
158164
Ok(stream) => return Ok(stream),

0 commit comments

Comments
 (0)