Capture token usage for conversation turns in telementry (#4703)
Adds capture of token usage data for conversation turns in the telemetry service. This includes tokensIn, tokensOut, cacheWriteTokens, cacheReadTokens, and totalCost. The changes involve: - Modifying the `captureConversationTurnEvent` method in `TelemetryService.ts` to accept and include token usage data in the captured event properties. - Updating the `Task` class in `src/core/task/index.ts` to pass token usage information when capturing conversation turn events. This ensures that token usage is tracked for both regular and cached responses. - Refactor capture event to use object destructuring for easier readability Co-authored-by: Beatrix Woo <beatrix@cline.bot>
This commit is contained in:
1 parent
6d2cf55fc5
commit
0262e13ac4
2 files changed
+32
-11
No files matched your search
@@ -2124,6 +2124,13 @@ export class Task {
|
||||
this.api.getModel().id,
|
||||
"assistant",
|
||||
true,
|
||||
{
|
||||
tokensIn: inputTokens,
|
||||
tokensOut: outputTokens,
|
||||
cacheWriteTokens,
|
||||
cacheReadTokens,
|
||||
totalCost,
|
||||
},
|
||||
)
|
||||
|
||||
// signals to provider that it can retrieve the saved messages from disk, as abortTask can not be awaited on in nature
|
||||
@@ -2297,6 +2304,13 @@ export class Task {
|
||||
this.api.getModel().id,
|
||||
"assistant",
|
||||
true,
|
||||
{
|
||||
tokensIn: inputTokens,
|
||||
tokensOut: outputTokens,
|
||||
cacheWriteTokens,
|
||||
cacheReadTokens,
|
||||
totalCost,
|
||||
},
|
||||
)
|
||||
|
||||
await this.messageStateHandler.addToApiConversationHistory({
|
||||
|
||||
Reference in new issue
Block a user