refactor: 模型错误解析改为 ErrorMessageMapping 配置驱动

- parseModelError 按模型配置的 ErrorMessageMapping(schema 树)解析错误响应
- 成功判定: code 提取为空 / code 节点配置 defaultValue 且提取值等于它 → 成功
- 未配置 mapping 不识别错误(纯配置驱动), 删硬编码 ModelErrorResp/ModelError1Resp
- DTO 加 errorMessageMapping 字段, update.sql 建 error_message_mapping JSONB 列
- 单测: parse_error_test.go 覆盖扁平/嵌套/数组/纯字符串路径/未配置/坏 JSON
This commit is contained in:
2026-08-29 17:52:23 +08:00
parent 7dcfb6744d
commit 923644db2b
8 changed files with 341 additions and 35 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ LOOP:
}
docMsg := new(dto.ModelCallRes)
docMsg.TaskId = id
errCode, errMsg, err := parseModelError(modelRespBody)
errCode, errMsg, err := parseModelError(modelRespBody, modelInfo.ErrorMessageMapping)
if err != nil {
return nil, fmt.Errorf("模型返回参数解析失败:%v", err)
}