chore: update implementation
This commit is contained in:
parent
d8e8a654a2
commit
21804b7e2f
@ -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")
|
||||||
|
Loading…
Reference in New Issue
Block a user