This commit is contained in:
Pluto 2024-01-14 13:42:57 +08:00 committed by GitHub
commit 830acc9133
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,6 +37,14 @@ func openaiStreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*O
if data[:6] != "data: " && data[:6] != "[DONE]" {
continue
}
// Ignore invalid results in the first line of azure api results.
if c.GetInt("channel") == common.ChannelTypeAzure && !strings.HasPrefix(data[6:], "[DONE]") {
var streamResponse ChatCompletionsStreamResponse
err := json.Unmarshal([]byte(data[6:]), &streamResponse)
if err == nil && streamResponse.Id == "" {
continue
}
}
dataChan <- data
data = data[6:]
if !strings.HasPrefix(data, "[DONE]") {