Skip to content

Commit

Permalink
fix: reset buf when usage
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Feb 24, 2025
1 parent c345fb3 commit 1446064
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions service/aiproxy/relay/adaptor/openai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func StreamHandler(meta *meta.Meta, c *gin.Context, resp *http.Response) (*model
}
if streamResponse.Usage != nil {
usage = streamResponse.Usage
responseText.Reset()
}
for _, choice := range streamResponse.Choices {
if usage == nil {
Expand Down Expand Up @@ -139,6 +140,7 @@ func StreamHandler(meta *meta.Meta, c *gin.Context, resp *http.Response) (*model
}
if streamResponse.Usage != nil {
usage = streamResponse.Usage
responseText.Reset()
} else {
for _, choice := range streamResponse.Choices {
responseText.WriteString(choice.Text)
Expand Down

0 comments on commit 1446064

Please sign in to comment.