token-stats-timer 1.0.17 → 1.0.18
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/package.json +1 -1
- package/token-stats.ts +18 -11
package/package.json
CHANGED
package/token-stats.ts
CHANGED
|
@@ -196,7 +196,7 @@ type QuotaError =
|
|
|
196
196
|
* Token 格式化(对齐 @firstpick/pi-utils formatTokens)
|
|
197
197
|
*/
|
|
198
198
|
function formatTokens(count: number): string {
|
|
199
|
-
if (count < 1000) return count.
|
|
199
|
+
if (count < 1000) return count.toFixed(1);
|
|
200
200
|
if (count < 10000) return `${(count / 1000).toFixed(1)}k`;
|
|
201
201
|
if (count < 1000000) return `${Math.round(count / 1000)}k`;
|
|
202
202
|
if (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;
|
|
@@ -1632,16 +1632,23 @@ export function createTokenStats(
|
|
|
1632
1632
|
records.sort((a, b) => a.hour - b.hour);
|
|
1633
1633
|
|
|
1634
1634
|
const lines = renderTable(
|
|
1635
|
-
["时间", "次数", "
|
|
1636
|
-
records.map((r) =>
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1635
|
+
["时间", "次数", "新增输入", "缓存输入", "输出", "总token", "命中率", "速率"],
|
|
1636
|
+
records.map((r) => {
|
|
1637
|
+
const totalPrompt = r.sumInput + r.sumCacheRead + r.sumCacheWrite;
|
|
1638
|
+
return [
|
|
1639
|
+
String(r.hour).padStart(2, "0"),
|
|
1640
|
+
String(r.count),
|
|
1641
|
+
formatTokens(r.sumInput),
|
|
1642
|
+
formatTokens(r.sumCacheRead),
|
|
1643
|
+
formatTokens(r.sumOutput),
|
|
1644
|
+
formatTokens(totalPrompt),
|
|
1645
|
+
`${weightedCacheHitRate(r).toFixed(1)}%`,
|
|
1646
|
+
`${(r.sumTokensPerSec / r.count).toFixed(1)}`,
|
|
1647
|
+
];
|
|
1648
|
+
}),
|
|
1649
|
+
{
|
|
1650
|
+
aligns: ["left", "right", "right", "right", "right", "right", "right", "right"],
|
|
1651
|
+
},
|
|
1645
1652
|
);
|
|
1646
1653
|
|
|
1647
1654
|
await showStats(lines, `按小时分布 | ${date}`, ctx);
|