feat: show normalized prompt cache hit rates
Token usage previously showed cache reads and writes without a comparable hit rate. Activity usage now calculates a weighted cache hit rate using OpenAI-compatible input totals and Anthropic's separately reported input, cache-read, and cache-write tokens, then shows it in totals and grouped details. Release note: Token 用量统计新增缓存命中率,并针对 OpenAI 兼容接口与 Anthropic Messages 的不同上报口径进行归一化计算。
This commit is contained in:
@@ -2175,6 +2175,7 @@ describe('AssistantDatabase', () => {
|
||||
output: 25,
|
||||
cacheRead: 40,
|
||||
cacheWrite: 12,
|
||||
cacheInput: 177,
|
||||
totalTokens: 150
|
||||
},
|
||||
records: [
|
||||
@@ -2185,6 +2186,7 @@ describe('AssistantDatabase', () => {
|
||||
output: 25,
|
||||
cacheRead: 40,
|
||||
cacheWrite: 12,
|
||||
cacheInput: 177,
|
||||
totalTokens: 150
|
||||
})
|
||||
]
|
||||
@@ -2334,6 +2336,7 @@ describe('AssistantDatabase', () => {
|
||||
output: 105,
|
||||
cacheRead: 42,
|
||||
cacheWrite: 15,
|
||||
cacheInput: 312,
|
||||
totalTokens: 360
|
||||
})
|
||||
expect(summary.records).toHaveLength(3)
|
||||
@@ -2353,6 +2356,7 @@ describe('AssistantDatabase', () => {
|
||||
output: 60,
|
||||
cacheRead: 35,
|
||||
cacheWrite: 12,
|
||||
cacheInput: 197,
|
||||
totalTokens: 210
|
||||
}),
|
||||
expect.objectContaining({
|
||||
@@ -2684,6 +2688,7 @@ describe('AssistantDatabase', () => {
|
||||
output: 0,
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
cacheInput: 0,
|
||||
totalTokens: 0
|
||||
},
|
||||
records: []
|
||||
|
||||
Reference in New Issue
Block a user