* Loads the current code index.
()
| 231 | * Loads the current code index. |
| 232 | */ |
| 233 | public async load(): Promise<LocalDocumentIndex> { |
| 234 | if (!this._config) { |
| 235 | const configPath = path.join(this.folderPath, 'config.json'); |
| 236 | this._config = JSON.parse(await fs.readFile(configPath, 'utf-8')); |
| 237 | } |
| 238 | |
| 239 | if (!this._keys) { |
| 240 | const keysPath = path.join(this.folderPath, 'vectra.keys'); |
| 241 | this._keys = JSON.parse(await fs.readFile(keysPath, 'utf-8')); |
| 242 | } |
| 243 | |
| 244 | if (!this._index) { |
| 245 | const folderPath = path.join(this.folderPath, 'index'); |
| 246 | const embeddings = new OpenAIEmbeddings(Object.assign({ model: 'text-embedding-ada-002' }, this._keys)); |
| 247 | this._index = new LocalDocumentIndex({ |
| 248 | folderPath, |
| 249 | embeddings, |
| 250 | }); |
| 251 | } |
| 252 | |
| 253 | return this._index; |
| 254 | } |
| 255 | |
| 256 | // LLM-REGION |
| 257 |
no outgoing calls
no test coverage detected