improvement: azure api result transformation
This commit is contained in:
parent
3bfbd0bc2b
commit
9d5d4eb486
@ -40,6 +40,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]") {
|
||||
|
Loading…
Reference in New Issue
Block a user