From 5a9b6d98905225f76ccf07428e076cc2a36f1ae6 Mon Sep 17 00:00:00 2001 From: CI Bot Date: Thu, 23 Jul 2026 18:11:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(#584):=20=E4=BF=AE=E5=A4=8D=E6=99=BA?= =?UTF-8?q?=E8=83=BD=E5=8C=B9=E9=85=8D=E6=A8=A1=E5=BC=8F=E5=90=91=E5=90=8E?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98=20-=20=5Fselect=5Fassets?= =?UTF-8?q?=5Ffrom=5Flibrary=E7=9A=84smart=E6=A8=A1=E5=BC=8F=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E7=AE=80=E5=8D=95=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #751引入SmartAssetSelector后破坏了_select_assets_from_library的smart模式原有行为: - 新增最低质量分过滤(旧逻辑只排序不过滤) - null quality_score处理逻辑变化(旧逻辑当0分,新逻辑当0.5分) - 时长tiebreaker变化(旧逻辑时长越长越靠前,新逻辑有最优区间) 修复:_select_assets_from_library恢复quality_score+时长的简单排序, 保持API层smart模式的向后兼容。SmartAssetSelector作为独立服务 继续存在,供AI推荐、自动剪辑等需要4维评分的高级场景使用。 修复tests/unit/test_asset_select_mode.py中5个失败的单测。 --- apps/api/app/api/routes/generation_tasks.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/api/app/api/routes/generation_tasks.py b/apps/api/app/api/routes/generation_tasks.py index e982bb248..325c76c72 100755 --- a/apps/api/app/api/routes/generation_tasks.py +++ b/apps/api/app/api/routes/generation_tasks.py @@ -124,10 +124,19 @@ def _select_assets_from_library( return [a.id for a in selected] if mode == "smart": - # 智能匹配:多维度综合评分 + 时长多样性保证 - selector = SmartAssetSelector() - result = selector.select(ready_video_assets, count=count, ensure_diversity=True) - return result.selected_ids + # 智能匹配:按质量分降序 + 时长降序作为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] # 默认 all 模式:返回全部 ready 视频素材 return [a.id for a in ready_video_assets] -- 2.54.0