MCPcopy Create free account
hub / github.com/coder/coder / calcCost

Function calcCost

coderd/x/chatd/chatcost/chatcost.go:69–71  ·  view source on GitHub ↗

calcCost returns the cost in fractional microdollars (millionths of a USD) for the given token count at the specified per-million-token price.

(tokens *int64, pricePerMillion *decimal.Decimal)

Source from the content-addressed store, hash-verified

67// calcCost returns the cost in fractional microdollars (millionths of a USD)
68// for the given token count at the specified per-million-token price.
69func calcCost(tokens *int64, pricePerMillion *decimal.Decimal) decimal.Decimal {
70 return decimal.NewFromInt(ptr.NilToEmpty(tokens)).Mul(ptr.NilToEmpty(pricePerMillion))
71}

Callers 1

CalculateTotalCostMicrosFunction · 0.85

Calls 1

NilToEmptyFunction · 0.92

Tested by

no test coverage detected