diff --git a/apps/worker/worker_app/tasks/viral_video.py b/apps/worker/worker_app/tasks/viral_video.py index ce37f9206..28d2925e7 100644 --- a/apps/worker/worker_app/tasks/viral_video.py +++ b/apps/worker/worker_app/tasks/viral_video.py @@ -598,7 +598,9 @@ def _step_intent_parsing(job: ViralVideoJob, image_analysis: dict) -> dict: for _m, _lbl in [(_fast, "fast"), (_pro, "pro-fallback")]: try: logger.info("[爆款视频] 意图解析 model=%s label=%s", _m, _lbl) - result = call_llm(prompt, temperature=0.4, max_tokens=800, model=_m, timeout=60) # #2183: pro 实测800tok约40s,给60s + result = call_llm( + prompt, temperature=0.4, max_tokens=800, model=_m, timeout=60 + ) # #2183: pro 实测800tok约40s,给60s return ( result if isinstance(result, dict) @@ -1259,6 +1261,7 @@ def _step_render(job: ViralVideoJob, copy_result: dict, tts_audio_url: str | Non ) try: from packages.shared.ai_service import preheat_trust_chain + _ia = getattr(job, "image_analysis", None) or {} _prods = (_ia.get("products") if isinstance(_ia, dict) else None) or [] _pdescs = [] @@ -1276,12 +1279,14 @@ def _step_render(job: ViralVideoJob, copy_result: dict, tts_audio_url: str | Non pre_trusted = list(_live_urls) logger.info( "[爆款视频] 现场信任链t2i完成 %d张 耗时%.1fs,将用AI人像传Seedance", - len(pre_trusted), time.time()-_t0, + len(pre_trusted), + time.time() - _t0, ) else: logger.warning( "[爆款视频] 现场信任链t2i返回不匹配 urls=%s n_portraits=%d,回退原图+400降级纯t2v", - _live_urls, len(all_portrait_urls), + _live_urls, + len(all_portrait_urls), ) else: logger.info("[爆款视频] 无有效人物描述(可能是商品图),无需现场跑信任链") @@ -1594,7 +1599,13 @@ def run_viral_video_analyze(self: Task, job_id: str) -> dict: except Exception as _e: logger.warning("[爆款视频][阶段1] 启动信任链t2i预热失败: %s", _e) _save_job(repo, job, session) - _emit_progress(job_id, ViralVideoStage.IMAGE_ANALYSIS, 60.0, "图片分析完成,AI人像预热中...", {"result": image_analysis, "trust_chain_preheating": True}) + _emit_progress( + job_id, + ViralVideoStage.IMAGE_ANALYSIS, + 60.0, + "图片分析完成,AI人像预热中...", + {"result": image_analysis, "trust_chain_preheating": True}, + ) style_guide = None if job.reference_video_url or job.style_template_id: diff --git a/packages/shared/ai_client.py b/packages/shared/ai_client.py index 5e115cf63..5e45ca31f 100755 --- a/packages/shared/ai_client.py +++ b/packages/shared/ai_client.py @@ -765,15 +765,13 @@ class DoubaoClient: # #2183: portrait_intercept / 真人肖像审核拦截 → 去掉所有参考图(含image_url首帧),纯 t2v 重试一次 # 信任链预热或现场 t2i 都失败时的最后兜底,保证能出片 - if ( - not task_id - and sc == 400 - ): + if not task_id and sc == 400: _err_code_for_400, _ = _classify_video_error(sc, body, last_err) if _err_code_for_400 == "portrait_intercept" and (image_url or ref_imgs): logger.warning( "Seedance 创建因 portrait_intercept 失败,降级纯 t2v(移除所有参考图)重试: img=%d ref=%d", - 1 if image_url else 0, len(ref_imgs), + 1 if image_url else 0, + len(ref_imgs), ) _t2v_payload = dict(create_payload) _t2v_payload["content"] = [{"type": "text", "text": prompt.strip()}]