feat: Engines- und Sprachseite trennen Dienst und Modellzustand, Sprachmodelle laden und entladen (#1167)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -29,7 +29,7 @@ fn back(page: &str, code: &str) -> Response {
|
||||
}
|
||||
|
||||
/// Knopf als eigenes kleines Formular (die CSP erlaubt keine Inline-Skripte).
|
||||
fn button(
|
||||
pub(super) fn button(
|
||||
viewer: &Viewer,
|
||||
action: &str,
|
||||
fields: &[(&str, &str)],
|
||||
@ -47,8 +47,8 @@ fn button(
|
||||
}
|
||||
|
||||
/// Zeichen für Knöpfe (Linien in der Textfarbe; Inline-SVG ist mit der CSP erlaubt).
|
||||
const ICON_PLAY: &str = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><polygon points=\"7 4 20 12 7 20 7 4\"/></svg>";
|
||||
const ICON_STOP: &str = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><rect x=\"6\" y=\"6\" width=\"12\" height=\"12\" rx=\"2\"/></svg>";
|
||||
pub(super) const ICON_PLAY: &str = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><polygon points=\"7 4 20 12 7 20 7 4\"/></svg>";
|
||||
pub(super) const ICON_STOP: &str = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><rect x=\"6\" y=\"6\" width=\"12\" height=\"12\" rx=\"2\"/></svg>";
|
||||
const ICON_TEST: &str =
|
||||
"<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 12l5 5L20 6\"/></svg>";
|
||||
pub(super) const ICON_EDIT: &str = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M12 20h9\"/><path d=\"M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z\"/></svg>";
|
||||
@ -58,7 +58,7 @@ const ICON_UNLOCK: &str = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><rect
|
||||
const ICON_TRASH: &str = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 7h16\"/><path d=\"M9 7V4h6v3\"/><path d=\"M6 7l1 13h10l1-13\"/></svg>";
|
||||
|
||||
/// Wie [`button`], aber als Zeichenknopf mit Name für Screenreader und Tooltip.
|
||||
fn icon_button(
|
||||
pub(super) fn icon_button(
|
||||
viewer: &Viewer,
|
||||
action: &str,
|
||||
fields: &[(&str, &str)],
|
||||
@ -103,6 +103,34 @@ struct ModelRow {
|
||||
embedding_dim: Option<i64>,
|
||||
}
|
||||
|
||||
/// Zustand eines Modells für alle Seiten: Art (Symbol), Text, laufend (Vorgang noch nicht abgeschlossen).
|
||||
/// Ein gemerkter Fehler gilt nur, solange das Modell nicht lädt (→ #1167).
|
||||
pub(super) fn zustand_von(
|
||||
view: &SchedulerView,
|
||||
fehler: Option<&(String, String)>,
|
||||
name: &str,
|
||||
) -> (&'static str, &'static str) {
|
||||
let inst = view.instances.iter().find(|i| i.model == name);
|
||||
let wartend = view.waiting.iter().any(|w| w.model == name);
|
||||
match (inst, fehler) {
|
||||
(Some(i), _) if i.state == "loading" => ("laedt", "lädt …"),
|
||||
(Some(i), _) if i.state == "unloading" => ("entlaedt", "wird entladen …"),
|
||||
(Some(_), Some((art, _))) if art == "stopp" => ("fehler", "Entladen nicht bestätigt"),
|
||||
(Some(_), _) => ("geladen", "geladen"),
|
||||
(None, Some((art, _))) if art == "start" => ("fehler", "Start fehlgeschlagen"),
|
||||
(None, _) if wartend => ("wartet", "wartet auf Platz"),
|
||||
(None, _) => ("aus", "nicht geladen"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Rücksprung nach einer Aktion: Die Seite, von der sie kam (nur bekannte Ziele).
|
||||
fn rueck_seite(body: &[u8]) -> &'static str {
|
||||
match form_field(body, "zurueck").as_deref() {
|
||||
Some("sprache") => "/ui/modelle?art=sprache",
|
||||
_ => "/ui/modelle",
|
||||
}
|
||||
}
|
||||
|
||||
fn model_rows(state: &AppState) -> Vec<ModelRow> {
|
||||
let store = state.store();
|
||||
let planning = store.planning_overview().unwrap_or_default();
|
||||
@ -221,20 +249,9 @@ fn models_table(state: &AppState, viewer: &Viewer, art: &str) -> String {
|
||||
.filter(|m| model_art(m.engine.as_deref()) == "llm" && m.embedding_modell == embedding_tab)
|
||||
.map(|m| {
|
||||
let inst = view.instances.iter().find(|i| i.model == m.name);
|
||||
let waiting = view.waiting.iter().filter(|w| w.model == m.name).count();
|
||||
// Zustand als Symbol; der Text steht im Hinweis und in `data-sort` (Tabellenfilter).
|
||||
let fehler = state.runtime.model_fault(&m.name);
|
||||
let (zustand_art, zustand_text) = match (inst, fehler.as_ref()) {
|
||||
(Some(i), _) if i.state == "loading" => ("laedt", "lädt …"),
|
||||
(Some(i), _) if i.state == "unloading" => ("entlaedt", "wird entladen …"),
|
||||
(Some(_), Some((art, _))) if art == "stopp" => {
|
||||
("fehler", "Entladen nicht bestätigt")
|
||||
}
|
||||
(Some(_), _) => ("geladen", "geladen"),
|
||||
(None, Some((art, _))) if art == "start" => ("fehler", "Start fehlgeschlagen"),
|
||||
(None, _) if waiting > 0 => ("wartet", "wartet auf Platz"),
|
||||
(None, _) => ("aus", "nicht geladen"),
|
||||
};
|
||||
let (zustand_art, zustand_text) = zustand_von(&view, fehler.as_ref(), &m.name);
|
||||
// Ein Fehler bleibt sichtbar, bis ein neuer Versuch gelingt; der Text nur für Verwalter.
|
||||
let fehler_detail = match (&fehler, viewer.admin()) {
|
||||
(Some((art, text)), admin) if zustand_art == "fehler" => format!(
|
||||
@ -644,16 +661,17 @@ pub(super) async fn model_load(
|
||||
let name = form_field(&body, "name").unwrap_or_default();
|
||||
let plan = state.store().start_plan(&name).ok().flatten();
|
||||
let Some(plan) = plan else {
|
||||
return back("/ui/modelle", "unbekannt");
|
||||
return back(rueck_seite(&body), "unbekannt");
|
||||
};
|
||||
// Ein zweiter Klick, solange das Modell schon lädt, wartet oder bereit ist, löst nichts Neues aus.
|
||||
let view = state.runtime.scheduler_view();
|
||||
if view.instances.iter().any(|i| i.model == name)
|
||||
|| view.waiting.iter().any(|w| w.model == name)
|
||||
{
|
||||
return back("/ui/modelle", "laeuft_schon");
|
||||
return back(rueck_seite(&body), "laeuft_schon");
|
||||
}
|
||||
audit(&state, &viewer, "model.load", &name);
|
||||
let rueck = rueck_seite(&body);
|
||||
let priority = viewer.key.default_priority;
|
||||
let state = state.clone();
|
||||
// Das Laden läuft wie eine Anfrage durch den Scheduler (es kann warten oder
|
||||
@ -664,7 +682,7 @@ pub(super) async fn model_load(
|
||||
tracing::warn!(model = %plan.model, fehler = %error, "Laden aus der Oberfläche gescheitert");
|
||||
}
|
||||
});
|
||||
back("/ui/modelle", "laden")
|
||||
back(rueck, "laden")
|
||||
}
|
||||
|
||||
pub(super) async fn model_unload(
|
||||
@ -686,7 +704,7 @@ pub(super) async fn model_unload(
|
||||
Err(UnloadRefusal::Busy) => "benutzt",
|
||||
Err(UnloadRefusal::InTransition) => "uebergang",
|
||||
};
|
||||
back("/ui/modelle", code)
|
||||
back(rueck_seite(&body), code)
|
||||
}
|
||||
|
||||
pub(super) async fn model_enable(
|
||||
|
||||
Reference in New Issue
Block a user