Skip to content

Commit f7e92f3

Browse files
committed
Add a fallback
1 parent 04462e5 commit f7e92f3

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/core/task/Task.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,19 +1440,21 @@ export class Task extends EventEmitter<ClineEvents> {
14401440
this.isStreaming = false
14411441
}
14421442

1443-
if (
1444-
inputTokens > 0 ||
1445-
outputTokens > 0 ||
1446-
cacheWriteTokens > 0 ||
1447-
cacheReadTokens > 0 ||
1448-
typeof totalCost !== "undefined"
1449-
) {
1443+
if (inputTokens > 0 || outputTokens > 0 || cacheWriteTokens > 0 || cacheReadTokens > 0) {
14501444
TelemetryService.instance.captureLlmCompletion(this.taskId, {
14511445
inputTokens,
14521446
outputTokens,
14531447
cacheWriteTokens,
14541448
cacheReadTokens,
1455-
cost: totalCost,
1449+
cost:
1450+
totalCost ??
1451+
calculateApiCostAnthropic(
1452+
this.api.getModel().info,
1453+
inputTokens,
1454+
outputTokens,
1455+
cacheWriteTokens,
1456+
cacheReadTokens,
1457+
),
14561458
})
14571459
}
14581460

0 commit comments

Comments
 (0)