Files
DEMO-AGENT/docs/详细设计/skill/风险预警编排Skill.md

91 lines
2.0 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.
# 风险预警编排Skill 设计
## 1. Skill 定位
`风险预警编排Skill` 是第五步工作流的总入口 Skill负责组织前序报告汇总、风险规则加载、风险项生成、风险归并、准入判定、整改建议生成和风险报告输出。
英文实现标识建议使用 `RiskWarningOrchestrateSkill`
## 2. 输入
```python
@dataclass
class RiskWarningOrchestrateInput:
batch_id: int
scenario_id: str = "registration_risk_report"
risk_rule_id: str = "ivd_registration_risk_v1"
include_reports: list[str] = field(default_factory=list)
enable_llm_summary: bool = True
```
## 3. 输出
```python
@dataclass
class RiskWarningOrchestrateOutput:
report_type: str
batch_id: int
summary: dict
risk_items: list[dict]
manual_review_items: list[dict]
suggestions: list[dict]
audit_id: int | None = None
```
## 4. 依赖 Skill
1. `前序报告汇总Skill`
2. `风险规则加载Skill`
3. `风险项生成Skill`
4. `风险归并Skill`
5. `准入判定Skill`
6. `整改建议生成Skill`
7. `风险报告生成Skill`
## 5. 核心方法
### 5.1 `run(input) -> RiskWarningOrchestrateOutput`
主入口方法。
### 5.2 `load_execution_context(input) -> RiskEvaluationContext`
加载批次、场景和前序报告上下文。
### 5.3 `merge_results(risks, admission, suggestions) -> dict`
合并风险、准入和建议。
## 6. 技术实现
使用技术:
1. Tool Registry
2. dataclass/Pydantic
3. Django ORM
4. Audit 服务
建议注册名:
```python
tool_registry.register(
name="risk_warning_orchestrate",
handler=RiskWarningOrchestrateSkill().run,
)
```
## 7. 异常处理
1. 前序报告缺失:输出业务提示。
2. 风险规则缺失:任务失败。
3. LLM 不可用:使用模板摘要。
4. 审计写入失败:报告返回并记录系统警告。
## 8. 测试要点
1. 能串联所有依赖 Skill。
2. 高风险导致不通过。
3. 前序报告缺失时提示清晰。
4. 输出报告 schema 稳定。