🐛 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

@@ -189,6 +189,9 @@ func (h *CohereStreamHandler) convertToOpenaiStream(cohereResponse *CohereStream
Role: types.ChatMessageRoleAssistant,
Content: cohereResponse.Text,
}
h.Usage.CompletionTokens += common.CountTokenText(cohereResponse.Text, h.Request.Model)
h.Usage.TotalTokens = h.Usage.PromptTokens + h.Usage.CompletionTokens
}
chatCompletion := types.ChatCompletionStreamResponse{