MCPcopy Index your code
hub / github.com/continuedev/continue / getAdjustedTokenCountFromModel

Function getAdjustedTokenCountFromModel

core/llm/getAdjustedTokenCount.ts:20–38  ·  view source on GitHub ↗
(
  baseTokens: number,
  modelName: string,
)

Source from the content-addressed store, hash-verified

18 * @returns Adjusted token count with safety buffer
19 */
20export function getAdjustedTokenCountFromModel(
21 baseTokens: number,
22 modelName: string,
23): number {
24 let multiplier = 1;
25 const lowerModelName = modelName?.toLowerCase() ?? "";
26 if (lowerModelName.includes("claude")) {
27 multiplier = ANTHROPIC_TOKEN_MULTIPLIER;
28 } else if (lowerModelName.includes("gemini")) {
29 multiplier = GEMINI_TOKEN_MULTIPLIER;
30 } else if (
31 lowerModelName.includes("stral") ||
32 lowerModelName.includes("mixtral")
33 ) {
34 // Mistral family models: mistral, mixtral, codestral, devstral, etc
35 multiplier = MISTRAL_TOKEN_MULTIPLIER;
36 }
37 return Math.ceil(baseTokens * multiplier);
38}

Callers 3

countTokensFunction · 0.85
countContentTokensFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected