first commit
This commit is contained in:
27
core/providers/vertex/count_tokens.go
Normal file
27
core/providers/vertex/count_tokens.go
Normal file
@@ -0,0 +1,27 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user