feat(kb-workflow): 添加严格失败判断逻辑

- kb-deep-analyzer: 新增判断逻辑,只有AI真正完成分析才算成功
- 失败条件: summary以'共'开头、topics为空、full_analysis为None
- kb-workflow: 明确深度分析失败则整个流程失败
- 禁止降级处理或使用模板'假装成功'
This commit is contained in:
2026-02-13 15:23:03 +08:00
parent 518f8e4805
commit c276df2d37
3 changed files with 115 additions and 67 deletions
+30 -3
View File
@@ -444,7 +444,7 @@ class DeepAnalyzer:
result = self._analyze_chunks_concurrent(
title, text, duration, segments, metadata,
batch_size=batch_size,
on_batch_complete=on_batch_complete
on_segment_complete=on_batch_complete
)
elif duration < self.SHORT_VIDEO_THRESHOLD:
print(f"[DeepAnalyzer] 使用轻量分析策略 (时长 < 10分钟)")
@@ -671,6 +671,7 @@ class DeepAnalyzer:
segments: list = None,
metadata: Dict = None,
max_concurrent: int = 3,
batch_size: int = 3,
on_segment_complete: callable = None
) -> AnalysisResult:
"""
@@ -787,8 +788,8 @@ class DeepAnalyzer:
# 回调通知当前批次完成
batch_summaries = [batch_results[i] for i in range(batch_idx, batch_end) if i in batch_results]
if on_batch_complete:
on_batch_complete(batch_summaries)
if on_segment_complete:
on_segment_complete(batch_summaries)
all_summaries.extend(batch_summaries)
@@ -1627,6 +1628,32 @@ def main():
f.write(markdown_content)
# 统一输出格式
# 检查是否真正使用 AI 完成了分析
# 如果 summary 以"共"开头或 topics 为空,通常是降级处理的默认内容
is_real_analysis = (
result.summary and
not result.summary.startswith("共") and
len(result.main_topics) > 0 and
len(result.key_insights) > 0 and
result.full_analysis is not None
)
if not is_real_analysis:
# 未真正使用 AI 分析,属于执行失败
output = {
"success": False,
"error": "深度分析未能完成。可能是 AI 调用失败或返回内容不完整。",
"message": "执行失败:未使用正确的 AI 完整分析字幕内容",
"stats": {
"summary_length": len(result.summary) if result.summary else 0,
"topics_count": len(result.main_topics),
"insights_count": len(result.key_insights),
"is_real_analysis": False
}
}
print(json.dumps(output, ensure_ascii=False, indent=2))
sys.exit(1)
output = {
"success": True,
"filename": Path(args.output).name,