A previous `git pull --rebase origin main` dropped 177 local commits,
losing 3400+ files across admin-v2, backend, studio-v2, website,
klausur-service, and many other services. The partial restore attempt
(660295e2) only recovered some files.
This commit restores all missing files from pre-rebase ref 98933f5e
while preserving post-rebase additions (night-scheduler, night-mode UI,
NightModeWidget dashboard integration).
Restored features include:
- AI Module Sidebar (FAB), OCR Labeling, OCR Compare
- GPU Dashboard, RAG Pipeline, Magic Help
- Klausur-Korrektur (8 files), Abitur-Archiv (5+ files)
- Companion, Zeugnisse-Crawler, Screen Flow
- Full backend, studio-v2, website, klausur-service
- All compliance SDKs, agent-core, voice-service
- CI/CD configs, documentation, scripts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1011 lines
25 KiB
Markdown
1011 lines
25 KiB
Markdown
# AI Content Generator - Dokumentation
|
|
|
|
**Stand:** 2025-12-30
|
|
**Version:** 1.0.0
|
|
**Status:** Produktionsbereit
|
|
|
|
---
|
|
|
|
## Übersicht
|
|
|
|
Der **AI Content Generator** ist ein KI-gestützter Service, der automatisch H5P-Lerninhalte aus hochgeladenen Materialien generiert. Lehrer können Lernmaterialien (PDFs, Bilder, Word-Dokumente) zu einem Thema hochladen, und das System erstellt automatisch alle 8 H5P Content-Typen.
|
|
|
|
### Hauptfunktionen
|
|
|
|
1. **Material-Analyse**: Automatische Extraktion von Text aus PDFs, Word-Dokumenten und Bildern (OCR)
|
|
2. **KI-Generierung**: Claude AI erstellt altersgerechte Lerninhalte basierend auf den Materialien
|
|
3. **YouTube-Integration**: Findet passende Videos und generiert interaktive Elemente mit Zeitstempeln
|
|
4. **8 H5P Content-Typen**: Automatische Erstellung aller interaktiven Lernformate
|
|
|
|
---
|
|
|
|
## Architektur
|
|
|
|
### Service-Stack
|
|
|
|
```
|
|
┌─────────────────────────────────────────────────────────┐
|
|
│ BreakPilot Studio │
|
|
│ (Frontend/Teacher UI) │
|
|
└─────────────────────┬───────────────────────────────────┘
|
|
│
|
|
│ Upload Materials (PDF, DOCX, Images)
|
|
↓
|
|
┌─────────────────────────────────────────────────────────┐
|
|
│ AI Content Generator Service (Port 8004) │
|
|
│ FastAPI │
|
|
├─────────────────────────────────────────────────────────┤
|
|
│ ┌─────────────────┐ ┌──────────────┐ ┌────────────┐ │
|
|
│ │ Material │ │ Content │ │ Job Store │ │
|
|
│ │ Analyzer │ │ Generator │ │ (In-Memory)│ │
|
|
│ │ │ │ │ │ │ │
|
|
│ │ • PDF Extract │ │ • Quiz │ │ • Tracking │ │
|
|
│ │ • OCR (Images) │ │ • Flashcards │ │ • Status │ │
|
|
│ │ • DOCX Parser │ │ • Timeline │ │ • Results │ │
|
|
│ └─────────────────┘ └──────────────┘ └────────────┘ │
|
|
│ │
|
|
│ ┌─────────────────┐ ┌──────────────┐ │
|
|
│ │ Claude Service │ │ YouTube │ │
|
|
│ │ │ │ Service │ │
|
|
│ │ • API Client │ │ │ │
|
|
│ │ • Prompts │ │ • Transcript │ │
|
|
│ │ • JSON Parse │ │ • Search │ │
|
|
│ └─────────────────┘ └──────────────┘ │
|
|
└───────────┬──────────────────────┬──────────────────────┘
|
|
│ │
|
|
│ │ Fetch Transcripts
|
|
↓ ↓
|
|
┌──────────────┐ ┌──────────────────┐
|
|
│ Anthropic │ │ YouTube │
|
|
│ Claude API │ │ Transcript API │
|
|
│ (External) │ │ (Public) │
|
|
└──────────────┘ └──────────────────┘
|
|
│
|
|
↓ Generated Content
|
|
┌──────────────────────────┐
|
|
│ H5P Service (Port 8003) │
|
|
│ Interactive Content │
|
|
│ Editors & Players │
|
|
└──────────────────────────┘
|
|
```
|
|
|
|
### Komponenten
|
|
|
|
| Komponente | Technologie | Port | Beschreibung |
|
|
|------------|-------------|------|--------------|
|
|
| **API Server** | FastAPI | 8004 | REST API für Content-Generierung |
|
|
| **Material Analyzer** | PyPDF2, Tesseract, python-docx | - | Analyse von Lernmaterialien |
|
|
| **Claude Service** | Anthropic SDK | - | KI-Content-Generierung |
|
|
| **YouTube Service** | youtube-transcript-api | - | Video-Transkript-Analyse |
|
|
| **Content Generator** | Python | - | Orchestriert alle 8 Content-Typen |
|
|
| **Job Store** | In-Memory (Python) | - | Tracking von Generation-Jobs |
|
|
|
|
---
|
|
|
|
## Installation & Setup
|
|
|
|
### Voraussetzungen
|
|
|
|
1. **Docker & Docker Compose** installiert
|
|
2. **Anthropic API Key** (für Claude AI)
|
|
- Registrierung: https://console.anthropic.com/
|
|
- Kostenpflichtig (Pay-per-use)
|
|
|
|
### Umgebungsvariablen
|
|
|
|
Erstelle `.env` Datei in `/ai-content-generator/`:
|
|
|
|
```bash
|
|
# Kopiere Example
|
|
cp ai-content-generator/.env.example ai-content-generator/.env
|
|
|
|
# Editiere .env
|
|
nano ai-content-generator/.env
|
|
```
|
|
|
|
**Wichtige Variablen:**
|
|
|
|
```env
|
|
# ERFORDERLICH
|
|
ANTHROPIC_API_KEY=sk-ant-api03-...
|
|
|
|
# Optional
|
|
YOUTUBE_API_KEY= # Für erweiterte Video-Suche
|
|
SERVICE_HOST=0.0.0.0
|
|
SERVICE_PORT=8004
|
|
MAX_UPLOAD_SIZE=10485760 # 10MB
|
|
MAX_CONCURRENT_JOBS=5
|
|
JOB_TIMEOUT=300 # 5 Minuten
|
|
```
|
|
|
|
### Docker Start
|
|
|
|
```bash
|
|
# Content Services starten (inkl. AI Generator)
|
|
docker-compose -f docker-compose.content.yml up -d
|
|
|
|
# Nur AI Generator neu bauen
|
|
docker-compose -f docker-compose.content.yml up -d --build ai-content-generator
|
|
|
|
# Logs anzeigen
|
|
docker-compose -f docker-compose.content.yml logs -f ai-content-generator
|
|
```
|
|
|
|
### Lokale Entwicklung
|
|
|
|
```bash
|
|
cd ai-content-generator
|
|
|
|
# Virtual Environment
|
|
python3 -m venv venv
|
|
source venv/bin/activate
|
|
|
|
# Dependencies
|
|
pip install -r requirements.txt
|
|
|
|
# Tesseract OCR installieren
|
|
# macOS:
|
|
brew install tesseract tesseract-lang
|
|
|
|
# Ubuntu/Debian:
|
|
sudo apt-get install tesseract-ocr tesseract-ocr-deu
|
|
|
|
# Server starten
|
|
uvicorn app.main:app --reload --port 8004
|
|
```
|
|
|
|
API-Dokumentation: http://localhost:8004/docs
|
|
|
|
---
|
|
|
|
## API Endpoints
|
|
|
|
### 1. Health Check
|
|
|
|
```http
|
|
GET /health
|
|
```
|
|
|
|
**Response:**
|
|
```json
|
|
{
|
|
"status": "healthy",
|
|
"claude_configured": true,
|
|
"youtube_configured": true
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### 2. Content-Generierung starten
|
|
|
|
```http
|
|
POST /api/generate-content
|
|
Content-Type: multipart/form-data
|
|
```
|
|
|
|
**Form Data:**
|
|
- `topic` (string, required): Thema (z.B. "Das Auge")
|
|
- `description` (string, optional): Beschreibung
|
|
- `target_grade` (string, required): Klassenstufe (z.B. "5-6", "7-8", "9-10")
|
|
- `materials` (File[], required): Lernmaterialien (PDF, DOCX, PNG, JPG)
|
|
|
|
**Beispiel (cURL):**
|
|
|
|
```bash
|
|
curl -X POST http://localhost:8004/api/generate-content \
|
|
-F "topic=Das Auge" \
|
|
-F "description=Biologie für Klasse 7" \
|
|
-F "target_grade=7-8" \
|
|
-F "materials=@auge_skizze.pdf" \
|
|
-F "materials=@auge_aufbau.docx" \
|
|
-F "materials=@diagramm.png"
|
|
```
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
"status": "pending",
|
|
"message": "Content generation started"
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### 3. Generation-Status prüfen
|
|
|
|
```http
|
|
GET /api/generation-status/{job_id}
|
|
```
|
|
|
|
**Response (Processing):**
|
|
|
|
```json
|
|
{
|
|
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
"status": "processing",
|
|
"progress": 50,
|
|
"current_step": "Generating Quiz questions...",
|
|
"started_at": "2025-12-30T10:00:00Z"
|
|
}
|
|
```
|
|
|
|
**Response (Completed):**
|
|
|
|
```json
|
|
{
|
|
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
"status": "completed",
|
|
"progress": 100,
|
|
"current_step": "All content generated",
|
|
"started_at": "2025-12-30T10:00:00Z",
|
|
"completed_at": "2025-12-30T10:05:00Z"
|
|
}
|
|
```
|
|
|
|
**Response (Failed):**
|
|
|
|
```json
|
|
{
|
|
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
"status": "failed",
|
|
"error_message": "API Key invalid",
|
|
"started_at": "2025-12-30T10:00:00Z",
|
|
"completed_at": "2025-12-30T10:00:15Z"
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### 4. Generierte Inhalte abrufen
|
|
|
|
```http
|
|
GET /api/generated-content/{job_id}
|
|
```
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"topic": "Das Auge",
|
|
"description": "Biologie für Klasse 7",
|
|
"target_grade": "7-8",
|
|
"generated_at": "2025-12-30T10:05:00Z",
|
|
"content_types": {
|
|
"quiz": {
|
|
"type": "quiz",
|
|
"title": "Quiz: Das Auge",
|
|
"description": "Teste dein Wissen über das Auge",
|
|
"questions": [...]
|
|
},
|
|
"interactive_video": {...},
|
|
"flashcards": {...},
|
|
"timeline": {...},
|
|
"drag_drop": {...},
|
|
"fill_blanks": {...},
|
|
"memory": {...},
|
|
"course_presentation": {...}
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### 5. YouTube Video-Suche
|
|
|
|
```http
|
|
POST /api/youtube-search
|
|
Content-Type: application/json
|
|
```
|
|
|
|
**Request:**
|
|
|
|
```json
|
|
{
|
|
"query": "Das Auge Biologie Schule",
|
|
"max_results": 5
|
|
}
|
|
```
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"videos": [
|
|
{
|
|
"video_id": "EXAMPLE_ID",
|
|
"title": "Video zum Thema: Das Auge",
|
|
"channel": "Educational Channel",
|
|
"url": "https://www.youtube.com/watch?v=...",
|
|
"has_transcript": false,
|
|
"note": "Use real YouTube Data API in production"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Content-Typen
|
|
|
|
### 1. Quiz (Question Set)
|
|
|
|
**Generierung:** Claude AI erstellt 10 Multiple-Choice-Fragen basierend auf den Materialien.
|
|
|
|
**Struktur:**
|
|
|
|
```json
|
|
{
|
|
"type": "quiz",
|
|
"title": "Quiz: Das Auge",
|
|
"description": "Teste dein Wissen über das Auge",
|
|
"questions": [
|
|
{
|
|
"question": "Was ist die Funktion der Pupille?",
|
|
"options": [
|
|
"Lichteinfall regulieren",
|
|
"Farben erkennen",
|
|
"Scharfstellen",
|
|
"Bewegungen erkennen"
|
|
],
|
|
"correct_answer": 0,
|
|
"explanation": "Die Pupille reguliert den Lichteinfall ins Auge..."
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### 2. Interactive Video
|
|
|
|
**Generierung:** YouTube-Video wird mit Transkript analysiert, Claude AI generiert 5 zeitbasierte Interaktionen.
|
|
|
|
**Struktur:**
|
|
|
|
```json
|
|
{
|
|
"type": "interactive-video",
|
|
"title": "Das Auge - Aufbau und Funktion",
|
|
"videoUrl": "https://youtube.com/watch?v=xyz",
|
|
"description": "Interaktives Video über das Auge",
|
|
"interactions": [
|
|
{
|
|
"time": "01:30",
|
|
"seconds": 90,
|
|
"type": "question",
|
|
"title": "Verständnisfrage",
|
|
"content": "Was wurde über die Netzhaut erklärt?"
|
|
},
|
|
{
|
|
"time": "03:15",
|
|
"seconds": 195,
|
|
"type": "info",
|
|
"title": "Wichtiger Hinweis",
|
|
"content": "Achte auf den Unterschied zwischen Stäbchen und Zapfen."
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
**Interaktionstypen:**
|
|
- `question`: Verständnisfrage (pausiert Video)
|
|
- `info`: Information/Hinweis
|
|
- `link`: Externer Link zu Zusatzmaterial
|
|
|
|
---
|
|
|
|
### 3. Course Presentation
|
|
|
|
**Generierung:** 6 Folien mit Titel, Inhalt und Hintergrundfarbe.
|
|
|
|
**Struktur:**
|
|
|
|
```json
|
|
{
|
|
"type": "course-presentation",
|
|
"title": "Präsentation: Das Auge",
|
|
"description": "Lerne alles über das Auge",
|
|
"slides": [
|
|
{
|
|
"id": 1,
|
|
"title": "Das Auge - Einführung",
|
|
"content": "Das Auge ist unser wichtigstes Sinnesorgan...",
|
|
"backgroundColor": "#ffffff"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"title": "Aufbau des Auges",
|
|
"content": "Das Auge besteht aus mehreren Teilen: Hornhaut, Linse...",
|
|
"backgroundColor": "#f0f8ff"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### 4. Flashcards
|
|
|
|
**Generierung:** 15 Lernkarten mit Begriff/Frage und Definition/Antwort.
|
|
|
|
**Struktur:**
|
|
|
|
```json
|
|
{
|
|
"type": "flashcards",
|
|
"title": "Lernkarten: Das Auge",
|
|
"description": "Wiederhole wichtige Begriffe",
|
|
"cards": [
|
|
{
|
|
"id": 1,
|
|
"front": "Pupille",
|
|
"back": "Öffnung in der Iris, die den Lichteinfall reguliert"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"front": "Was sind Stäbchen?",
|
|
"back": "Rezeptoren in der Netzhaut für Hell-Dunkel-Sehen"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### 5. Timeline
|
|
|
|
**Generierung:** 5-8 chronologische Ereignisse (z.B. Geschichte, Entwicklung).
|
|
|
|
**Struktur:**
|
|
|
|
```json
|
|
{
|
|
"type": "timeline",
|
|
"title": "Zeitleiste: Augenforschung",
|
|
"description": "Chronologie der Augenforschung",
|
|
"events": [
|
|
{
|
|
"id": 1,
|
|
"year": "1604",
|
|
"title": "Johannes Kepler",
|
|
"description": "Erste korrekte Erklärung der Bildentstehung im Auge"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"year": "1851",
|
|
"title": "Erfindung des Augenspiegels",
|
|
"description": "Hermann von Helmholtz entwickelt den Augenspiegel"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### 6. Drag and Drop
|
|
|
|
**Generierung:** 3-4 Kategorien (Zonen) mit 8-12 zuordenbaren Elementen.
|
|
|
|
**Struktur:**
|
|
|
|
```json
|
|
{
|
|
"type": "drag-drop",
|
|
"title": "Zuordnung: Teile des Auges",
|
|
"question": "Ordne die Begriffe den richtigen Kategorien zu",
|
|
"zones": [
|
|
{"id": 1, "name": "Lichtbrechung"},
|
|
{"id": 2, "name": "Lichtrezeption"},
|
|
{"id": 3, "name": "Bildverarbeitung"}
|
|
],
|
|
"draggables": [
|
|
{"id": 1, "text": "Hornhaut", "correctZoneId": 1},
|
|
{"id": 2, "text": "Linse", "correctZoneId": 1},
|
|
{"id": 3, "text": "Netzhaut", "correctZoneId": 2},
|
|
{"id": 4, "text": "Sehnerv", "correctZoneId": 3}
|
|
]
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### 7. Fill in the Blanks
|
|
|
|
**Generierung:** Text mit 10-15 Lücken (markiert mit `*Wort*`).
|
|
|
|
**Struktur:**
|
|
|
|
```json
|
|
{
|
|
"type": "fill-blanks",
|
|
"title": "Lückentext: Das Auge",
|
|
"text": "Das Licht tritt durch die *Hornhaut* ins Auge ein. Die *Pupille* reguliert den Lichteinfall. Die *Linse* bricht das Licht und projiziert es auf die *Netzhaut*.",
|
|
"hints": "Achte auf die richtige Reihenfolge des Lichteinfalls."
|
|
}
|
|
```
|
|
|
|
**Hinweis:** Lücken werden mit `*` markiert. Der H5P Player extrahiert die Wörter automatisch.
|
|
|
|
---
|
|
|
|
### 8. Memory Game
|
|
|
|
**Generierung:** 8 Paare von zusammengehörigen Begriffen/Konzepten.
|
|
|
|
**Struktur:**
|
|
|
|
```json
|
|
{
|
|
"type": "memory",
|
|
"title": "Memory: Das Auge",
|
|
"description": "Finde die passenden Paare",
|
|
"pairs": [
|
|
{
|
|
"id": 1,
|
|
"card1": "Pupille",
|
|
"card2": "Lichteinfall regulieren"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"card1": "Linse",
|
|
"card2": "Licht bündeln"
|
|
},
|
|
{
|
|
"id": 3,
|
|
"card1": "Netzhaut",
|
|
"card2": "Lichtsignale empfangen"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Material-Analyse
|
|
|
|
### Unterstützte Dateitypen
|
|
|
|
| Dateityp | Library | Funktion |
|
|
|----------|---------|----------|
|
|
| **PDF** | PyPDF2 | Textextraktion aus mehrseitigen PDFs |
|
|
| **PNG/JPG** | Pillow + Tesseract OCR | Optische Zeichenerkennung (deutsch) |
|
|
| **DOCX** | python-docx / mammoth | Word-Dokument Parsing |
|
|
| **TXT** | Python stdlib | Plain-Text Dateien |
|
|
|
|
### Beispiel: PDF-Analyse
|
|
|
|
```python
|
|
# Automatisch ausgeführt bei Upload
|
|
pdf_result = {
|
|
"filename": "auge_skizze.pdf",
|
|
"type": "pdf",
|
|
"num_pages": 3,
|
|
"content": "--- Seite 1 ---\nDas Auge ist...\n--- Seite 2 ---\n...",
|
|
"success": True
|
|
}
|
|
```
|
|
|
|
### Beispiel: Image-Analyse (OCR)
|
|
|
|
```python
|
|
# Tesseract OCR wird automatisch ausgeführt
|
|
image_result = {
|
|
"filename": "diagramm.png",
|
|
"type": "image",
|
|
"width": 1920,
|
|
"height": 1080,
|
|
"mode": "RGB",
|
|
"content": "Hornhaut\nLinse\nNetzhaut\nSehnerv", # OCR-Text
|
|
"success": True
|
|
}
|
|
```
|
|
|
|
**Voraussetzung:** Tesseract OCR muss installiert sein.
|
|
|
|
---
|
|
|
|
## Workflow
|
|
|
|
### Typischer Ablauf
|
|
|
|
```mermaid
|
|
sequenceDiagram
|
|
participant Teacher as Lehrer (Browser)
|
|
participant API as AI Generator API
|
|
participant Analyzer as Material Analyzer
|
|
participant Claude as Claude AI
|
|
participant YouTube as YouTube API
|
|
participant H5P as H5P Service
|
|
|
|
Teacher->>API: POST /api/generate-content (PDF, DOCX, Images)
|
|
API->>API: Create Job ID
|
|
API-->>Teacher: job_id + status: pending
|
|
|
|
API->>Analyzer: Analyze materials
|
|
Analyzer->>Analyzer: Extract text from PDF
|
|
Analyzer->>Analyzer: OCR on images
|
|
Analyzer->>Analyzer: Parse DOCX
|
|
Analyzer-->>API: Analyzed content
|
|
|
|
API->>Claude: Generate Quiz (materials + topic)
|
|
Claude-->>API: 10 questions
|
|
|
|
API->>Claude: Generate Flashcards
|
|
Claude-->>API: 15 cards
|
|
|
|
API->>YouTube: Search videos (topic)
|
|
YouTube-->>API: Video URLs
|
|
|
|
API->>YouTube: Get transcript (video_id)
|
|
YouTube-->>API: Transcript with timestamps
|
|
|
|
API->>Claude: Generate interactions (transcript + topic)
|
|
Claude-->>API: 5 interactions with times
|
|
|
|
API->>Claude: Generate remaining types
|
|
Claude-->>API: Timeline, Drag&Drop, Fill-Blanks, Memory, Presentation
|
|
|
|
API->>API: Update job status: completed
|
|
|
|
Teacher->>API: GET /api/generation-status/{job_id}
|
|
API-->>Teacher: status: completed
|
|
|
|
Teacher->>API: GET /api/generated-content/{job_id}
|
|
API-->>Teacher: All 8 content types
|
|
|
|
Teacher->>H5P: Use generated content in editors
|
|
H5P-->>Teacher: Interactive content ready
|
|
```
|
|
|
|
### Schritte im Detail
|
|
|
|
1. **Upload & Job Creation** (5s)
|
|
- Lehrer lädt Materialien hoch
|
|
- System erstellt Job-ID
|
|
- Status: `pending`
|
|
|
|
2. **Material-Analyse** (10-30s)
|
|
- PDF: Textextraktion pro Seite
|
|
- Images: Tesseract OCR
|
|
- DOCX: Dokument-Parsing
|
|
- Status: `processing` (10% progress)
|
|
|
|
3. **Quiz-Generierung** (15-30s)
|
|
- Claude API Call mit Materials + Thema
|
|
- 10 Multiple-Choice-Fragen
|
|
- Status: `processing` (25% progress)
|
|
|
|
4. **Flashcards-Generierung** (10-20s)
|
|
- 15 Lernkarten
|
|
- Status: `processing` (40% progress)
|
|
|
|
5. **YouTube-Integration** (20-40s)
|
|
- Video-Suche
|
|
- Transkript-Abruf
|
|
- Claude generiert Interaktionen
|
|
- Status: `processing` (60% progress)
|
|
|
|
6. **Restliche Content-Typen** (30-60s)
|
|
- Timeline (5-8 Events)
|
|
- Drag & Drop (3-4 Kategorien)
|
|
- Fill in the Blanks (10-15 Lücken)
|
|
- Memory (8 Paare)
|
|
- Course Presentation (6 Folien)
|
|
- Status: `processing` (80-100% progress)
|
|
|
|
7. **Fertigstellung** (<5s)
|
|
- Status: `completed`
|
|
- Content bereit zum Abruf
|
|
|
|
**Gesamtdauer:** Ca. 2-5 Minuten (abhängig von Claude API Latenz)
|
|
|
|
---
|
|
|
|
## Claude AI Prompts
|
|
|
|
### Beispiel: Quiz-Generierung
|
|
|
|
```python
|
|
prompt = f"""Erstelle {num_questions} Multiple-Choice-Fragen zum Thema "{topic}" für Klassenstufe {target_grade}.
|
|
|
|
Materialien:
|
|
{material_text}
|
|
|
|
Erstelle Fragen die:
|
|
1. Das Verständnis testen
|
|
2. Auf den Materialien basieren
|
|
3. Altersgerecht sind
|
|
4. 4 Antwortmöglichkeiten haben (1 richtig, 3 falsch)
|
|
|
|
Formatiere die Ausgabe als JSON-Array:
|
|
[
|
|
{{
|
|
"question": "Frage text?",
|
|
"options": ["Option A", "Option B", "Option C", "Option D"],
|
|
"correct_answer": 0,
|
|
"explanation": "Erklärung warum die Antwort richtig ist"
|
|
}}
|
|
]
|
|
|
|
Nur das JSON-Array zurückgeben, keine zusätzlichen Texte."""
|
|
|
|
system_prompt = "Du bist ein pädagogischer Experte der Quizfragen erstellt."
|
|
```
|
|
|
|
### Beispiel: Interactive Video Interactions
|
|
|
|
```python
|
|
prompt = f"""Analysiere dieses Video-Transkript zum Thema "{topic}" und identifiziere {num_interactions} wichtige Momente für interaktive Elemente.
|
|
|
|
Transkript:
|
|
{transcript_text[:8000]}
|
|
|
|
Für jeden Moment, erstelle:
|
|
1. Einen Zeitstempel (in Sekunden)
|
|
2. Einen Interaktionstyp (question, info, oder link)
|
|
3. Einen Titel
|
|
4. Den Inhalt (Frage, Information, oder URL)
|
|
|
|
Formatiere als JSON-Array:
|
|
[
|
|
{{
|
|
"seconds": 45,
|
|
"type": "question",
|
|
"title": "Verständnisfrage",
|
|
"content": "Was ist die Hauptfunktion...?"
|
|
}},
|
|
{{
|
|
"seconds": 120,
|
|
"type": "info",
|
|
"title": "Wichtiger Hinweis",
|
|
"content": "Beachte dass..."
|
|
}}
|
|
]
|
|
|
|
Wähle Momente die:
|
|
- Wichtige Konzepte einführen
|
|
- Verständnis testen
|
|
- Zusatzinformationen bieten
|
|
|
|
Nur JSON zurückgeben."""
|
|
|
|
system_prompt = "Du bist ein Experte für interaktive Video-Didaktik."
|
|
```
|
|
|
|
---
|
|
|
|
## Kosten & Limits
|
|
|
|
### Anthropic Claude API
|
|
|
|
| Modell | Input | Output | Verwendung |
|
|
|--------|-------|--------|------------|
|
|
| **Claude Sonnet 4.5** | $3/MTok | $15/MTok | Alle Content-Typen |
|
|
|
|
**Geschätzte Kosten pro Generation:**
|
|
- Materials: ~500 Tokens Input
|
|
- 8 Content-Typen: ~8 API Calls
|
|
- Total Input: ~4,000 Tokens ($0.012)
|
|
- Total Output: ~8,000 Tokens ($0.120)
|
|
- **Pro Generation: ~$0.13**
|
|
|
|
**Bei 100 Generierungen/Monat: ~$13/Monat**
|
|
|
|
### YouTube API (Optional)
|
|
|
|
| API | Kosten | Quota |
|
|
|-----|--------|-------|
|
|
| **YouTube Data API v3** | Kostenlos | 10,000 Einheiten/Tag |
|
|
| **YouTube Transcript API** | Kostenlos | Unbegrenzt (Public API) |
|
|
|
|
**Hinweis:** Transcript API funktioniert ohne API Key. Data API nur für erweiterte Video-Suche.
|
|
|
|
---
|
|
|
|
## Troubleshooting
|
|
|
|
### Problem: "Claude API not configured"
|
|
|
|
**Lösung:**
|
|
```bash
|
|
# Prüfe ob API Key gesetzt ist
|
|
docker-compose -f docker-compose.content.yml exec ai-content-generator env | grep ANTHROPIC
|
|
|
|
# Setze API Key in .env
|
|
echo "ANTHROPIC_API_KEY=sk-ant-api03-..." >> ai-content-generator/.env
|
|
|
|
# Service neu starten
|
|
docker-compose -f docker-compose.content.yml restart ai-content-generator
|
|
```
|
|
|
|
---
|
|
|
|
### Problem: OCR funktioniert nicht (Images)
|
|
|
|
**Lösung:**
|
|
|
|
Docker (automatisch installiert):
|
|
```bash
|
|
# Dockerfile enthält bereits:
|
|
RUN apt-get install -y tesseract-ocr tesseract-ocr-deu
|
|
```
|
|
|
|
Lokal:
|
|
```bash
|
|
# macOS
|
|
brew install tesseract tesseract-lang
|
|
|
|
# Ubuntu/Debian
|
|
sudo apt-get install tesseract-ocr tesseract-ocr-deu
|
|
|
|
# Testen
|
|
tesseract --version
|
|
```
|
|
|
|
---
|
|
|
|
### Problem: Job bleibt bei "processing" hängen
|
|
|
|
**Lösung:**
|
|
|
|
```bash
|
|
# Prüfe Logs
|
|
docker-compose -f docker-compose.content.yml logs -f ai-content-generator
|
|
|
|
# Häufige Ursachen:
|
|
# 1. Claude API Rate Limit → Warte 1 Minute
|
|
# 2. Timeout (5 Min) → Materialien zu groß? Reduziere Upload-Größe
|
|
# 3. Network Error → Prüfe Internetverbindung
|
|
|
|
# Job Store zurücksetzen (nur Development)
|
|
docker-compose -f docker-compose.content.yml restart ai-content-generator
|
|
```
|
|
|
|
---
|
|
|
|
### Problem: YouTube Video hat kein Transkript
|
|
|
|
**Lösung:**
|
|
|
|
Das System generiert dann generische Interaktionen:
|
|
|
|
```json
|
|
{
|
|
"type": "interactive-video",
|
|
"videoUrl": "https://youtube.com/watch?v=xyz",
|
|
"interactions": [
|
|
{
|
|
"time": "01:00",
|
|
"type": "question",
|
|
"content": "Was ist das Hauptthema dieses Videos über {topic}?"
|
|
}
|
|
],
|
|
"note": "Generische Interaktionen - Video hat kein Transkript"
|
|
}
|
|
```
|
|
|
|
**Alternative:** Lehrer kann manuell Video-URL mit Transkript eingeben.
|
|
|
|
---
|
|
|
|
## Sicherheit & Datenschutz
|
|
|
|
### Datenspeicherung
|
|
|
|
- **Uploads:** Temporär in `/app/uploads/` (Docker Volume)
|
|
- **Jobs:** In-Memory (verloren bei Neustart)
|
|
- **TODO:** Redis Backend für Persistenz
|
|
|
|
### Datenfluss
|
|
|
|
```
|
|
Teacher Upload → AI Generator (temp storage) → Claude API (external) → Results → Deleted
|
|
```
|
|
|
|
**Wichtig:**
|
|
- Hochgeladene Materialien werden NICHT dauerhaft gespeichert
|
|
- Claude API (Anthropic) verarbeitet Materialien gemäß ihrer [Commercial Terms](https://www.anthropic.com/legal/commercial-terms)
|
|
- Keine Speicherung in Cloud nach Generation (außer Lehrer speichert in H5P Service)
|
|
|
|
### DSGVO-Compliance
|
|
|
|
- ✅ Keine dauerhafte Speicherung von Schülerdaten
|
|
- ✅ Materialien werden nach Generation gelöscht
|
|
- ✅ Claude API: EU-Data Processing Agreement verfügbar
|
|
- ⚠️ YouTube Transcript API: Public API (keine Authentifizierung)
|
|
|
|
**Empfehlung:** Keine personenbezogenen Daten in Materialien hochladen.
|
|
|
|
---
|
|
|
|
## Deployment
|
|
|
|
### Production Checklist
|
|
|
|
- [ ] Anthropic API Key gesetzt (`ANTHROPIC_API_KEY`)
|
|
- [ ] Optional: YouTube API Key für erweiterte Suche
|
|
- [ ] Tesseract OCR installiert (im Dockerfile: ✅)
|
|
- [ ] H5P Service läuft (Port 8003)
|
|
- [ ] Content Service läuft (Port 8002)
|
|
- [ ] Docker Volumes erstellt
|
|
- [ ] Health Check: `curl http://localhost:8004/health`
|
|
- [ ] Logs monitoring: `docker-compose logs -f ai-content-generator`
|
|
|
|
### Monitoring
|
|
|
|
```bash
|
|
# Health Check
|
|
curl http://localhost:8004/health
|
|
|
|
# API Docs
|
|
open http://localhost:8004/docs
|
|
|
|
# Logs
|
|
docker-compose -f docker-compose.content.yml logs -f ai-content-generator
|
|
|
|
# Container Status
|
|
docker-compose -f docker-compose.content.yml ps
|
|
```
|
|
|
|
---
|
|
|
|
## Roadmap / TODO
|
|
|
|
### Phase 1 (Aktuell) ✅
|
|
- [x] Material-Analyse (PDF, DOCX, Images)
|
|
- [x] Claude AI Integration
|
|
- [x] Alle 8 H5P Content-Typen
|
|
- [x] YouTube Transcript Integration
|
|
- [x] Docker Integration
|
|
- [x] API Endpoints
|
|
|
|
### Phase 2 (Geplant)
|
|
- [ ] Redis Backend für Job Store (Persistenz)
|
|
- [ ] Celery für Background Tasks (async)
|
|
- [ ] Webhook Notifications (Lehrer wird benachrichtigt)
|
|
- [ ] Batch Processing (mehrere Themen gleichzeitig)
|
|
- [ ] Content Quality Validation (automatische Prüfung)
|
|
|
|
### Phase 3 (Future)
|
|
- [ ] Multi-Language Support (nicht nur Deutsch)
|
|
- [ ] Custom Prompts (Lehrer kann Prompts anpassen)
|
|
- [ ] A/B Testing für Prompts
|
|
- [ ] Analytics (welche Content-Typen werden am meisten genutzt)
|
|
- [ ] Rate Limiting & Quota Management
|
|
- [ ] API Authentication (JWT)
|
|
|
|
---
|
|
|
|
## Support & Kontakt
|
|
|
|
### Dokumentation
|
|
- **Haupt-Docs:** `/docs/ai-content-generator.md`
|
|
- **Service README:** `/ai-content-generator/README.md`
|
|
- **API Spec:** http://localhost:8004/docs (Swagger UI)
|
|
|
|
### Issues
|
|
- GitHub Issues: https://github.com/breakpilot/breakpilot-pwa/issues
|
|
|
|
### Team
|
|
- E-Mail: dev@breakpilot.app
|
|
- Slack: #ai-content-generator
|
|
|
|
---
|
|
|
|
## Änderungsprotokoll
|
|
|
|
| Datum | Version | Änderung |
|
|
|-------|---------|----------|
|
|
| 2025-12-30 | 1.0.0 | Initiale Implementierung |
|
|
| 2025-12-30 | 1.0.0 | Alle 8 H5P Content-Typen implementiert |
|
|
| 2025-12-30 | 1.0.0 | Docker Integration abgeschlossen |
|
|
| 2025-12-30 | 1.0.0 | Dokumentation erstellt |
|
|
|
|
---
|
|
|
|
**Status:** Produktionsbereit
|
|
**Nächste Schritte:** Redis Backend + Celery Background Tasks
|