fix: pricing show 0 when it is defined (#1266)

This commit is contained in:
Ralph Khreish
2025-10-03 16:21:32 +02:00
committed by GitHub
parent 738ec51c04
commit f1393f47b1
3 changed files with 60 additions and 17 deletions

View File

@@ -2310,7 +2310,8 @@ function displayAiUsageSummary(telemetryData, outputType = 'cli') {
outputTokens,
totalTokens,
totalCost,
commandName
commandName,
isUnknownCost
} = telemetryData;
let summary = chalk.bold.blue('AI Usage Summary:') + '\n';
@@ -2320,7 +2321,10 @@ function displayAiUsageSummary(telemetryData, outputType = 'cli') {
summary += chalk.gray(
` Tokens: ${totalTokens} (Input: ${inputTokens}, Output: ${outputTokens})\n`
);
summary += chalk.gray(` Est. Cost: $${totalCost.toFixed(6)}`);
// Show "Unknown" if pricing data is not available, otherwise show the cost
const costDisplay = isUnknownCost ? 'Unknown' : `$${totalCost.toFixed(6)}`;
summary += chalk.gray(` Est. Cost: ${costDisplay}`);
console.log(
boxen(summary, {