MCPcopy Create free account
hub / github.com/winfunc/opcode / estimateTokens

Function estimateTokens

src/components/ToolWidgets.tsx:1328–1331  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

1326
1327 // Count tokens approximation (very rough estimate)
1328 const estimateTokens = (str: string) => {
1329 // Rough approximation: ~4 characters per token
1330 return Math.ceil(str.length / 4);
1331 };
1332
1333 const inputTokens = hasInput ? estimateTokens(inputString) : 0;
1334

Callers 1

MCPWidgetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected