* Removes sources and extensions from the index. * @param config The configuration containing the sources and extensions to remove.
(config)
| 266 | * @param config The configuration containing the sources and extensions to remove. |
| 267 | */ |
| 268 | remove(config) { |
| 269 | var _a; |
| 270 | return __awaiter(this, void 0, void 0, function* () { |
| 271 | if (!(yield this.isCreated())) { |
| 272 | throw new Error('Index has not been created yet. Please run `codepilot create` first.'); |
| 273 | } |
| 274 | // Ensure config loaded |
| 275 | const configPath = path.join(this.folderPath, 'config.json'); |
| 276 | if (!this._config) { |
| 277 | this._config = JSON.parse(yield fs.readFile(configPath, 'utf-8')); |
| 278 | } |
| 279 | // Clone config |
| 280 | const newConfig = Object.assign({}, this._config); |
| 281 | // Remove sources |
| 282 | if (Array.isArray(config.sources)) { |
| 283 | newConfig.sources = newConfig.sources.filter(source => !config.sources.includes(source)); |
| 284 | } |
| 285 | // Remove extensions |
| 286 | if (Array.isArray(config.extensions)) { |
| 287 | newConfig.extensions = (_a = newConfig.extensions) === null || _a === void 0 ? void 0 : _a.filter(extension => !config.extensions.includes(extension)); |
| 288 | } |
| 289 | // Write config |
| 290 | yield fs.writeFile(configPath, JSON.stringify(newConfig)); |
| 291 | this._config = newConfig; |
| 292 | }); |
| 293 | } |
| 294 | // LLM-REGION |
| 295 | /** |
| 296 | * Updates the OpenAI keys for the index. |