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
@@ -10,7 +10,7 @@ This module now focuses on FORMATTING for AI consumption.
|
||||
import json
|
||||
import re
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Dict, List, Optional, Callable, Tuple
|
||||
from typing import Any, Dict, List, Optional, Callable, Tuple
|
||||
from db import get_db, get_cursor, r2d
|
||||
|
||||
# Phase 0c: Import data layer
|
||||
@@ -62,6 +62,17 @@ def _ai_caption_for_placeholder_key(key: str) -> Optional[str]:
|
||||
return None
|
||||
|
||||
|
||||
def format_value_with_d_modifier(value: str, catalog_row: Dict[str, Any]) -> str:
|
||||
"""
|
||||
Entspricht der Prompt-Ersetzung bei {{key|d}}: „Wert — Kontext“.
|
||||
Kontext: ai_caption aus dem Katalog, sonst description (wie prompt_executor).
|
||||
"""
|
||||
cap = (catalog_row.get("ai_caption") or catalog_row.get("description") or "").strip()
|
||||
if cap:
|
||||
return f"{value} — {cap}"
|
||||
return str(value)
|
||||
|
||||
|
||||
# ── Helper Functions ──────────────────────────────────────────────────────────
|
||||
|
||||
def get_profile_data(profile_id: str) -> Dict:
|
||||
|
||||
Reference in new issue
Block a user