Browse Source

wip:并发限制提交

wangkaiyue 2 years ago
parent
commit
6417f6175d
1 changed files with 2 additions and 4 deletions
  1. 2 4
      internal/model/ws.go

+ 2 - 4
internal/model/ws.go

@@ -119,6 +119,8 @@ func (m *WsChat) Handle(ws *ghttp.WebSocket, msg []byte) {
 		for {
 		for {
 			line, _, err := buf.ReadLine()
 			line, _, err := buf.ReadLine()
 			if err == io.EOF {
 			if err == io.EOF {
+				//放回链接池
+				ChatGptPool.Add()
 				replyId := ChatHistory.Save(m.Ctx, &ChatRecord{
 				replyId := ChatHistory.Save(m.Ctx, &ChatRecord{
 					Content:    lastData.Response,
 					Content:    lastData.Response,
 					Type:       2,
 					Type:       2,
@@ -140,10 +142,6 @@ func (m *WsChat) Handle(ws *ghttp.WebSocket, msg []byte) {
 	}
 	}
 }
 }
 
 
-func saveAndReturnMap() {
-
-}
-
 func parseEventStream(line []byte) (event string, date *BufRes) {
 func parseEventStream(line []byte) (event string, date *BufRes) {
 	// 如果行以 "event:" 开头,表示这是一个事件的标识符
 	// 如果行以 "event:" 开头,表示这是一个事件的标识符
 	if len(line) > 6 && string(line[:6]) == "event:" {
 	if len(line) > 6 && string(line[:6]) == "event:" {