(modelName: ModelName)
| 119 | } |
| 120 | |
| 121 | function 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 | |
| 141 | function buildCacheKey(modelName: ModelName, text: string): string { |
| 142 | const checksum = CRC32.str(text); |
no test coverage detected