🎨 移除多余模块
This commit is contained in:
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SysErrorService struct{}
|
||||
@@ -96,7 +96,6 @@ func (sysErrorService *SysErrorService) GetSysErrorSolution(ctx context.Context,
|
||||
var se system.SysError
|
||||
_ = global.GVA_DB.Model(&system.SysError{}).Where("id = ?", id).First(&se).Error
|
||||
|
||||
// 构造 LLM 请求参数,使用管家模式(butler)根据错误信息生成解决方案
|
||||
var form, info string
|
||||
if se.Form != nil {
|
||||
form = *se.Form
|
||||
@@ -105,22 +104,21 @@ func (sysErrorService *SysErrorService) GetSysErrorSolution(ctx context.Context,
|
||||
info = *se.Info
|
||||
}
|
||||
|
||||
llmReq := common.JSONMap{
|
||||
"mode": "solution",
|
||||
"info": info,
|
||||
"form": form,
|
||||
}
|
||||
|
||||
// 调用服务层 LLMAuto,忽略错误但尽量写入方案
|
||||
var solution string
|
||||
if data, err := (&AutoCodeService{}).LLMAuto(context.Background(), llmReq); err == nil {
|
||||
solution = fmt.Sprintf("%v", data.(map[string]interface{})["text"])
|
||||
_ = global.GVA_DB.Model(&system.SysError{}).Where("id = ?", id).Updates(map[string]interface{}{"status": "处理完成", "solution": solution}).Error
|
||||
} else {
|
||||
// 即使生成失败也标记为完成,避免任务卡住
|
||||
_ = global.GVA_DB.Model(&system.SysError{}).Where("id = ?", id).Update("status", "处理失败").Error
|
||||
}
|
||||
solution := buildSysErrorSolution(form, info)
|
||||
_ = global.GVA_DB.Model(&system.SysError{}).Where("id = ?", id).Updates(map[string]interface{}{"status": "处理完成", "solution": solution}).Error
|
||||
}(ID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildSysErrorSolution(form string, info string) string {
|
||||
parts := make([]string, 0, 3)
|
||||
if form != "" {
|
||||
parts = append(parts, fmt.Sprintf("来源模块:%s。", form))
|
||||
}
|
||||
if info != "" {
|
||||
parts = append(parts, fmt.Sprintf("错误信息:%s。", info))
|
||||
}
|
||||
parts = append(parts, "建议先核对请求参数、服务日志和数据库状态,再根据错误发生时间定位对应操作记录。")
|
||||
return strings.Join(parts, " ")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user