Flexibles KI Prompt System #48
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "develop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Migration 018: - Add display_name column to ai_prompts - Migrate existing prompts from hardcoded SLUG_LABELS - Fallback: name if display_name is NULL Backend: - PromptCreate/Update models with display_name field - create/update/duplicate endpoints handle display_name - Fallback: use name if display_name not provided Frontend: - PromptEditModal: display_name input field - Placeholder picker: button + dropdown with all placeholders - Shows example values, inserts {{placeholder}} on click - Analysis.jsx: use display_name instead of SLUG_LABELS User-facing changes: - Prompts now show custom display names (e.g. '🍽️ Ernährung') - Admin can edit display names instead of hardcoded labels - Template editor has 'Platzhalter einfügen' button - No more hardcoded SLUG_LABELS in frontend Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Backend: - get_placeholder_catalog(): grouped placeholders with descriptions - Returns {category: [{key, description, example}]} format - Categories: Profil, Körper, Ernährung, Training, Schlaf, Vitalwerte, Zeitraum Frontend - Placeholder Picker: - Grouped by category with visual separation - Search/filter across keys and descriptions - Hover effects for better UX - Insert at cursor position (not at end) - Shows: key + description + example value - 'Keine Platzhalter gefunden' message when filtered Frontend - Insight Display Names: - InsightCard receives prompts array - Finds matching prompt by scope/slug - Shows prompt.display_name instead of hardcoded SLUG_LABELS - History tab also shows display_name in group headers - Fallback chain: display_name → SLUG_LABELS → scope User-facing improvements: ✓ Platzhalter zeigen echte Daten statt Zahlen ✓ Durchsuchbar + filterbar ✓ Einfügen an Cursor-Position ✓ Insights zeigen custom Namen (z.B. '🍽️ Meine Ernährung') Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Implementiert konfigurierbare mehrstufige Analysen. Admins können mehrere Pipeline-Konfigurationen erstellen mit unterschiedlichen Modulen, Zeiträumen und Prompts. **Backend:** - Migration 019: pipeline_configs Tabelle + ai_prompts erweitert - Pipeline-Config Models: PipelineConfigCreate, PipelineConfigUpdate - Pipeline-Executor: refactored für config-basierte Ausführung - CRUD-Endpoints: /api/prompts/pipeline-configs (list, create, update, delete, set-default) - Reset-to-Default: /api/prompts/{id}/reset-to-default für System-Prompts **Features:** - 3 Seed-Configs: "Alltags-Check" (default), "Schlaf & Erholung", "Wettkampf-Analyse" - Dynamische Platzhalter: {{stage1_<slug>}} für alle Stage-1-Ergebnisse - Backward-compatible: /api/insights/pipeline ohne config_id nutzt default **Dateien:** - backend/migrations/019_pipeline_system.sql - backend/models.py (PipelineConfigCreate, PipelineConfigUpdate) - backend/routers/insights.py (analyze_pipeline refactored) - backend/routers/prompts.py (Pipeline-Config CRUD + Reset-to-Default) **Nächste Schritte:** - Frontend: Pipeline-Config Dialog + Admin-UI - Design: Mobile-Responsive + Icons Issue #28 Progress: Backend 3/3 ✅ | Frontend 0/3 🔲 | Design 0/3 🔲 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>- Migration 020: Add type, stages, output_format columns to ai_prompts - Migrate existing prompts to 1-stage pipeline format - Migrate pipeline_configs into ai_prompts as multi-stage pipelines - Add UnifiedPrompt Pydantic models for new API - Backup pipeline_configs table (keep during transition) Schema structure: - type: 'base' (reusable) or 'pipeline' (multi-stage) - stages: JSONB array [{stage:1, prompts:[{source, slug, template, output_key, output_format}]}] - output_format: 'text' or 'json' - output_schema: JSON validation schema (optional) Next: Backend executor + Frontend UI consolidationBackend: - prompt_executor.py: Universal executor for base + pipeline prompts - Dynamic placeholder resolution - JSON output validation - Multi-stage parallel execution (sequential impl) - Reference and inline prompt support - Data loading per module (körper, ernährung, training, schlaf, vitalwerte) Endpoints: - POST /api/prompts/execute - Execute unified prompts - POST /api/prompts/unified - Create unified prompts - PUT /api/prompts/unified/{id} - Update unified prompts Frontend: - api.js: executeUnifiedPrompt, createUnifiedPrompt, updateUnifiedPrompt Next: Phase 3 - Frontend UI consolidationFixed curly brace escaping in JSX string. Changed from {{'{{'}} to {'{{'}}Placeholder resolver returns keys with {{ }} wrappers, but resolve_placeholders expects clean keys. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>- New placeholder: {{activity_detail}} returns formatted activity log - Shows last 20 activities with date, type, duration, kcal, HR - Makes activity analysis prompts work properly Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Added "📋 Platzhalter exportieren" button in debug viewer: - Exports all resolved placeholders with values - Includes all available_variables - For pipelines: exports per-stage placeholder data - JSON format with timestamp and prompt metadata - Filename: placeholders-{slug}-{date}.json Use case: Development aid - see exactly what data is available for prompt templates without null values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Zentraler Export aller verfügbaren Platzhalter mit aktuellen Werten. Backend: - GET /api/prompts/placeholders/export-values - Returns all placeholders organized by category - Includes resolved values for current profile - Includes metadata (description, example) - Flat list + categorized structure Frontend SettingsPage: - Button "📊 Platzhalter exportieren" - Downloads: placeholders-{profile}-{date}.json - Shows all 38+ placeholders with current values - Useful for: - Understanding available data - Debugging prompt templates - Verifying placeholder resolution Frontend api.js: - exportPlaceholderValues() Export Format: { "export_date": "2026-03-26T...", "profile_id": "...", "count": 38, "all_placeholders": { "name": "Lars", ... }, "placeholders_by_category": { "Profil": [...], "Körper": [...], ... } } Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Problem: dob Spalte ist DATE (PostgreSQL) → Python bekommt datetime.date, nicht String → strptime() schlägt fehl → age = "unbekannt" Fix: Prüfe isinstance(dob, str) und handle beide Typen: - String → strptime() - date object → direkt verwenden Jetzt funktioniert {{age}} Platzhalter korrekt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Problem: Schlafphasen werden lowercase gespeichert (deep, rem, light, awake), aber get_sleep_avg_quality() prüfte Titlecase (Deep, REM) → 0% Match Fix: Ändere Prüfung zu lowercase: ['deep', 'rem'] Jetzt wird {{sleep_avg_quality}} korrekt berechnet aus JSONB segments. Quelle: backend/routers/sleep.py → phase_map speichert lowercase Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>BUG: sleep_avg_quality showed 0% despite valid sleep data ROOT CAUSE: sleep_segments use 'phase' key, not 'stage' FIX: Changed s.get('stage') to s.get('phase') in get_sleep_avg_quality() version: 9.5.1 (bugfix) module: prompts 2.0.1BUG: Wertetabelle wurde nicht angezeigt FIX: enable_debug=true wenn save=true (für metadata collection) - metadata wird nur gespeichert wenn debug aktiv - jetzt: debug or save → metadata immer verfügbar BUG: {{placeholder|d}} Modifier funktionierte nicht ROOT CAUSE: catalog wurde bei Exception nicht zu variables hinzugefügt FIX: - variables['_catalog'] = catalog (auch wenn None) - Warning-Log wenn catalog nicht geladen werden kann - Debug warning wenn |d ohne catalog verwendet BUG: Platzhalter in Pipeline-Stages am Ende statt an Cursor FIX: - stageTemplateRefs Map für alle Stage-Textareas - onClick + onKeyUp tracking für Cursor-Position - Insert at cursor: template.slice(0, pos) + placeholder + template.slice(pos) - Focus + Cursor restore nach Insert TECHNICAL: - prompt_executor.py: Besseres Exception Handling für catalog - UnifiedPromptModal.jsx: Refs für alle Template-Felder - prompts.py: enable_debug=debug or save version: 9.6.1 (bugfix) module: prompts 2.1.1BUG: Wertetabelle wurde nicht angezeigt bei neuer Analyse ROOT CAUSE: newResult hatte nur {scope, content}, kein metadata FIX: Build metadata from result.debug.resolved_placeholders - Für Base: direkt aus resolved_placeholders - Für Pipeline: collect aus allen stages - Metadata structure: {prompt_type, placeholders: {key: {value, description}}} NOTE: Immediate preview hat keine descriptions (nur values) Saved insights (nach loadAll) haben full metadata with descriptions aus DB version: 9.6.2 (bugfix)FEATURE: Basis-Analysen Einzelwerte Vorher: stage_1_body → {"bmi": 26.6, "weight": "85.2kg"} (1 Zeile) Jetzt: bmi → 26.6 (eigene Zeile) weight → 85.2kg (eigene Zeile) BACKEND: JSON-Extraktion - Stage outputs (JSON) → extract individual fields - extracted_values dict sammelt alle Einzelwerte - Deduplizierung: Gleiche Keys nur einmal - Flags: - is_extracted: true → Wert aus Stage-Output extrahiert - is_stage_raw: true → Rohdaten (JSON) nur Experten-Modus BEISPIEL Stage 1 Output: { "stage_1_body": { "bmi": 26.6, "weight": "85.2 kg", "trend": "sinkend" } } → Metadata: { "bmi": { value: "26.6", description: "Aus Stage 1 (stage_1_body)", is_extracted: true }, "weight": { value: "85.2 kg", description: "Aus Stage 1 (stage_1_body)", is_extracted: true }, "stage_1_body": { value: "{\"bmi\": 26.6, ...}", description: "Rohdaten Stage 1 (Basis-Analyse JSON)", is_stage_raw: true } } FRONTEND: Smart Filtering Normal-Modus: - Zeigt: Einzelwerte (bmi, weight, trend) - Versteckt: Rohdaten (stage_1_body JSON) - Filter: is_stage_raw === false Experten-Modus: - Zeigt: Alles (Einzelwerte + Rohdaten) - Rohdaten: Grauer Hintergrund + 🔬 Icon VISUAL Indicators: ↳ bmi → Extrahierter Wert (grün) weight → Normaler Platzhalter (accent) 🔬 stage_1_* → Rohdaten JSON (grau, klein, nur Experten) ERGEBNIS: ┌──────────────────────────────────────────┐ │ 📊 Verwendete Werte (8) (+2 ausgeblendet)│ │ ┌────────────────────────────────────────┐│ │ │ weight_aktuell │ 85.2 kg │ Gewicht ││ ← Normal │ │ ↳ bmi │ 26.6 │ Aus St..││ ← Extrahiert │ │ ↳ trend │ sinkend │ Aus St..││ ← Extrahiert │ └────────────────────────────────────────┘│ └──────────────────────────────────────────┘ Experten-Modus zusätzlich: │ 🔬 stage_1_body │ {"bmi":...│ Rohdaten││ ← JSON version: 9.9.0 (feature) module: prompts 2.4.0, insights 1.7.0FEATURE: Gruppierung nach Kategorien - Wertetabelle jetzt nach Modulen/Kategorien gruppiert - Bessere Übersicht und Zuordnung der Werte BACKEND: Category Metadata - Für normale Platzhalter: Kategorie aus Catalog (Profil, Körper, Ernährung, etc.) - Für extrahierte Werte: "Stage X - [Output Name]" - Für Rohdaten: "Stage X - Rohdaten" - Fallback: "Sonstiges" FRONTEND: Grouped Display - sortedCategories: Sortierung (Normal → Stage Outputs → Rohdaten) - Section Headers: Grauer Hintergrund mit Kategorie-Name - React.Fragment für Gruppierung SORTIERUNG: 1. Normale Kategorien (Profil, Körper, Ernährung, Training, etc.) 2. Stage Outputs (Stage 1 - Body, Stage 1 - Nutrition, etc.) 3. Rohdaten (Stage 1 - Rohdaten, Stage 2 - Rohdaten) 4. Innerhalb: Alphabetisch BEISPIEL: ┌────────────────────────────────────────────┐ │ PROFIL │ ├────────────────────────────────────────────┤ │ name │ Lars │ Name des Nutzers │ │ age │ 55 │ Alter in Jahren │ ├────────────────────────────────────────────┤ │ KÖRPER │ ├────────────────────────────────────────────┤ │ weight_... │ 85.2 kg │ Aktuelles Gewicht │ │ bmi │ 26.6 │ Body Mass Index │ ├────────────────────────────────────────────┤ │ ERNÄHRUNG │ ├────────────────────────────────────────────┤ │ kcal_avg │ 1427... │ Durchschn. Kalorien│ │ protein... │ 106g... │ Durchschn. Protein │ ├────────────────────────────────────────────┤ │ STAGE 1 - BODY │ ├────────────────────────────────────────────┤ │ ↳ bmi │ 26.6 │ Aus Stage 1 (body) │ │ ↳ trend │ sinkend │ Aus Stage 1 (body) │ ├────────────────────────────────────────────┤ │ STAGE 1 - NUTRITION │ ├────────────────────────────────────────────┤ │ ↳ kcal_... │ 1427 │ Aus Stage 1 (nutr.)│ └────────────────────────────────────────────┘ Experten-Modus zusätzlich: ├────────────────────────────────────────────┤ │ STAGE 1 - ROHDATEN │ ├────────────────────────────────────────────┤ │ 🔬 stage...│ {"bmi"..│ Rohdaten Stage 1 │ └────────────────────────────────────────────┘ version: 9.10.0 (feature) module: prompts 2.5.0, insights 1.8.0