🐛 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

@@ -242,6 +242,8 @@ func (h *ClaudeStreamHandler) HandlerStream(rawLine *[]byte, dataChan chan strin
case "content_block_delta":
h.convertToOpenaiStream(&claudeResponse, dataChan)
h.Usage.CompletionTokens += common.CountTokenText(claudeResponse.Delta.Text, h.Request.Model)
h.Usage.TotalTokens = h.Usage.PromptTokens + h.Usage.CompletionTokens
default:
return