chore: update implementation

This commit is contained in:
JustSong 2023-08-01 23:50:45 +08:00
parent d8e8a654a2
commit 21804b7e2f

View File

@ -210,7 +210,9 @@ func zhipuStreamHandler(c *gin.Context, resp *http.Response) (*OpenAIErrorWithSt
data := scanner.Text() data := scanner.Text()
lines := strings.Split(data, "\n") lines := strings.Split(data, "\n")
for i, line := range lines { for i, line := range lines {
if len(line) >= 5 { if len(line) < 5 {
continue
}
if line[:5] == "data:" { if line[:5] == "data:" {
dataChan <- line[5:] dataChan <- line[5:]
if i != len(lines)-1 { if i != len(lines)-1 {
@ -221,7 +223,6 @@ func zhipuStreamHandler(c *gin.Context, resp *http.Response) (*OpenAIErrorWithSt
} }
} }
} }
}
stopChan <- true stopChan <- true
}() }()
c.Writer.Header().Set("Content-Type", "text/event-stream") c.Writer.Header().Set("Content-Type", "text/event-stream")