From a86ec0bb4647617313f6c818f40cb4060b435679 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sat, 22 Mar 2025 20:37:47 -0700 Subject: [PATCH] remove more pre-indexed refs --- core/.eslintrc.json | 2 +- core/index.d.ts | 1 - core/indexing/docs/DocsService.ts | 82 +++++++++++-------- docs/docs/customize/deep-dives/docs.mdx | 4 +- gui/src/components/mainInput/getSuggestion.ts | 2 +- 5 files changed, 54 insertions(+), 37 deletions(-) diff --git a/core/.eslintrc.json b/core/.eslintrc.json index e541d57c1..633895fb7 100644 --- a/core/.eslintrc.json +++ b/core/.eslintrc.json @@ -14,7 +14,7 @@ "eqeqeq": "error", "complexity": ["error", { "max": 38 }], "max-lines-per-function": ["error", { "max": 996 }], - "max-statements": ["error", { "max": 112 }], + "max-statements": ["error", { "max": 114 }], "max-depth": ["error", { "max": 6 }], "max-nested-callbacks": ["error", { "max": 4 }], "max-params": ["error", { "max": 11 }] diff --git a/core/index.d.ts b/core/index.d.ts index 8d79da044..aa4040ad8 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -236,7 +236,6 @@ export interface SiteIndexingConfig { maxDepth?: number; faviconUrl?: string; useLocalCrawling?: boolean; - rootUrl?: string; // Currently only used by preindexed docs } export interface DocsIndexingDetails { diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index a10acb268..dedf80d6f 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -366,6 +366,44 @@ export default class DocsService { } } + /** + * Attempt to load document embeddings from cache + * @returns true if cache was successfully loaded, false otherwise + */ + private async tryLoadFromCache( + startUrl: string, + embeddingId: string, + siteIndexingConfig: SiteIndexingConfig, + ): Promise { + try { + const cacheHit = await this.tryFetchFromCache(startUrl, embeddingId); + + if (cacheHit) { + console.log(`Successfully loaded cached embeddings for ${startUrl}`); + // Update status to complete + this.handleStatusUpdate({ + type: "docs", + id: startUrl, + embeddingsProviderId: embeddingId, + isReindexing: false, + title: siteIndexingConfig.title, + debugInfo: "Loaded from cache", + icon: siteIndexingConfig.faviconUrl, + url: startUrl, + progress: 1, + description: "Complete", + status: "complete", + }); + return true; + } + } catch (e) { + console.log(`Error trying to fetch from cache: ${e}`); + // Continue with regular indexing + } + + return false; + } + async indexAndAdd( siteIndexingConfig: SiteIndexingConfig, forceReindex: boolean = false, @@ -387,39 +425,20 @@ export default class DocsService { // Try to fetch from cache first before crawling if (!forceReindex) { - try { - const cacheHit = await this.tryFetchFromCache( - startUrl, - provider.embeddingId, - ); - if (cacheHit) { - console.log(`Successfully loaded cached embeddings for ${startUrl}`); - // Update status to complete - this.handleStatusUpdate({ - type: "docs", - id: startUrl, - embeddingsProviderId: provider.embeddingId, - isReindexing: false, - title: siteIndexingConfig.title, - debugInfo: "Loaded from cache", - icon: siteIndexingConfig.faviconUrl, - url: startUrl, - progress: 1, - description: "Complete", - status: "complete", - }); - return; - } - } catch (e) { - console.log(`Error trying to fetch from cache: ${e}`); - // Continue with regular indexing + const cacheLoaded = await this.tryLoadFromCache( + startUrl, + provider.embeddingId, + siteIndexingConfig, + ); + + if (cacheLoaded) { + return; } } const startedWithEmbedder = provider.embeddingId; // Check if doc has been successfully indexed with the given embedder - // Note at this point we know it's not a pre-indexed doc const indexExists = await this.hasMetadata(startUrl); // Build status update - most of it is fixed values @@ -874,7 +893,7 @@ export default class DocsService { console.warn("Error retrieving chunks from LanceDB", e); } - // If no docs are found and this isn't a retry, try fetching from S3 cache + // If no docs are found and this isn't a retry, try fetching from cache if (docs.length === 0 && !isRetry) { try { // Try to fetch the document from the S3 cache @@ -941,10 +960,9 @@ export default class DocsService { return result.favicon; } - /* - Sync with no embeddings provider change - Ignores pre-indexed docs - */ + /** + * Sync with no embeddings provider change + */ private async syncDocs( oldConfig: ContinueConfig | undefined, newConfig: ContinueConfig, diff --git a/docs/docs/customize/deep-dives/docs.mdx b/docs/docs/customize/deep-dives/docs.mdx index 880d7516c..2431e0db3 100644 --- a/docs/docs/customize/deep-dives/docs.mdx +++ b/docs/docs/customize/deep-dives/docs.mdx @@ -242,7 +242,7 @@ You can also use the following IDE command to force a re-index of all docs: `Con ### VS Code minimal setup -The following configuration example works out of the box for VS Code. This uses the built-in embeddings provider with no reranking. Pre-indexed docs will be accessible. +The following configuration example works out of the box for VS Code. This uses the built-in embeddings provider with no reranking. @@ -276,7 +276,7 @@ The following configuration example works out of the box for VS Code. This uses ### Jetbrains minimal setup -Here is the equivalent minimal example for Jetbrains, which requires setting up an [embeddings provider](../model-roles/embeddings.mdx). Pre-indexed docs will _not_ be accessible. +Here is the equivalent minimal example for Jetbrains, which requires setting up an [embeddings provider](../model-roles/embeddings.mdx). diff --git a/gui/src/components/mainInput/getSuggestion.ts b/gui/src/components/mainInput/getSuggestion.ts index ab107f146..e96d67084 100644 --- a/gui/src/components/mainInput/getSuggestion.ts +++ b/gui/src/components/mainInput/getSuggestion.ts @@ -95,7 +95,7 @@ function getSubActionsForSubmenuItem( item: ContextSubmenuItem & { providerTitle: string }, ideMessenger: IIdeMessenger, ): ComboBoxSubAction[] | undefined { - if (item.providerTitle === "docs" && !item.metadata?.preIndexed) { + if (item.providerTitle === "docs") { return [ { label: "Open in new tab",