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

Function asyncEncoderForModel

core/llm/countTokens.ts:56–71  ·  view source on GitHub ↗
(modelName: string)

Source from the content-addressed store, hash-verified

54const llamaAsyncEncoder = new LlamaAsyncEncoder();
55
56function asyncEncoderForModel(modelName: string): AsyncEncoder {
57 // Temporary due to issues packaging the worker files
58 if (process.env.IS_BINARY) {
59 const encoding = encodingForModel(modelName);
60 return new NonWorkerAsyncEncoder(encoding);
61 }
62
63 const modelType = autodetectTemplateType(modelName);
64 if (!modelType || modelType === "none") {
65 // Right now there is a problem packaging js-tiktoken in workers. Until then falling back
66 // Cannot find package 'js-tiktoken' imported from /Users/nate/gh/continuedev/continue/extensions/vscode/out/tiktokenWorkerPool.mjs
67 // return gptAsyncEncoder;
68 return llamaAsyncEncoder;
69 }
70 return llamaAsyncEncoder;
71}
72
73function encodingForModel(modelName: string): Encoding {
74 const modelType = autodetectTemplateType(modelName);

Callers 1

countTokensAsyncFunction · 0.85

Calls 2

encodingForModelFunction · 0.85
autodetectTemplateTypeFunction · 0.85

Tested by

no test coverage detected