Merge feature/modellseite: Modellarten und Stimmenfreigabe

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmHhg5PTXgibMTZUHzfLYM
This commit is contained in:
2026-11-18 20:35:59 +01:00
11 changed files with 429 additions and 15 deletions

View File

@ -16,7 +16,7 @@ use nexus_core::Priority;
use nexus_store::Rights;
use super::{Viewer, audit, csrf_field, esc, form_field, guard, html, layout, mb, notice, opt};
use super::{redirect, viewer};
use super::{redirect, stimmen, viewer};
use crate::runtime::{SchedulerView, UnloadRefusal};
use crate::state::AppState;
@ -80,6 +80,8 @@ struct ModelRow {
engine: Option<String>,
gpus: String,
context: Option<u32>,
quantization: Option<String>,
size_bytes: Option<i64>,
path: String,
declared_mb: Option<i64>,
measured_mb: Option<i64>,
@ -111,6 +113,8 @@ fn model_rows(state: &AppState) -> Vec<ModelRow> {
})
.unwrap_or_default(),
context: details.as_ref().and_then(|d| d.context),
quantization: details.as_ref().and_then(|d| d.quantization.clone()),
size_bytes: details.as_ref().and_then(|d| d.size_bytes),
path: details.as_ref().map(|d| d.path.clone()).unwrap_or_default(),
declared_mb: p.and_then(|p| p.1),
measured_mb: p.and_then(|p| p.2),
@ -129,6 +133,25 @@ fn idle_text(secs: Option<i64>) -> String {
}
}
fn model_art(engine: Option<&str>) -> &'static str {
if engine == Some("tts") {
"sprache"
} else {
"llm"
}
}
#[cfg(test)]
mod art_tests {
use super::model_art;
#[test]
fn art_kommt_von_der_engine() {
assert_eq!(model_art(Some("tts")), "sprache");
assert_eq!(model_art(Some("llama.cpp")), "llm");
assert_eq!(model_art(Some("strata")), "llm");
}
}
fn models_table(state: &AppState, viewer: &Viewer) -> String {
let rows = model_rows(state);
if rows.is_empty() {
@ -145,6 +168,7 @@ fn models_table(state: &AppState, viewer: &Viewer) -> String {
.collect();
let body: String = rows
.iter()
.filter(|m| model_art(m.engine.as_deref()) == "llm")
.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();
@ -226,7 +250,7 @@ fn models_table(state: &AppState, viewer: &Viewer) -> String {
let row_id = format!("modell-{}", dialog_id(&m.name));
format!(
"<tr id=\"{row_id}\"><td class=\"name\">{}</td><td>{}</td><td>{}</td>{faehig}<td>{}</td><td class=\"num\"{context_attr}>{context}</td>\
<td class=\"num\"{memory_attr}>{memory}</td><td data-sort=\"{state_sort}\">{state_chip}</td>{actions}</tr>",
<td class=\"num\"{memory_attr}>{memory}</td><td>{}</td><td>{}</td><td data-sort=\"{state_sort}\">{state_chip}</td>{actions}</tr>",
esc(&m.name),
m.engine
.as_ref()
@ -242,12 +266,14 @@ fn models_table(state: &AppState, viewer: &Viewer) -> String {
} else {
super::faehigkeiten::gpu_symbole(&m.gpus)
},
m.quantization.as_deref().map(esc).unwrap_or_else(|| "–".to_string()),
m.size_bytes.map(|v| format!("{:.1} GiB", v as f64 / 1073741824.0)).unwrap_or_else(|| "–".to_string()),
)
})
.collect();
format!(
"<div class=\"breit\"><table data-filtern=\"modelle\"><thead><tr><th data-spalte=\"name\">Name</th><th data-spalte=\"engine\" data-filter>Engine</th><th data-spalte=\"status\" data-filter>Status</th><th>Kann</th><th>GPUs</th>\
<th class=\"num\" data-spalte=\"kontext\" data-zahl>Kontext</th><th class=\"num\" data-spalte=\"speicher\" data-zahl>Speicher</th><th data-spalte=\"zustand\" data-filter>Zustand</th>{}</tr></thead><tbody>{body}</tbody></table></div>\
<th class=\"num\" data-spalte=\"kontext\" data-zahl>Kontext</th><th class=\"num\" data-spalte=\"speicher\" data-zahl>Speicher</th><th>Quantisierung</th><th>Größe</th><th data-spalte=\"zustand\" data-filter>Zustand</th>{}</tr></thead><tbody>{body}</tbody></table></div>\
<p class=\"klein\">Kann: Symbole auf gefüllter Kachel sind aus den Dateien des Modells erkannt (zum Beispiel eine Bild-Zusatzdatei), Symbole mit gestricheltem Umriss sind Fähigkeiten der Engine, für das einzelne Modell nicht geprüft. Chat, Streaming und Completions können alle Modelle einer Engine und stehen auf der Seite „Engines“.</p>",
if viewer.admin() { "<th></th>" } else { "" }
)
@ -384,11 +410,17 @@ pub(super) async fn models_page(
let Some(viewer) = viewer(&state, &headers) else {
return redirect("/ui/login");
};
let mut body = format!(
"{}<section class=\"card\" data-refresh=\"/ui/teil/modelle\" data-interval=\"3000\">{}</section>",
notice(query.as_deref()),
models_table(&state, &viewer)
);
let art = query
.as_deref()
.and_then(|q| form_field(q.as_bytes(), "art"))
.unwrap_or_default();
let nav = "<nav class=\"zeile\" aria-label=\"Modellarten\"><a href=\"/ui/modelle\">LLM</a><a href=\"/ui/modelle?art=sprache\">Sprache</a><a href=\"/ui/modelle?art=bild\">Bild</a><a href=\"/ui/modelle?art=musik\">Musik</a></nav>";
let content = match art.as_str() {
"sprache" => stimmen::page(&state, &viewer).await,
"bild" | "musik" => "<section class=\"card\"><h2>Workflows</h2><p class=\"leer\">Noch keine Workflows: ComfyUI ist noch nicht gebaut.</p></section>".to_string(),
_ => format!("<section class=\"card\" data-refresh=\"/ui/teil/modelle\" data-interval=\"3000\">{}</section><p class=\"klein\">Denkstufe: von der Engine abhängig, je Modell noch nicht erfasst.</p>", models_table(&state, &viewer)),
};
let mut body = format!("{}{nav}{content}", notice(query.as_deref()));
if viewer.admin() {
for m in model_rows(&state) {
body.push_str(&edit_dialog(&state, &viewer, &m));