feat: align product suite prompts with reference images

This commit is contained in:
chengma
2026-07-17 17:06:47 +08:00
parent 1fabd8afcf
commit f64dfffe40
9 changed files with 77 additions and 17 deletions
+17 -4
View File
@@ -168,11 +168,10 @@ class ProductSuiteTests(unittest.TestCase):
template_text=template,
)
self.assertIn(
"参考图规则:使用第一張上傳圖作為主商品圖,其餘圖片只作為參考。",
"参考图规则:当前上传图片是本任务唯一主参考图;保持商品主体、款式、颜色和关键细节准确;不编造用户与参考图均未提供的信息。",
single_primary,
)
self.assertNotIn("当前上传图片是本任务唯一主参考图", single_primary)
self.assertNotIn("参考图规则:使用", single_primary)
self.assertNotIn("第2至", single_primary)
settings["per_image_primary"] = True
per_image_primary = product_suite.build_suite_prompt(
@@ -187,9 +186,23 @@ class ProductSuiteTests(unittest.TestCase):
"参考图规则:当前上传图片是本任务唯一主参考图;保持商品主体、款式、颜色和关键细节准确;不编造用户与参考图均未提供的信息。",
per_image_primary,
)
self.assertNotIn("使用第一張上傳圖作為主商品圖", per_image_primary)
self.assertNotIn("第2至", per_image_primary)
self.assertNotIn("序号2", per_image_primary)
multi_reference = product_suite.build_suite_prompt(
"卖点",
product_suite.default_suite_settings(),
"场景图",
"51100639510",
reference_asset_count=2,
template_text=template,
)
self.assertIn(
"参考图规则:第1张为主商品图,请保持其主体、款式、颜色和关键细节准确;第2至3张仅作为风格、构图、场景或排版参考,不得替换主商品;不编造用户与参考图均未提供的信息。",
multi_reference,
)
self.assertEqual(7, product_suite.reference_asset_count({}, 9))
def test_product_suite_template_validation_and_custom_category_rendering(self):
default_text = prompts.load_default_product_suite_prompt()
self.assertEqual([], product_suite.product_suite_prompt_errors(default_text))
+3 -1
View File
@@ -422,7 +422,7 @@ class ProductSuiteGuiTests(TempDirMixin, unittest.TestCase):
def test_prompt_preview_matches_frozen_generation_job_prompt(self):
with self.make_temp_dir() as temp_dir:
config = self._config(temp_dir)
project, _ = self._create_project_with_assets(temp_dir, config, 1)
project, assets = self._create_project_with_assets(temp_dir, config, 3)
tab = ProductSuiteTab(config=config, db_path=config["db_path"])
self.addCleanup(tab.close)
state = tab._displayed_state
@@ -437,6 +437,7 @@ class ProductSuiteGuiTests(TempDirMixin, unittest.TestCase):
base_prompt=state.prompt,
settings=state.settings,
item_id=state.item_id,
source_image_count=len(assets),
)
self.addCleanup(dialog.close)
expected = dialog.preview_edit.toPlainText()
@@ -448,6 +449,7 @@ class ProductSuiteGuiTests(TempDirMixin, unittest.TestCase):
), mock.patch.object(tab, "_start_thread", return_value=object()):
self.assertTrue(tab.start_generation(state))
self.assertEqual(expected, state.worker.job_specs[0]["prompt"])
self.assertIn("第2至3张仅作为风格、构图、场景或排版参考", expected)
state.worker = None
state.thread = None