refactor: 统一智能选素材逻辑,迁移 generation_tasks smart 模式到 smart_match (#1243)
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 1m22s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 1m31s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 2m4s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 2m55s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 4m34s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 5m20s
CI/CD Pipeline / Integration Tests (push) Successful in 2m42s
CI/CD Pipeline / Unit Tests (push) Successful in 9m25s
CI/CD Pipeline / Build Staging API Image (push) Successful in 13m35s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 49s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 42s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 59s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m4s
CI/CD Pipeline / Canary Release to Production (push) Failing after 1011h41m47s
CI/CD Pipeline / Deploy Production (push) Failing after 1011h49m52s
CI/CD Pipeline / CI Gate (push) Failing after 1011h49m52s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 1011h59m16s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1011h49m53s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1011h49m53s
CI/CD Pipeline / PR Build Web Image (push) Failing after 1011h59m18s
CI/CD Pipeline / Frontend Lint (push) Failing after 1011h59m20s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 1011h59m21s
CI/CD Pipeline / Production Browser E2E (push) Failing after 1012h23m9s
CI/CD Pipeline / Build Production API Image (push) Failing after 1012h23m11s
CI/CD Pipeline / PR Build API Image (push) Failing after 1012h32m35s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 1m22s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 1m31s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 2m4s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 2m55s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 4m34s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 5m20s
CI/CD Pipeline / Integration Tests (push) Successful in 2m42s
CI/CD Pipeline / Unit Tests (push) Successful in 9m25s
CI/CD Pipeline / Build Staging API Image (push) Successful in 13m35s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 49s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 42s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 59s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m4s
CI/CD Pipeline / Canary Release to Production (push) Failing after 1011h41m47s
CI/CD Pipeline / Deploy Production (push) Failing after 1011h49m52s
CI/CD Pipeline / CI Gate (push) Failing after 1011h49m52s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 1011h59m16s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1011h49m53s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1011h49m53s
CI/CD Pipeline / PR Build Web Image (push) Failing after 1011h59m18s
CI/CD Pipeline / Frontend Lint (push) Failing after 1011h59m20s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 1011h59m21s
CI/CD Pipeline / Production Browser E2E (push) Failing after 1012h23m9s
CI/CD Pipeline / Build Production API Image (push) Failing after 1012h23m11s
CI/CD Pipeline / PR Build API Image (push) Failing after 1012h32m35s
This commit was merged in pull request #1243.
This commit is contained in:
@@ -38,6 +38,7 @@ from packages.application import (
|
||||
GetGenerationTaskUseCase,
|
||||
ListGeneratedVideosByTaskUseCase,
|
||||
)
|
||||
from packages.domain.smart_match import smart_select_assets
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -124,19 +125,11 @@ def _select_assets_from_library(
|
||||
return [a.id for a in selected]
|
||||
|
||||
if mode == "smart":
|
||||
# 智能匹配:按质量分降序 + 时长降序作为tiebreaker
|
||||
# 注意:这里使用简单的 quality_score 排序保持向后兼容
|
||||
# 更复杂的4维评分+多样性策略由 SmartAssetSelector 服务提供(用于 AI 精选等场景)
|
||||
scored_assets = sorted(
|
||||
ready_video_assets,
|
||||
key=lambda a: (
|
||||
-(a.quality_score if a.quality_score is not None else 0.0),
|
||||
-(getattr(a, "duration", 0.0) or 0.0),
|
||||
),
|
||||
)
|
||||
if count > 0:
|
||||
scored_assets = scored_assets[:count]
|
||||
return [a.id for a in scored_assets]
|
||||
# 智能匹配:统一使用 packages/domain/smart_match.py 的多维评分+多样性选取
|
||||
# 评分维度:质量分(40%) + 时长适配(30%) + 新鲜度(20%) + 未使用加分(10%)
|
||||
limit = count if count > 0 else None
|
||||
results = smart_select_assets(ready_video_assets, limit=limit, kind="video")
|
||||
return [r.asset.id for r in results]
|
||||
|
||||
# 默认 all 模式:返回全部 ready 视频素材
|
||||
return [a.id for a in ready_video_assets]
|
||||
|
||||
Reference in New Issue
Block a user