Compare commits

...

2 Commits

Author SHA1 Message Date
xiaoxia 80103f8c6d fix(viral-video): 修复call_llm传list bug 改为直接chat_completion
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m3s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Failing after 50s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m51s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 1m6s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m38s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 3m13s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 3m44s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m48s
CI/CD Pipeline / Validate - Style (pull_request) Failing after 6m17s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 7m15s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m14s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 8m59s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 2s
AI Code Review / AI Code Review (pull_request) Successful in 10m51s
审计发现 _step_intent_parsing(L482) 和 _step_script_generation(L867) 两处
把 messages list 当作第一个位置参数传给 call_llm(prompt:str,...),
list被repr成字符串再套一层默认system_prompt,实际发给豆包的消息结构异常。

修复:
- 改为直接用 get_doubao_client().chat_completion(messages,...),
  与 reviewer.py/generator.py 调用方式一致
- 增加 is_available 预检,不可用时直接走fallback(意图解析默认dict / _fallback_script)
- 不再走 call_llm 字符串包装层

本次PR同时包含#2214 timeout调优(cherry-pick):
- fast_json _DEFAULT_TIMEOUT 12→15s
- fast_path _FAST_TIMEOUT/_FAST_JSON_TIMEOUT 12→15s
- pro fallback _DEFAULT_TIMEOUT 25→30s,外层_PRO_TIMEOUT 25→30s
- 保留环境变量覆盖能力
2026-10-06 00:41:31 +08:00
xiaoxia cdf3ef360b tune(vision-v2): timeout上调应对staging到DashScope网络抖动
staging E2E实测:
- 3图总耗时39.79s,1/3 fast+pro双超时全失败(fast 14.7s超时/pro 25.1s超时)
- 8图总耗时30.50s,7/8 fast命中,1张fast超时pro兜底成功
- fast单图普遍6-8s(之前本地2.6-4.2s),12s/25s超时设置边缘擦挂

调整:
- fast_json _DEFAULT_TIMEOUT 12→15s
- fast_path _FAST_TIMEOUT/_FAST_JSON_TIMEOUT 12→15s
- pro fallback _DEFAULT_TIMEOUT 25→30s,外层_PRO_TIMEOUT 25→30s
- 保留环境变量覆盖能力
2026-10-06 00:40:02 +08:00
4 changed files with 18 additions and 10 deletions
+13 -5
View File
@@ -421,10 +421,14 @@ def _step_intent_parsing(job: ViralVideoJob, image_analysis: dict) -> dict:
render_system_prompt,
render_user_prompt,
)
from packages.shared.ai_service import call_llm
from packages.shared.ai_client import get_doubao_client
except ImportError:
return {"intent": "推广产品", "key_messages": ["产品亮点"], "tone": "专业", "suggested_title": ""}
_llm_client = get_doubao_client()
if not _llm_client.is_available:
return {"intent": "推广产品", "key_messages": ["产品亮点"], "tone": "专业", "suggested_title": ""}
products_summary = ""
products = (image_analysis or {}).get("products", []) or []
for p in products:
@@ -479,13 +483,13 @@ 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)
raw = call_llm(
raw = _llm_client.chat_completion(
[{"role": "system", "content": system}, {"role": "user", "content": user}],
temperature=0.4,
max_tokens=1024,
model=_m,
timeout=60,
) # #2180: 意图解析 LLM 实测需更长响应,原25s太紧
) # #2180/#2215: 直接用 client.chat_completion 传 messages list,不再走 call_llm 字符串包装
if not raw:
continue
parsed = _parse(raw)
@@ -825,10 +829,14 @@ def _step_script_generation(job: ViralVideoJob, intent: dict, image_analysis: di
GLOBAL_CONSTRAINTS,
NEGATIVE_RULES,
)
from packages.shared.ai_service import call_llm
from packages.shared.ai_client import get_doubao_client
except ImportError:
return _fallback_script(job)
_llm_client2 = get_doubao_client()
if not _llm_client2.is_available:
return _fallback_script(job)
products_summary = _build_products_summary(image_analysis)
dur = max(5, min(30, int(getattr(job, "duration", 15) or 15)))
@@ -864,7 +872,7 @@ def _step_script_generation(job: ViralVideoJob, intent: dict, image_analysis: di
def _try_gen(model: str, temp: float, max_tok: int, label: str, tmo: int = 25):
logger.info("[爆款视频] 编导脚本生成 model=%s label=%s timeout=%d", model, label, tmo)
raw = call_llm(
raw = _llm_client2.chat_completion(
[{"role": "system", "content": system_tpl}, {"role": "user", "content": user}],
temperature=temp,
max_tokens=max_tok,
@@ -23,10 +23,10 @@ logger = logging.getLogger(__name__)
# 超时(可通过环境变量覆盖)
_IMG_WORKERS = int(os.environ.get("VISION_V2_IMG_WORKERS", "8"))
_FAST_TIMEOUT = float(os.environ.get("VISION_V2_FAST_TIMEOUT", "12"))
_FAST_JSON_TIMEOUT = float(os.environ.get("VISION_V2_FAST_JSON_TIMEOUT", "12"))
_FAST_TIMEOUT = float(os.environ.get("VISION_V2_FAST_TIMEOUT", "15"))
_FAST_JSON_TIMEOUT = float(os.environ.get("VISION_V2_FAST_JSON_TIMEOUT", "15"))
_OCR_TIMEOUT = float(os.environ.get("VISION_V2_OCR_TIMEOUT", "6"))
_PRO_TIMEOUT = float(os.environ.get("VISION_V2_PRO_TIMEOUT", "25"))
_PRO_TIMEOUT = float(os.environ.get("VISION_V2_PRO_TIMEOUT", "30"))
_FALLBACK_RESULT = {
"name": "未识别",
@@ -25,7 +25,7 @@ logger = logging.getLogger(__name__)
_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
_PRO_MODEL = "qwen3.7-plus"
_DEFAULT_TIMEOUT = 25
_DEFAULT_TIMEOUT = 30
_DEFAULT_MAX_TOKENS = 800
@@ -27,7 +27,7 @@ logger = logging.getLogger(__name__)
# DashScope OpenAI 兼容 endpoint
_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
_FAST_MODEL = "qwen3.8-flash"
_DEFAULT_TIMEOUT = 12
_DEFAULT_TIMEOUT = 15
_DEFAULT_MAX_TOKENS = 350