feat: Systemprompt-Ebenen: global, je Modell, Standard-Persona, ersetzen statt stapeln, Schema 20, Version 0.1.32 (#1248, #1249)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -543,7 +543,7 @@ fn edit_dialog(state: &AppState, viewer: &Viewer, m: &ModelRow) -> String {
|
||||
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>",
|
||||
"<form class=\"dlg-form\" method=\"post\" action=\"/ui/modelle/systemprompt\">{}<input type=\"hidden\" name=\"name\" value=\"{}\"><label class=\"feld\">Systemprompt für dieses Modell<textarea name=\"systemprompt\" rows=\"5\" maxlength=\"32000\">{}</textarea><span class=\"hilfe\">Ersetzt den globalen Systemprompt für dieses Modell; leer: der globale gilt. Ein Benutzer-Standard oder eine Persona im Chat ersetzt ihn wiederum.</span></label><button class=\"primary\" type=\"submit\">Speichern</button></form>",
|
||||
csrf_field(viewer),
|
||||
esc(&m.name),
|
||||
esc(&m.systemprompt)
|
||||
@ -650,6 +650,22 @@ pub(super) async fn models_page(
|
||||
_ => format!("<section class=\"card\" data-refresh=\"/ui/teil/modelle\" data-interval=\"3000\">{}</section><p class=\"klein\">Das Denkstufen-Symbol erscheint in „Kann“, sobald der Test am Modell (Knopf mit Haken) „ja“ ergeben hat.</p>", models_table(&state, &viewer, "llm")),
|
||||
};
|
||||
let mut body = format!("{}{nav}{content}", notice(query.as_deref()));
|
||||
if viewer.admin() && art.is_empty() {
|
||||
// Globaler Systemprompt (→ #1248): Standard für alle Modelle ohne eigenen Text.
|
||||
let global = state.store().globaler_systemprompt().unwrap_or_default();
|
||||
body.push_str(&format!(
|
||||
"<section class=\"card\" id=\"systemprompt-global\"><h2>Systemprompt (global)</h2>\
|
||||
<p class=\"klein\">Gilt für jedes Chat-Modell ohne eigenen Text (Dialog „Bearbeiten“ des Modells). \
|
||||
Die speziellere Ebene <b>ersetzt</b> die allgemeinere: Ein Text des Modells ersetzt diesen, der Standard des Benutzers \
|
||||
oder eine gewählte Persona ersetzt beide, ein Systemprompt in der Anfrage eines API-Clients ersetzt sie ebenfalls. \
|
||||
Leer lassen, damit das Modell bleibt, wie es ist.</p>\
|
||||
<form method=\"post\" action=\"/ui/systemprompt/global\" class=\"formular\">{csrf}\
|
||||
<label>Systemprompt <textarea name=\"systemprompt\" rows=\"5\" maxlength=\"32000\">{text}</textarea></label>\
|
||||
<button class=\"primary\" type=\"submit\">Speichern</button></form></section>",
|
||||
csrf = csrf_field(&viewer),
|
||||
text = esc(&global),
|
||||
));
|
||||
}
|
||||
if viewer.admin() {
|
||||
for m in model_rows(&state) {
|
||||
body.push_str(&edit_dialog(&state, &viewer, &m));
|
||||
@ -1151,6 +1167,32 @@ pub(super) async fn model_systemprompt(
|
||||
}
|
||||
}
|
||||
|
||||
/// `POST /ui/systemprompt/global`: globalen Systemprompt setzen (nur Admin; das Audit nennt die Länge, nie den Text).
|
||||
pub(super) async fn global_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 prompt = form_field(&body, "systemprompt").unwrap_or_default();
|
||||
if state.store().set_globaler_systemprompt(&prompt).is_err() {
|
||||
return super::refused(
|
||||
StatusCode::BAD_REQUEST,
|
||||
"Der Systemprompt ist ungültig (höchstens 32.000 Zeichen).",
|
||||
);
|
||||
}
|
||||
audit(
|
||||
&state,
|
||||
&viewer,
|
||||
"systemprompt.global",
|
||||
&format!("{} Zeichen", prompt.chars().count()),
|
||||
);
|
||||
back("/ui/modelle", "systemprompt_global")
|
||||
}
|
||||
|
||||
// --- Warteschlange -----------------------------------------------------------
|
||||
|
||||
fn queue_html(view: &SchedulerView) -> String {
|
||||
|
||||
Reference in New Issue
Block a user