selftest / selftest (push) Canceled after 0s
Wire deliver_report/listen_pack/retry hooks; gen --auto-retry and intro light check; make AGENTS_MIN the up-to-date agent entry with full command map. Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""开曲衬词 FAIL 时给出重试建议;供 gen --auto-retry 读取。"""
|
|
import json
|
|
import os
|
|
|
|
from ..hooks import bus
|
|
|
|
# 判定文案关键字(与 qc_worker judge 一致)
|
|
_INTRO_KEYS = ("开曲衬词", "前 2s 就已唱出", "人声在")
|
|
|
|
|
|
def is_intro_fail(why_list):
|
|
text = " ".join(why_list or [])
|
|
return any(k in text for k in _INTRO_KEYS)
|
|
|
|
|
|
@bus.on("after_qc")
|
|
def _hint(run_dir=None, report=None, **_kw):
|
|
if not run_dir or not report:
|
|
return None
|
|
verd = report.get("verdicts") or []
|
|
reasons = []
|
|
for v in verd:
|
|
if v.get("verdict") == "FAIL":
|
|
reasons.extend(v.get("why") or [])
|
|
if not is_intro_fail(reasons):
|
|
# 也看 intro_check.json
|
|
ip = os.path.join(run_dir, "intro_check.json")
|
|
if os.path.isfile(ip):
|
|
with open(ip, encoding="utf-8") as f:
|
|
blob = json.load(f)
|
|
if blob.get("fail") or blob.get("ok") is False:
|
|
reasons.append("intro_check fail")
|
|
else:
|
|
return None
|
|
else:
|
|
return None
|
|
hint = dict(
|
|
retry=True,
|
|
reason="intro_filler_or_early_vocal",
|
|
why=reasons[:8],
|
|
suggest="换 seed 重 gen,或 songforge recheck --run <id> 后再决定",
|
|
)
|
|
path = os.path.join(run_dir, "retry_hint.json")
|
|
with open(path, "w", encoding="utf-8") as f:
|
|
json.dump(hint, f, ensure_ascii=False, indent=1)
|
|
return hint
|
|
|
|
|
|
def should_retry_intro_blob(blob):
|
|
"""给 gen --auto-retry 用:intro_check blob 是否应换 seed。"""
|
|
if not blob or blob.get("error"):
|
|
return False
|
|
return bool(blob.get("fail") or blob.get("ok") is False)
|