结构修改
This commit is contained in:
parent
4b5f7355b6
commit
ad58547eed
|
@ -78,13 +78,13 @@ func (r *AiRouterBiz) RouteWithSocket(c *websocket.Conn, req *entitys.ChatSockRe
|
||||||
if err != nil {
|
if err != nil {
|
||||||
entitys.MsgSend(c, entitys.ResponseData{
|
entitys.MsgSend(c, entitys.ResponseData{
|
||||||
Done: true,
|
Done: true,
|
||||||
Content: []byte(err.Error()),
|
Content: err.Error(),
|
||||||
Type: entitys.ResponseErr,
|
Type: entitys.ResponseErr,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
entitys.MsgSend(c, entitys.ResponseData{
|
entitys.MsgSend(c, entitys.ResponseData{
|
||||||
Done: true,
|
Done: true,
|
||||||
Content: []byte(err.Error()),
|
Content: "",
|
||||||
Type: entitys.ResponseEnd,
|
Type: entitys.ResponseEnd,
|
||||||
})
|
})
|
||||||
err = r.channelPool.Put(ch)
|
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)
|
log.Info(match.Choices[0].Content)
|
||||||
ch <- entitys.ResponseData{
|
ch <- entitys.ResponseData{
|
||||||
Done: false,
|
Done: false,
|
||||||
Content: []byte(match.Choices[0].Content),
|
Content: match.Choices[0].Content,
|
||||||
Type: entitys.ResponseLog,
|
Type: entitys.ResponseLog,
|
||||||
}
|
}
|
||||||
var matchJson entitys.Match
|
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) {
|
func (r *AiRouterBiz) handleOtherTask(c *websocket.Conn, ch chan entitys.ResponseData, matchJson *entitys.Match) (err error) {
|
||||||
ch <- entitys.ResponseData{
|
ch <- entitys.ResponseData{
|
||||||
Done: false,
|
Done: false,
|
||||||
Content: []byte(matchJson.Reasoning),
|
Content: matchJson.Reasoning,
|
||||||
Type: entitys.ResponseText,
|
Type: entitys.ResponseText,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ func (r *AiRouterBiz) handleMatch(c *websocket.Conn, ch chan entitys.ResponseDat
|
||||||
if !matchJson.IsMatch {
|
if !matchJson.IsMatch {
|
||||||
ch <- entitys.ResponseData{
|
ch <- entitys.ResponseData{
|
||||||
Done: false,
|
Done: false,
|
||||||
Content: []byte(matchJson.Reasoning),
|
Content: matchJson.Reasoning,
|
||||||
Type: entitys.ResponseText,
|
Type: entitys.ResponseText,
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
@ -22,14 +22,15 @@ const (
|
||||||
|
|
||||||
type ResponseData struct {
|
type ResponseData struct {
|
||||||
Done bool
|
Done bool
|
||||||
Content []byte
|
Content string
|
||||||
Type Response
|
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{
|
jsonByte, err := json.Marshal(ResponseData{
|
||||||
Done: done,
|
Done: done,
|
||||||
Content: msg,
|
Content: msg,
|
||||||
|
|
||||||
Type: msgType,
|
Type: msgType,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -76,7 +76,7 @@ func (c *Client) ChatStream(ctx context.Context, ch chan entitys.ResponseData, m
|
||||||
if resp.Message.Content != "" {
|
if resp.Message.Content != "" {
|
||||||
ch <- entitys.ResponseData{
|
ch <- entitys.ResponseData{
|
||||||
Done: false,
|
Done: false,
|
||||||
Content: []byte(resp.Message.Content),
|
Content: resp.Message.Content,
|
||||||
Type: entitys.ResponseStream,
|
Type: entitys.ResponseStream,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,13 +131,13 @@ func (w *ZltxOrderDetailTool) getZltxOrderDetail(ch chan entitys.ResponseData, c
|
||||||
}
|
}
|
||||||
ch <- entitys.ResponseData{
|
ch <- entitys.ResponseData{
|
||||||
Done: false,
|
Done: false,
|
||||||
Content: res.Content,
|
Content: res.Text,
|
||||||
Type: entitys.ResponseJson,
|
Type: entitys.ResponseJson,
|
||||||
}
|
}
|
||||||
if resData.Data.Direct != nil && resData.Data.Direct["needAi"].(bool) {
|
if resData.Data.Direct != nil && resData.Data.Direct["needAi"].(bool) {
|
||||||
ch <- entitys.ResponseData{
|
ch <- entitys.ResponseData{
|
||||||
Done: false,
|
Done: false,
|
||||||
Content: []byte("正在分析订单日志"),
|
Content: "正在分析订单日志",
|
||||||
Type: entitys.ResponseLoading,
|
Type: entitys.ResponseLoading,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ func (t *ZltxOrderLogTool) getZltxOrderLog(channel chan entitys.ResponseData, c
|
||||||
} else {
|
} else {
|
||||||
channel <- entitys.ResponseData{
|
channel <- entitys.ResponseData{
|
||||||
Done: false,
|
Done: false,
|
||||||
Content: res.Content,
|
Content: res.Text,
|
||||||
Type: entitys.ResponseJson,
|
Type: entitys.ResponseJson,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ func (z ZltxProductTool) getZltxProduct(channel chan entitys.ResponseData, c *we
|
||||||
}
|
}
|
||||||
channel <- entitys.ResponseData{
|
channel <- entitys.ResponseData{
|
||||||
Done: false,
|
Done: false,
|
||||||
Content: res.Content,
|
Content: res.Text,
|
||||||
Type: entitys.ResponseJson,
|
Type: entitys.ResponseJson,
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -105,7 +105,7 @@ func (z ZltxOrderStatisticsTool) getZltxOrderStatistics(channel chan entitys.Res
|
||||||
} else {
|
} else {
|
||||||
channel <- entitys.ResponseData{
|
channel <- entitys.ResponseData{
|
||||||
Done: false,
|
Done: false,
|
||||||
Content: res.Content,
|
Content: res.Text,
|
||||||
Type: entitys.ResponseJson,
|
Type: entitys.ResponseJson,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue