From c37db35a33339ae06b454f8891a538fde81a30e0 Mon Sep 17 00:00:00 2001 From: cookeem Date: Mon, 13 Feb 2023 10:04:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=BB=E5=BE=AA=E7=8E=AFbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chat/service.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/chat/service.go b/chat/service.go index f132539..0fea5e1 100644 --- a/chat/service.go +++ b/chat/service.go @@ -4,15 +4,17 @@ import ( "context" "errors" "fmt" + "io" + "net/http" + "runtime" + "strings" + "sync" + "time" + "github.com/gin-gonic/gin" "github.com/google/uuid" "github.com/gorilla/websocket" gogpt "github.com/sashabaranov/go-gpt3" - "io" - "net/http" - "strings" - "sync" - "time" ) type Api struct { @@ -164,7 +166,7 @@ func (api *Api) GetChatMessage(conn *websocket.Conn, cli *gogpt.Client, mutex *s _ = conn.WriteJSON(chatMsg) mutex.Unlock() api.Logger.LogError(err.Error()) - return + break } if len(response.Choices) > 0 { @@ -189,8 +191,9 @@ func (api *Api) GetChatMessage(conn *websocket.Conn, cli *gogpt.Client, mutex *s i = i + 1 } if strResp != "" { - api.Logger.LogInfo(fmt.Sprintf("[RESPONSE] %s%s", requestMsg, strResp)) + api.Logger.LogInfo(fmt.Sprintf("[RESPONSE] %s", strResp)) } + runtime.GC() } func (api *Api) WsChat(c *gin.Context) {