feat: cap cmhub image concurrency

This commit is contained in:
chengma
2026-07-07 21:00:43 +08:00
parent 2928624019
commit 3d902d4907
12 changed files with 601 additions and 95 deletions
+25 -7
View File
@@ -55,13 +55,25 @@ class GenerateWorker(BaseWorker):
batch_ids = self._batch_ids(eligible)
self._run_id = self._create_run_log(eligible, batch_ids)
if generate_cover:
start_message = "[开始] 本轮生成 {total} 条:标题{title_total},图片{cover_total};标题并发{title_concurrency},图片并发{image_concurrency}".format(
total=len(eligible),
title_total=component_totals["title_total"],
cover_total=component_totals["cover_total"],
title_concurrency=ai_cfg.get("title_concurrency", 1),
image_concurrency=ai_cfg.get("image_concurrency", 1),
)
if appconfig.ai_backend(self.config) == "cmhub":
concurrency = ai.cmhub_image_concurrency_plan(ai_cfg)
start_message = "[开始] 本轮生成 {total} 条:标题{title_total},图片{cover_total};标题并发{title_concurrency},图片并发{image_concurrency},cmhub实际生图并发{request_concurrency},下载并发{download_concurrency}".format(
total=len(eligible),
title_total=component_totals["title_total"],
cover_total=component_totals["cover_total"],
title_concurrency=ai_cfg.get("title_concurrency", 1),
image_concurrency=concurrency["configured_image_concurrency"],
request_concurrency=concurrency["request_concurrency"],
download_concurrency=concurrency["download_concurrency"],
)
else:
start_message = "[开始] 本轮生成 {total} 条:标题{title_total},图片{cover_total};标题并发{title_concurrency},图片并发{image_concurrency}".format(
total=len(eligible),
title_total=component_totals["title_total"],
cover_total=component_totals["cover_total"],
title_concurrency=ai_cfg.get("title_concurrency", 1),
image_concurrency=ai_cfg.get("image_concurrency", 1),
)
else:
start_message = "[开始] 本轮生成 {total} 条:本轮仅生成标题,不生成图片;标题{title_total};标题并发{title_concurrency}".format(
total=len(eligible),
@@ -185,6 +197,12 @@ class GenerateWorker(BaseWorker):
if phase == "cover":
if result == "start" and step == "cover_submit":
return f"[图片] {self._task_progress_label(task)} 开始生成"
if result == "success" and step == "cover_request":
return f"[图片] {self._task_progress_label(task)} {detail or 'cmhub 已返回,耗时未知'}"
if result == "success" and step == "cover_download":
return f"[图片] {self._task_progress_label(task)} {detail or '图片下载完成,耗时未知'}"
if result == "success" and step == "cover_save":
return f"[图片] {self._task_progress_label(task)} 本地保存完成,{detail or '耗时未知'}"
if result == "success" and step == "db_write":
suffix = f",已保存 {detail}" if detail else ""
return f"[图片] {self._task_progress_label(task)} 成功{suffix}"