feat(product-suite): add category targets and prompt compatibility
This commit is contained in:
@@ -12,7 +12,10 @@ class ProductSuiteTests(unittest.TestCase):
|
||||
def test_defaults_and_per_image_total(self):
|
||||
settings = product_suite.default_suite_settings()
|
||||
|
||||
self.assertEqual(["白底图", "场景图", "卖点图"], product_suite.category_order(settings))
|
||||
self.assertEqual(
|
||||
["白底图", "场景图", "模特场景图", "细节说明图", "卖点图"],
|
||||
product_suite.category_order(settings),
|
||||
)
|
||||
self.assertEqual(5, product_suite.suite_total_count(settings, 3))
|
||||
|
||||
settings["per_image_primary"] = True
|
||||
@@ -34,7 +37,10 @@ class ProductSuiteTests(unittest.TestCase):
|
||||
)
|
||||
|
||||
self.assertEqual("3:4", settings["ratio"])
|
||||
self.assertEqual(["白底图", "场景图", "卖点图", "尺寸图"], product_suite.category_order(settings))
|
||||
self.assertEqual(
|
||||
["白底图", "场景图", "模特场景图", "细节说明图", "卖点图", "尺寸图"],
|
||||
product_suite.category_order(settings),
|
||||
)
|
||||
self.assertEqual(5, product_suite.suite_total_count(settings, 1))
|
||||
|
||||
def test_recent_settings_only_keep_allowed_dropdown_values(self):
|
||||
@@ -108,8 +114,14 @@ class ProductSuiteTests(unittest.TestCase):
|
||||
spec["prompt"].splitlines()[-1].startswith("本次生成比例:4:3")
|
||||
)
|
||||
|
||||
self.assertIn("套图名称:白底图,白底主图", specs[0]["prompt"])
|
||||
self.assertIn("套图名称:场景图,生活化场景", specs[1]["prompt"])
|
||||
self.assertIn(
|
||||
"生成目标:生成 Shopee 台灣商品白底主圖,純白背景,商品清晰置中,不添加多餘文字。",
|
||||
specs[0]["prompt"],
|
||||
)
|
||||
self.assertIn(
|
||||
"生成目标:生成生活化使用場景圖,展示商品在真實情境中的用途與氛圍,畫面自然可信。",
|
||||
specs[1]["prompt"],
|
||||
)
|
||||
white_prompt = specs[0]["prompt"]
|
||||
self.assertLess(white_prompt.index("重要尺寸要求"), white_prompt.index("重要禁用内容"))
|
||||
self.assertLess(white_prompt.index("重要禁用内容"), white_prompt.index("价格信息规则"))
|
||||
@@ -153,9 +165,33 @@ class ProductSuiteTests(unittest.TestCase):
|
||||
"draft_hidden",
|
||||
)
|
||||
rendered = product_suite.render_product_suite_prompt(default_text, context)
|
||||
self.assertIn("套图名称:尺寸图", rendered)
|
||||
self.assertIn("生成目标:生成自定义分类图片:尺寸图。", rendered)
|
||||
self.assertNotIn("draft_", rendered)
|
||||
self.assertNotIn("白底主图", rendered)
|
||||
self.assertNotIn("套图名称:", rendered)
|
||||
|
||||
legacy_template = default_text.replace(
|
||||
"生成目标:{生成目标}",
|
||||
"套图名称:{套图名称}{补充描述}",
|
||||
)
|
||||
self.assertEqual([], product_suite.product_suite_prompt_errors(legacy_template))
|
||||
legacy_rendered = product_suite.render_product_suite_prompt(legacy_template, context)
|
||||
self.assertIn("套图名称:尺寸图,生成自定义分类图片:尺寸图。", legacy_rendered)
|
||||
|
||||
def test_category_descriptions_are_fixed_and_custom_name_is_explicit(self):
|
||||
expected = {
|
||||
"白底图": "生成 Shopee 台灣商品白底主圖,純白背景,商品清晰置中,不添加多餘文字。",
|
||||
"场景图": "生成生活化使用場景圖,展示商品在真實情境中的用途與氛圍,畫面自然可信。",
|
||||
"模特场景图": "生成模特或手持使用情境圖,畫面自然可信,商品為主角。",
|
||||
"细节说明图": "生成商品細節特寫說明圖,突出材質、做工、接口、紋理或關鍵細節。",
|
||||
"卖点图": "生成賣點詳解圖,使用繁體中文短文案呈現核心優勢,版面乾淨。",
|
||||
}
|
||||
for category, description in expected.items():
|
||||
self.assertEqual(description, product_suite.category_description(category))
|
||||
|
||||
self.assertEqual(
|
||||
"生成自定义分类图片:结构展示。",
|
||||
product_suite.category_description("结构展示"),
|
||||
)
|
||||
|
||||
def test_product_suite_optional_item_and_reference_variables(self):
|
||||
template = prompts.load_default_product_suite_prompt() + (
|
||||
|
||||
Reference in New Issue
Block a user