save request payload on any API error, not just timeouts
Serialize request JSON before send_and_check so it's available for both HTTP errors and stream errors. Extracted save logic into save_failed_request helper on SseReader. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
64dbcbf061
commit
e0a54a3b43
2 changed files with 40 additions and 22 deletions
|
|
@ -55,6 +55,7 @@ pub async fn stream_events(
|
|||
None => String::new(),
|
||||
};
|
||||
let debug_label = format!("{} messages, model={}{}", msg_count, model, pri_label);
|
||||
let request_json = serde_json::to_string_pretty(&request).ok();
|
||||
|
||||
let mut response = super::send_and_check(
|
||||
client,
|
||||
|
|
@ -64,11 +65,12 @@ pub async fn stream_events(
|
|||
&[],
|
||||
ui_tx,
|
||||
&debug_label,
|
||||
request_json.as_deref(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let mut reader = super::SseReader::new(ui_tx);
|
||||
reader.set_request(&request);
|
||||
reader.request_json = request_json;
|
||||
|
||||
let mut content_len: usize = 0;
|
||||
let mut reasoning_chars: usize = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue