feat: Enhance placeholder caption generation and formatting
- Updated `build_ai_placeholder_caption` in `placeholder_registry.py` to improve the generation of AI context captions by prioritizing descriptions and avoiding redundancy. - Introduced `format_value_with_d_modifier` in `placeholder_resolver.py` to format values with contextual information, enhancing the clarity of exported placeholder values. - Modified `export_placeholder_values` in `prompts.py` to utilize the new formatting function, ensuring that exported data includes both raw values and contextual descriptions. - Added tests for the new formatting function and updated existing tests to ensure accurate caption generation. These changes improve the contextual relevance of placeholder data and enhance the user experience when interacting with exported values.
This commit is contained in:
1 parent
baeddd7c13
commit
a9a414b956
4 files changed
+91
-19
No files matched your search
@@ -21,6 +21,7 @@ from placeholder_resolver import (
|
||||
resolve_placeholders,
|
||||
get_unknown_placeholders,
|
||||
get_placeholder_example_values,
|
||||
format_value_with_d_modifier,
|
||||
get_available_placeholders,
|
||||
get_placeholder_catalog
|
||||
)
|
||||
@@ -457,8 +458,8 @@ def export_placeholder_values(session: dict = Depends(require_auth)):
|
||||
"""
|
||||
Export all available placeholders with their current resolved values.
|
||||
|
||||
Returns JSON export suitable for download with all placeholders
|
||||
resolved for the current user's profile.
|
||||
Pro Zeile: value = Rohwert wie bei {{key}}, example = Vorschau wie bei {{key|d}}
|
||||
(Wert — ai_caption bzw. description). JSON-Download für das aktive Profil.
|
||||
"""
|
||||
from datetime import datetime
|
||||
profile_id = session['profile_id']
|
||||
@@ -486,11 +487,12 @@ def export_placeholder_values(session: dict = Depends(require_auth)):
|
||||
export_data['placeholders_by_category'][category] = []
|
||||
for item in items:
|
||||
key = item['key'].replace('{{', '').replace('}}', '')
|
||||
raw_val = cleaned_values.get(key, 'nicht verfügbar')
|
||||
row = {
|
||||
'key': item['key'],
|
||||
'description': item['description'],
|
||||
'value': cleaned_values.get(key, 'nicht verfügbar'),
|
||||
'example': item.get('example'),
|
||||
'value': raw_val,
|
||||
'example': format_value_with_d_modifier(str(raw_val), item),
|
||||
}
|
||||
if item.get('ai_caption'):
|
||||
row['ai_caption'] = item['ai_caption']
|
||||
@@ -662,11 +664,12 @@ def export_placeholder_values_extended(
|
||||
export_data['legacy']['placeholders_by_category'][category] = []
|
||||
for item in items:
|
||||
key = item['key'].replace('{{', '').replace('}}', '')
|
||||
raw_val = cleaned_values.get(key, 'nicht verfügbar')
|
||||
export_data['legacy']['placeholders_by_category'][category].append({
|
||||
'key': item['key'],
|
||||
'description': item['description'],
|
||||
'value': cleaned_values.get(key, 'nicht verfügbar'),
|
||||
'example': item.get('example')
|
||||
'value': raw_val,
|
||||
'example': format_value_with_d_modifier(str(raw_val), item),
|
||||
})
|
||||
|
||||
# Fill metadata flat
|
||||
|
||||
Reference in new issue
Block a user