MCPcopy
hub / github.com/coder/mux / resolveEncoding

Function resolveEncoding

src/node/utils/main/tokenizer.ts:121–139  ·  view source on GitHub ↗
(modelName: ModelName)

Source from the content-addressed store, hash-verified

119}
120
121function resolveEncoding(modelName: ModelName): Promise<string> {
122 let promise = encodingPromises.get(modelName);
123 if (!promise) {
124 promise = run<string>("encodingName", modelName)
125 .then((result: unknown) => {
126 assert(
127 typeof result === "string" && result.length > 0,
128 "Token encoding name must be a non-empty string"
129 );
130 return result;
131 })
132 .catch((error) => {
133 encodingPromises.delete(modelName);
134 throw error;
135 });
136 encodingPromises.set(modelName, promise);
137 }
138 return promise;
139}
140
141function buildCacheKey(modelName: ModelName, text: string): string {
142 const checksum = CRC32.str(text);

Callers 2

loadTokenizerModulesFunction · 0.85
getTokenizerForModelFunction · 0.85

Calls 5

runFunction · 0.90
setMethod · 0.80
getMethod · 0.65
assertFunction · 0.50
deleteMethod · 0.45

Tested by

no test coverage detected