feat: Refine placeholder resolution with enhanced modifiers support
- Updated `resolve_placeholders` in `prompt_executor.py` to support combined modifiers for placeholders, allowing for more flexible output formats. - Enhanced `build_ai_placeholder_caption` in `placeholder_registry.py` to clarify the generation of AI context captions, focusing on descriptions and explanations. - Introduced new helper functions in `placeholder_resolver.py` to streamline the retrieval of descriptions and explanations for placeholders. - Modified tests to cover new functionality, ensuring accurate behavior for combined modifiers and improved placeholder resolution. These changes enhance the usability and clarity of placeholder outputs, providing users with richer contextual information.
This commit is contained in:
1 parent
a9a414b956
commit
4868e44882
5 files changed
+151
-91
No files matched your search
@@ -17,8 +17,8 @@ from models import (
|
||||
PromptCreate, PromptUpdate, PromptGenerateRequest,
|
||||
PipelineConfigCreate, PipelineConfigUpdate
|
||||
)
|
||||
from prompt_executor import resolve_placeholders as resolve_prompt_placeholders
|
||||
from placeholder_resolver import (
|
||||
resolve_placeholders,
|
||||
get_unknown_placeholders,
|
||||
get_placeholder_example_values,
|
||||
format_value_with_d_modifier,
|
||||
@@ -432,7 +432,13 @@ def preview_prompt(data: dict, session: dict=Depends(require_auth)):
|
||||
template = data.get('template', '')
|
||||
profile_id = session['profile_id']
|
||||
|
||||
resolved = resolve_placeholders(template, profile_id)
|
||||
catalog = get_placeholder_catalog(profile_id)
|
||||
processed = get_placeholder_example_values(profile_id)
|
||||
variables = {
|
||||
k.replace('{{', '').replace('}}', ''): v
|
||||
for k, v in processed.items()
|
||||
}
|
||||
resolved = resolve_prompt_placeholders(template, variables, None, catalog)
|
||||
unknown = get_unknown_placeholders(template)
|
||||
|
||||
return {
|
||||
@@ -458,8 +464,8 @@ def export_placeholder_values(session: dict = Depends(require_auth)):
|
||||
"""
|
||||
Export all available placeholders with their current resolved values.
|
||||
|
||||
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.
|
||||
Pro Zeile: value = {{key}}, example = Vorschau {{key|d}} (Wert — description),
|
||||
ai_caption = Text für {{key|x}} (Erklärung ohne Wert). JSON für das aktive Profil.
|
||||
"""
|
||||
from datetime import datetime
|
||||
profile_id = session['profile_id']
|
||||
|
||||
Reference in new issue
Block a user