Merge pull request #3883 from continuedev/pe/unsupported-cpu-check-pt-2
fix: only perform lancedb cpu check for linux
This commit is contained in:
commit
ca5463f4de
11 changed files with 180 additions and 106 deletions
|
|
@ -3,6 +3,11 @@ import * as fs from "fs";
|
|||
import os from "os";
|
||||
import path from "path";
|
||||
|
||||
import {
|
||||
ConfigResult,
|
||||
ConfigValidationError,
|
||||
ModelRole,
|
||||
} from "@continuedev/config-yaml";
|
||||
import { fetchwithRequestOptions } from "@continuedev/fetch";
|
||||
import * as JSONC from "comment-json";
|
||||
import * as tar from "tar";
|
||||
|
|
@ -31,14 +36,16 @@ import {
|
|||
import {
|
||||
slashCommandFromDescription,
|
||||
slashFromCustomCommand,
|
||||
} from "../commands/index.js";
|
||||
} from "../commands/index";
|
||||
import { AllRerankers } from "../context/allRerankers";
|
||||
import { MCPManagerSingleton } from "../context/mcp";
|
||||
import CodebaseContextProvider from "../context/providers/CodebaseContextProvider";
|
||||
import ContinueProxyContextProvider from "../context/providers/ContinueProxyContextProvider";
|
||||
import CustomContextProviderClass from "../context/providers/CustomContextProvider";
|
||||
import FileContextProvider from "../context/providers/FileContextProvider";
|
||||
import { contextProviderClassFromName } from "../context/providers/index";
|
||||
import PromptFilesContextProvider from "../context/providers/PromptFilesContextProvider";
|
||||
import { useHub } from "../control-plane/env";
|
||||
import { allEmbeddingsProviders } from "../indexing/allEmbeddingsProviders";
|
||||
import { BaseLLM } from "../llm";
|
||||
import { llmFromDescription } from "../llm/llms";
|
||||
|
|
@ -62,14 +69,8 @@ import {
|
|||
getContinueDotEnv,
|
||||
getEsbuildBinaryPath,
|
||||
} from "../util/paths";
|
||||
|
||||
import {
|
||||
ConfigResult,
|
||||
ConfigValidationError,
|
||||
ModelRole,
|
||||
} from "@continuedev/config-yaml";
|
||||
import { useHub } from "../control-plane/env";
|
||||
import { localPathToUri } from "../util/pathToUri";
|
||||
|
||||
import {
|
||||
defaultContextProvidersJetBrains,
|
||||
defaultContextProvidersVsCode,
|
||||
|
|
@ -78,7 +79,7 @@ import {
|
|||
} from "./default";
|
||||
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
|
||||
import { modifyAnyConfigWithSharedConfig } from "./sharedConfig";
|
||||
import { getModelByRole } from "./util";
|
||||
import { getModelByRole, isSupportedLanceDbCpuTargetForLinux } from "./util";
|
||||
import { validateConfig } from "./validation.js";
|
||||
|
||||
export function resolveSerializedConfig(
|
||||
|
|
@ -172,10 +173,9 @@ function loadSerializedConfig(
|
|||
? [...defaultSlashCommandsVscode]
|
||||
: [...defaultSlashCommandsJetBrains];
|
||||
|
||||
// Temporarily disabling this check until we can verify the commands are accuarate
|
||||
// if (!isSupportedLanceDbCpuTarget(ide)) {
|
||||
// config.disableIndexing = true;
|
||||
// }
|
||||
if (os.platform() === "linux" && !isSupportedLanceDbCpuTargetForLinux(ide)) {
|
||||
config.disableIndexing = true;
|
||||
}
|
||||
|
||||
return { config, errors, configLoadInterrupted: false };
|
||||
}
|
||||
|
|
@ -232,13 +232,6 @@ export function isContextProviderWithParams(
|
|||
return (contextProvider as ContextProviderWithParams).name !== undefined;
|
||||
}
|
||||
|
||||
const getCodebaseProvider = async (params: any) => {
|
||||
const { default: CodebaseContextProvider } = await import(
|
||||
"../context/providers/CodebaseContextProvider"
|
||||
);
|
||||
return new CodebaseContextProvider(params);
|
||||
};
|
||||
|
||||
/** Only difference between intermediate and final configs is the `models` array */
|
||||
async function intermediateToFinalConfig(
|
||||
config: Config,
|
||||
|
|
@ -405,7 +398,7 @@ async function intermediateToFinalConfig(
|
|||
new FileContextProvider({}),
|
||||
// Add codebase provider if indexing is enabled
|
||||
...(!config.disableIndexing
|
||||
? [await getCodebaseProvider(codebaseContextParams)]
|
||||
? [new CodebaseContextProvider(codebaseContextParams)]
|
||||
: []),
|
||||
// Add prompt files provider if enabled
|
||||
...(loadPromptFiles ? [new PromptFilesContextProvider({})] : []),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { execSync } from "child_process";
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
|
||||
import {
|
||||
|
|
@ -121,11 +121,13 @@ export function getModelByRole<T extends keyof ExperimentalModelRoles>(
|
|||
*
|
||||
* See here for details: https://github.com/continuedev/continue/issues/940
|
||||
*/
|
||||
export function isSupportedLanceDbCpuTarget(ide: IDE) {
|
||||
export function isSupportedLanceDbCpuTargetForLinux(ide?: IDE) {
|
||||
const CPU_FEATURES_TO_CHECK = ["avx2", "fma"] as const;
|
||||
|
||||
const globalContext = new GlobalContext();
|
||||
const globalContextVal = globalContext.get("isSupportedLanceDbCpuTarget");
|
||||
const globalContextVal = globalContext.get(
|
||||
"isSupportedLanceDbCpuTargetForLinux",
|
||||
);
|
||||
|
||||
// If we've already checked the CPU target, return the cached value
|
||||
if (globalContextVal !== undefined) {
|
||||
|
|
@ -133,51 +135,35 @@ export function isSupportedLanceDbCpuTarget(ide: IDE) {
|
|||
}
|
||||
|
||||
const arch = os.arch();
|
||||
const platform = os.platform();
|
||||
|
||||
// This check only applies to x64
|
||||
//https://github.com/lancedb/lance/issues/2195#issuecomment-2057841311
|
||||
if (arch !== "x64") {
|
||||
globalContext.update("isSupportedLanceDbCpuTarget", true);
|
||||
globalContext.update("isSupportedLanceDbCpuTargetForLinux", true);
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
const cpuFlags = (() => {
|
||||
switch (platform) {
|
||||
case "darwin":
|
||||
return execSync("sysctl -n machdep.cpu.features")
|
||||
.toString()
|
||||
.toLowerCase();
|
||||
case "linux":
|
||||
return execSync("cat /proc/cpuinfo").toString().toLowerCase();
|
||||
case "win32":
|
||||
return execSync("wmic cpu get caption /format:list")
|
||||
.toString()
|
||||
.toLowerCase();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
})();
|
||||
const cpuFlags = fs.readFileSync("/proc/cpuinfo", "utf-8").toLowerCase();
|
||||
|
||||
const isSupportedLanceDbCpuTarget = cpuFlags
|
||||
const isSupportedLanceDbCpuTargetForLinux = cpuFlags
|
||||
? CPU_FEATURES_TO_CHECK.every((feature) => cpuFlags.includes(feature))
|
||||
: true;
|
||||
|
||||
// If it's not a supported CPU target, and it's the first time we are checking,
|
||||
// show a toast to inform the user that we are going to disable indexing.
|
||||
if (!isSupportedLanceDbCpuTarget) {
|
||||
if (!isSupportedLanceDbCpuTargetForLinux && ide) {
|
||||
// We offload our async toast to `showUnsupportedCpuToast` to prevent making
|
||||
// our config loading async upstream of `isSupportedLanceDbCpuTarget`
|
||||
// our config loading async upstream of `isSupportedLanceDbCpuTargetForLinux`
|
||||
void showUnsupportedCpuToast(ide);
|
||||
}
|
||||
|
||||
globalContext.update(
|
||||
"isSupportedLanceDbCpuTarget",
|
||||
isSupportedLanceDbCpuTarget,
|
||||
"isSupportedLanceDbCpuTargetForLinux",
|
||||
isSupportedLanceDbCpuTargetForLinux,
|
||||
);
|
||||
|
||||
return isSupportedLanceDbCpuTarget;
|
||||
return isSupportedLanceDbCpuTargetForLinux;
|
||||
} catch (error) {
|
||||
// If we can't determine CPU features, default to true
|
||||
return true;
|
||||
|
|
@ -187,11 +173,13 @@ export function isSupportedLanceDbCpuTarget(ide: IDE) {
|
|||
async function showUnsupportedCpuToast(ide: IDE) {
|
||||
const shouldOpenLink = await ide.showToast(
|
||||
"warning",
|
||||
"Codebase indexing is disabled due to CPU incompatibility",
|
||||
"Codebase indexing disabled - Your Linux system lacks required CPU features (AVX2, FMA)",
|
||||
"Learn more",
|
||||
);
|
||||
|
||||
if (shouldOpenLink) {
|
||||
void ide.openUrl("https://github.com/continuedev/continue/pull/3551");
|
||||
void ide.openUrl(
|
||||
"https://docs.continue.dev/troubleshooting#i-received-a-codebase-indexing-disabled---your-linux-system-lacks-required-cpu-features-avx2-fma-notification",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,12 +33,21 @@ export interface IRetrievalPipeline {
|
|||
|
||||
export default class BaseRetrievalPipeline implements IRetrievalPipeline {
|
||||
private ftsIndex = new FullTextSearchCodebaseIndex();
|
||||
private lanceDbIndex: LanceDbIndex;
|
||||
private lanceDbIndex: LanceDbIndex | null = null;
|
||||
|
||||
constructor(protected readonly options: RetrievalPipelineOptions) {
|
||||
this.lanceDbIndex = new LanceDbIndex(
|
||||
options.config.selectedModelByRole.embed,
|
||||
(uri) => options.ide.readFile(uri),
|
||||
void this.initLanceDb();
|
||||
}
|
||||
|
||||
private async initLanceDb() {
|
||||
const embedModel = this.options.config.selectedModelByRole.embed;
|
||||
|
||||
if (!embedModel) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.lanceDbIndex = await LanceDbIndex.create(embedModel, (uri) =>
|
||||
this.options.ide.readFile(uri),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +120,8 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
|
|||
filepath,
|
||||
contents,
|
||||
maxChunkSize:
|
||||
this.options.config.selectedModelByRole.embed?.maxEmbeddingChunkSize ?? DEFAULT_CHUNK_SIZE,
|
||||
this.options.config.selectedModelByRole.embed
|
||||
?.maxEmbeddingChunkSize ?? DEFAULT_CHUNK_SIZE,
|
||||
digest: filepath,
|
||||
});
|
||||
|
||||
|
|
@ -127,6 +137,13 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
|
|||
input: string,
|
||||
n: number,
|
||||
): Promise<Chunk[]> {
|
||||
if (!this.lanceDbIndex) {
|
||||
console.warn(
|
||||
"LanceDB index not available, skipping embeddings retrieval",
|
||||
);
|
||||
return [];
|
||||
}
|
||||
|
||||
return this.lanceDbIndex.retrieve(
|
||||
input,
|
||||
n,
|
||||
|
|
|
|||
|
|
@ -85,24 +85,31 @@ export class CodebaseIndexer {
|
|||
return [];
|
||||
}
|
||||
|
||||
const indexes = [
|
||||
const indexes: CodebaseIndex[] = [
|
||||
new ChunkCodebaseIndex(
|
||||
this.ide.readFile.bind(this.ide),
|
||||
this.continueServerClient,
|
||||
embeddingsModel.maxEmbeddingChunkSize,
|
||||
), // Chunking must come first
|
||||
new LanceDbIndex(
|
||||
embeddingsModel,
|
||||
this.ide.readFile.bind(this.ide),
|
||||
this.continueServerClient,
|
||||
),
|
||||
];
|
||||
|
||||
const lanceDbIndex = await LanceDbIndex.create(
|
||||
embeddingsModel,
|
||||
this.ide.readFile.bind(this.ide),
|
||||
this.continueServerClient,
|
||||
);
|
||||
|
||||
if (lanceDbIndex) {
|
||||
indexes.push(lanceDbIndex);
|
||||
}
|
||||
|
||||
indexes.push(
|
||||
new FullTextSearchCodebaseIndex(),
|
||||
new CodeSnippetsCodebaseIndex(this.ide),
|
||||
];
|
||||
);
|
||||
|
||||
return indexes;
|
||||
}
|
||||
|
||||
public async refreshFile(
|
||||
file: string,
|
||||
workspaceDirs: string[],
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ describe.skip("ChunkCodebaseIndex", () => {
|
|||
throw new Error("No embeddings model selected");
|
||||
}
|
||||
|
||||
index = new LanceDbIndex(
|
||||
index = (await LanceDbIndex.create(
|
||||
mockConfig.selectedModelByRole.embed,
|
||||
testIde.readFile.bind(testIde),
|
||||
testContinueServerClient,
|
||||
);
|
||||
))!;
|
||||
|
||||
sqliteDb = await SqliteDb.get();
|
||||
lanceDb = await lance.connect(getLanceDbPath());
|
||||
|
|
|
|||
|
|
@ -1,30 +1,30 @@
|
|||
// NOTE: vectordb requirement must be listed in extensions/vscode to avoid error
|
||||
import { RunResult } from "sqlite3";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import lance, { Table } from "vectordb";
|
||||
|
||||
import { IContinueServerClient } from "../continueServer/interface.js";
|
||||
import { isSupportedLanceDbCpuTargetForLinux } from "../config/util";
|
||||
import { IContinueServerClient } from "../continueServer/interface";
|
||||
import {
|
||||
BranchAndDir,
|
||||
Chunk,
|
||||
ILLM,
|
||||
IndexTag,
|
||||
IndexingProgressUpdate,
|
||||
} from "../index.js";
|
||||
import { getLanceDbPath, migrate } from "../util/paths.js";
|
||||
} from "../index";
|
||||
import { getLanceDbPath, migrate } from "../util/paths";
|
||||
import { getUriPathBasename } from "../util/uri";
|
||||
|
||||
import { chunkDocument, shouldChunk } from "./chunk/chunk.js";
|
||||
import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex.js";
|
||||
import { chunkDocument, shouldChunk } from "./chunk/chunk";
|
||||
import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex";
|
||||
import {
|
||||
CodebaseIndex,
|
||||
IndexResultType,
|
||||
MarkCompleteCallback,
|
||||
PathAndCacheKey,
|
||||
RefreshIndexResults,
|
||||
} from "./types.js";
|
||||
import { getUriPathBasename } from "../util/uri.js";
|
||||
} from "./types";
|
||||
|
||||
import type * as LanceType from "vectordb";
|
||||
|
||||
// LanceDB converts to lowercase, so names must all be lowercase
|
||||
interface LanceDbRow {
|
||||
uuid: string;
|
||||
path: string;
|
||||
|
|
@ -38,16 +38,53 @@ type ItemWithChunks = { item: PathAndCacheKey; chunks: Chunk[] };
|
|||
type ChunkMap = Map<string, ItemWithChunks>;
|
||||
|
||||
export class LanceDbIndex implements CodebaseIndex {
|
||||
private static lance: typeof LanceType | null = null;
|
||||
|
||||
relativeExpectedTime: number = 13;
|
||||
get artifactId(): string {
|
||||
return `vectordb::${this.embeddingsProvider?.embeddingId}`;
|
||||
}
|
||||
|
||||
constructor(
|
||||
private readonly embeddingsProvider: ILLM | null,
|
||||
/**
|
||||
* Factory method for creating LanceDbIndex instances.
|
||||
*
|
||||
* We dynamically import LanceDB only when supported to avoid native module loading errors
|
||||
* on incompatible platforms. LanceDB has CPU-specific native dependencies that can crash
|
||||
* the application if loaded on unsupported architectures.
|
||||
*
|
||||
* See isSupportedLanceDbCpuTargetForLinux() for platform compatibility details.
|
||||
*/
|
||||
static async create(
|
||||
embeddingsProvider: ILLM,
|
||||
readFile: (filepath: string) => Promise<string>,
|
||||
continueServerClient?: IContinueServerClient,
|
||||
): Promise<LanceDbIndex | null> {
|
||||
if (!isSupportedLanceDbCpuTargetForLinux()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
this.lance = await import("vectordb");
|
||||
return new LanceDbIndex(
|
||||
embeddingsProvider,
|
||||
readFile,
|
||||
continueServerClient,
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("Failed to load LanceDB:", err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private constructor(
|
||||
private readonly embeddingsProvider: ILLM,
|
||||
private readonly readFile: (filepath: string) => Promise<string>,
|
||||
private readonly continueServerClient?: IContinueServerClient,
|
||||
) {}
|
||||
) {
|
||||
if (!LanceDbIndex.lance) {
|
||||
throw new Error("LanceDB not initialized");
|
||||
}
|
||||
}
|
||||
|
||||
tableNameForTag(tag: IndexTag) {
|
||||
return tagToString(tag).replace(/[^\w-_.]/g, "");
|
||||
|
|
@ -97,12 +134,10 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
);
|
||||
const embeddings = await this.getEmbeddings(allChunks);
|
||||
|
||||
// Remove undefined embeddings and their corresponding chunks
|
||||
for (let i = embeddings.length - 1; i >= 0; i--) {
|
||||
if (embeddings[i] === undefined) {
|
||||
const chunk = allChunks[i];
|
||||
const chunks = chunkMap.get(chunk.filepath)?.chunks;
|
||||
|
||||
if (chunks) {
|
||||
const index = chunks.findIndex((c) => c === chunk);
|
||||
if (index !== -1) {
|
||||
|
|
@ -210,6 +245,7 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
markComplete: MarkCompleteCallback,
|
||||
repoName: string | undefined,
|
||||
): AsyncGenerator<IndexingProgressUpdate> {
|
||||
const lance = LanceDbIndex.lance!;
|
||||
const sqliteDb = await SqliteDb.get();
|
||||
await this.createSqliteCacheTable(sqliteDb);
|
||||
|
||||
|
|
@ -217,15 +253,13 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
const lanceDb = await lance.connect(getLanceDbPath());
|
||||
const existingLanceTables = await lanceDb.tableNames();
|
||||
|
||||
let lanceTable: Table<number[]> | undefined = undefined;
|
||||
let lanceTable: LanceType.Table<number[]> | undefined = undefined;
|
||||
let needToCreateLanceTable = !existingLanceTables.includes(lanceTableName);
|
||||
|
||||
// Compute
|
||||
const addComputedLanceDbRows = async (
|
||||
pathAndCacheKeys: PathAndCacheKey[],
|
||||
computedRows: LanceDbRow[],
|
||||
) => {
|
||||
// Create table if needed, add computed rows
|
||||
if (lanceTable) {
|
||||
if (computedRows.length > 0) {
|
||||
await lanceTable.add(computedRows);
|
||||
|
|
@ -241,11 +275,9 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
needToCreateLanceTable = false;
|
||||
}
|
||||
|
||||
// Mark item complete
|
||||
await markComplete(pathAndCacheKeys, IndexResultType.Compute);
|
||||
};
|
||||
|
||||
// Check remote cache
|
||||
if (this.continueServerClient?.connected) {
|
||||
try {
|
||||
const keys = results.compute.map(({ cacheKey }) => cacheKey);
|
||||
|
|
@ -255,7 +287,6 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
repoName,
|
||||
);
|
||||
for (const [cacheKey, chunks] of Object.entries(resp.files)) {
|
||||
// Get path for cacheKey
|
||||
const path = results.compute.find(
|
||||
(item) => item.cacheKey === cacheKey,
|
||||
)?.path;
|
||||
|
|
@ -267,7 +298,6 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Build LanceDbRow objects
|
||||
const rows: LanceDbRow[] = [];
|
||||
for (const chunk of chunks) {
|
||||
const row = {
|
||||
|
|
@ -294,7 +324,6 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
await addComputedLanceDbRows([{ cacheKey, path }], rows);
|
||||
}
|
||||
|
||||
// Remove items that don't need to be recomputed
|
||||
results.compute = results.compute.filter(
|
||||
(item) => !resp.files[item.cacheKey],
|
||||
);
|
||||
|
|
@ -316,7 +345,6 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
await addComputedLanceDbRows(results.compute, dbRows);
|
||||
let accumulatedProgress = 0;
|
||||
|
||||
// Add tag - retrieve the computed info from lance sqlite cache
|
||||
for (const { path, cacheKey } of results.addTag) {
|
||||
const stmt = await sqliteDb.prepare(
|
||||
"SELECT * FROM lance_db_cache WHERE cacheKey = ? AND path = ? AND artifact_id = ?",
|
||||
|
|
@ -360,7 +388,6 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
};
|
||||
}
|
||||
|
||||
// Delete or remove tag - remove from lance table)
|
||||
if (!needToCreateLanceTable) {
|
||||
const toDel = [...results.removeTag, ...results.del];
|
||||
|
||||
|
|
@ -369,7 +396,6 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
}
|
||||
|
||||
for (const { path, cacheKey } of toDel) {
|
||||
// This is where the aforementioned lowercase conversion problem shows
|
||||
await lanceTable.delete(
|
||||
`cachekey = '${cacheKey}' AND path = '${path}'`,
|
||||
);
|
||||
|
|
@ -385,7 +411,6 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
|
||||
await markComplete(results.removeTag, IndexResultType.RemoveTag);
|
||||
|
||||
// Delete - also remove from sqlite cache
|
||||
for (const { path, cacheKey } of results.del) {
|
||||
await sqliteDb.run(
|
||||
"DELETE FROM lance_db_cache WHERE cacheKey = ? AND path = ? AND artifact_id = ?",
|
||||
|
|
@ -415,7 +440,7 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
n: number,
|
||||
directory: string | undefined,
|
||||
vector: number[],
|
||||
db: any, /// lancedb.Connection
|
||||
db: any,
|
||||
): Promise<LanceDbRow[]> {
|
||||
const tableName = this.tableNameForTag(tag);
|
||||
const tableNames = await db.tableNames();
|
||||
|
|
@ -427,7 +452,6 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
const table = await db.openTable(tableName);
|
||||
let query = table.search(vector);
|
||||
if (directory) {
|
||||
// seems like lancedb is only post-filtering, so have to return a bunch of results and slice after
|
||||
query = query.where(`path LIKE '${directory}%'`).limit(300);
|
||||
} else {
|
||||
query = query.limit(n);
|
||||
|
|
@ -442,6 +466,7 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
tags: BranchAndDir[],
|
||||
filterDirectory: string | undefined,
|
||||
): Promise<Chunk[]> {
|
||||
const lance = LanceDbIndex.lance!;
|
||||
if (!this.embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { open, type Database } from "sqlite";
|
||||
import sqlite3 from "sqlite3";
|
||||
import lancedb, { Connection } from "vectordb";
|
||||
|
||||
import {
|
||||
Chunk,
|
||||
|
|
@ -14,7 +13,10 @@ import {
|
|||
SiteIndexingConfig,
|
||||
} from "../..";
|
||||
import { ConfigHandler } from "../../config/ConfigHandler";
|
||||
import { addContextProvider } from "../../config/util";
|
||||
import {
|
||||
addContextProvider,
|
||||
isSupportedLanceDbCpuTargetForLinux,
|
||||
} from "../../config/util";
|
||||
import DocsContextProvider from "../../context/providers/DocsContextProvider";
|
||||
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { FromCoreProtocol, ToCoreProtocol } from "../../protocol";
|
||||
|
|
@ -43,6 +45,8 @@ import {
|
|||
} from "./preIndexed";
|
||||
import preIndexedDocs from "./preIndexedDocs";
|
||||
|
||||
import type * as LanceType from "vectordb";
|
||||
|
||||
// Purposefully lowercase because lancedb converts
|
||||
export interface LanceDbDocsRow {
|
||||
title: string;
|
||||
|
|
@ -81,6 +85,7 @@ export type AddParams = {
|
|||
- add/index one
|
||||
*/
|
||||
export default class DocsService {
|
||||
private static lance: typeof LanceType | null = null;
|
||||
static lanceTableName = "docs";
|
||||
static sqlitebTableName = "docs";
|
||||
|
||||
|
|
@ -112,6 +117,22 @@ export default class DocsService {
|
|||
this.githubToken = token;
|
||||
}
|
||||
|
||||
private async initLanceDb() {
|
||||
if (!isSupportedLanceDbCpuTargetForLinux()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!DocsService.lance) {
|
||||
DocsService.lance = await import("vectordb");
|
||||
}
|
||||
return DocsService.lance;
|
||||
} catch (err) {
|
||||
console.error("Failed to load LanceDB:", err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Singleton pattern: only one service globally
|
||||
private static instance?: DocsService;
|
||||
static createSingleton(
|
||||
|
|
@ -988,7 +1009,7 @@ export default class DocsService {
|
|||
|
||||
// Lance DB Initialization
|
||||
private async createLanceDocsTable(
|
||||
connection: Connection,
|
||||
connection: LanceType.Connection,
|
||||
initializationVector: number[],
|
||||
tableName: string,
|
||||
) {
|
||||
|
|
@ -1035,7 +1056,12 @@ export default class DocsService {
|
|||
initializationVector: number[];
|
||||
startUrl: string;
|
||||
}) {
|
||||
const conn = await lancedb.connect(getLanceDbPath());
|
||||
const lance = await this.initLanceDb();
|
||||
if (!lance) {
|
||||
throw new Error("LanceDB not available on this platform");
|
||||
}
|
||||
|
||||
const conn = await lance.connect(getLanceDbPath());
|
||||
const tableNames = await conn.tableNames();
|
||||
const { provider } = await this.getEmbeddingsProvider(startUrl);
|
||||
|
||||
|
|
@ -1157,8 +1183,13 @@ export default class DocsService {
|
|||
|
||||
// Delete methods
|
||||
private async deleteEmbeddingsFromLance(startUrl: string) {
|
||||
const lance = await this.initLanceDb();
|
||||
if (!lance) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const tableName of this.lanceTableNamesSet) {
|
||||
const conn = await lancedb.connect(getLanceDbPath());
|
||||
const conn = await lance.connect(getLanceDbPath());
|
||||
const table = await conn.openTable(tableName);
|
||||
await table.delete(`starturl = '${startUrl}'`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { type Database } from "sqlite";
|
||||
import { Table } from "vectordb";
|
||||
import { type Table } from "vectordb";
|
||||
|
||||
import { editConfigJson, migrate } from "../../util/paths.js";
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export type GlobalContextType = {
|
|||
hasDismissedConfigTsNoticeJetBrains: boolean;
|
||||
hasAlreadyCreatedAPromptFile: boolean;
|
||||
showConfigUpdateToast: boolean;
|
||||
isSupportedLanceDbCpuTarget: boolean;
|
||||
isSupportedLanceDbCpuTargetForLinux: boolean;
|
||||
sharedConfig: SharedConfigSchema;
|
||||
failedDocs: SiteIndexingConfig[];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -151,6 +151,14 @@ This can be accomplished using the following command: `Continue: Rebuild codebas
|
|||
|
||||
This can be fixed by selecting `Actions > Choose Boot runtime for the IDE` then selecting the latest version, and then restarting Android Studio. [See this thread](https://github.com/continuedev/continue/issues/596#issuecomment-1789327178) for details.
|
||||
|
||||
### I received a "Codebase indexing disabled - Your Linux system lacks required CPU features (AVX2, FMA)" notification
|
||||
|
||||
We use LanceDB as our vector database for codebase search features. On x64 Linux systems, LanceDB requires specific CPU features (FMA and AVX2) which may not be available on older processors.
|
||||
|
||||
Most Continue features will work normally, including autocomplete and chat. However, commands that rely on codebase indexing, such as `@codebase`, `@files`, and `@folder`, will be disabled.
|
||||
|
||||
For more details about this requirement, see the [LanceDB issue #2195](https://github.com/lancedb/lance/issues/2195).
|
||||
|
||||
## Still having trouble?
|
||||
|
||||
You can also join our Discord community [here](https://discord.gg/vapESyrFmJ) for additional support and discussions. Alternatively, you can create a GitHub issue [here](https://github.com/continuedev/continue/issues/new?assignees=&labels=bug&projects=&template=bug-report-%F0%9F%90%9B.md&title=), providing details of your problem, and we'll be able to help you out more quickly.
|
||||
|
|
|
|||
|
|
@ -21,9 +21,8 @@ function MorePage() {
|
|||
const dispatch = useAppDispatch();
|
||||
const navigate = useNavigate();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const disableIndexing = useAppSelector(
|
||||
(state) => state.config.config.disableIndexing,
|
||||
);
|
||||
const config = useAppSelector((store) => store.config.config);
|
||||
const { disableIndexing } = config;
|
||||
|
||||
return (
|
||||
<div className="overflow-y-scroll">
|
||||
|
|
@ -38,8 +37,14 @@ function MorePage() {
|
|||
</span>
|
||||
</div>
|
||||
{disableIndexing ? (
|
||||
<div className="pb-2 pt-5 text-center font-semibold">
|
||||
Indexing is disabled
|
||||
<div className="pb-2 pt-5">
|
||||
<p className="py-1 text-center font-semibold">
|
||||
Indexing is disabled
|
||||
</p>
|
||||
<p className="text-lightgray cursor-pointer text-center text-xs">
|
||||
Open settings and toggle <code>Disable Indexing</code> to
|
||||
re-enable
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<IndexingProgress />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue