refactor(vision): #2201 代码精简 — 删lite/pro竞速/#2194临时止血/V1V2双分支 #2201

Merged
xiaoxia merged 2 commits from refactor/vision-v2-clean into develop 2026-10-05 17:27:07 +08:00
Owner

背景

按灵应补充要求清理冗余代码:上专用API架构后,VLM一把梭时代的竞速/超时/重试/fallback/GET+Range检查等临时方案该删就删,不要两套逻辑并存。

清理内容

  1. _step_image_analysis:去掉V1/V2 if/else分支,直接走V2主路径
  2. 删除 _analyze_single_image 整个函数(450行 lite/pro 竞速 + 复杂 _xml_to_product 解析 + _normalize 多分支),VLM兜底抽到 vision/vlm_fallback.py,只保留单次pro调用+简化版XML/JSON解析
  3. _normalize_image_url:删除 #2194 临时加的 GET+Range:0-1024 可达性检查
  4. fast_path.py:去掉 VISION_V2_ENABLED 开关判断,简化默认超时(fast=8s/lite=6s/ocr=6s/pro=45s),兜底直接调 vlm_fallback 而不是反向依赖 viral_video
  5. 删除未使用的 _is_vision_result_usable 函数、ThreadPoolExecutor/as_completed 在 viral_video.py 的 import
  6. 文件头 docstring 更新为V2架构说明

代码量变化

  • viral_video.py:2583行 → 2031行(净删 552 行)
  • vision/ 模块:6 个文件共 873 行(职责清晰,vlm_fast_json=141行、ocr_volc=108行、assembler=297行、vlm_fallback=197行、fast_path=127行)
  • 主力路径只有一条:OCR + lite JSON 并行 → 失败单次 pro 兜底

架构

_step_image_analysis
  └─ analyze_images_v2(urls, workers=8)         ← 外层8图全并发
        └─ per-image: analyze_image_v2          ← 单图 ThreadPoolExecutor(2)
              ├─ OCR (火山MediaKit专用API)  ──┐
              │                                ├─ as_completed → assembler → usable? return
              └─ lite JSON VLM (fast)     ──┘
                                                        │ 不可用
                                                        ▼
                                                   vlm_fallback.call_pro_vlm (单次pro, 45s)
## 背景 按灵应补充要求清理冗余代码:上专用API架构后,VLM一把梭时代的竞速/超时/重试/fallback/GET+Range检查等临时方案该删就删,不要两套逻辑并存。 ## 清理内容 1. **_step_image_analysis**:去掉V1/V2 if/else分支,直接走V2主路径 2. **删除 `_analyze_single_image` 整个函数**(450行 lite/pro 竞速 + 复杂 _xml_to_product 解析 + _normalize 多分支),VLM兜底抽到 `vision/vlm_fallback.py`,只保留**单次pro调用**+简化版XML/JSON解析 3. **_normalize_image_url**:删除 #2194 临时加的 GET+Range:0-1024 可达性检查 4. **fast_path.py**:去掉 VISION_V2_ENABLED 开关判断,简化默认超时(fast=8s/lite=6s/ocr=6s/pro=45s),兜底直接调 vlm_fallback 而不是反向依赖 viral_video 5. 删除未使用的 `_is_vision_result_usable` 函数、`ThreadPoolExecutor/as_completed` 在 viral_video.py 的 import 6. 文件头 docstring 更新为V2架构说明 ## 代码量变化 - `viral_video.py`:2583行 → 2031行(净删 552 行) - `vision/` 模块:6 个文件共 873 行(职责清晰,vlm_fast_json=141行、ocr_volc=108行、assembler=297行、vlm_fallback=197行、fast_path=127行) - 主力路径只有一条:OCR + lite JSON 并行 → 失败单次 pro 兜底 ## 架构 ``` _step_image_analysis └─ analyze_images_v2(urls, workers=8) ← 外层8图全并发 └─ per-image: analyze_image_v2 ← 单图 ThreadPoolExecutor(2) ├─ OCR (火山MediaKit专用API) ──┐ │ ├─ as_completed → assembler → usable? return └─ lite JSON VLM (fast) ──┘ │ 不可用 ▼ vlm_fallback.call_pro_vlm (单次pro, 45s)

🚀 预览环境已部署

项目 详情
PR号 #2201
预览链接 https://pr-2201.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #2201 | | 预览链接 | [https://pr-2201.preview.xiaoxiajianji.com](https://pr-2201.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia force-pushed refactor/vision-v2-clean from 9ee1c50520 to ae2ddc2af2 2026-10-05 17:25:15 +08:00 Compare
xiaoxia added 2 commits 2026-10-05 17:26:25 +08:00
按灵应要求清理冗余:
1. _step_image_analysis 直接走V2主路径,去掉V1/V2 if/else分支
2. 删除 _analyze_single_image 整个函数(450行lite/pro竞速/_xml_to_product复杂解析)
3. VLM兜底抽到vision/vlm_fallback.py:单次pro调用,简化版XML/JSON解析,无竞速/无复杂超时
4. _normalize_image_url 删除#2194临时加的GET+Range:0-1024可达性检查
5. fast_path.py 去掉VISION_V2_ENABLED判断,简化默认超时(fast=8s/lite=6s/ocr=6s)
6. 删掉未使用的_is_vision_result_usable、ThreadPoolExecutor/as_completed import
7. viral_video.py从2583行精简到2031行(净删552行),结构清爽

代码只有一条主力路径:OCR+lite JSON并行 → 失败单次pro兜底。
fix(vision): assembler portrait_prompt 拼接自然化 + 清死代码三元
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 4s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 18s
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 / PR Build Worker Image (pull_request) Successful in 37s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 38s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 10s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m11s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 3m10s
CI/CD Pipeline / Retag skipped Staging API Image (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 / Unit Tests (pull_request) Failing after 4m23s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 4m35s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 5m44s
AI Code Review / AI Code Review (pull_request) Successful in 6m50s
CI/CD Pipeline / Validate - Style (pull_request) Failing after 6m28s
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
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 48s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 12m44s
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 / CI Gate (pull_request) Failing after 1s
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
ed24c7cd68
- _AGE_PREFIX 去掉儿童/青少年死代码(已在 _person_subject 里单独按性别处理)
- 风格段(style/mood/scene)之间不用逗号,改为紧凑拼接(休闲阳光街拍风格而非'休闲,阳光,街拍风格')
xiaoxia force-pushed refactor/vision-v2-clean from ae2ddc2af2 to ed24c7cd68 2026-10-05 17:26:25 +08:00 Compare
xiaoxia merged commit 2d823a9255 into develop 2026-10-05 17:27:07 +08:00

🗑️ 预览环境已清理

PR #2201 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #2201 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.