feat: Modellkopf aus der GGUF-Datei lesen und Passung schätzen (#1233, #1234)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 13:55:13 +01:00
parent 065e10432d
commit 4c7301e7db
16 changed files with 1543 additions and 10 deletions

View File

@ -459,6 +459,36 @@ pub(super) fn model_engine_names(state: &AppState) -> Vec<(String, Option<String
.collect()
}
/// Werte aus der Modelldatei und Passung (nur llama.cpp, → #1233, #1234); sonst leer.
fn modellkopf_block(state: &AppState, m: &ModelRow) -> String {
if m.engine.as_deref() != Some("llama.cpp") {
return String::new();
}
let Some(kopf) = state.store().artifact_kopf(&m.name).ok().flatten() else {
return String::new();
};
let gpus: Vec<u32> = m
.gpus
.split(',')
.filter_map(|g| g.trim().parse().ok())
.collect();
let gesamt: Vec<(u32, u64)> = state
.runtime
.metrics
.gpus()
.iter()
.map(|g| (g.index, g.memory_total_mb))
.collect();
crate::modellkopf::block_html(
&kopf,
u64::try_from(m.size_bytes.unwrap_or(0)).unwrap_or(0),
m.context,
&gpus,
&gesamt,
m.measured_mb,
)
}
/// Dialog „Bearbeiten“ für ein Modell: Eigenschaften, Speicher und Leerlauf,
/// Freigabe.
fn edit_dialog(state: &AppState, viewer: &Viewer, m: &ModelRow) -> String {
@ -494,6 +524,7 @@ fn edit_dialog(state: &AppState, viewer: &Viewer, m: &ModelRow) -> String {
<div><dt>Kontext</dt><dd>{context}</dd></div>\
<div><dt>Leerlauf</dt><dd>{idle_now}</dd></div>\
<div class=\"breit-zeile\"><dt>Modelldatei oder Engine-Konfiguration</dt><dd class=\"pfad\">{path}</dd></div></dl>\
{modellkopf}\
<form class=\"dlg-form\" method=\"post\" action=\"/ui/modelle/planung\">{csrf}\
<input type=\"hidden\" name=\"name\" value=\"{name}\">\
<label class=\"feld\"><span class=\"titel\">Speicherbedarf (VRAM) in MB</span>\
@ -523,6 +554,7 @@ fn edit_dialog(state: &AppState, viewer: &Viewer, m: &ModelRow) -> String {
&m.name,
m.engine.as_deref().unwrap_or("")
),
modellkopf = modellkopf_block(state, m),
id = dialog_id(&m.name),
name = esc(&m.name),
csrf = csrf_field(viewer),
@ -854,6 +886,8 @@ pub(super) async fn model_register(
{
return back("/ui/engines", "nicht_installiert");
}
let kopf = artifact.kopf.clone();
let mmproj = artifact.mmproj.clone();
let new = NewLlm {
name: name.clone(),
engine: engine.clone(),
@ -874,6 +908,16 @@ pub(super) async fn model_register(
match result {
Ok(()) => {
audit(&state, &viewer, "model.add", &name);
if let Some(k) = &kopf {
let jetzt = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|d| d.as_secs() as i64)
.unwrap_or(0);
let k = crate::modellkopf::aus_kopf(k, mmproj.as_deref(), jetzt);
if let Err(e) = state.store().set_artifact_kopf(&name, &k) {
tracing::warn!(fehler = %e, "Modellkopf nicht gespeichert");
}
}
// Fähigkeiten gleich prüfen (#1157): nur bei Sprachmodellen, nur mit Freigabe (sonst gibt es keinen Startplan).
let pruefen = form_field(&body, "pruefen").as_deref() == Some("1")
&& model_art(Some(&engine)) == "llm"