@agnishc/edb-global-footer 0.14.3 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/package.json +1 -1
- package/src/footer.ts +7 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/footer.ts
CHANGED
|
@@ -109,6 +109,7 @@ export function createFooterRenderer(
|
|
|
109
109
|
let totalCacheRead = 0;
|
|
110
110
|
let totalCacheWrite = 0;
|
|
111
111
|
let totalCost = 0;
|
|
112
|
+
let latestCacheHitRate: number | undefined;
|
|
112
113
|
|
|
113
114
|
for (const entry of ctx.sessionManager.getEntries()) {
|
|
114
115
|
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
@@ -119,12 +120,14 @@ export function createFooterRenderer(
|
|
|
119
120
|
totalCacheRead += msg.usage.cacheRead;
|
|
120
121
|
totalCacheWrite += msg.usage.cacheWrite;
|
|
121
122
|
totalCost += msg.usage.cost.total;
|
|
123
|
+
const promptTokens = msg.usage.input + msg.usage.cacheRead + msg.usage.cacheWrite;
|
|
124
|
+
latestCacheHitRate = promptTokens > 0 ? (msg.usage.cacheRead / promptTokens) * 100 : undefined;
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
127
|
|
|
125
128
|
// Build three groups separated by pipes
|
|
126
129
|
// Group 1: ↑input ↓output
|
|
127
|
-
// Group 2: Rcache Wcache $cost
|
|
130
|
+
// Group 2: Rcache Wcache CH% $cost
|
|
128
131
|
// Group 3: context%
|
|
129
132
|
const { tps } = tpsState;
|
|
130
133
|
const showTps = tps > 0;
|
|
@@ -139,6 +142,9 @@ export function createFooterRenderer(
|
|
|
139
142
|
const group2Parts: string[] = [];
|
|
140
143
|
if (totalCacheRead) group2Parts.push(`${iconCacheRead}${formatTokens(totalCacheRead)}`);
|
|
141
144
|
if (totalCacheWrite) group2Parts.push(`${iconCacheWrite}${formatTokens(totalCacheWrite)}`);
|
|
145
|
+
if ((totalCacheRead > 0 || totalCacheWrite > 0) && latestCacheHitRate !== undefined) {
|
|
146
|
+
group2Parts.push(`CH${latestCacheHitRate.toFixed(1)}%`);
|
|
147
|
+
}
|
|
142
148
|
const usingSubscription = ctx.model ? ctx.modelRegistry.isUsingOAuth(ctx.model) : false;
|
|
143
149
|
if (totalCost || usingSubscription) {
|
|
144
150
|
group2Parts.push(`$${totalCost.toFixed(3)}${usingSubscription ? " (sub)" : ""}`);
|