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:
2026-06-22 10:40:28 +08:00
co-authored by Claude Opus 4.8
parent 031c420f33
commit d4082ec477
4 changed files with 62 additions and 13 deletions
+7 -4
View File
@@ -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 ----------------------------------------------------