style: auto-format with black + isort + ruff + prettier [skip ci-format-check]

This commit is contained in:
CI Bot
2026-10-05 09:12:45 +00:00
parent ed20fbad49
commit b4e84eb7b6
6 changed files with 21 additions and 3 deletions
@@ -789,6 +789,7 @@ def _analyze_single_image(
# 不是 XML 也不是 dict:尝试当作纯 JSON 字符串再解析一次
try:
import json as _j2
_jd = _j2.loads(raw)
if isinstance(_jd, dict):
return _normalize(_jd, source)
@@ -893,6 +894,7 @@ def _step_image_analysis(job: ViralVideoJob) -> dict:
# ========== V2 路径(VISION_V2_ENABLED=true)==========
import os as _os_v2
_v2_enabled = _os_v2.environ.get("VISION_V2_ENABLED", "false").lower() in ("1", "true", "yes", "on")
if _v2_enabled:
try:
@@ -905,6 +907,7 @@ def _step_image_analysis(job: ViralVideoJob) -> dict:
_aiv2 = None # type: ignore
if _aiv2 is not None:
from packages.shared.ai_client import get_doubao_client as _gdc_v2
_cli = _gdc_v2()
_orig_retries_v2 = _cli.max_retries
_cli.max_retries = 0
@@ -12,4 +12,5 @@
输出 dict 格式与 viral_video._normalize() 完全一致,下游信任链/t2i 零改动。
灰度开关:VISION_V2_ENABLED=true(默认 false,走旧 #2198/#2199 竞速逻辑)。
"""
from .fast_path import analyze_image_v2, analyze_images_v2 # noqa: F401
@@ -5,6 +5,7 @@
必出字段:name, brand, category, appearance, packaging, text_on_package,
key_features, scene, mood, portrait_prompt, summary, _source
"""
from __future__ import annotations
from typing import Any
@@ -170,6 +171,7 @@ def _build_portrait_prompt(fj: dict[str, Any]) -> str:
# ---------- 商品字段 ----------
def _infer_name(fj: dict[str, Any], ocr_texts: list[str]) -> str:
pname = fj.get("product_name")
if pname and pname != "未识别":
@@ -209,7 +211,7 @@ def _infer_category(fj: dict[str, Any]) -> str:
def _build_appearance(fj: dict[str, Any]) -> str:
"""外观描述:颜色+款式+材质+图案 拼成一段。"""
parts: list[str] = []
for key, label in [
for key, _label in [
("upper_color", "主色"),
("upper_wear", "款式"),
("material", "材质"),
@@ -227,8 +229,17 @@ def _build_appearance(fj: dict[str, Any]) -> str:
def _build_key_features(fj: dict[str, Any], ocr_texts: list[str]) -> list[str]:
feats: list[str] = []
for key in ("upper_wear", "lower_wear", "upper_color", "lower_color", "dress_color",
"material", "pattern", "style", "accessories"):
for key in (
"upper_wear",
"lower_wear",
"upper_color",
"lower_color",
"dress_color",
"material",
"pattern",
"style",
"accessories",
):
v = fj.get(key)
if not v:
continue
@@ -5,6 +5,7 @@
外层 8 图全并发,目标 8 图 <15s。
终极兜底:复用旧 _analyze_single_image 完整 pro VLM 逻辑。
"""
from __future__ import annotations
import logging
@@ -9,6 +9,7 @@
目标:识别商品包装/Logo/水印上的文字,作为 fast_json VLM 的补充。
返回值:识别到的文本字符串列表(失败返回 [])。
"""
from __future__ import annotations
import logging
@@ -9,6 +9,7 @@
- timeout=8s(够快,失败则由外层走 pro VLM 兜底)
- 期望返回纯 JSON object(无 ```json 包裹、无解释文字)
"""
from __future__ import annotations
import json