mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-08-17 19:47:10 +08:00
32 lines
983 B
Go
32 lines
983 B
Go
package historymetrics
|
|
|
|
type Summary struct {
|
|
ProviderCallsTotal int `json:"providerCallsTotal"`
|
|
TurnsTotal int `json:"turnsTotal"`
|
|
ValidTurnsTotal int `json:"validTurnsTotal"`
|
|
InvalidTurnsTotal int `json:"invalidTurnsTotal"`
|
|
RequestTokensTotal int64 `json:"requestTokensTotal"`
|
|
PromptTokensTotal int64 `json:"promptTokensTotal"`
|
|
CacheReadTokens int64 `json:"cacheReadTokens"`
|
|
CacheWriteTokens int64 `json:"cacheWriteTokens"`
|
|
CacheHitRate *float64 `json:"cacheHitRate"`
|
|
}
|
|
|
|
type Totals struct {
|
|
InputTokens int64
|
|
OutputTokens int64
|
|
CacheReadTokens int64
|
|
CacheWriteTokens int64
|
|
PromptTokensTotal int64
|
|
RequestTokensTotal int64
|
|
}
|
|
|
|
func cacheHitRateFromTotals(totals Totals) *float64 {
|
|
inputCacheTokensTotal := totals.CacheReadTokens + totals.InputTokens
|
|
if inputCacheTokensTotal <= 0 {
|
|
return nil
|
|
}
|
|
value := float64(totals.CacheReadTokens) / float64(inputCacheTokensTotal)
|
|
return &value
|
|
}
|