feat: Enhance placeholder system with AI context support
- Introduced `build_ai_placeholder_caption` function in `placeholder_registry.py` to generate AI context captions based on placeholder metadata. - Updated `resolve_placeholders` in `placeholder_resolver.py` to support modifiers for AI context, allowing for enhanced descriptions when placeholders are resolved. - Modified `get_placeholder_catalog` to include AI captions in the output, improving the metadata available for placeholders. - Adjusted `export_placeholder_values` to include AI captions in the exported data, enhancing the information provided to users. These changes improve the flexibility and functionality of the placeholder system, enabling richer context generation for dynamic content.
This commit is contained in:
1 parent
41bf593d4c
commit
baeddd7c13
5 files changed
+146
-27
No files matched your search
@@ -19,7 +19,7 @@ def resolve_placeholders(template: str, variables: Dict[str, Any], debug_info: O
|
||||
Replace {{placeholder}} with values from variables dict.
|
||||
|
||||
Supports modifiers:
|
||||
- {{key|d}} - Include description in parentheses (requires catalog)
|
||||
- {{key|d}} — angehängter KI-Kontext (ai_caption aus Katalog, sonst description; Katalog nötig)
|
||||
|
||||
Args:
|
||||
template: String with {{key}} or {{key|modifiers}} placeholders
|
||||
@@ -52,16 +52,16 @@ def resolve_placeholders(template: str, variables: Dict[str, Any], debug_info: O
|
||||
# Apply modifiers
|
||||
if 'd' in modifiers:
|
||||
if catalog:
|
||||
# Add description from catalog
|
||||
description = None
|
||||
caption = None
|
||||
for cat_items in catalog.values():
|
||||
matching = [item for item in cat_items if item['key'] == key]
|
||||
if matching:
|
||||
description = matching[0].get('description', '')
|
||||
row = matching[0]
|
||||
caption = (row.get('ai_caption') or row.get('description') or '').strip()
|
||||
break
|
||||
|
||||
if description:
|
||||
resolved_value = f"{resolved_value} ({description})"
|
||||
if caption:
|
||||
resolved_value = f"{resolved_value} — {caption}"
|
||||
else:
|
||||
# Catalog not available - log warning in debug
|
||||
if debug_info is not None:
|
||||
|
||||
Reference in new issue
Block a user