|
@@ -86,7 +86,7 @@ func (m *WsChat) Handle(ws *ghttp.WebSocket, msg []byte) {
|
|
|
return reply, res, 0, nil
|
|
|
}
|
|
|
if reply == "" {
|
|
|
- reply, from = g.Cfg().MustGet(m.Ctx, "limit.emptyMsg").String(), -1
|
|
|
+ reply = g.Cfg().MustGet(m.Ctx, "limit.emptyMsg").String()
|
|
|
}
|
|
|
replyId := ChatHistory.Save(m.Ctx, &ChatRecord{
|
|
|
Content: reply,
|
|
@@ -121,8 +121,9 @@ func (m *WsChat) Handle(ws *ghttp.WebSocket, msg []byte) {
|
|
|
if err == io.EOF {
|
|
|
//放回链接池
|
|
|
ChatGptPool.Add()
|
|
|
+ finalReply := If(lastData.Response != "", lastData.Response, g.Cfg().MustGet(m.Ctx, "limit.emptyMsg").String()).(string)
|
|
|
replyId := ChatHistory.Save(m.Ctx, &ChatRecord{
|
|
|
- Content: lastData.Response,
|
|
|
+ Content: finalReply,
|
|
|
Type: 2,
|
|
|
Actions: 1,
|
|
|
QuestionId: questionId,
|
|
@@ -130,7 +131,7 @@ func (m *WsChat) Handle(ws *ghttp.WebSocket, msg []byte) {
|
|
|
Item: Answer_ChatGPT,
|
|
|
CreateTime: time.Now().Format(date.Date_Full_Layout),
|
|
|
})
|
|
|
- _ = ws.WriteJSON(g.Map{"error_code": 0, "error_msg": "", "data": g.Map{"id": encrypt.SE.Encode2Hex(fmt.Sprintf("%d", replyId)), "reply": lastData.Response, "isEnd": true}})
|
|
|
+ _ = ws.WriteJSON(g.Map{"error_code": 0, "error_msg": "", "data": g.Map{"id": encrypt.SE.Encode2Hex(fmt.Sprintf("%d", replyId)), "reply": finalReply, "isEnd": true}})
|
|
|
break
|
|
|
}
|
|
|
if _, data := parseEventStream(line); data != nil {
|