结构修改

This commit is contained in:
renzhiyuan 2025-09-22 21:35:08 +08:00
parent 4b5f7355b6
commit ad58547eed
7 changed files with 15 additions and 14 deletions

View File

@ -78,13 +78,13 @@ func (r *AiRouterBiz) RouteWithSocket(c *websocket.Conn, req *entitys.ChatSockRe
if err != nil {
entitys.MsgSend(c, entitys.ResponseData{
Done: true,
Content: []byte(err.Error()),
Content: err.Error(),
Type: entitys.ResponseErr,
})
}
entitys.MsgSend(c, entitys.ResponseData{
Done: true,
Content: []byte(err.Error()),
Content: "",
Type: entitys.ResponseEnd,
})
err = r.channelPool.Put(ch)
@ -130,7 +130,7 @@ func (r *AiRouterBiz) RouteWithSocket(c *websocket.Conn, req *entitys.ChatSockRe
log.Info(match.Choices[0].Content)
ch <- entitys.ResponseData{
Done: false,
Content: []byte(match.Choices[0].Content),
Content: match.Choices[0].Content,
Type: entitys.ResponseLog,
}
var matchJson entitys.Match
@ -162,7 +162,7 @@ func (r *AiRouterBiz) RouteWithSocket(c *websocket.Conn, req *entitys.ChatSockRe
func (r *AiRouterBiz) handleOtherTask(c *websocket.Conn, ch chan entitys.ResponseData, matchJson *entitys.Match) (err error) {
ch <- entitys.ResponseData{
Done: false,
Content: []byte(matchJson.Reasoning),
Content: matchJson.Reasoning,
Type: entitys.ResponseText,
}
@ -174,7 +174,7 @@ func (r *AiRouterBiz) handleMatch(c *websocket.Conn, ch chan entitys.ResponseDat
if !matchJson.IsMatch {
ch <- entitys.ResponseData{
Done: false,
Content: []byte(matchJson.Reasoning),
Content: matchJson.Reasoning,
Type: entitys.ResponseText,
}
return

View File

@ -22,15 +22,16 @@ const (
type ResponseData struct {
Done bool
Content []byte
Content string
Type Response
}
func MsgSet(msgType Response, msg []byte, done bool) []byte {
func MsgSet(msgType Response, msg string, done bool) []byte {
jsonByte, err := json.Marshal(ResponseData{
Done: done,
Content: msg,
Type: msgType,
Type: msgType,
})
if err != nil {
return nil

View File

@ -76,7 +76,7 @@ func (c *Client) ChatStream(ctx context.Context, ch chan entitys.ResponseData, m
if resp.Message.Content != "" {
ch <- entitys.ResponseData{
Done: false,
Content: []byte(resp.Message.Content),
Content: resp.Message.Content,
Type: entitys.ResponseStream,
}
}

View File

@ -131,13 +131,13 @@ func (w *ZltxOrderDetailTool) getZltxOrderDetail(ch chan entitys.ResponseData, c
}
ch <- entitys.ResponseData{
Done: false,
Content: res.Content,
Content: res.Text,
Type: entitys.ResponseJson,
}
if resData.Data.Direct != nil && resData.Data.Direct["needAi"].(bool) {
ch <- entitys.ResponseData{
Done: false,
Content: []byte("正在分析订单日志"),
Content: "正在分析订单日志",
Type: entitys.ResponseLoading,
}

View File

@ -112,7 +112,7 @@ func (t *ZltxOrderLogTool) getZltxOrderLog(channel chan entitys.ResponseData, c
} else {
channel <- entitys.ResponseData{
Done: false,
Content: res.Content,
Content: res.Text,
Type: entitys.ResponseJson,
}
}

View File

@ -179,7 +179,7 @@ func (z ZltxProductTool) getZltxProduct(channel chan entitys.ResponseData, c *we
}
channel <- entitys.ResponseData{
Done: false,
Content: res.Content,
Content: res.Text,
Type: entitys.ResponseJson,
}
return nil

View File

@ -105,7 +105,7 @@ func (z ZltxOrderStatisticsTool) getZltxOrderStatistics(channel chan entitys.Res
} else {
channel <- entitys.ResponseData{
Done: false,
Content: res.Content,
Content: res.Text,
Type: entitys.ResponseJson,
}
}