🐛 fix: Tokens may not be counted in the stream below

This commit is contained in:
MartialBE
2024-05-31 14:03:06 +08:00
parent 05adacefff
commit acf61f8b89
9 changed files with 31 additions and 9 deletions

View File

@@ -376,3 +376,11 @@ type ChatCompletionStreamResponse struct {
PromptAnnotations any `json:"prompt_annotations,omitempty"`
Usage *Usage `json:"usage,omitempty"`
}
func (c *ChatCompletionStreamResponse) GetResponseText() (responseText string) {
for _, choice := range c.Choices {
responseText += choice.Delta.Content
}
return
}