Skip to content

Commit 3ad7adf

Browse files
committed
Add logging
1 parent 2e646e7 commit 3ad7adf

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/api/providers/workers/token-counter.worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ parentPort?.on("message", async (content: Array<ContentBlock>) => {
1010
const now = performance.now()
1111
const result = await countTokens(content)
1212
const duration = performance.now() - now
13-
console.log(`token count -> ${result} (${duration}ms)`)
13+
console.log(`[token-counter] token count -> ${result} (${duration}ms)`)
1414
parentPort?.postMessage(result)
1515
}
1616
} catch (error) {

src/core/sliding-window/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ export async function estimateTokenCount(
1717
content: Array<Anthropic.Messages.ContentBlockParam>,
1818
apiHandler: ApiHandler,
1919
): Promise<number> {
20-
if (!content || content.length === 0) return 0
21-
return apiHandler.countTokens(content)
20+
if (!content || content.length === 0) {
21+
return 0
22+
}
23+
24+
const now = performance.now()
25+
const count = await apiHandler.countTokens(content)
26+
const duration = performance.now() - now
27+
console.log(`[sliding-window] token count -> ${count} (${duration}ms)`)
28+
return count
2229
}
2330

2431
/**

0 commit comments

Comments
 (0)