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

28 lines
762 B
Go

package vertex
import (
"github.com/maximhq/bifrost/core/schemas"
)
func (resp *VertexCountTokensResponse) ToBifrostCountTokensResponse(model string) *schemas.BifrostCountTokensResponse {
if resp == nil {
return nil
}
inputDetails := &schemas.ResponsesResponseInputTokens{}
inputTokens := int(resp.TotalTokens) // Vertex response typically represents prompt tokens for countTokens
total := int(resp.TotalTokens)
if resp.CachedContentTokenCount > 0 {
inputDetails.CachedReadTokens = int(resp.CachedContentTokenCount)
}
return &schemas.BifrostCountTokensResponse{
Model: model,
Object: "response.input_tokens",
InputTokens: inputTokens,
InputTokensDetails: inputDetails,
TotalTokens: &total,
}
}