结构修改
This commit is contained in:
parent
1e1a479ab4
commit
8900ea6fbd
|
@ -149,17 +149,17 @@ func (r *AiRouterBiz) RouteWithSocket(c *websocket.Conn, req *entitys.ChatSockRe
|
|||
|
||||
sysInfo, err := r.getSysInfo(key)
|
||||
if err != nil {
|
||||
return errors.SysNotFound
|
||||
return errors.SysErr("获取系统信息失败:%v", err.Error())
|
||||
}
|
||||
|
||||
history, err := r.getSessionChatHis(session)
|
||||
if err != nil {
|
||||
return errors.SystemError
|
||||
return errors.SysErr("获取历史记录失败:%v", err.Error())
|
||||
}
|
||||
|
||||
task, err := r.getTasks(sysInfo.SysID)
|
||||
if err != nil {
|
||||
return errors.SystemError
|
||||
return errors.SysErr("获取任务列表失败:%v", err.Error())
|
||||
}
|
||||
|
||||
prompt := r.getPromptLLM(sysInfo, history, req.Text, task)
|
||||
|
@ -197,7 +197,8 @@ func (r *AiRouterBiz) RouteWithSocket(c *websocket.Conn, req *entitys.ChatSockRe
|
|||
}
|
||||
var matchJson entitys.Match
|
||||
if err := json.Unmarshal([]byte(resMsg), &matchJson); err != nil {
|
||||
return errors.SystemError
|
||||
return errors.SysErr("数据结构错误:%v", err.Error())
|
||||
|
||||
}
|
||||
|
||||
if err := r.handleMatch(ctx, c, ch, &matchJson, task, sysInfo); err != nil {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package errorcode
|
||||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
Success = &BusinessErr{code: 200, message: "成功"}
|
||||
ParamError = &BusinessErr{code: 401, message: "参数错误"}
|
||||
|
@ -40,6 +42,10 @@ func NewBusinessErr(code int, message string) *BusinessErr {
|
|||
return &BusinessErr{code: code, message: message}
|
||||
}
|
||||
|
||||
func SysErr(message string, arg ...any) *BusinessErr {
|
||||
return &BusinessErr{code: SystemError.code, message: fmt.Sprintf(message, arg)}
|
||||
}
|
||||
|
||||
func (e *BusinessErr) Wrap(err error) *BusinessErr {
|
||||
return NewBusinessErr(e.code, err.Error())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue