response_parsing_config.yaml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # AI审查响应解析配置模板
  2. # JSON解析规则配置
  3. json_parsing_rules:
  4. # 直接JSON检测规则
  5. direct_json_patterns:
  6. # 单行对象模式
  7. - pattern: "^{.*}$"
  8. type: "single_object"
  9. description: "直接JSON对象"
  10. # 多行对象模式
  11. - pattern: "^\\{[\\s\\S]*\\}$"
  12. type: "multiline_object"
  13. description: "多行JSON对象"
  14. # JSON数组模式(新增)
  15. - pattern: "^\\[[\\s\\S]*\\]$"
  16. type: "json_array"
  17. description: "JSON数组"
  18. # 代码块模式
  19. code_block_patterns:
  20. - pattern: "```json\\s*([\\s\\S]*?)\\s*```"
  21. type: "json_code_block"
  22. description: "标准JSON代码块"
  23. - pattern: "```JSON\\s*([\\s\\S]*?)\\s*```"
  24. type: "json_code_block_upper"
  25. description: "大写JSON代码块"
  26. - pattern: "```\s*([\\s\\S]*?)\s*```"
  27. type: "generic_code_block"
  28. description: "通用代码块"
  29. # 特殊格式模式
  30. special_patterns:
  31. - pattern: '"check_result":\s*"[^"]*\[[\s\S]*?\]"'
  32. type: "embedded_array"
  33. description: "嵌入式JSON数组"
  34. # 必需关键字验证
  35. required_keywords:
  36. # 标准检查项关键字
  37. standard:
  38. - "issue_point"
  39. - "location"
  40. - "suggestion"
  41. - "reason"
  42. - "risk_level"
  43. # 可选关键字(有则提取,无则跳过)
  44. optional:
  45. - "check_item"
  46. - "status"
  47. - "severity"
  48. - "category"
  49. # JSON内容验证规则
  50. content_validation:
  51. # 最小字段数量
  52. min_fields: 3
  53. # 必需字段
  54. required_fields: ["issue_point", "suggestion"]
  55. # 字段长度限制
  56. max_field_length: 1000
  57. # 字符编码验证
  58. encoding_check: true
  59. # 解析优先级
  60. parsing_priority:
  61. 1: "direct_json_patterns"
  62. 2: "code_block_patterns"
  63. 3: "special_patterns"
  64. 4: "text_fallback"
  65. # 风险等级映射
  66. risk_level_mapping:
  67. high_risk:
  68. - "高风险"
  69. - "high"
  70. - "严重"
  71. - "critical"
  72. medium_risk:
  73. - "中风险"
  74. - "medium"
  75. - "中等"
  76. - "一般"
  77. low_risk:
  78. - "低风险"
  79. - "low"
  80. - "轻微"
  81. - "minor"
  82. default: "medium_risk"
  83. # 错误处理策略
  84. error_handling:
  85. # JSON解析失败时的策略
  86. json_parse_failed:
  87. - "try_next_pattern"
  88. - "extract_keywords_manually"
  89. - "fallback_to_text"
  90. # 关键字缺失时的策略
  91. missing_keywords:
  92. - "extract_from_text"
  93. - "use_default_values"
  94. - "log_warning"