* Adds a document to the index. * @param path Path to the document to add.
(path)
| 346 | * @param path Path to the document to add. |
| 347 | */ |
| 348 | upsertDocument(path) { |
| 349 | return __awaiter(this, void 0, void 0, function* () { |
| 350 | if (!(yield this.isCreated())) { |
| 351 | throw new Error('Index has not been created yet. Please run `codepilot create` first.'); |
| 352 | } |
| 353 | if (!(yield this.hasKeys())) { |
| 354 | throw new Error("A local vectra.keys file couldn't be found. Please run `codepilot set --key <your OpenAI key>`."); |
| 355 | } |
| 356 | // Ensure index is loaded |
| 357 | const index = yield this.load(); |
| 358 | // Fetch document |
| 359 | const fetcher = new vectra_1.FileFetcher(); |
| 360 | yield fetcher.fetch(path, (uri, text, docType) => __awaiter(this, void 0, void 0, function* () { |
| 361 | // Upsert document |
| 362 | yield index.upsertDocument(uri, text, docType); |
| 363 | return true; |
| 364 | })); |
| 365 | }); |
| 366 | } |
| 367 | } |
| 368 | exports.CodeIndex = CodeIndex; |
| 369 | //# sourceMappingURL=CodeIndex.js.map |
no test coverage detected