remove more pre-indexed refs

This commit is contained in:
Patrick Erichsen 2025-03-22 20:37:47 -07:00
parent 3f8afbefeb
commit a86ec0bb46
5 changed files with 54 additions and 37 deletions

View file

@ -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 }]

1
core/index.d.ts vendored
View file

@ -236,7 +236,6 @@ export interface SiteIndexingConfig {
maxDepth?: number;
faviconUrl?: string;
useLocalCrawling?: boolean;
rootUrl?: string; // Currently only used by preindexed docs
}
export interface DocsIndexingDetails {

View file

@ -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<boolean> {
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,

View file

@ -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.
<Tabs groupId="config-example">
<TabItem value="yaml" label="YAML">
@ -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).
<Tabs groupId="config-example">
<TabItem value="yaml" label="YAML">

View file

@ -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",