Merge pull request #1 from byte911/return_usage

Return the usage info
This commit is contained in:
byte911 2024-09-06 15:18:29 +08:00 committed by GitHub
commit dfbbbab952
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -55,8 +55,8 @@ func StreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*model.E
render.StringData(c, data) // if error happened, pass the data to client
continue // just ignore the error
}
if len(streamResponse.Choices) == 0 {
// but for empty choice, we should not pass it to client, this is for azure
if len(streamResponse.Choices) == 0 && streamResponse.Usage == nil {
// but for empty choice and no usage, we should not pass it to client, this is for azure
continue // just ignore empty choice
}
render.StringData(c, data)