- serve.py: TOCTOU in do_GET (urlparse), MAX_BODY vor content_length check - index.html: Hover-CSS dark-theme, empty-state categories entfernt, extractInputValue JSON.parse safe - validate.py: enum values-Leercheck, Exit-Code 2 für Validierungsfehler, ALLOWED_DIRS korrigiert - smoke_test.sh: stderr durchreichen (2>&1), dynamische Endpunkt-Zahl - README.md: --type-json, Schema-Sektionen bereinigt
160 lines
3.6 KiB
Markdown
160 lines
3.6 KiB
Markdown
# Prompt Templates
|
|
|
|
> Eine Sammlung von strukturierten Prompt-Templates für KI-Assistenten. Verwaltet über Git für Versionierung und Kollaboration.
|
|
|
|
---
|
|
|
|
## Struktur
|
|
|
|
```
|
|
prompt_template/
|
|
├── templates/ # Haupt-Templates
|
|
│ ├── system/ # System-Prompts (Code, Analyse, etc.)
|
|
│ ├── user/ # Benutzer-Prompts (Emails, Texte, etc.)
|
|
│ └── custom/ # Benutzerdefinierte Templates
|
|
│
|
|
├── scripts/ # Hilfsskripte
|
|
│ └── validate.py # Template-Validierung
|
|
│
|
|
├── README.md
|
|
└── .gitignore
|
|
```
|
|
|
|
---
|
|
|
|
## Web-Ansicht
|
|
|
|
Der Server startet mit:
|
|
```bash
|
|
python3 web/serve.py # http://localhost:8081
|
|
```
|
|
|
|
### API-Endpunkte
|
|
|
|
| URL | Methode | Beschreibung |
|
|
|-----|---------|--------------|
|
|
| `/` | GET | Frontend (index.html) |
|
|
| `/templates.json` | GET | Katalog (aus web/templates.json) |
|
|
| `/templates/system/*.json` | GET | System-Templates |
|
|
| `/templates/user/*.md` | GET | User-Templates |
|
|
| `/templates/...` | PUT | Template speichern (Content-Type: text/plain) |
|
|
|
|
### Validierung
|
|
```bash
|
|
python3 scripts/validate.py --all
|
|
```
|
|
|
|
## Dateiformate
|
|
|
|
### JSON-Templates (strukturiert)
|
|
Ein Template-File (z.B. `templates/system/code_reviewer.json`) hat dieses Schema:
|
|
```json
|
|
{
|
|
"name": "Template Name",
|
|
"version": "1.0",
|
|
"description": "Beschreibung...",
|
|
"role": "Rolle der KI",
|
|
"template": "Der eigentliche Prompt mit {variables}",
|
|
"variables": {
|
|
"var1": {"type": "string", "required": true, "description": "..."}
|
|
},
|
|
"tags": ["tag1", "tag2"],
|
|
"language": "de"
|
|
}
|
|
```
|
|
|
|
### Katalog (web/templates.json)
|
|
Der Katalog ist eine Liste von Einträgen mit diesem Schema:
|
|
```json
|
|
[
|
|
{
|
|
"path": "templates/system/code_reviewer.json",
|
|
"type": "system",
|
|
"name": "Code Reviewer",
|
|
"description": "Analysiert Code auf Qualität",
|
|
"version": "1.0",
|
|
"tags": ["code", "review"],
|
|
"format": "json"
|
|
}
|
|
]
|
|
```
|
|
|
|
### Markdown-Templates (einfach)
|
|
```markdown
|
|
# Template Name
|
|
|
|
**Rolle**: Beschreibung
|
|
|
|
**Template**:
|
|
```
|
|
Prompt-Text mit {variables}
|
|
```
|
|
|
|
**Variablen**:
|
|
| Variable | Typ | Required | Beschreibung |
|
|
```
|
|
|
|
---
|
|
|
|
## erweitert verwenden
|
|
|
|
### Neues Template hinzufügen
|
|
1. Template in passendem Verzeichnis erstellen (`.json` oder `.md`)
|
|
2. Validieren:
|
|
```bash
|
|
python scripts/validate.py templates/system/mein_template.json
|
|
```
|
|
3. Commiten:
|
|
```bash
|
|
git add templates/system/mein_template.json
|
|
git commit -m "feat: neues Template XY hinzugefügt"
|
|
```
|
|
|
|
### Template validieren
|
|
```bash
|
|
# Einzelnes Template
|
|
python scripts/validate.py pfad/zum/template.json
|
|
|
|
# Alle Templates
|
|
python scripts/validate.py --all
|
|
|
|
# Nur JSON-Templates
|
|
python scripts/validate.py --type-json
|
|
```
|
|
|
|
---
|
|
|
|
## Git Workflow
|
|
|
|
### Branches
|
|
- `master` / `main`: Stabile Templates
|
|
- `feature/*`: Neue Templates in Entwicklung
|
|
- `fix/*`: Korrekturen an bestehenden Templates
|
|
|
|
### Commit Messages
|
|
- `feat: neues Template hinzugefügt`
|
|
- `fix: Variable in Template XY korrigiert`
|
|
- `docs: Beschreibung aktualisiert`
|
|
- `refactor: Template-Struktur verbessert`
|
|
|
|
---
|
|
|
|
## Tags
|
|
|
|
| Tag | Beschreibung |
|
|
|-----|--------------|
|
|
| `#code` | Code-bezogene Templates |
|
|
| `#text` | Textgenerierung/Verarbeitung |
|
|
| `#creative` | Kreatives Schreiben |
|
|
| `#analysis` | Analyse-Tasks |
|
|
| `#communication` | Emails, Chat, etc. |
|
|
|
|
---
|
|
|
|
## Beispiele
|
|
|
|
Siehe:
|
|
- [Code Reviewer](templates/system/code_reviewer.json) - Code-Analyse
|
|
- [Text Summarizer](templates/system/summarizer.json) - Textzusammenfassung
|
|
- [Email Draft](templates/user/email_draft.md) - Email-Generierung
|
|
- [Brainstorming](templates/custom/brainstorming.md) - Ideenfindung
|