Adds token usage tracking for text cleanup requests
Enhances Anthropic API client to return token usage information Modifies cleanup service to capture and store input and output token counts from API responses Refactors request and response handling to extract and pass usage metrics Provides more detailed tracking of API request resource consumption
This commit is contained in:
2 files changed
+13
-7
No files matched your search
@@ -37,7 +37,7 @@ export class CleanupService {
|
||||
const startTime = Date.now();
|
||||
|
||||
try {
|
||||
const { cleanedText, commentary } = await this.client.cleanupText(
|
||||
const { cleanedText, commentary, usage } = await this.client.cleanupText(
|
||||
text,
|
||||
settings.model,
|
||||
settings.cleanupPrompt,
|
||||
@@ -53,8 +53,8 @@ export class CleanupService {
|
||||
timestamp: new Date(),
|
||||
model: settings.model,
|
||||
tokensUsed: {
|
||||
input: 0, // We don't have access to this from the response
|
||||
output: 0 // We don't have access to this from the response
|
||||
input: usage?.input_tokens ?? 0,
|
||||
output: usage?.output_tokens ?? 0
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user