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

Class GPTAsyncEncoder

core/llm/asyncEncoder.ts:35–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34// this class does not yet do anything asynchronous
35export class GPTAsyncEncoder implements AsyncEncoder {
36 private workerPool: workerpool.Pool;
37
38 constructor() {
39 this.workerPool = workerpool.pool(
40 workerCodeFilePath("tiktokenWorkerPool.mjs"),
41 );
42 }
43
44 async encode(text: string): Promise<number[]> {
45 return this.workerPool.exec("encode", [text]);
46 }
47
48 async decode(tokens: number[]): Promise<string> {
49 return this.workerPool.exec("decode", [tokens]);
50 }
51
52 // TODO: this should be called somewhere before exit or potentially with a shutdown hook
53 public async close(): Promise<void> {
54 await this.workerPool.terminate();
55 }
56}
57
58function workerCodeFilePath(workerFileName: string): string {
59 if (process.env.NODE_ENV === "test") {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected