From c08cfcd5c1f4e99da48e8a7f7cff1e63dcfdafbf Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Sat, 3 Oct 2026 01:31:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?chore(points):=20worker=20settle=20?= =?UTF-8?q?=E9=98=B6=E6=AE=B5=E6=89=93=E5=8D=B0=E9=A2=84=E4=BC=B0/?= =?UTF-8?q?=E5=AE=9E=E9=99=85=20tokens=20diff=20=E4=BE=BF=E4=BA=8E?= =?UTF-8?q?=E5=85=AC=E5=BC=8F=E6=A0=A1=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上线后可通过日志对比 formula 预估 tokens 与 Seedance 返回的 completion_tokens,误差应在 10% 以内(视频编码余量)。 --- apps/worker/worker_app/tasks/viral_video.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/worker/worker_app/tasks/viral_video.py b/apps/worker/worker_app/tasks/viral_video.py index 8adc448c2..34d3fd54d 100644 --- a/apps/worker/worker_app/tasks/viral_video.py +++ b/apps/worker/worker_app/tasks/viral_video.py @@ -1615,13 +1615,26 @@ def _settle_viral_video(job: ViralVideoJob, usage: dict | None) -> None: getattr(job, "video_resolution", "720p") or "720p", getattr(job, "video_ratio", "9:16") or "9:16", ) + fps = 24 + duration = int(getattr(job, "duration", 15) or 15) + est_tokens = duration * w * h * fps // 1024 actual_tokens = None if isinstance(usage, dict): at = usage.get("completion_tokens") if isinstance(at, (int, float)) and at > 0: actual_tokens = int(at) + diff_pct = None + if actual_tokens and est_tokens > 0: + diff_pct = (actual_tokens - est_tokens) * 100.0 / est_tokens + logger.info( + "[爆款视频] tokens估算vs实际 job_id=%s duration=%s %sx%s model=%s est=%s actual=%s diff=%.1f%%", + job.id, duration, w, h, + getattr(job, "video_model", "seedance-2.5"), + est_tokens, actual_tokens, + diff_pct if diff_pct is not None else 0.0, + ) actual_credits = calculate_viral_video_credits( - int(getattr(job, "duration", 15) or 15), + duration, w, h, getattr(job, "video_model", "") or "seedance-2.5", -- 2.54.0 From dec9852a64959041a91108f0b8f0482d97f59d91 Mon Sep 17 00:00:00 2001 From: CI Bot Date: Fri, 2 Oct 2026 17:41:23 +0000 Subject: [PATCH 2/3] style: auto-format with black + isort + ruff + prettier [skip ci-format-check] --- apps/worker/worker_app/tasks/viral_video.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/worker/worker_app/tasks/viral_video.py b/apps/worker/worker_app/tasks/viral_video.py index 34d3fd54d..01a77a4fb 100644 --- a/apps/worker/worker_app/tasks/viral_video.py +++ b/apps/worker/worker_app/tasks/viral_video.py @@ -1628,9 +1628,13 @@ def _settle_viral_video(job: ViralVideoJob, usage: dict | None) -> None: diff_pct = (actual_tokens - est_tokens) * 100.0 / est_tokens logger.info( "[爆款视频] tokens估算vs实际 job_id=%s duration=%s %sx%s model=%s est=%s actual=%s diff=%.1f%%", - job.id, duration, w, h, + job.id, + duration, + w, + h, getattr(job, "video_model", "seedance-2.5"), - est_tokens, actual_tokens, + est_tokens, + actual_tokens, diff_pct if diff_pct is not None else 0.0, ) actual_credits = calculate_viral_video_credits( -- 2.54.0 From b8ca725f5d00830efcf27e09ec8d6eefa9333802 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Sat, 3 Oct 2026 01:49:25 +0800 Subject: [PATCH 3/3] chore: retry CI -- 2.54.0