feat(safety): 扩展规则覆盖幻觉、越权和合规检查 #30

Merged
solahqb merged 1 commits from feat/safety-extended into main 2026-08-25 08:02:06 +00:00
Owner

Summary

扩展 safety 规则,新增三个安全检查维度。

Changes

  • 幻觉检测check_hallucination):LLM 判断回答是否编造事实
  • 越权操作检测unauthorized_actions):模式匹配检测越权行为
  • 合规性检查required_disclaimers):检查必需声明是否存在
  • 保持原有 blacklist + moderation API 向后兼容
  • RuleResult.details 包含所有问题列表
  • 新增 10 项单元测试(656 tests passed)

Configuration Example

rules:
  - type: safety
    params:
      blacklist: ["违禁词"]
      check_hallucination: true
      hallucination_criteria: "判断回答是否编造了不存在的事实"
      unauthorized_actions: ["已为您预约", "已下单", "已支付"]
      required_disclaimers: ["仅供参考", "请咨询专业人士"]

Test plan

  • 单元测试通过(656 tests)
  • 向后兼容验证(blacklist + moderation API)
  • 越权操作检测测试
  • 合规性检查测试
  • 多问题组合测试

Closes #22

## Summary 扩展 `safety` 规则,新增三个安全检查维度。 ## Changes - **幻觉检测**(`check_hallucination`):LLM 判断回答是否编造事实 - **越权操作检测**(`unauthorized_actions`):模式匹配检测越权行为 - **合规性检查**(`required_disclaimers`):检查必需声明是否存在 - 保持原有 blacklist + moderation API 向后兼容 - RuleResult.details 包含所有问题列表 - 新增 10 项单元测试(656 tests passed) ## Configuration Example ```yaml rules: - type: safety params: blacklist: ["违禁词"] check_hallucination: true hallucination_criteria: "判断回答是否编造了不存在的事实" unauthorized_actions: ["已为您预约", "已下单", "已支付"] required_disclaimers: ["仅供参考", "请咨询专业人士"] ``` ## Test plan - [x] 单元测试通过(656 tests) - [x] 向后兼容验证(blacklist + moderation API) - [x] 越权操作检测测试 - [x] 合规性检查测试 - [x] 多问题组合测试 Closes #22
solahqb added 1 commit 2026-08-25 07:31:07 +00:00
feat(safety): 扩展规则覆盖幻觉、越权和合规检查
All checks were successful
CI / test (pull_request) Successful in 4m2s
192fe0fc5f
扩展 safety 规则,新增三个安全检查维度。

- 幻觉检测(check_hallucination):LLM 判断回答是否编造事实
- 越权操作检测(unauthorized_actions):模式匹配检测越权行为
- 合规性检查(required_disclaimers):检查必需声明是否存在
- 保持原有 blacklist + moderation API 向后兼容
- RuleResult.details 包含所有问题列表
- 新增 10 项单元测试(656 tests passed)

Closes #22
solahqb merged commit 2c79abf1de into main 2026-08-25 08:02:06 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: solahqb/AgentEvalTool#30
No description provided.