chore: update implementation

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

View File

@ -210,15 +210,16 @@ 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 {
if line[:5] == "data:" { continue
dataChan <- line[5:] }
if i != len(lines)-1 { if line[:5] == "data:" {
dataChan <- "\n" dataChan <- line[5:]
} if i != len(lines)-1 {
} else if line[:5] == "meta:" { dataChan <- "\n"
metaChan <- line[5:]
} }
} else if line[:5] == "meta:" {
metaChan <- line[5:]
} }
} }
} }