(messages []dto.ChatCompletionsStreamResponseChoice, model string)
| 412 | } |
| 413 | |
| 414 | func CountTokenStreamChoices(messages []dto.ChatCompletionsStreamResponseChoice, model string) int { |
| 415 | tokens := 0 |
| 416 | for _, message := range messages { |
| 417 | tkm := CountTokenInput(message.Delta.GetContentString(), model) |
| 418 | tokens += tkm |
| 419 | if message.Delta.ToolCalls != nil { |
| 420 | for _, tool := range message.Delta.ToolCalls { |
| 421 | tkm := CountTokenInput(tool.Function.Name, model) |
| 422 | tokens += tkm |
| 423 | tkm = CountTokenInput(tool.Function.Arguments, model) |
| 424 | tokens += tkm |
| 425 | } |
| 426 | } |
| 427 | } |
| 428 | return tokens |
| 429 | } |
| 430 | |
| 431 | func CountTTSToken(text string, model string) int { |
| 432 | if strings.HasPrefix(model, "tts") { |
nothing calls this directly
no test coverage detected