fix: ignore data if not have proper prefix

This commit is contained in:
JustSong 2023-07-30 12:03:06 +08:00 committed by ckt1031
parent 003bbf1b95
commit 2663fbc51a

View File

@ -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]") {