- step1: 所有 LLM 调用返回空 function_units 时抛出 RuntimeError - step1: main() 在 _quick_validate 未通过时 sys.exit(1) - step2: function_units 为空时提前报错终止 - step3: fragments 为空时提前报错终止 - test: test_step1 捕获 SystemExit, test_step2_5/step3 空数据改为 skip Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -632,6 +632,18 @@ def run_ensemble_semantic_index(doc: dict) -> dict:
|
||||
if not raw_results:
|
||||
raise RuntimeError("所有集成的 LLM 调用均失败")
|
||||
|
||||
# Check that at least some raw results have function_units
|
||||
all_empty = all(
|
||||
len(r[2].get("function_units", [])) == 0 for r in raw_results
|
||||
)
|
||||
if all_empty:
|
||||
raise RuntimeError(
|
||||
"所有集成的 LLM 调用返回了空的 function_units。请检查:\n"
|
||||
" 1. API Key 是否配置正确 (secrets.yaml 或环境变量)\n"
|
||||
" 2. 输入文档格式是否与 Prompt 兼容\n"
|
||||
" 3. LLM 服务是否可访问"
|
||||
)
|
||||
|
||||
# Sort by temperature for determinism
|
||||
raw_results.sort(key=lambda x: x[1])
|
||||
semantic_indices = [r[2] for r in raw_results]
|
||||
@@ -709,6 +721,17 @@ def main():
|
||||
n_concepts = cs.get("total_concepts", len(merged_index.get("concepts", [])))
|
||||
n_units = cs.get("total_units", len(merged_index.get("function_units", [])))
|
||||
n_versions = merged_index.get("ensemble_versions", len(config.ENSEMBLE_TEMPERATURES))
|
||||
|
||||
if not merged_index.get("validation_passed", True):
|
||||
print(f"\n错误: 语义索引验证未通过!")
|
||||
gaps = merged_index.get("validation_gaps", {})
|
||||
for category, issues in gaps.items():
|
||||
for issue in issues:
|
||||
print(f" [{category}] {issue}")
|
||||
print(f"\n流水线中止: {n_units} 个功能单元不满足最低覆盖率要求。")
|
||||
print("请检查 LLM 配置、输入文档格式和 Prompt 兼容性。")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"\n完成! {n_versions} 版本集成, {n_concepts} 个概念, {n_units} 个功能单元.")
|
||||
print(f"输出: {config.SEMANTIC_INDEX_JSON}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user