fix: disable indexing for unsupported CPUs
This commit is contained in:
parent
74035c35cc
commit
a005aa78ac
4 changed files with 88 additions and 4 deletions
|
|
@ -46,6 +46,8 @@ import CustomLLMClass from "../llm/llms/CustomLLM";
|
|||
import FreeTrial from "../llm/llms/FreeTrial";
|
||||
import { LLMReranker } from "../llm/llms/llm";
|
||||
import TransformersJsEmbeddingsProvider from "../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { slashCommandFromPromptFileV1 } from "../promptFiles/v1/slashCommandFromPromptFile";
|
||||
import { getAllPromptFiles } from "../promptFiles/v2/getPromptFiles";
|
||||
import { allTools } from "../tools";
|
||||
import { copyOf } from "../util";
|
||||
import { GlobalContext } from "../util/GlobalContext";
|
||||
|
|
@ -61,8 +63,6 @@ import {
|
|||
getEsbuildBinaryPath,
|
||||
} from "../util/paths";
|
||||
|
||||
import { slashCommandFromPromptFileV1 } from "../promptFiles/v1/slashCommandFromPromptFile";
|
||||
import { getAllPromptFiles } from "../promptFiles/v2/getPromptFiles";
|
||||
import {
|
||||
defaultContextProvidersJetBrains,
|
||||
defaultContextProvidersVsCode,
|
||||
|
|
@ -70,6 +70,7 @@ import {
|
|||
defaultSlashCommandsVscode,
|
||||
} from "./default";
|
||||
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
|
||||
import { isSupportedLanceDbCpuTarget } from "./util";
|
||||
import { ConfigValidationError, validateConfig } from "./validation.js";
|
||||
|
||||
export interface ConfigResult<T> {
|
||||
|
|
@ -112,6 +113,7 @@ function loadSerializedConfig(
|
|||
ideSettings: IdeSettings,
|
||||
ideType: IdeType,
|
||||
overrideConfigJson: SerializedContinueConfig | undefined,
|
||||
ide: IDE
|
||||
): ConfigResult<SerializedContinueConfig> {
|
||||
const configPath = getConfigJsonPath(ideType);
|
||||
let config: SerializedContinueConfig = overrideConfigJson!;
|
||||
|
|
@ -174,6 +176,10 @@ function loadSerializedConfig(
|
|||
? [...defaultSlashCommandsVscode]
|
||||
: [...defaultSlashCommandsJetBrains];
|
||||
|
||||
if (!isSupportedLanceDbCpuTarget(ide)) {
|
||||
config.disableIndexing = true;
|
||||
}
|
||||
|
||||
return { config, errors, configLoadInterrupted: false };
|
||||
}
|
||||
|
||||
|
|
@ -767,6 +773,7 @@ async function loadFullConfigNode(
|
|||
ideSettings,
|
||||
ideType,
|
||||
overrideConfigJson,
|
||||
ide
|
||||
);
|
||||
|
||||
if (!serialized || configLoadInterrupted) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
import { execSync } from "child_process";
|
||||
import os from "os";
|
||||
|
||||
import {
|
||||
ContextProviderWithParams,
|
||||
ContinueConfig,
|
||||
IDE,
|
||||
ILLM,
|
||||
ModelDescription,
|
||||
ModelRoles,
|
||||
} from "../";
|
||||
import { GlobalContext } from "../util/GlobalContext";
|
||||
import { editConfigJson } from "../util/paths";
|
||||
|
||||
function stringify(obj: any, indentation?: number): string {
|
||||
|
|
@ -96,3 +101,74 @@ export function getModelByRole<T extends keyof ModelRoles>(
|
|||
|
||||
return matchingModel;
|
||||
}
|
||||
|
||||
// https://github.com/continuedev/continue/issues/940
|
||||
export async function isSupportedLanceDbCpuTarget(ide: IDE) {
|
||||
const globalContext = new GlobalContext();
|
||||
const globalContextVal = globalContext.get("isSupportedLanceDbCpuTarget");
|
||||
|
||||
// If we've already checked the CPU target, return the cached value
|
||||
if (globalContextVal !== undefined) {
|
||||
return globalContextVal;
|
||||
}
|
||||
|
||||
const arch = os.arch();
|
||||
const platform = os.platform();
|
||||
|
||||
//https://github.com/lancedb/lance/issues/2195#issuecomment-2057841311
|
||||
// Only applies to x64
|
||||
if (arch !== "x64") {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
const CPU_FEATURES_TO_CHECK = ["avx", "fma"] as const;
|
||||
|
||||
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 "";
|
||||
}
|
||||
})();
|
||||
|
||||
// TODO: Remvoe !
|
||||
const isSupportedLanceDbCpuTarget = 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) {
|
||||
const shouldOpenLink = await ide.showToast(
|
||||
"warning",
|
||||
"Cdoebase indexing is disabled due to CPU incompatibility",
|
||||
"View details",
|
||||
);
|
||||
|
||||
if (shouldOpenLink) {
|
||||
// TODO
|
||||
void ide.openUrl("https://continue.dev");
|
||||
}
|
||||
}
|
||||
|
||||
globalContext.update(
|
||||
"isSupportedLanceDbCpuTarget",
|
||||
isSupportedLanceDbCpuTarget,
|
||||
);
|
||||
|
||||
return isSupportedLanceDbCpuTarget;
|
||||
} catch (error) {
|
||||
// If we can't determine CPU features, default to true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export type GlobalContextType = {
|
|||
hasDismissedConfigTsNoticeJetBrains: boolean;
|
||||
hasAlreadyCreatedAPromptFile: boolean;
|
||||
showConfigUpdateToast: boolean;
|
||||
isSupportedLanceDbCpuTarget: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.247",
|
||||
"version": "0.9.248",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.247",
|
||||
"version": "0.9.248",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue