feat(ai-outfit): auto-append output requirements to prompt (§19.6)
- core/ai_outfit: OUTPUT_REQUIREMENTS constant + build_output_requirements(); render_prompt(template, task, resolution=None) appends the block when a resolution is given; generate_outfit_image passes the current resolution. - ai_outfit_panel: inline preview now uses render_prompt/build_output_requirements with the selected resolution and refreshes when the resolution combo changes, so the preview equals what is actually sent. - tests: +3 cases (tail with resolution, none without, helper empty/filled); updated the success test for the appended tail. Full suite (12 files) green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -258,6 +258,7 @@ class AiOutfitPanel(QWidget):
|
||||
self._retry_count.setRange(0, 10)
|
||||
self._resolution = QComboBox()
|
||||
self._resolution.addItems(_RESOLUTIONS)
|
||||
self._resolution.currentIndexChanged.connect(self._refresh_preview)
|
||||
self._quality = QComboBox()
|
||||
self._quality.addItems(_QUALITIES)
|
||||
|
||||
@@ -472,17 +473,19 @@ class AiOutfitPanel(QWidget):
|
||||
def _refresh_preview(self):
|
||||
if not hasattr(self, "_preview_view"):
|
||||
return
|
||||
from core.ai_outfit import build_output_requirements, render_prompt
|
||||
template = self._prompt_edit.toPlainText()
|
||||
self._preview_warn.setVisible("{title}" not in template)
|
||||
if "{title}" not in template:
|
||||
self._preview_warn.setText("⚠ 话术缺少 {title} 占位符")
|
||||
# Mirror what actually gets sent: append the output-requirements block
|
||||
# for the currently selected resolution (docs/11 §7.1).
|
||||
resolution = self._resolution.currentText() if hasattr(self, "_resolution") else None
|
||||
task = self._sample_combo.currentData() if hasattr(self, "_sample_combo") else None
|
||||
if task is None:
|
||||
self._preview_view.setPlainText(template)
|
||||
self._preview_view.setPlainText(template + build_output_requirements(resolution))
|
||||
else:
|
||||
rendered = template.replace("{title}", task.title).replace(
|
||||
"{product_id}", task.product_id)
|
||||
self._preview_view.setPlainText(rendered)
|
||||
self._preview_view.setPlainText(render_prompt(template, task, resolution))
|
||||
|
||||
# -- run control ----------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user