refactor(model): 重构模型网关实体和映射逻辑

This commit is contained in:
2026-06-12 17:50:22 +08:00
parent b3b111995e
commit 445ee02c5a
5 changed files with 152 additions and 162 deletions

View File

@@ -22,13 +22,13 @@ import (
// ParseAndValidate 解析并校验结果
func ParseAndValidate(raw map[string]any, model *entity.ModelGatewayModel) (map[string]any, error) {
// 1) 解析 content 字符串为 rounds 数组
contentVal, ok := raw[model.ResponseBody]
contentVal, ok := raw[entity.ResponseBody]
if !ok {
return raw, fmt.Errorf("字段 %s 不存在", model.ResponseBody)
return raw, fmt.Errorf("字段 %s 不存在", entity.ResponseBody)
}
contentStr, ok := contentVal.(string)
if !ok || strings.TrimSpace(contentStr) == "" {
return raw, fmt.Errorf("字段 %s 为空或不是字符串", model.ResponseBody)
return raw, fmt.Errorf("字段 %s 为空或不是字符串", entity.ResponseBody)
}
var arr []any
if err := json.Unmarshal([]byte(contentStr), &arr); err != nil {