{% extends "base.html" %} {% block title %}Redax-WP — Prompts{% endblock %} {% block content %}

🧠 Prompt-Bibliothek

Klicke auf einen Prompt, um ihn zu bearbeiten oder als Standard zu setzen. Neuer Prompt: Speichern setzt ihn automatisch als Standard.

{% for p in prompts %}
{{ p.name }} {% if p.is_default %}Standard{% endif %}
{% if not p.is_default %} {% endif %}
{{ p.system_prompt[:80] }}...
{% endfor %}
{% endblock %} {% block extra_js %} function loadPrompt(id, text, name, is_default) { document.getElementById('prompt-id').value = id; document.getElementById('prompt-name').value = name; document.getElementById('prompt-text').value = text; } function newPrompt() { document.getElementById('prompt-id').value = ''; document.getElementById('prompt-name').value = ''; document.getElementById('prompt-text').value = ''; } async function savePrompt() { const currentId = document.getElementById('prompt-id').value || null; const r = await fetch('/api/prompts/save', {method:'POST',headers:{'Content-Type':'application/json'}, body: JSON.stringify({id: currentId, name: document.getElementById('prompt-name').value, system_prompt: document.getElementById('prompt-text').value})}); const d = await r.json(); if (d.success) { showToast('💾 Gespeichert'); // Neuer Prompt: automatisch als Standard setzen if (!currentId && d.id) { await fetch(`/api/prompts/${d.id}/default`, {method:'POST'}); showToast('💾 Gespeichert & ⭐ als Standard gesetzt'); } location.reload(); } } async function setDefault() { const id = document.getElementById('prompt-id').value; if (!id) { showToast('⚠️ Prompt zuerst auswählen (klicken) und ggf. speichern'); return; } await fetch(`/api/prompts/${id}/default`, {method:'POST'}); showToast('⭐ Als Standard gesetzt'); location.reload(); } async function deletePrompt(id) { if (!confirm('Prompt löschen?')) return; await fetch(`/api/prompts/${id}/delete`, {method:'POST'}); location.reload(); } {% endblock %}