MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / estimateTokens

Function estimateTokens

src/diagnostics/token-analyzer.ts:75–78  ·  view source on GitHub ↗
(text: string | null | undefined)

Source from the content-addressed store, hash-verified

73 * we round to 4 for a stable baseline.
74 */
75export function estimateTokens(text: string | null | undefined): number {
76 if (!text) return 0;
77 return countTokens(text);
78}
79
80/** Estimate tokens for any JSON-serializable value (used for tool_calls). */
81export function estimateTokensJson(value: unknown): number {

Callers 1

analyzeMessagesFunction · 0.70

Calls 1

countTokensFunction · 0.85

Tested by

no test coverage detected