From 93b3e896c805b1946749c1a3ab3ea4c5423bb4e1 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 6 Oct 2026 10:15:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(viral-video):=20=E7=BC=96=E5=AF=BC=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E7=94=9F=E6=88=90timeout=2090=E2=86=92150s=20+=20?= =?UTF-8?q?=E4=BF=AEai=5Fclient=20logger=E5=8D=A0=E4=BD=8D=E7=AC=A6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P0根因:用户09:57反馈『生成不了文案』,排查确认: 1. #2215的call_llm→chat_completion修复本身正确,凌晨/上午日志均验证意图解析HTTP 200成功(33s返回1505 tokens) 2. 编导脚本fast tmo=90s超时(#2183沿用至今,非#2215引入):doubao-seed-2-1-pro输出完整分镜脚本token量大,高峰期read timeout 90.1s,重试期间被watchtower容器重启打断 3. ai_client.py:287 logger.info格式串6个占位符只传5个参数(缺_req_timeout),每次chat_completion成功都打TypeError假错误栈,干扰排查 修复: - 编导脚本fast tmo 90→150s,pro 120→150s,支持ENV VIRAL_VIDEO_SCRIPT_FAST_TIMEOUT/VIRAL_VIDEO_SCRIPT_PRO_TIMEOUT覆盖 - 补ai_client.py logger.info缺失的_req_timeout参数 文件变更: - apps/worker/worker_app/tasks/viral_video.py: 编导脚本超时上调 - packages/shared/ai_client.py: logger占位符补参 --- apps/worker/worker_app/tasks/viral_video.py | 13 +++++++------ packages/shared/ai_client.py | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/worker/worker_app/tasks/viral_video.py b/apps/worker/worker_app/tasks/viral_video.py index ed648fe0f..04bda80cf 100644 --- a/apps/worker/worker_app/tasks/viral_video.py +++ b/apps/worker/worker_app/tasks/viral_video.py @@ -910,18 +910,19 @@ def _step_script_generation(job: ViralVideoJob, intent: dict, image_analysis: di _s = get_shared_settings() _fast = _s.doubao_fast_model _pro = getattr(_s, "doubao_model", None) or _fast + _script_fast_tmo = int(os.environ.get("VIRAL_VIDEO_SCRIPT_FAST_TIMEOUT", "150")) + _script_pro_tmo = int(os.environ.get("VIRAL_VIDEO_SCRIPT_PRO_TIMEOUT", "150")) try: - # 第一次:快模型 25s - normalized = _try_gen(_fast, 0.8, 2500, "fast-first", tmo=90) + # #2217: doubao-seed-2-1-pro生成长编导脚本高峰期>90s,上调到150s,支持ENV覆盖 + normalized = _try_gen(_fast, 0.8, 2500, "fast-first", tmo=_script_fast_tmo) if normalized is not None: return normalized - # #2183: 实测pro 1500tok输出需75.8s,单次timeout提到90s - normalized = _try_gen(_fast, 0.6, 3200, "fast-retry", tmo=90) + normalized = _try_gen(_fast, 0.6, 3200, "fast-retry", tmo=_script_fast_tmo) if normalized is not None: return normalized - # 第三次:用主力模型兜底,给 120s + # 第三次:用主力模型兜底 if _pro and _pro != _fast: - normalized = _try_gen(_pro, 0.7, 3500, "pro-fallback", tmo=120) + normalized = _try_gen(_pro, 0.7, 3500, "pro-fallback", tmo=_script_pro_tmo) if normalized is not None: return normalized logger.warning("[爆款视频] 编导脚本三次都未生成合格结果,使用兜底脚本") diff --git a/packages/shared/ai_client.py b/packages/shared/ai_client.py index 5e45ca31f..3b4dc4692 100755 --- a/packages/shared/ai_client.py +++ b/packages/shared/ai_client.py @@ -291,6 +291,7 @@ class DoubaoClient: data.get("usage", {}).get("completion_tokens", 0), _elapsed, attempt + 1, + _req_timeout, ) return content.strip() except Exception as e: