Files
reader/skills/llm-summary-review/SKILL.md
T

102 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: llm-summary-review
description: 验证和优化 LLM 生成的文章摘要 JSON。当用户需要审查、验证、修复或迭代 `outputs/result.json` 或其他由已提取文章 JSON 生成的摘要输出时使用。
---
# LLM 摘要审查
在文章提取完成后,处理本仓库摘要循环时使用此技能。
## 功能说明
- 验证 LLM 摘要结果是否符合预期的 JSON 约定
- 复用仓库验证器,而非手动逐字段检查
- 通过告知 LLM 具体需要修复的内容来修复无效输出
- 保持工作流与本项目生成的提取 JSON 保持一致
## 输入
典型文件:
- 已提取的文章 JSON:`outputs/*.extracted.json`
- LLM 摘要结果 JSON:`outputs/result.json`
- 提示词模板:`outputs/llm-summary-prompt.txt`
## 工作流程
1. 使用仓库验证器验证当前摘要结果:
```bash
python -m summary_mcp.validate_llm_result outputs/result.json --extracted outputs/read-flow-2026.extracted.json
```
2. 如果验证通过:
- 报告结果结构有效
- 简要说明任何警告
- 除非用户要求,否则不重写结果
3. 如果验证失败:
- 仔细阅读验证器错误信息
- 要求 LLM 仅重新生成或修复失败的部分
- 重新运行验证器,直到通过或达到重试上限
## 修复提示词模式
当要求 LLM 修复有问题的结果时,需提供:
- 原始已提取的文章 JSON
- 当前无效的摘要 JSON
- 验证器错误列表
- 严格指令:保留正确字段,仅修复失败字段
使用以下修复模板:
```text
请修复下面这份不符合要求的摘要 JSON。
要求:
- 只输出合法 JSON
- 保留已经正确的字段
- 只修复 validator 报出的错误
- 不要补充解释
validator errors:
{{errors}}
原始提取结果:
{{extracted_json}}
当前摘要结果:
{{result_json}}
```
## 验证规则
验证器当前强制执行以下规则:
- 必填字段存在
- 字段类型正确
- `category` 取值为以下之一:`资讯` `方法论` `工具实践` `观点评论`
- `summary` 长度在允许范围内
- `highlights`、`keywords` 和 `topics` 数量在允许范围内
- `keywords` 和 `topics` 不重叠
- 提供已提取 JSON 文件时,`title` 和 `url` 与已提取文章匹配
## 代码实现
相关代码:
- 验证器模型:`src/summary_mcp/models/llm_result.py`
- 验证器逻辑:`src/summary_mcp/validators/llm_result.py`
- CLI 入口:`src/summary_mcp/validate_llm_result.py`
优先使用现有验证器,而非在自由推理中重新创建检查逻辑。
## 何时停止
满足以下条件之一时停止:
- 验证器返回 `valid: true`
- 用户要求手动检查剩余的失败项
- 反复重试失败,应由用户决定后续操作