Refactor ClineMessage

This commit is contained in:
Saoud Rizwan
2024-10-06 00:19:44 -04:00
parent 7dd9abda46
commit d67523596b
7 changed files with 23 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
import { ClaudeMessage } from "./ExtensionMessage"
import { ClineMessage } from "./ExtensionMessage"
interface ApiMetrics {
totalTokensIn: number
@@ -9,13 +9,13 @@ interface ApiMetrics {
}
/**
* Calculates API metrics from an array of ClaudeMessages.
* Calculates API metrics from an array of ClineMessages.
*
* This function processes 'api_req_started' messages that have been combined with their
* corresponding 'api_req_finished' messages by the combineApiRequests function.
* It extracts and sums up the tokensIn, tokensOut, cacheWrites, cacheReads, and cost from these messages.
*
* @param messages - An array of ClaudeMessage objects to process.
* @param messages - An array of ClineMessage objects to process.
* @returns An ApiMetrics object containing totalTokensIn, totalTokensOut, totalCacheWrites, totalCacheReads, and totalCost.
*
* @example
@@ -25,7 +25,7 @@ interface ApiMetrics {
* const { totalTokensIn, totalTokensOut, totalCost } = getApiMetrics(messages);
* // Result: { totalTokensIn: 10, totalTokensOut: 20, totalCost: 0.005 }
*/
export function getApiMetrics(messages: ClaudeMessage[]): ApiMetrics {
export function getApiMetrics(messages: ClineMessage[]): ApiMetrics {
const result: ApiMetrics = {
totalTokensIn: 0,
totalTokensOut: 0,