🐛 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

@@ -131,6 +131,9 @@ func (h *mistralStreamHandler) handlerStream(rawLine *[]byte, dataChan chan stri
if mistralResponse.Usage != nil {
*h.Usage = *mistralResponse.Usage
} else {
h.Usage.CompletionTokens += common.CountTokenText(mistralResponse.GetResponseText(), h.Request.Model)
h.Usage.TotalTokens = h.Usage.PromptTokens + h.Usage.CompletionTokens
}
stop := false