Includes the current working directory changes. Historical commits and release binaries are excluded to limit Gitea storage. Source base: d7515973fbfd6dd2001fa156c483455b8081c7cb
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
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
|
|
// IncludeCacheWriteInHitRate 控制 CacheHitRate 分母是否计入缓存写入 Token。
|
|
IncludeCacheWriteInHitRate bool
|
|
}
|
|
|
|
func cacheHitRateFromTotals(totals Totals) *float64 {
|
|
inputCacheTokensTotal := totals.CacheReadTokens + totals.InputTokens
|
|
if totals.IncludeCacheWriteInHitRate {
|
|
inputCacheTokensTotal += totals.CacheWriteTokens
|
|
}
|
|
if inputCacheTokensTotal <= 0 {
|
|
return nil
|
|
}
|
|
value := float64(totals.CacheReadTokens) / float64(inputCacheTokensTotal)
|
|
return &value
|
|
}
|