fix: Abstürze erkennen, abgebrochene Streams melden, Messwerte und Speicher absichern, Startgrund nennen (#1273, #1274, #1275, #1276, #1277)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 14:47:33 +01:00
parent 54186593a8
commit 12347cd031
12 changed files with 419 additions and 49 deletions

View File

@ -3,6 +3,7 @@
//! und Antwort durch (auch als SSE-Stream).
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use axum::body::{Body, Bytes};
use axum::extract::{Extension, State};
@ -325,6 +326,9 @@ async fn forward_to(
RuntimeError::QueueFull => ApiError::queue_full(),
RuntimeError::Paused => ApiError::queue_paused(),
RuntimeError::Timeout => ApiError::queue_timeout(),
RuntimeError::Start {
grund: Some(grund), ..
} => ApiError::start_failed(&grund),
_ => ApiError::engine_unavailable(),
})?;
let endpoint = lease.endpoint.clone();
@ -425,16 +429,18 @@ async fn forward_to(
}
};
}
let abgebrochen = Arc::new(AtomicBool::new(false));
// #1266: Die Antwort nennt die Modell-ID von Nexus, nicht den Namen der Engine.
if status.is_success() && path != "/v1/audio/speech" {
let anpassung = Anpassung {
model: model.clone(),
base64,
};
let sse = response_headers
.get(CONTENT_TYPE)
.and_then(|v| v.to_str().ok())
.is_some_and(|v| v.starts_with("text/event-stream"));
let anpassung = Anpassung {
model: model.clone(),
base64,
abbruch: (sse && path == "/v1/chat/completions").then(|| abgebrochen.clone()),
};
response_stream = if sse {
anpassung.strom(response_stream)
} else {
@ -479,6 +485,7 @@ async fn forward_to(
started,
latency_ms: started.elapsed().as_millis() as u64,
lease,
abgebrochen,
},
);
response