diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f7e1634f..73997880a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,7 +26,6 @@ - [Writing Context Providers](#writing-context-providers) - [Adding an LLM Provider](#adding-an-llm-provider) - [Adding Models](#adding-models) - - [Adding Pre-indexed Documentation](#adding-pre-indexed-documentation) - [📐 Continue Architecture](#-continue-architecture) - [Continue VS Code Extension](#continue-vs-code-extension) - [Continue JetBrains Extension](#continue-jetbrains-extension) @@ -212,10 +211,6 @@ While any model that works with a supported provider can be used with Continue, - LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Replicate](https://replicate.com/collections/streaming-language-models). - [Prompt Templates](./core/llm/index.ts) - In this file you'll find the `autodetectTemplateType` function. Make sure that for the model name you just added, this function returns the correct template type. This is assuming that the chat template for that model is already built in Continue. If not, you will have to add the template type and corresponding edit and chat templates. -### Adding Pre-indexed Documentation - -Continue's @docs context provider lets you easily reference entire documentation sites and then uses embeddings to add the most relevant pages to context. To make the experience as smooth as possible, we pre-index many of the most popular documentation sites. If you'd like to add new documentation to this list, just add an object to the list in [preIndexedDocs.ts](./core/indexing/docs/preIndexedDocs.ts). `startUrl` is where the crawler will start and `rootUrl` will filter out any pages not on that site and under the path of `rootUrl`. - ## 📐 Continue Architecture Continue consists of 2 parts that are split so that it can be extended to work in other IDEs as easily as possible: 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/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index 3b9fa0cf4..360e68670 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -9,7 +9,6 @@ import { LoadSubmenuItemsArgs, } from "../.."; import DocsService from "../../indexing/docs/DocsService"; -import preIndexedDocs from "../../indexing/docs/preIndexedDocs"; import { INSTRUCTIONS_BASE_ITEM } from "./utils"; @@ -64,23 +63,12 @@ class DocsContextProvider extends BaseContextProvider { return chunksCopy; } - private _sortByPreIndexedDocs( + private _sortAlphabetically( submenuItems: ContextSubmenuItem[], ): ContextSubmenuItem[] { - // Sort submenuItems such that the objects with titles which don't occur in configs occur first, and alphabetized + // Sort submenu items alphabetically by title return submenuItems.sort((a, b) => { - const aTitleInConfigs = a.metadata?.preIndexed ?? false; - const bTitleInConfigs = b.metadata?.preIndexed ?? false; - - // Primary criterion: Items not in configs come first - if (!aTitleInConfigs && bTitleInConfigs) { - return -1; - } else if (aTitleInConfigs && !bTitleInConfigs) { - return 1; - } else { - // Secondary criterion: Alphabetical order when both items are in the same category - return a.title.toString().localeCompare(b.title.toString()); - } + return a.title.toString().localeCompare(b.title.toString()); }); } @@ -165,13 +153,13 @@ class DocsContextProvider extends BaseContextProvider { } await docsService.isInitialized; - // Create map of docs url -> submenu item - const submenuItemsMap = new Map(); + // Create an array to hold submenu items + const submenuItems: ContextSubmenuItem[] = []; - // Add custom docs from config + // Get all indexed docs from the database const docs = (await docsService.listMetadata()) ?? []; for (const { startUrl, title, favicon } of docs) { - submenuItemsMap.set(startUrl, { + submenuItems.push({ title, id: startUrl, description: new URL(startUrl).hostname, @@ -179,32 +167,8 @@ class DocsContextProvider extends BaseContextProvider { }); } - // Add pre-indexed docs if supported - const canUsePreindexedDocs = await docsService.canUsePreindexedDocs(); - if (canUsePreindexedDocs) { - for (const { startUrl, title } of Object.values(preIndexedDocs)) { - // Skip if overridden in config - if (docs.find((d) => d.startUrl === startUrl)) { - continue; - } - submenuItemsMap.set(startUrl, { - title, - id: startUrl, - description: new URL(startUrl).hostname, - metadata: { - preIndexed: true, - }, - }); - } - } - - // Create array and sort if pre-indexed is supported - const submenuItems = Array.from(submenuItemsMap.values()); - if (canUsePreindexedDocs) { - return this._sortByPreIndexedDocs(submenuItems); - } - - return submenuItems; + // Sort alphabetically + return this._sortAlphabetically(submenuItems); } } diff --git a/core/index.d.ts b/core/index.d.ts index c7ac930ca..9c5ffe7aa 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 { @@ -244,7 +243,6 @@ export interface DocsIndexingDetails { config: SiteIndexingConfig; indexingStatus: IndexingStatus | undefined; chunks: Chunk[]; - isPreIndexedDoc: boolean; } export interface IContextProvider { diff --git a/core/indexing/docs/DocsCache.test.ts b/core/indexing/docs/DocsCache.test.ts new file mode 100644 index 000000000..341cd0229 --- /dev/null +++ b/core/indexing/docs/DocsCache.test.ts @@ -0,0 +1,25 @@ +import OpenAI from "../../llm/llms/OpenAI"; +import { DocsCache } from "./DocsCache"; // adjust import path as needed + +describe("DocsCache", () => { + let openAIEmbeddings: OpenAI; + + beforeAll(() => { + openAIEmbeddings = new OpenAI({ + apiKey: "", + model: "text-embedding-ada-002", + }); + }); + + test("normalizeEmbeddingId() produces a valid ID without constructor name", async () => { + // Get the embedding ID from OpenAI embeddings provider + const embeddingId = DocsCache.normalizeEmbeddingId( + openAIEmbeddings.embeddingId, + ); + + // The ID should not contain the constructor name (OpenAI) + expect(embeddingId).toEqual( + `${openAIEmbeddings.model}::${openAIEmbeddings.maxEmbeddingChunkSize}`, + ); + }); +}); diff --git a/core/indexing/docs/DocsCache.ts b/core/indexing/docs/DocsCache.ts new file mode 100644 index 000000000..f250b797c --- /dev/null +++ b/core/indexing/docs/DocsCache.ts @@ -0,0 +1,83 @@ +import request from "request"; +import { Chunk } from "../.."; + +export interface SiteIndexingResults { + chunks: (Chunk & { embedding: number[] })[]; + url: string; + title: string; +} + +export class DocsCache { + static readonly AWS_REGION: string = "us-west-1"; + static readonly BUCKET_NAME: string = "continue-preindexed-docs"; + + /** + * Normalizes an embedding ID by stripping the constructor name part. + * This is done because we don't care about the provider, just the + * model and the max embedding chunk size. + */ + static normalizeEmbeddingId(embeddingId: string): string { + // Split by "::" and remove the first part (constructor name) + const parts = embeddingId.split("::"); + if (parts.length <= 1) return embeddingId; // Return original if no "::" found + + // Return everything except the first part, joining with "::" + return parts.slice(1).join("::"); + } + + /** + * Gets the filepath for a given embedding ID and URL + */ + static getFilepathForEmbeddingIdAndUrl( + embeddingId: string, + url: string, + ): string { + const normalizedEmbeddingId = DocsCache.normalizeEmbeddingId(embeddingId); + const normalizedUrl = encodeURIComponent(url.replace(/\//g, "_")); + return normalizedEmbeddingId + "/" + normalizedUrl; + } + + /** + * Gets the fully qualified S3 URL for a given filepath + */ + private static getS3Url(filepath: string): string { + const pathname = filepath.split("/").map(encodeURIComponent).join("/"); + return `https://${this.BUCKET_NAME}.s3.${this.AWS_REGION}.amazonaws.com/${pathname}`; + } + + /** + * Downloads cached site indexing results from S3 for a given embedding ID and URL + * @param embeddingId The embedding ID + * @param url The URL of the document + * @returns The downloaded data as a string + */ + static async getDocsCacheForUrl( + embeddingId: string, + url: string, + ): Promise { + const filepath = DocsCache.getFilepathForEmbeddingIdAndUrl( + embeddingId, + url, + ); + + return new Promise((resolve, reject) => { + let data = ""; + const url = this.getS3Url(filepath); + const download = request({ + url, + }); + + download.on("response", (response: any) => { + if (response.statusCode !== 200) { + reject( + new Error("There was an error retrieving the pre-indexed doc"), + ); + } + }); + + download.on("error", (err: any) => reject(err)); + download.on("data", (chunk: any) => (data += chunk)); + download.on("end", () => resolve(data)); + }); + } +} diff --git a/core/indexing/docs/DocsService.skip.ts b/core/indexing/docs/DocsService.skip.ts index 682b76a23..6021fc260 100644 --- a/core/indexing/docs/DocsService.skip.ts +++ b/core/indexing/docs/DocsService.skip.ts @@ -1,156 +1,156 @@ -/** - * @jest-environment jsdom - */ -import { ConfigHandler } from "../../config/ConfigHandler.js"; -import { SiteIndexingConfig } from "../../index.js"; -import FileSystemIde from "../../util/filesystem.js"; -import { editConfigJson } from "../../util/paths.js"; +// /** +// * @jest-environment jsdom +// */ +// import { ConfigHandler } from "../../config/ConfigHandler.js"; +// import { SiteIndexingConfig } from "../../index.js"; +// import FileSystemIde from "../../util/filesystem.js"; +// import { editConfigJson } from "../../util/paths.js"; -import DocsService from "./DocsService.js"; -import preIndexedDocs from "./preIndexedDocs.js"; +// import DocsService from "./DocsService.js"; +// import preIndexedDocs from "./preIndexedDocs.js"; -describe.skip("DocsService Integration Tests", () => { - let ide: FileSystemIde; - let configHandler: ConfigHandler; - let docsService: DocsService; +// describe.skip("DocsService Integration Tests", () => { +// let ide: FileSystemIde; +// let configHandler: ConfigHandler; +// let docsService: DocsService; - const mockSiteConfig: SiteIndexingConfig = { - startUrl: "https://amplified.dev/", - title: "Test repo", - faviconUrl: "https://github.com/favicon.ico", - }; +// const mockSiteConfig: SiteIndexingConfig = { +// startUrl: "https://amplified.dev/", +// title: "Test repo", +// faviconUrl: "https://github.com/favicon.ico", +// }; - /** - * We need to reload config explicitly to handle the scenario where the - * config file update listeners are not called before we attempt to - * use the new config - */ - async function getReloadedConfig() { - await configHandler.reloadConfig(); - const latestConfig = await configHandler.loadConfig(); +// /** +// * We need to reload config explicitly to handle the scenario where the +// * config file update listeners are not called before we attempt to +// * use the new config +// */ +// async function getReloadedConfig() { +// await configHandler.reloadConfig(); +// const latestConfig = await configHandler.loadConfig(); - return latestConfig; - } +// return latestConfig; +// } - beforeEach(async () => { - ide = new FileSystemIde(process.cwd()); +// beforeEach(async () => { +// ide = new FileSystemIde(process.cwd()); - const ideSettingsPromise = Promise.resolve({ - remoteConfigSyncPeriod: 60, - userToken: "", - enableControlServerBeta: false, - continueTestEnvironment: "none" as const, - pauseCodebaseIndexOnStart: false, - ideSettings: {} as any, - enableDebugLogs: false, - remoteConfigServerUrl: "", - }); - configHandler = new ConfigHandler( - ide, - ideSettingsPromise, - async () => {}, - Promise.resolve(undefined), - ); +// const ideSettingsPromise = Promise.resolve({ +// remoteConfigSyncPeriod: 60, +// userToken: "", +// enableControlServerBeta: false, +// continueTestEnvironment: "none" as const, +// pauseCodebaseIndexOnStart: false, +// ideSettings: {} as any, +// enableDebugLogs: false, +// remoteConfigServerUrl: "", +// }); +// configHandler = new ConfigHandler( +// ide, +// ideSettingsPromise, +// async () => {}, +// Promise.resolve(undefined), +// ); - docsService = DocsService.createSingleton(configHandler, ide); +// docsService = DocsService.createSingleton(configHandler, ide); - await docsService.isInitialized; - }); +// await docsService.isInitialized; +// }); - test("Indexing, retrieval, and deletion of a new documentation site", async () => { - await docsService.indexAndAdd(mockSiteConfig); +// test("Indexing, retrieval, and deletion of a new documentation site", async () => { +// await docsService.indexAndAdd(mockSiteConfig); - let latestConfig = await getReloadedConfig(); +// let latestConfig = await getReloadedConfig(); - // Sqlite check - expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(true); +// // Sqlite check +// expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(true); - // config.json check - expect(latestConfig.config!.docs).toContainEqual(mockSiteConfig); +// // config.json check +// expect(latestConfig.config!.docs).toContainEqual(mockSiteConfig); - // Lance DB check - let retrievedChunks = await docsService.retrieveChunksFromQuery( - "test", - mockSiteConfig.startUrl, - 5, - ); +// // Lance DB check +// let retrievedChunks = await docsService.retrieveChunksFromQuery( +// "test", +// mockSiteConfig.startUrl, +// 5, +// ); - expect(retrievedChunks.length).toBeGreaterThan(0); +// expect(retrievedChunks.length).toBeGreaterThan(0); - await docsService.delete(mockSiteConfig.startUrl); +// await docsService.delete(mockSiteConfig.startUrl); - // Sqlite check - expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(false); +// // Sqlite check +// expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(false); - // config.json check - latestConfig = await getReloadedConfig(); - expect(latestConfig.config!.docs).not.toContainEqual( - expect.objectContaining(mockSiteConfig), - ); +// // config.json check +// latestConfig = await getReloadedConfig(); +// expect(latestConfig.config!.docs).not.toContainEqual( +// expect.objectContaining(mockSiteConfig), +// ); - // LanceDB check - retrievedChunks = await docsService.retrieveChunksFromQuery( - "test", - mockSiteConfig.startUrl, - 5, - ); - expect(retrievedChunks.length).toBe(0); - }); +// // LanceDB check +// retrievedChunks = await docsService.retrieveChunksFromQuery( +// "test", +// mockSiteConfig.startUrl, +// 5, +// ); +// expect(retrievedChunks.length).toBe(0); +// }); - // test("Reindexes when changing embeddings provider", async () => { - // const originalEmbeddingsProvider = - // await docsService.getEmbeddingsProvider(); +// // test("Reindexes when changing embeddings provider", async () => { +// // const originalEmbeddingsProvider = +// // await docsService.getEmbeddingsProvider(); - // // Change embeddings provider - // editConfigJson((config) => ({ - // ...config, - // embeddingsProvider: { - // provider: FreeTrial.providerName, - // }, - // })); +// // // Change embeddings provider +// // editConfigJson((config) => ({ +// // ...config, +// // embeddingsProvider: { +// // provider: FreeTrial.providerName, +// // }, +// // })); - // await getReloadedConfig(); +// // await getReloadedConfig(); - // const { provider, isPreindexed} = await docsService.getEmbeddingsProvider(); +// // const { provider, isPreindexed} = await docsService.getEmbeddingsProvider(); - // // Verify reindexing - // const [originalVector] = await originalEmbeddingsProvider.embed(["test"]); - // const [newMockVector] = await provider.embed(["test"]); +// // // Verify reindexing +// // const [originalVector] = await originalEmbeddingsProvider.embed(["test"]); +// // const [newMockVector] = await provider.embed(["test"]); - // expect(originalVector).not.toEqual(newMockVector); - // }); +// // expect(originalVector).not.toEqual(newMockVector); +// // }); - test("Handles pulling down and adding pre-indexed docs", async () => { - const preIndexedDoc = Object.values(preIndexedDocs)[0]; - await docsService.indexAndAdd(preIndexedDoc); - }); +// test("Handles pulling down and adding pre-indexed docs", async () => { +// const preIndexedDoc = Object.values(preIndexedDocs)[0]; +// await docsService.indexAndAdd(preIndexedDoc); +// }); - test("Config synchronization with SQLite", async () => { - await docsService.indexAndAdd(mockSiteConfig); +// test("Config synchronization with SQLite", async () => { +// await docsService.indexAndAdd(mockSiteConfig); - await getReloadedConfig(); +// await getReloadedConfig(); - expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(true); +// expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(true); - editConfigJson((config) => { - const { docs, ...restConfig } = config; - return restConfig; - }); +// editConfigJson((config) => { +// const { docs, ...restConfig } = config; +// return restConfig; +// }); - await getReloadedConfig(); +// await getReloadedConfig(); - const startTime = Date.now(); - const maxWaitTimeMs = 10_000; +// const startTime = Date.now(); +// const maxWaitTimeMs = 10_000; - while (docsService.isSyncing) { - if (Date.now() - startTime > maxWaitTimeMs) { - throw new Error( - `Timeout: docsService.isSyncing did not complete within within ${maxWaitTimeMs}ms`, - ); - } - await new Promise((resolve) => setTimeout(resolve, 100)); - } +// while (docsService.isSyncing) { +// if (Date.now() - startTime > maxWaitTimeMs) { +// throw new Error( +// `Timeout: docsService.isSyncing did not complete within within ${maxWaitTimeMs}ms`, +// ); +// } +// await new Promise((resolve) => setTimeout(resolve, 100)); +// } - expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(false); - }); -}); +// expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(false); +// }); +// }); diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 75f92b145..c4743fcd7 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -21,7 +21,7 @@ import DocsContextProvider from "../../context/providers/DocsContextProvider"; import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider"; import { FromCoreProtocol, ToCoreProtocol } from "../../protocol"; import { IMessenger } from "../../protocol/messenger"; -import { fetchFavicon, getFaviconBase64 } from "../../util/fetchFavicon"; +import { fetchFavicon } from "../../util/fetchFavicon"; import { GlobalContext } from "../../util/GlobalContext"; import { editConfigJson, @@ -37,15 +37,9 @@ import { } from "./article"; import DocsCrawler, { DocsCrawlerType, PageData } from "./crawlers/DocsCrawler"; import { runLanceMigrations, runSqliteMigrations } from "./migrations"; -import { - downloadFromS3, - getS3Filename, - S3Buckets, - SiteIndexingResults, -} from "./preIndexed"; -import preIndexedDocs from "./preIndexedDocs"; import type * as LanceType from "vectordb"; +import { DocsCache, SiteIndexingResults } from "./DocsCache"; // Purposefully lowercase because lancedb converts export interface LanceDbDocsRow { @@ -89,8 +83,7 @@ export default class DocsService { static lanceTableName = "docs"; static sqlitebTableName = "docs"; - static preIndexedDocsEmbeddingsProvider = - new TransformersJsEmbeddingsProvider(); + static defaultEmbeddingsProvider = new TransformersJsEmbeddingsProvider(); public isInitialized: Promise; public isSyncing: boolean = false; @@ -250,12 +243,8 @@ export default class DocsService { return false; } - /* - * Currently, we generate and host embeddings for pre-indexed docs using transformers. - * However, we don't ship transformers with the JetBrains extension. - * So, we only include pre-indexed docs in the submenu for non-JetBrains IDEs. - */ - async canUsePreindexedDocs() { + // Determine if transformers.js embeddings are supported in this environment + async canUseTransformersEmbeddings() { const ideInfo = await this.ideInfoPromise; if (ideInfo.ideType === "jetbrains") { return false; @@ -263,28 +252,26 @@ export default class DocsService { return true; } - // Determines if using preIndexed and returns proper embeddings provider - async getEmbeddingsProvider(startUrl: string) { - // Conditions for using a pre-indexed doc - - // Must be in pre indexed docs file - const preIndexedDoc = preIndexedDocs[startUrl]; - if (preIndexedDoc) { - // Most not be overriden by config - if (!this.config?.docs?.find((doc) => doc.startUrl === startUrl)) { - // Must be supported - const canUsePreindexedDocs = await this.canUsePreindexedDocs(); - if (canUsePreindexedDocs) { - return { - provider: DocsService.preIndexedDocsEmbeddingsProvider, - isPreindexed: true, - }; - } - } + // Get the appropriate embeddings provider + async getEmbeddingsProvider() { + // First check if there's a config selected embeddings provider + if (this.config.selectedModelByRole.embed) { + return { + provider: this.config.selectedModelByRole.embed, + }; } + + // Fall back to transformers if supported + const canUseTransformers = await this.canUseTransformersEmbeddings(); + if (canUseTransformers) { + return { + provider: DocsService.defaultEmbeddingsProvider, + }; + } + + // No provider available return { - provider: this.config.selectedModelByRole.embed, - isPreindexed: false, + provider: undefined, }; } @@ -379,6 +366,45 @@ 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, @@ -392,21 +418,28 @@ export default class DocsService { return; } - const { isPreindexed, provider } = - await this.getEmbeddingsProvider(startUrl); - if (isPreindexed) { - console.warn("Attempted to indexAndAdd pre-indexed doc"); - return; - } + const { provider } = await this.getEmbeddingsProvider(); if (!provider) { console.warn("@docs indexAndAdd: no embeddings provider found"); return; } + // Try to fetch from cache first before crawling + if (!forceReindex) { + 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 @@ -672,7 +705,12 @@ export default class DocsService { progress: 1, }); - void this.ide.showToast("info", `Successfully indexed ${startUrl}`); + // Only show notificaitons if the user manually re-indexed, otherwise + // they are too noisy, especially when switching embeddings providers + // and we automatically re-index all docs + if (forceReindex) { + void this.ide.showToast("info", `Successfully indexed ${startUrl}`); + } this.messenger?.send("refreshSubmenuItems", { providers: ["docs"], @@ -705,36 +743,42 @@ export default class DocsService { } } - // When user requests a pre-indexed doc for the first time - // And pre-indexed embeddings are supported - // Fetch pre-indexed embeddings from S3, add to Lance, and then search those - private async fetchAndAddPreIndexedDocEmbeddings(title: string) { - const data = await downloadFromS3( - S3Buckets.continueIndexedDocs, - getS3Filename( - DocsService.preIndexedDocsEmbeddingsProvider.embeddingId, - title, - ), - ); + /** + * Try to fetch embeddings from the S3 cache for any document URL + * @param startUrl The URL of the documentation site + * @param embeddingsProviderId The ID of the embeddings provider + * @returns True if cache hit and successfully loaded, false otherwise + */ + private async tryFetchFromCache( + startUrl: string, + embeddingId: string, + ): Promise { + try { + const data = await DocsCache.getDocsCacheForUrl(embeddingId, startUrl); - const siteEmbeddings = JSON.parse(data) as SiteIndexingResults; - const startUrl = new URL(siteEmbeddings.url).toString(); + // Parse the cached data + const siteEmbeddings = JSON.parse(data) as SiteIndexingResults; - const faviconUrl = preIndexedDocs[startUrl].faviconUrl; - const favicon = - typeof faviconUrl === "string" - ? await getFaviconBase64(faviconUrl) - : undefined; + // Try to get a favicon for the site + const favicon = await fetchFavicon(new URL(startUrl)); - await this.add({ - favicon, - siteIndexingConfig: { - startUrl, - title: siteEmbeddings.title, - }, - chunks: siteEmbeddings.chunks, - embeddings: siteEmbeddings.chunks.map((c) => c.embedding), - }); + // Add the cached embeddings to our database + await this.add({ + favicon, + siteIndexingConfig: { + startUrl, + title: siteEmbeddings.title || new URL(startUrl).hostname, + }, + chunks: siteEmbeddings.chunks, + embeddings: siteEmbeddings.chunks.map((c) => c.embedding), + }); + + return true; + } catch (e) { + // Cache miss or error - silently fail + console.log(`Cache miss for ${startUrl} with provider ${embeddingId}`); + return false; + } } // Retrieve docs embeds based on user input @@ -743,8 +787,7 @@ export default class DocsService { startUrl: string, nRetrieve: number, ) { - const { isPreindexed, provider } = - await this.getEmbeddingsProvider(startUrl); + const { provider } = await this.getEmbeddingsProvider(); if (!provider) { void this.ide.showToast( @@ -755,15 +798,11 @@ export default class DocsService { return []; } - if (isPreindexed) { - void Telemetry.capture("docs_pre_indexed_doc_used", { - doc: preIndexedDocs[startUrl]!["title"], - }); - } - + // Try to get embeddings for the query const [vector] = await provider.embed([query]); - return await this.retrieveChunks(startUrl, vector, nRetrieve, isPreindexed); + // Retrieve chunks using the query vector + return await this.retrieveChunks(startUrl, vector, nRetrieve); } private lanceDBRowToChunk(row: LanceDbDocsRow): Chunk { @@ -783,8 +822,7 @@ export default class DocsService { const db = await this.getOrCreateSqliteDb(); try { - const { isPreindexed, provider } = - await this.getEmbeddingsProvider(startUrl); + const { provider } = await this.getEmbeddingsProvider(); if (!provider) { throw new Error("No embeddings model set"); @@ -819,22 +857,26 @@ export default class DocsService { config: siteIndexingConfig, indexingStatus: this.statuses.get(startUrl), chunks: rows.map(this.lanceDBRowToChunk), - isPreIndexedDoc: isPreindexed, }; } catch (e) { console.warn("Error getting details", e); throw e; } } - // This is split into its own function so that it can be recursive - // in the case of fetching preindexed docs from s3 + // This function attempts to retrieve chunks by vector similarity + // It will also attempt to fetch from cache if no results are found async retrieveChunks( startUrl: string, vector: number[], nRetrieve: number, - isPreindexed: boolean, isRetry: boolean = false, ): Promise { + // Get the appropriate embeddings provider + const { provider } = await this.getEmbeddingsProvider(); + if (!provider) { + return []; + } + // Lance doesn't have an embeddingsprovider column, instead it includes it in the table name const table = await this.getOrCreateLanceTable({ initializationVector: vector, @@ -852,15 +894,22 @@ export default class DocsService { console.warn("Error retrieving chunks from LanceDB", e); } - // No docs are found for preindexed? try fetching once - if (docs.length === 0 && isPreindexed) { - if (isRetry) { - return []; + // 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 + const cacheHit = await this.tryFetchFromCache( + startUrl, + provider.embeddingId, + ); + + if (cacheHit) { + // If cache hit, retry the search once + return await this.retrieveChunks(startUrl, vector, nRetrieve, true); + } + } catch (e) { + console.warn("Error trying to fetch from cache:", e); } - await this.fetchAndAddPreIndexedDocEmbeddings( - preIndexedDocs[startUrl]!["title"], - ); - return await this.retrieveChunks(startUrl, vector, nRetrieve, true, true); } return docs.map(this.lanceDBRowToChunk); @@ -912,10 +961,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, @@ -933,11 +981,9 @@ export default class DocsService { const currentlyIndexedDocs = await this.listMetadata(); const currentStartUrls = currentlyIndexedDocs.map((doc) => doc.startUrl); - // Anything found in sqlite but not in new config should be deleted if not preindexed + // Anything found in sqlite but not in new config should be deleted const deletedDocs = currentlyIndexedDocs.filter( - (doc) => - !preIndexedDocs[doc.startUrl] && - !newConfigStartUrls.includes(doc.startUrl), + (doc) => !newConfigStartUrls.includes(doc.startUrl), ); // Anything found in old config, new config, AND sqlite that doesn't match should be reindexed @@ -1063,7 +1109,7 @@ export default class DocsService { const conn = await lance.connect(getLanceDbPath()); const tableNames = await conn.tableNames(); - const { provider } = await this.getEmbeddingsProvider(startUrl); + const { provider } = await this.getEmbeddingsProvider(); if (!provider) { throw new Error( diff --git a/core/indexing/docs/preIndexed.ts b/core/indexing/docs/preIndexed.ts deleted file mode 100644 index b66d21e70..000000000 --- a/core/indexing/docs/preIndexed.ts +++ /dev/null @@ -1,52 +0,0 @@ -import request from "request"; - -import { Chunk } from "../../"; - -export function getS3Filename( - embeddingsProviderId: string, - title: string, -): string { - return `_TransformersJsEmbeddingsProvider::all-MiniLM-L6-v2/${title}`; -} - -export enum S3Buckets { - continueIndexedDocs = "continue-indexed-docs", -} - -const AWS_REGION = "us-west-1"; - -export async function downloadFromS3( - bucket: string, - fileName: string, -): Promise { - return new Promise((resolve, reject) => { - let data = ""; - - const download = request({ - url: `https://${bucket}.s3.${AWS_REGION}.amazonaws.com/${fileName}`, - }); - download.on("response", (response: any) => { - if (response.statusCode !== 200) { - reject(new Error("There was an error retreiving the pre-indexed doc")); - } - }); - - download.on("error", (err: any) => { - reject(err); - }); - - download.on("data", (chunk: any) => { - data += chunk; - }); - - download.on("end", () => { - resolve(data); - }); - }); -} - -export interface SiteIndexingResults { - chunks: (Chunk & { embedding: number[] })[]; - url: string; - title: string; -} diff --git a/core/indexing/docs/preIndexedDocs.ts b/core/indexing/docs/preIndexedDocs.ts deleted file mode 100644 index 5342396fd..000000000 --- a/core/indexing/docs/preIndexedDocs.ts +++ /dev/null @@ -1,368 +0,0 @@ -import { SiteIndexingConfig } from "../../"; - -const preIndexedDocs: Record< - SiteIndexingConfig["startUrl"], - SiteIndexingConfig -> = { - "https://jinja.palletsprojects.com/en/3.1.x/": { - title: "Jinja", - startUrl: "https://jinja.palletsprojects.com/en/3.1.x/", - rootUrl: "https://jinja.palletsprojects.com/en/3.1.x/", - faviconUrl: "https://jinja.palletsprojects.com/favicon.ico", - }, - "https://react.dev/reference/": { - title: "React", - startUrl: "https://react.dev/reference/", - rootUrl: "https://react.dev/reference/", - faviconUrl: "https://react.dev/favicon.ico", - }, - "https://posthog.com/docs": { - title: "PostHog", - startUrl: "https://posthog.com/docs", - rootUrl: "https://posthog.com/docs", - faviconUrl: "https://posthog.com/favicon.ico", - }, - "https://expressjs.com/en/5x/api.html": { - title: "Express", - startUrl: "https://expressjs.com/en/5x/api.html", - rootUrl: "https://expressjs.com/en/5x/", - faviconUrl: "https://expressjs.com/favicon.ico", - }, - "https://platform.openai.com/docs/": { - title: "OpenAI", - startUrl: "https://platform.openai.com/docs/", - rootUrl: "https://platform.openai.com/docs/", - faviconUrl: "https://platform.openai.com/favicon.ico", - }, - "https://www.prisma.io/docs": { - title: "Prisma", - startUrl: "https://www.prisma.io/docs", - rootUrl: "https://www.prisma.io/docs", - faviconUrl: "https://www.prisma.io/favicon.ico", - }, - "https://boto3.amazonaws.com/v1/documentation/api/latest/index.html": { - title: "Boto3", - startUrl: - "https://boto3.amazonaws.com/v1/documentation/api/latest/index.html", - rootUrl: "https://boto3.amazonaws.com/v1/documentation/api/latest/", - faviconUrl: "https://boto3.amazonaws.com/favicon.ico", - }, - "https://pytorch.org/docs/stable/": { - title: "Pytorch", - startUrl: "https://pytorch.org/docs/stable/", - rootUrl: "https://pytorch.org/docs/stable/", - faviconUrl: "https://pytorch.org/favicon.ico", - }, - "https://redis.io/docs/": { - title: "Redis", - startUrl: "https://redis.io/docs/", - rootUrl: "https://redis.io/docs/", - faviconUrl: "https://redis.io/favicon.ico", - }, - "https://axios-http.com/docs/intro": { - title: "Axios", - startUrl: "https://axios-http.com/docs/intro", - rootUrl: "https://axios-http.com/docs", - faviconUrl: "https://axios-http.com/favicon.ico", - }, - "https://redwoodjs.com/docs/introduction": { - title: "Redwood JS", - startUrl: "https://redwoodjs.com/docs/introduction", - rootUrl: "https://redwoodjs.com/docs", - faviconUrl: "https://redwoodjs.com/favicon.ico", - }, - "https://graphql.org/learn/": { - title: "GraphQL", - startUrl: "https://graphql.org/learn/", - rootUrl: "https://graphql.org/learn/", - faviconUrl: "https://graphql.org/favicon.ico", - }, - "https://www.typescriptlang.org/docs/": { - title: "Typescript", - startUrl: "https://www.typescriptlang.org/docs/", - rootUrl: "https://www.typescriptlang.org/docs/", - faviconUrl: "https://www.typescriptlang.org/favicon.ico", - }, - "https://jestjs.io/docs/getting-started": { - title: "Jest", - startUrl: "https://jestjs.io/docs/getting-started", - rootUrl: "https://jestjs.io/docs", - faviconUrl: "https://jestjs.io/favicon.ico", - }, - "https://tailwindcss.com/docs/installation": { - title: "Tailwind CSS", - startUrl: "https://tailwindcss.com/docs/installation", - rootUrl: "https://tailwindcss.com/docs", - faviconUrl: "https://tailwindcss.com/favicon.ico", - }, - "https://vuejs.org/guide/introduction.html": { - title: "Vue.js", - startUrl: "https://vuejs.org/guide/introduction.html", - rootUrl: "https://vuejs.org", - faviconUrl: "https://vuejs.org/favicon.ico", - }, - "https://svelte.dev/docs/introduction": { - title: "Svelte", - startUrl: "https://svelte.dev/docs/introduction", - rootUrl: "https://svelte.dev/docs", - faviconUrl: "https://svelte.dev/favicon.ico", - }, - "https://docs.github.com/en/actions": { - title: "GitHub Actions", - startUrl: "https://docs.github.com/en/actions", - rootUrl: "https://docs.github.com/en/actions", - faviconUrl: "https://docs.github.com/favicon.ico", - }, - "https://nodejs.org/docs/latest/api/": { - title: "NodeJS", - startUrl: "https://nodejs.org/docs/latest/api/", - rootUrl: "https://nodejs.org/docs/latest/api/", - faviconUrl: "https://nodejs.org/favicon.ico", - }, - "https://socket.io/docs/v4/": { - title: "Socket.io", - startUrl: "https://socket.io/docs/v4/", - rootUrl: "https://socket.io/docs/v4/", - faviconUrl: "https://socket.io/favicon.ico", - }, - "https://docs.gradle.org/current/userguide/userguide.html": { - title: "Gradle", - startUrl: "https://docs.gradle.org/current/userguide/userguide.html", - rootUrl: "https://docs.gradle.org/current", - faviconUrl: "https://docs.gradle.org/favicon.ico", - }, - "https://redux-toolkit.js.org/introduction/getting-started": { - title: "Redux Toolkit", - startUrl: "https://redux-toolkit.js.org/introduction/getting-started", - rootUrl: "https://redux-toolkit.js.org", - faviconUrl: "https://redux-toolkit.js.org/favicon.ico", - }, - "https://docs.trychroma.com/": { - title: "Chroma", - startUrl: "https://docs.trychroma.com/", - rootUrl: "https://docs.trychroma.com/", - faviconUrl: "https://docs.trychroma.com/favicon.ico", - }, - "https://www.sqlite.org/docs.html": { - title: "SQLite", - startUrl: "https://www.sqlite.org/docs.html", - rootUrl: "https://www.sqlite.org", - faviconUrl: "https://www.sqlite.org/favicon.ico", - }, - "https://redux.js.org/introduction/getting-started": { - title: "Redux", - startUrl: "https://redux.js.org/introduction/getting-started", - rootUrl: "https://redux.js.org", - faviconUrl: "https://redux.js.org/favicon.ico", - }, - "https://prettier.io/docs/en/": { - title: "Prettier", - startUrl: "https://prettier.io/docs/en/", - rootUrl: "https://prettier.io/docs/en/", - faviconUrl: "https://prettier.io/favicon.ico", - }, - "https://code.visualstudio.com/api": { - title: "VS Code Extension API", - startUrl: "https://code.visualstudio.com/api", - rootUrl: "https://code.visualstudio.com/api", - faviconUrl: "https://code.visualstudio.com/favicon.ico", - }, - "https://docs.continue.dev/intro": { - title: "Continue", - startUrl: "https://docs.continue.dev/intro", - rootUrl: "https://docs.continue.dev", - faviconUrl: "https://docs.continue.dev/favicon.ico", - }, - "https://api.jquery.com/": { - title: "jQuery", - startUrl: "https://api.jquery.com/", - rootUrl: "https://api.jquery.com/", - faviconUrl: "https://api.jquery.com/favicon.ico", - }, - "https://docs.python.org/3/": { - title: "Python", - startUrl: "https://docs.python.org/3/", - rootUrl: "https://docs.python.org/3/", - faviconUrl: "https://docs.python.org/favicon.ico", - }, - "https://doc.rust-lang.org/book/": { - title: "Rust", - startUrl: "https://doc.rust-lang.org/book/", - rootUrl: "https://doc.rust-lang.org/book/", - faviconUrl: "https://doc.rust-lang.org/favicon.ico", - }, - "https://plugins.jetbrains.com/docs/intellij/welcome.html": { - title: "IntelliJ Platform SDK", - startUrl: "https://plugins.jetbrains.com/docs/intellij/welcome.html", - rootUrl: "https://plugins.jetbrains.com/docs/intellij", - faviconUrl: "https://plugins.jetbrains.com/favicon.ico", - }, - "https://docs.docker.com/": { - title: "Docker", - startUrl: "https://docs.docker.com/", - rootUrl: "https://docs.docker.com/", - faviconUrl: "https://docs.docker.com/favicon.ico", - }, - "https://docs.npmjs.com/": { - title: "NPM", - startUrl: "https://docs.npmjs.com/", - rootUrl: "https://docs.npmjs.com/", - faviconUrl: "https://docs.npmjs.com/favicon.ico", - }, - "https://tiptap.dev/docs/editor/introduction": { - title: "TipTap", - startUrl: "https://tiptap.dev/docs/editor/introduction", - rootUrl: "https://tiptap.dev/docs", - faviconUrl: "https://tiptap.dev/favicon.ico", - }, - "https://esbuild.github.io/": { - title: "esbuild", - startUrl: "https://esbuild.github.io/", - rootUrl: "https://esbuild.github.io/", - faviconUrl: "https://esbuild.github.io/favicon.ico", - }, - "https://tree-sitter.github.io/tree-sitter/": { - title: "Tree Sitter", - startUrl: "https://tree-sitter.github.io/tree-sitter/", - rootUrl: "https://tree-sitter.github.io/tree-sitter/", - faviconUrl: "https://tree-sitter.github.io/favicon.ico", - }, - "https://docs.netlify.com/": { - title: "Netlify", - startUrl: "https://docs.netlify.com/", - rootUrl: "https://docs.netlify.com/", - faviconUrl: "https://docs.netlify.com/favicon.ico", - }, - "https://replicate.com/docs": { - title: "Replicate", - startUrl: "https://replicate.com/docs", - rootUrl: "https://replicate.com/docs", - faviconUrl: "https://replicate.com/favicon.ico", - }, - "https://www.w3schools.com/html/default.asp": { - title: "HTML", - startUrl: "https://www.w3schools.com/html/default.asp", - rootUrl: "https://www.w3schools.com/html", - faviconUrl: "https://www.w3schools.com/favicon.ico", - }, - "https://www.w3schools.com/css/default.asp": { - title: "CSS", - startUrl: "https://www.w3schools.com/css/default.asp", - rootUrl: "https://www.w3schools.com/css", - faviconUrl: "https://www.w3schools.com/favicon.ico", - }, - "https://python.langchain.com/docs/get_started/introduction": { - title: "Langchain", - startUrl: "https://python.langchain.com/docs/get_started/introduction", - rootUrl: "https://python.langchain.com/docs", - faviconUrl: "https://python.langchain.com/favicon.ico", - }, - "https://developer.woocommerce.com/docs/": { - title: "WooCommerce", - startUrl: "https://developer.woocommerce.com/docs/", - rootUrl: "https://developer.woocommerce.com/docs/", - faviconUrl: "https://developer.woocommerce.com/favicon.ico", - }, - "https://developer.wordpress.org/reference/": { - title: "WordPress", - startUrl: "https://developer.wordpress.org/reference/", - rootUrl: "https://developer.wordpress.org/reference/", - faviconUrl: "https://developer.wordpress.org/favicon.ico", - }, - "https://doc.qt.io/qtforpython-6/quickstart.html": { - title: "PySide6", - startUrl: "https://doc.qt.io/qtforpython-6/quickstart.html", - rootUrl: "https://doc.qt.io/qtforpython-6/api.html", - faviconUrl: "https://doc.qt.io/favicon.ico", - }, - "https://getbootstrap.com/docs/5.3/getting-started/introduction/": { - title: "Bootstrap", - startUrl: "https://getbootstrap.com/docs/5.3/getting-started/introduction/", - rootUrl: "https://getbootstrap.com/docs/5.3/", - faviconUrl: "https://getbootstrap.com/favicon.ico", - }, - "https://alpinejs.dev/start-here": { - title: "Alpine.js", - startUrl: "https://alpinejs.dev/start-here", - rootUrl: "https://alpinejs.dev/", - faviconUrl: "https://alpinejs.dev/favicon.ico", - }, - "https://learn.microsoft.com/en-us/dotnet/csharp/": { - title: "C# Language Reference", - startUrl: "https://learn.microsoft.com/en-us/dotnet/csharp/", - rootUrl: "https://learn.microsoft.com/en-us/dotnet/csharp/", - faviconUrl: "https://learn.microsoft.com/favicon.ico", - }, - "https://docs.godotengine.org/en/latest/": { - title: "Godot", - startUrl: "https://docs.godotengine.org/en/latest/", - rootUrl: "https://docs.godotengine.org/en/latest/", - faviconUrl: "https://godotengine.org/favicon.ico", - }, - "https://docs.amplify.aws/react/start/": { - title: "AWS Amplify (Gen 2)", - startUrl: "https://docs.amplify.aws/react/start/", - rootUrl: "https://docs.amplify.aws/react/", - faviconUrl: "https://docs.amplify.aws/favicon.ico", - }, - "https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/": { - title: "AWS SDK for JavaScript v3", - startUrl: "https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/", - rootUrl: "https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/", - faviconUrl: "https://docs.aws.amazon.com/favicon.ico", - }, - "https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html": { - title: "AWS CDK v2", - startUrl: - "https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html", - rootUrl: "https://docs.aws.amazon.com/cdk/api/v2/docs/", - faviconUrl: "https://docs.aws.amazon.com/cdk/api/v2/img/favicon-32x32.png", - }, - "https://awscli.amazonaws.com/v2/documentation/api/latest/index.html": { - title: "AWS CLI commands", - startUrl: - "https://awscli.amazonaws.com/v2/documentation/api/latest/index.html", - rootUrl: "https://awscli.amazonaws.com/v2/documentation/api/latest/", - faviconUrl: "https://docs.aws.amazon.com/favicon.ico", - }, - "https://llama-stack.readthedocs.io/": { - title: "Llama Stack", - startUrl: "https://llama-stack.readthedocs.io/", - rootUrl: "https://llama-stack.readthedocs.io/", - }, - "https://go.dev/doc": { - title: "Go", - startUrl: "https://go.dev/doc", - rootUrl: "https://go.dev", - faviconUrl: "https://go.dev/favicon.ico", - }, - "https://api.flutter.dev": { - title: "Flutter", - startUrl: "https://api.flutter.dev", - rootUrl: "https://api.flutter.dev", - faviconUrl: "https://api.flutter.dev/flutter/static-assets/favicon.png", - }, - "https://api.dart.dev": { - title: "Dart", - startUrl: "https://api.dart.dev", - rootUrl: "https://api.dart.dev", - faviconUrl: "https://api.dart.dev/static-assets/favicon.png", - }, - "https://docs.asksage.ai/": { - title: "Ask Sage", - startUrl: "https://docs.asksage.ai/", - rootUrl: "https://docs.asksage.ai/", - }, - "https://angular.dev/": { - title: "Angular", - startUrl: "https://angular.dev/", - rootUrl: "https://angular.dev/", - }, - "https://docs.djangoproject.com/": { - title: "Django", - startUrl: "https://docs.djangoproject.com/", - rootUrl: "https://docs.djangoproject.com/", - } -}; - -export default preIndexedDocs; diff --git a/docs/docs/customize/deep-dives/docs.mdx b/docs/docs/customize/deep-dives/docs.mdx index ee806263e..2431e0db3 100644 --- a/docs/docs/customize/deep-dives/docs.mdx +++ b/docs/docs/customize/deep-dives/docs.mdx @@ -54,12 +54,6 @@ The `@Docs` context provider works by 3. Storing the embeddings locally on your machine 4. Embedding chat input to include similar documentation chunks as context -## Pre-indexed Documentation Sites - -In VS Code, Continue offers a selection of pre-indexed documentation sites for popular frameworks and libraries. You can view the list of [available pre-indexed sites and request additions here](https://github.com/continuedev/continue/blob/main/core/indexing/docs/preIndexedDocs.ts). - -Pre-indexed docs are only available in VS Code because the VS Code extension ships with the Transformers.js embedder built in, while Jetbrains currently does not. You can override a pre-indexed doc to index it with your own embeddings provider by adding it to your config (unique by `startUrl`). Otherwise, it will always use Transformers.js for queries. - ## Indexing Your Own Documentation ### Hub `docs` Blocks @@ -248,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. @@ -282,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/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/docs.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/docs.md index e14ac4afc..151eb87e8 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/docs.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/docs.md @@ -31,12 +31,6 @@ toc_max_heading_level: 5 3. 本地保存嵌入在你的机器上 4. 通过 `@Docs` 上下文提供者提供访问索引内容 -## 预先索引文档网站 - -我们提供一个流行的框架和库的预先索引文档网站的选择。你可以 [在这里查看可用的预先索引网站和请求附加内容](https://github.com/continuedev/continue/blob/main/core/indexing/docs/preIndexedDocs.ts) 列表。 - -## 索引你自己的文档 - ### 通过 `@Docs` 上下文提供者 为了添加一个单独的文档网站,我们推荐使用 `@Docs` 上下文提供者。 diff --git a/gui/src/components/dialogs/AddDocsDialog.tsx b/gui/src/components/dialogs/AddDocsDialog.tsx index 754c2bbc7..504ac94a8 100644 --- a/gui/src/components/dialogs/AddDocsDialog.tsx +++ b/gui/src/components/dialogs/AddDocsDialog.tsx @@ -84,8 +84,8 @@ function AddDocsDialog() {

Add documentation

Add docs

-

- For the @docs context provider +

+ Common documentation sites are cached for faster loading

@@ -157,14 +157,9 @@ function AddDocsDialog() { {docsIndexingStatuses.length > 0 && ( <> -
-
- -

- Closing this dialog will not affect indexing progress -

-
-
+

+ Closing this dialog will not affect indexing progress +

)}
diff --git a/gui/src/components/mainInput/AtMentionDropdown/index.tsx b/gui/src/components/mainInput/AtMentionDropdown/index.tsx index 0b354d902..beeb37070 100644 --- a/gui/src/components/mainInput/AtMentionDropdown/index.tsx +++ b/gui/src/components/mainInput/AtMentionDropdown/index.tsx @@ -175,7 +175,7 @@ const AtMentionDropdown = forwardRef((props: AtMentionDropdownProps, ref) => { tr.delete(start, tr.selection.from).scrollIntoView(), ); }, - description: "Add a new documentation source", + description: "", }); } else if (subMenuTitle === ".prompt files") { items.push({ diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsDetailsDialog.tsx b/gui/src/components/mainInput/Lump/sections/docs/DocsDetailsDialog.tsx index 3c91946b3..d9faee814 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/DocsDetailsDialog.tsx +++ b/gui/src/components/mainInput/Lump/sections/docs/DocsDetailsDialog.tsx @@ -65,8 +65,7 @@ function DocsDetailsDialog({ startUrl }: DocsDetailsDialogProps) { if (data) { comp = (
-

{`Title: ${data.config.title}`}

-

{`Pre-indexed doc: ${data.isPreIndexedDoc}`}

+

{`Title: ${data.config.title}`}

{!data.chunks?.length ? (
No article chunks
) : ( diff --git a/gui/src/components/mainInput/tiptap/getSuggestion.ts b/gui/src/components/mainInput/tiptap/getSuggestion.ts index 27963aab9..264258dd5 100644 --- a/gui/src/components/mainInput/tiptap/getSuggestion.ts +++ b/gui/src/components/mainInput/tiptap/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", diff --git a/gui/src/context/SubmenuContextProviders.tsx b/gui/src/context/SubmenuContextProviders.tsx index 7a876c3c0..c89a67972 100644 --- a/gui/src/context/SubmenuContextProviders.tsx +++ b/gui/src/context/SubmenuContextProviders.tsx @@ -279,20 +279,28 @@ export const SubmenuContextProvidersProvider = ({ const itemsWithProvider = submenuItems.map((item) => ({ ...item, providerTitle, - renderInlineAs + renderInlineAs, })); const minisearch = new MiniSearch( { fields: ["title", "description"], storeFields: ["id", "title", "description", "providerTitle"], - tokenize: text => deduplicateArray(MiniSearch.getDefault('tokenize')(text).concat(splitCamelCaseAndNonAlphaNumeric(text)), (a, b) => a === b) + tokenize: (text) => + deduplicateArray( + MiniSearch.getDefault("tokenize")(text).concat( + splitCamelCaseAndNonAlphaNumeric(text), + ), + (a, b) => a === b, + ), }, ); - minisearch.addAll( + const deduplicatedItems = deduplicateArray( submenuItems.map((item) => ({ ...item, providerTitle })), + (a, b) => a.id === b.id, ); + minisearch.addAll(deduplicatedItems); setMinisearches((prev) => ({ ...prev, diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 50f1291ec..e8d0a83d7 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -19,7 +19,6 @@ import FeedbackDialog from "../../components/dialogs/FeedbackDialog"; import FreeTrialOverDialog from "../../components/dialogs/FreeTrialOverDialog"; import { useFindWidget } from "../../components/find/FindWidget"; import TimelineItem from "../../components/gui/TimelineItem"; -import ChatIndexingPeeks from "../../components/indexing/ChatIndexingPeeks"; import { NewSessionButton } from "../../components/mainInput/belowMainInput/NewSessionButton"; import ThinkingBlockPeek from "../../components/mainInput/belowMainInput/ThinkingBlockPeek"; import ContinueInputBox from "../../components/mainInput/ContinueInputBox"; @@ -461,12 +460,6 @@ export function Chat() { )}
- -
- -
); }