Files
bifrost/core/providers/anthropic/count_tokens.go
Beyhan Oğur 880f412e2c first commit
2026-04-26 21:52:23 +03:00

35 lines
903 B
Go

package anthropic
import (
"github.com/maximhq/bifrost/core/schemas"
)
// ToBifrostCountTokensResponse converts an Anthropic count tokens response to Bifrost format
func (resp *AnthropicCountTokensResponse) ToBifrostCountTokensResponse(model string) *schemas.BifrostCountTokensResponse {
if resp == nil {
return nil
}
totalTokens := resp.InputTokens
bifrostResp := &schemas.BifrostCountTokensResponse{
Model: model,
InputTokens: resp.InputTokens,
TotalTokens: &totalTokens,
Object: "response.input_tokens",
}
return bifrostResp
}
// ToAnthropicCountTokensResponse converts a Bifrost count tokens response to Anthropic format.
func ToAnthropicCountTokensResponse(bifrostResp *schemas.BifrostCountTokensResponse) *AnthropicCountTokensResponse {
if bifrostResp == nil {
return nil
}
return &AnthropicCountTokensResponse{
InputTokens: bifrostResp.InputTokens,
}
}