aihezu 2.8.4 → 2.8.6
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/commands/usage.js +34 -0
- package/package.json +1 -1
package/commands/usage.js
CHANGED
|
@@ -318,6 +318,21 @@ function formatDurationMinutes(value) {
|
|
|
318
318
|
return `${human} (${minuteText} 分钟)`;
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
+
function formatNumber(value) {
|
|
322
|
+
const n = asNumber(value);
|
|
323
|
+
if (n === null) return '-';
|
|
324
|
+
return n.toLocaleString('en-US');
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function formatCompactNumber(value) {
|
|
328
|
+
const n = asNumber(value);
|
|
329
|
+
if (n === null) return '-';
|
|
330
|
+
if (n >= 1e9) return `${(n / 1e9).toFixed(2)}B`;
|
|
331
|
+
if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
|
|
332
|
+
if (n >= 1e3) return `${(n / 1e3).toFixed(1)}K`;
|
|
333
|
+
return String(n);
|
|
334
|
+
}
|
|
335
|
+
|
|
321
336
|
function renderBar(current, limit, width = 18) {
|
|
322
337
|
const c = asNumber(current);
|
|
323
338
|
const l = asNumber(limit);
|
|
@@ -419,6 +434,12 @@ function displayUsageStats(stats, origin, source) {
|
|
|
419
434
|
return l - c;
|
|
420
435
|
})();
|
|
421
436
|
|
|
437
|
+
// 提取请求次数和 Token 用量
|
|
438
|
+
const currentDailyRequests = (stats.currentDailyRequests !== undefined) ? stats.currentDailyRequests : limits.currentDailyRequests;
|
|
439
|
+
const currentDailyTokens = (stats.currentDailyTokens !== undefined) ? stats.currentDailyTokens : limits.currentDailyTokens;
|
|
440
|
+
const currentWindowRequests = (stats.currentWindowRequests !== undefined) ? stats.currentWindowRequests : limits.currentWindowRequests;
|
|
441
|
+
const currentWindowTokens = (stats.currentWindowTokens !== undefined) ? stats.currentWindowTokens : limits.currentWindowTokens;
|
|
442
|
+
|
|
422
443
|
console.log(`域名: ${origin}`);
|
|
423
444
|
console.log(`来源: ${source}`);
|
|
424
445
|
console.log('');
|
|
@@ -429,6 +450,12 @@ function displayUsageStats(stats, origin, source) {
|
|
|
429
450
|
if (dailyRemaining !== null) {
|
|
430
451
|
console.log(`日剩余: ${formatCost(dailyRemaining)}`);
|
|
431
452
|
}
|
|
453
|
+
if (asNumber(currentDailyRequests) !== null || asNumber(currentDailyTokens) !== null) {
|
|
454
|
+
const parts = [];
|
|
455
|
+
if (asNumber(currentDailyRequests) !== null) parts.push(`请求 ${formatNumber(currentDailyRequests)} 次`);
|
|
456
|
+
if (asNumber(currentDailyTokens) !== null) parts.push(`Token ${formatCompactNumber(currentDailyTokens)}`);
|
|
457
|
+
console.log(`日统计: ${parts.join(' | ')}`);
|
|
458
|
+
}
|
|
432
459
|
|
|
433
460
|
console.log('');
|
|
434
461
|
console.log(
|
|
@@ -438,6 +465,12 @@ function displayUsageStats(stats, origin, source) {
|
|
|
438
465
|
if (windowRemaining !== null) {
|
|
439
466
|
console.log(`窗口剩余: ${formatCost(windowRemaining)}`);
|
|
440
467
|
}
|
|
468
|
+
if (asNumber(currentWindowRequests) !== null || asNumber(currentWindowTokens) !== null) {
|
|
469
|
+
const parts = [];
|
|
470
|
+
if (asNumber(currentWindowRequests) !== null) parts.push(`请求 ${formatNumber(currentWindowRequests)} 次`);
|
|
471
|
+
if (asNumber(currentWindowTokens) !== null) parts.push(`Token ${formatCompactNumber(currentWindowTokens)}`);
|
|
472
|
+
console.log(`窗口统计: ${parts.join(' | ')}`);
|
|
473
|
+
}
|
|
441
474
|
const windowStartText = formatDateTime(windowStartTime);
|
|
442
475
|
const windowEndText = formatDateTime(windowEndTime);
|
|
443
476
|
if (windowStartText !== '-' || windowEndText !== '-') {
|
|
@@ -457,6 +490,7 @@ function displayUsageStats(stats, origin, source) {
|
|
|
457
490
|
if (resetCountdownText !== '-') {
|
|
458
491
|
console.log(`窗口剩余时间: ${resetCountdownText} (距重置)`);
|
|
459
492
|
}
|
|
493
|
+
|
|
460
494
|
console.log('');
|
|
461
495
|
}
|
|
462
496
|
|