fix: resolve legacy evidence targets without guessing and guide retries
This commit is contained in:
@@ -238,11 +238,19 @@ def validate_score(result: ScoreResult, criterion: dict, chunks: list[dict], *,
|
||||
# Empty identifiers are accepted only for pre-object legacy rubrics.
|
||||
if any(isinstance(value, dict) for value in criterion.get("required_evidence", [])):
|
||||
raise ModelError("模型证据缺少 target_id")
|
||||
target = default_content or (targets[0] if targets else None)
|
||||
associated = [by_target[key] for key in chunk.get("target_ids", []) if key in by_target]
|
||||
if associated:
|
||||
if len(associated) != 1:
|
||||
raise ModelError(f"模型证据缺少 target_id:chunk_id={chunk['chunk_id']} 对应多个检索目标,请明确选择")
|
||||
target = associated[0]
|
||||
else:
|
||||
target = default_content or (targets[0] if targets else None)
|
||||
if target is None:
|
||||
raise ModelError("模型证据未关联任何必备证据目标")
|
||||
if chunk.get("target_ids") and target["target_id"] not in chunk["target_ids"]:
|
||||
raise ModelError("模型证据未关联该片段的检索目标")
|
||||
allowed = ",".join(str(key) for key in chunk["target_ids"] if key in by_target)
|
||||
raise ModelError(f"模型证据未关联该片段的检索目标:chunk_id={chunk['chunk_id']},"
|
||||
f"target_id={target['target_id']};允许 target_id={allowed}")
|
||||
if not page_type_allowed(page_type, target["allowed_page_types"]):
|
||||
raise ModelError(f"模型证据来自不允许的页面类型({page_type}),不能支持「{target['label']}」")
|
||||
if target["use"] == USE_CONTENT and not content_evidence_allowed(page_type):
|
||||
|
||||
Reference in New Issue
Block a user