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

Class LlamaAsyncEncoder

core/llm/asyncEncoder.ts:11–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9}
10
11export class LlamaAsyncEncoder implements AsyncEncoder {
12 private workerPool: workerpool.Pool;
13
14 constructor() {
15 this.workerPool = workerpool.pool(
16 workerCodeFilePath("llamaTokenizerWorkerPool.mjs"),
17 );
18 }
19
20 async encode(text: string): Promise<number[]> {
21 return this.workerPool.exec("encode", [text]);
22 }
23
24 async decode(tokens: number[]): Promise<string> {
25 return this.workerPool.exec("decode", [tokens]);
26 }
27
28 // TODO: this should be called somewhere before exit or potentially with a shutdown hook
29 public async close(): Promise<void> {
30 await this.workerPool.terminate();
31 }
32}
33
34// this class does not yet do anything asynchronous
35export class GPTAsyncEncoder implements AsyncEncoder {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected