Explorar o código

fix: ignore data if not have proper prefix

JustSong %!s(int64=2) %!d(string=hai) anos
pai
achega
8cbbeb784f
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      controller/relay-openai.go

+ 3 - 0
controller/relay-openai.go

@@ -34,6 +34,9 @@ func openaiStreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*O
 			if len(data) < 6 { // ignore blank line or wrong format
 				continue
 			}
+			if data[:6] != "data: " && data[:6] != "[DONE]" {
+				continue
+			}
 			dataChan <- data
 			data = data[6:]
 			if !strings.HasPrefix(data, "[DONE]") {