feat: private Personas und Modellgrundlage ergänzen
This commit is contained in:
@ -80,6 +80,7 @@ struct ModelRow {
|
||||
engine: Option<String>,
|
||||
gpus: String,
|
||||
context: Option<u32>,
|
||||
systemprompt: String,
|
||||
quantization: Option<String>,
|
||||
size_bytes: Option<i64>,
|
||||
path: String,
|
||||
@ -113,6 +114,11 @@ fn model_rows(state: &AppState) -> Vec<ModelRow> {
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
context: details.as_ref().and_then(|d| d.context),
|
||||
systemprompt: store
|
||||
.model_systemprompt(&m.name)
|
||||
.ok()
|
||||
.flatten()
|
||||
.unwrap_or_default(),
|
||||
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(),
|
||||
@ -349,8 +355,18 @@ fn edit_dialog(state: &AppState, viewer: &Viewer, m: &ModelRow) -> String {
|
||||
<span class=\"hilfe\">Leer: Standard der Konfiguration. 0: nie entladen. Gilt ab dem nächsten Laden.</span></label>\
|
||||
<div class=\"dlg-fuss\"><button class=\"primary\" type=\"submit\">Speichern</button>\
|
||||
<button type=\"button\" data-close>Abbrechen</button></div></form>\
|
||||
{start_parameters}<div class=\"dlg-gefahr\"><div><b>Freigabe</b><span class=\"hilfe\">Gesperrte Modelle erscheinen nicht im Katalog; \
|
||||
{systemprompt}{start_parameters}<div class=\"dlg-gefahr\"><div><b>Freigabe</b><span class=\"hilfe\">Gesperrte Modelle erscheinen nicht im Katalog; \
|
||||
eine geladene Instanz bleibt bis zum Entladen bestehen.</span></div>{toggle}</div>{remove}</dialog>",
|
||||
systemprompt = if m.engine.as_deref() == Some("tts") {
|
||||
String::new()
|
||||
} else {
|
||||
format!(
|
||||
"<form class=\"dlg-form\" method=\"post\" action=\"/ui/modelle/systemprompt\">{}<input type=\"hidden\" name=\"name\" value=\"{}\"><label class=\"feld\">Grundlage (Systemprompt)<textarea name=\"systemprompt\" rows=\"5\" maxlength=\"32000\">{}</textarea></label><button class=\"primary\" type=\"submit\">Grundlage speichern</button></form>",
|
||||
csrf_field(viewer),
|
||||
esc(&m.name),
|
||||
esc(&m.systemprompt)
|
||||
)
|
||||
},
|
||||
start_parameters = super::startprofiles::section(
|
||||
state,
|
||||
viewer,
|
||||
@ -726,6 +742,34 @@ pub(super) async fn model_planning(
|
||||
}
|
||||
}
|
||||
|
||||
/// Nur Admins dürfen die Grundlage eines registrierten Modells ändern.
|
||||
pub(super) async fn model_systemprompt(
|
||||
State(state): State<Arc<AppState>>,
|
||||
headers: HeaderMap,
|
||||
body: Bytes,
|
||||
) -> Response {
|
||||
let _viewer = match admin(&state, &headers, &body) {
|
||||
Ok(v) => v,
|
||||
Err(r) => return *r,
|
||||
};
|
||||
let name = form_field(&body, "name").unwrap_or_default();
|
||||
let prompt = form_field(&body, "systemprompt").unwrap_or_default();
|
||||
if prompt.chars().count() > 32_000
|
||||
|| state
|
||||
.store()
|
||||
.model_details(&name)
|
||||
.ok()
|
||||
.flatten()
|
||||
.is_none_or(|d| d.engine == "tts")
|
||||
{
|
||||
return super::refused(StatusCode::BAD_REQUEST, "Modell oder Grundlage ungültig.");
|
||||
}
|
||||
match state.store().set_model_systemprompt(&name, &prompt) {
|
||||
Ok(true) => back("/ui/modelle", "grundlage"),
|
||||
_ => back("/ui/modelle", "unbekannt"),
|
||||
}
|
||||
}
|
||||
|
||||
// --- Warteschlange -----------------------------------------------------------
|
||||
|
||||
fn queue_html(view: &SchedulerView) -> String {
|
||||
|
||||
Reference in New Issue
Block a user