fix: placeholder picker improvements + insight display names (Issue #28)
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>
This commit is contained in:
1 parent
0c4264de44
commit
5e7ef718e0
4 files changed
+208
-43
No files matched your search
@@ -306,3 +306,79 @@ def get_placeholder_example_values(profile_id: str) -> Dict[str, str]:
|
||||
examples[placeholder] = f"[Fehler: {str(e)}]"
|
||||
|
||||
return examples
|
||||
|
||||
|
||||
def get_placeholder_catalog(profile_id: str) -> Dict[str, List[Dict[str, str]]]:
|
||||
"""
|
||||
Get grouped placeholder catalog with descriptions and example values.
|
||||
|
||||
Args:
|
||||
profile_id: User profile ID
|
||||
|
||||
Returns:
|
||||
Dict mapping category to list of {key, description, example}
|
||||
"""
|
||||
# Placeholder definitions with descriptions
|
||||
placeholders = {
|
||||
'Profil': [
|
||||
('name', 'Name des Nutzers'),
|
||||
('age', 'Alter in Jahren'),
|
||||
('height', 'Körpergröße in cm'),
|
||||
('geschlecht', 'Geschlecht'),
|
||||
],
|
||||
'Körper': [
|
||||
('weight_aktuell', 'Aktuelles Gewicht in kg'),
|
||||
('weight_trend', 'Gewichtstrend (7d/30d)'),
|
||||
('kf_aktuell', 'Aktueller Körperfettanteil in %'),
|
||||
('bmi', 'Body Mass Index'),
|
||||
],
|
||||
'Ernährung': [
|
||||
('kcal_avg', 'Durchschn. Kalorien (30d)'),
|
||||
('protein_avg', 'Durchschn. Protein in g (30d)'),
|
||||
('carb_avg', 'Durchschn. Kohlenhydrate in g (30d)'),
|
||||
('fat_avg', 'Durchschn. Fett in g (30d)'),
|
||||
],
|
||||
'Training': [
|
||||
('activity_summary', 'Aktivitäts-Zusammenfassung (7d)'),
|
||||
('trainingstyp_verteilung', 'Verteilung nach Trainingstypen'),
|
||||
],
|
||||
'Schlaf & Erholung': [
|
||||
('sleep_avg_duration', 'Durchschn. Schlafdauer (7d)'),
|
||||
('sleep_avg_quality', 'Durchschn. Schlafqualität (7d)'),
|
||||
('rest_days_count', 'Anzahl Ruhetage (30d)'),
|
||||
],
|
||||
'Vitalwerte': [
|
||||
('vitals_avg_hr', 'Durchschn. Ruhepuls (7d)'),
|
||||
('vitals_avg_hrv', 'Durchschn. HRV (7d)'),
|
||||
('vitals_vo2_max', 'Aktueller VO2 Max'),
|
||||
],
|
||||
'Zeitraum': [
|
||||
('datum_heute', 'Heutiges Datum'),
|
||||
('zeitraum_7d', '7-Tage-Zeitraum'),
|
||||
('zeitraum_30d', '30-Tage-Zeitraum'),
|
||||
],
|
||||
}
|
||||
|
||||
catalog = {}
|
||||
|
||||
for category, items in placeholders.items():
|
||||
catalog[category] = []
|
||||
for key, description in items:
|
||||
placeholder = f'{{{{{key}}}}}'
|
||||
# Get example value if resolver exists
|
||||
resolver = PLACEHOLDER_MAP.get(placeholder)
|
||||
if resolver:
|
||||
try:
|
||||
example = resolver(profile_id)
|
||||
except Exception:
|
||||
example = '[Nicht verfügbar]'
|
||||
else:
|
||||
example = '[Nicht implementiert]'
|
||||
|
||||
catalog[category].append({
|
||||
'key': key,
|
||||
'description': description,
|
||||
'example': str(example)
|
||||
})
|
||||
|
||||
return catalog
|
||||
@@ -17,7 +17,8 @@ from placeholder_resolver import (
|
||||
resolve_placeholders,
|
||||
get_unknown_placeholders,
|
||||
get_placeholder_example_values,
|
||||
get_available_placeholders
|
||||
get_available_placeholders,
|
||||
get_placeholder_catalog
|
||||
)
|
||||
|
||||
# Environment variables
|
||||
@@ -204,13 +205,13 @@ def preview_prompt(data: dict, session: dict=Depends(require_auth)):
|
||||
@router.get("/placeholders")
|
||||
def list_placeholders(session: dict=Depends(require_auth)):
|
||||
"""
|
||||
Get list of available placeholders with example values.
|
||||
Get grouped catalog of available placeholders with descriptions and examples.
|
||||
|
||||
Returns:
|
||||
Dict mapping placeholder to example value using current user's data
|
||||
Dict mapping category to list of {key, description, example}
|
||||
"""
|
||||
profile_id = session['profile_id']
|
||||
return get_placeholder_example_values(profile_id)
|
||||
return get_placeholder_catalog(profile_id)
|
||||
|
||||
|
||||
# ── KI-Assisted Prompt Engineering ───────────────────────────────────────────
|
||||
|
||||
Reference in new issue
Block a user