MCPcopy
hub / github.com/continuedev/continue / pruneStringFromBottom

Function pruneStringFromBottom

core/llm/countTokens.ts:338–351  ·  view source on GitHub ↗
(
  modelName: string,
  maxTokens: number,
  prompt: string,
)

Source from the content-addressed store, hash-verified

336}
337
338function pruneStringFromBottom(
339 modelName: string,
340 maxTokens: number,
341 prompt: string,
342): string {
343 const encoding = encodingForModel(modelName);
344
345 const tokens = encoding.encode(prompt, "all", []);
346 if (tokens.length <= maxTokens) {
347 return prompt;
348 }
349
350 return encoding.decode(tokens.slice(0, maxTokens));
351}
352
353function pruneStringFromTop(
354 modelName: string,

Callers 2

trimSnippetForContextFunction · 0.90

Calls 3

encodingForModelFunction · 0.85
encodeMethod · 0.65
decodeMethod · 0.65

Tested by

no test coverage detected