feat(product-suite): add cmhub vision AI writing
This commit is contained in:
@@ -20,6 +20,7 @@ from app.workers import BaseWorker, run_worker
|
||||
from app.gui.workers import (
|
||||
ImageStudioDownloadOriginalWorker,
|
||||
ImageStudioPullImagesWorker,
|
||||
ProductSuiteAiWriteWorker,
|
||||
ProductSuiteGenerateWorker,
|
||||
)
|
||||
|
||||
@@ -198,6 +199,36 @@ class WorkerTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual({"asset_id": 12, "cancelled": True}, summary)
|
||||
|
||||
def test_product_suite_ai_write_worker_uses_image_analysis_not_title_generation(self):
|
||||
worker = ProductSuiteAiWriteWorker(
|
||||
"补充要求",
|
||||
"输出语言:繁体中文",
|
||||
image_paths=["first.jpg", "second.jpg"],
|
||||
config={"ai": {"backend": "cmhub"}},
|
||||
cmhub_config_path="cmhub.json",
|
||||
)
|
||||
expected = {
|
||||
"text": "根据图片整理的商品卖点",
|
||||
"image_count": 2,
|
||||
"metadata": {"points_cost": 1, "points_balance": 231},
|
||||
}
|
||||
|
||||
with mock.patch(
|
||||
"app.gui.workers.ai.analyze_product_images",
|
||||
return_value=expected,
|
||||
) as analyze, mock.patch("app.gui.workers.ai.gen_title") as gen_title:
|
||||
result = worker.execute()
|
||||
|
||||
analyze.assert_called_once_with(
|
||||
"补充要求",
|
||||
"输出语言:繁体中文",
|
||||
["first.jpg", "second.jpg"],
|
||||
config={"ai": {"backend": "cmhub"}},
|
||||
cmhub_config_path="cmhub.json",
|
||||
)
|
||||
gen_title.assert_not_called()
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
def test_product_suite_worker_writes_generation_round_and_stable_slots(self):
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
db_path = os.path.join(temp_dir, "cmshopee.db")
|
||||
|
||||
Reference in New Issue
Block a user