Pair black and bright defect evidence for priority products
This commit is contained in:
@@ -1980,6 +1980,49 @@ def run_turn(payload: dict[str, Any], *, stdout: Any = sys.stdout, stdin: Any =
|
||||
actor_root=actor_root, cancel_event=cancel_event,
|
||||
timeout=480 if model_name == "mimo-v2.6-flash" else TURN_TIMEOUT_SECONDS,
|
||||
)
|
||||
# The model may investigate one stage of a priority product and forget
|
||||
# the other. Complete the same release/period/filter pair before the
|
||||
# evidence-based answer and charts are assembled. Never borrow a result
|
||||
# from another turn or infer a missing stage from the first one.
|
||||
pairable_stop = status in ("COMPLETED", "PARTIAL") or (
|
||||
status == "FAILED" and stop_reason in ("length", "timeout", "超时停止")
|
||||
and stop_succeeded is True)
|
||||
if pairable_stop and not cancel_event.is_set():
|
||||
try:
|
||||
from analysis_visual_evidence import load_visual_evidence
|
||||
from nao_product_defect_pairing import plan_missing_product_defect_stages
|
||||
from nao_quality_tools import QualityTools
|
||||
documents = load_visual_evidence(actor_root / "evidence", request["releaseId"],
|
||||
exclude_files=prior_evidence_files, budget_seconds=2.0)
|
||||
missing_stages = plan_missing_product_defect_stages(
|
||||
documents, request["question"], request["context"])
|
||||
if missing_stages:
|
||||
pairing_api = DelegatedApi(access_path, runtime_root=manager.users_root,
|
||||
expected_actor_id=request["actorId"],
|
||||
expected_session_id=request["sessionId"], timeout=5).login()
|
||||
quality_tools = QualityTools(api_factory=lambda: pairing_api,
|
||||
evidence_dir=actor_root / "evidence")
|
||||
for arguments in missing_stages:
|
||||
if cancel_event.is_set():
|
||||
break
|
||||
stage_name = "黑片" if arguments["stage"] == "black" else "亮片"
|
||||
emit({"type": "progress", "message": f"正在补查同规格的{stage_name}具体缺陷…"})
|
||||
try:
|
||||
paired = quality_tools.quality_data(arguments)
|
||||
except (ValueError, OSError, RuntimeError):
|
||||
emit({"type": "progress", "message": f"{stage_name}具体缺陷补查未成功,结论将保留该阶段的数据限制。"})
|
||||
continue
|
||||
call = {"tool": "quality_data", "toolCallId": "pair-" + paired["evidenceRef"],
|
||||
"label": f"补查{stage_name}具体缺陷", "status": "completed",
|
||||
"startedAt": datetime.now(timezone.utc).isoformat(),
|
||||
"finishedAt": datetime.now(timezone.utc).isoformat(),
|
||||
"outputSummary": f"同规格、同期间补查完成;依据 {paired['evidenceRef']}"}
|
||||
accumulator.tool_calls.append(call)
|
||||
accumulator.record_event("tool_result", tool=call["tool"],
|
||||
toolCallId=call["toolCallId"], label=call["label"],
|
||||
status="completed", text=call["outputSummary"])
|
||||
except (ValueError, OSError, RuntimeError):
|
||||
emit({"type": "progress", "message": "阶段配对检查未完成,已有查询结果仍按原范围呈现。"})
|
||||
from nao_evidence_finalizer import eligible, evidence_summaries, synthesize, coverage_sufficient, FinalizationUnavailable
|
||||
finalized = False
|
||||
evidence_completion = None
|
||||
|
||||
Reference in New Issue
Block a user