fix embed and reranking logic
This commit is contained in:
parent
b5f689306f
commit
a0a152e603
21 changed files with 262 additions and 225 deletions
|
|
@ -18,6 +18,7 @@ import {
|
|||
EmbeddingsProviderDescription,
|
||||
IContextProvider,
|
||||
IDE,
|
||||
IdeInfo,
|
||||
IdeSettings,
|
||||
IdeType,
|
||||
ILLM,
|
||||
|
|
@ -243,6 +244,7 @@ async function intermediateToFinalConfig(
|
|||
config: Config,
|
||||
ide: IDE,
|
||||
ideSettings: IdeSettings,
|
||||
ideInfo: IdeInfo,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
|
|
@ -442,15 +444,15 @@ async function intermediateToFinalConfig(
|
|||
|
||||
// Embeddings Provider
|
||||
function getEmbeddingsILLM(
|
||||
configEmbedder: EmbeddingsProviderDescription | ILLM | undefined,
|
||||
): ILLM {
|
||||
if (!configEmbedder) {
|
||||
return new TransformersJsEmbeddingsProvider();
|
||||
embedConfig: EmbeddingsProviderDescription | ILLM | undefined,
|
||||
): ILLM | null {
|
||||
if (!embedConfig) {
|
||||
return null;
|
||||
}
|
||||
if ("providerName" in configEmbedder) {
|
||||
return configEmbedder;
|
||||
if ("providerName" in embedConfig) {
|
||||
return embedConfig;
|
||||
}
|
||||
const { provider, ...options } = configEmbedder;
|
||||
const { provider, ...options } = embedConfig;
|
||||
const embeddingsProviderClass = allEmbeddingsProviders[provider];
|
||||
if (embeddingsProviderClass) {
|
||||
if (
|
||||
|
|
@ -477,16 +479,16 @@ async function intermediateToFinalConfig(
|
|||
message: `Embeddings provider ${provider} not found. Using default`,
|
||||
});
|
||||
}
|
||||
return new TransformersJsEmbeddingsProvider();
|
||||
return null;
|
||||
}
|
||||
const newEmbedder = getEmbeddingsILLM(config.embeddingsProvider);
|
||||
|
||||
// Reranker
|
||||
function getRerankingILLM(
|
||||
rerankingConfig: ILLM | RerankerDescription | undefined,
|
||||
): ILLM | undefined {
|
||||
): ILLM | null {
|
||||
if (!rerankingConfig) {
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
if ("providerName" in rerankingConfig) {
|
||||
return rerankingConfig;
|
||||
|
|
@ -501,7 +503,7 @@ async function intermediateToFinalConfig(
|
|||
fatal: false,
|
||||
message: `Unknown reranking model ${params?.modelTitle}`,
|
||||
});
|
||||
return undefined;
|
||||
return null;
|
||||
} else {
|
||||
return new LLMReranker(llm);
|
||||
}
|
||||
|
|
@ -512,7 +514,7 @@ async function intermediateToFinalConfig(
|
|||
};
|
||||
return new rerankerClass(llmOptions);
|
||||
}
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
const newReranker = getRerankingILLM(config.reranker);
|
||||
|
||||
|
|
@ -520,17 +522,14 @@ async function intermediateToFinalConfig(
|
|||
...config,
|
||||
contextProviders,
|
||||
models,
|
||||
embeddingsProvider: newEmbedder,
|
||||
tabAutocompleteModels,
|
||||
reranker: newReranker,
|
||||
tools: allTools,
|
||||
modelsByRole: {
|
||||
chat: models,
|
||||
edit: models,
|
||||
apply: models,
|
||||
summarize: models,
|
||||
embed: [newEmbedder],
|
||||
autocomplete: [...tabAutocompleteModels],
|
||||
embed: newEmbedder ? [newEmbedder] : [],
|
||||
rerank: newReranker ? [newReranker] : [],
|
||||
},
|
||||
selectedModelByRole: {
|
||||
|
|
@ -619,6 +618,18 @@ async function intermediateToFinalConfig(
|
|||
}
|
||||
}
|
||||
|
||||
// Add transformers JS to the embed models list if not already added
|
||||
if (
|
||||
ideInfo.ideType === "vscode" &&
|
||||
!continueConfig.modelsByRole.embed.find(
|
||||
(m) => m.providerName === "transformers.js",
|
||||
)
|
||||
) {
|
||||
continueConfig.modelsByRole.embed.push(
|
||||
new TransformersJsEmbeddingsProvider(),
|
||||
);
|
||||
}
|
||||
|
||||
return { config: continueConfig, errors };
|
||||
}
|
||||
|
||||
|
|
@ -658,7 +669,6 @@ async function finalToBrowserConfig(
|
|||
disableIndexing: final.disableIndexing,
|
||||
disableSessionTitles: final.disableSessionTitles,
|
||||
userToken: final.userToken,
|
||||
embeddingsProvider: final.embeddingsProvider?.embeddingId,
|
||||
ui: final.ui,
|
||||
experimental: final.experimental,
|
||||
docs: final.docs,
|
||||
|
|
@ -864,7 +874,7 @@ async function loadContinueConfigFromJson(
|
|||
ide: IDE,
|
||||
workspaceConfigs: ContinueRcJson[],
|
||||
ideSettings: IdeSettings,
|
||||
ideType: IdeType,
|
||||
ideInfo: IdeInfo,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
|
|
@ -878,7 +888,7 @@ async function loadContinueConfigFromJson(
|
|||
} = loadSerializedConfig(
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
ideType,
|
||||
ideInfo.ideType,
|
||||
overrideConfigJson,
|
||||
ide,
|
||||
);
|
||||
|
|
@ -901,7 +911,10 @@ async function loadContinueConfigFromJson(
|
|||
let intermediate = await serializedToIntermediateConfig(withShared, ide);
|
||||
|
||||
// Apply config.ts to modify intermediate config
|
||||
const configJsContents = await buildConfigTsandReadConfigJs(ide, ideType);
|
||||
const configJsContents = await buildConfigTsandReadConfigJs(
|
||||
ide,
|
||||
ideInfo.ideType,
|
||||
);
|
||||
if (configJsContents) {
|
||||
try {
|
||||
// Try config.ts first
|
||||
|
|
@ -961,6 +974,7 @@ async function loadContinueConfigFromJson(
|
|||
intermediate,
|
||||
ide,
|
||||
ideSettings,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {
|
|||
AssistantUnrolled,
|
||||
ConfigResult,
|
||||
ConfigValidationError,
|
||||
ModelRole,
|
||||
} from "@continuedev/config-yaml";
|
||||
import {
|
||||
ContinueConfig,
|
||||
|
|
@ -60,7 +61,7 @@ export default async function doLoadConfig(
|
|||
ide,
|
||||
workspaceConfigs.map((c) => JSON.stringify(c)),
|
||||
ideSettings,
|
||||
ideInfo.ideType,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
|
|
@ -76,7 +77,7 @@ export default async function doLoadConfig(
|
|||
ide,
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
ideInfo.ideType,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
|
|
@ -153,21 +154,26 @@ async function injectControlPlaneProxyInfo(
|
|||
config: ContinueConfig,
|
||||
info: ControlPlaneProxyInfo,
|
||||
): Promise<ContinueConfig> {
|
||||
[...config.models, ...(config.tabAutocompleteModels ?? [])].forEach(
|
||||
async (model) => {
|
||||
Object.keys(config.modelsByRole).forEach((key) => {
|
||||
config.modelsByRole[key as ModelRole].forEach((model) => {
|
||||
if (model.providerName === "continue-proxy") {
|
||||
(model as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
if (config.embeddingsProvider?.providerName === "continue-proxy") {
|
||||
(config.embeddingsProvider as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
Object.keys(config.selectedModelByRole).forEach((key) => {
|
||||
const model = config.selectedModelByRole[key as ModelRole];
|
||||
if (model?.providerName === "continue-proxy") {
|
||||
(model as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
});
|
||||
|
||||
if (config.reranker?.providerName === "continue-proxy") {
|
||||
(config.reranker as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
config.models.forEach((model) => {
|
||||
if (model.providerName === "continue-proxy") {
|
||||
(model as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,11 @@ export function convertConfigJsonToConfigYaml(
|
|||
name: model.title,
|
||||
// defaultCompletionOptions: model.completionOptions,
|
||||
provider: model.provider,
|
||||
roles: ["chat"],
|
||||
roles: ["chat", "edit", "apply", "summarize"],
|
||||
}),
|
||||
),
|
||||
// ... tabAutocompleteModels
|
||||
// TODO
|
||||
// tabAutocompleteModels
|
||||
// embeddingsModels
|
||||
// rerankModels
|
||||
],
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import {
|
|||
ContinueConfig,
|
||||
IContextProvider,
|
||||
IDE,
|
||||
IdeInfo,
|
||||
IdeSettings,
|
||||
IdeType,
|
||||
SlashCommand,
|
||||
} from "../..";
|
||||
import { slashFromCustomCommand } from "../../commands";
|
||||
|
|
@ -98,6 +98,7 @@ async function configYamlToContinueConfig(
|
|||
config: AssistantUnrolled,
|
||||
ide: IDE,
|
||||
ideSettings: IdeSettings,
|
||||
ideInfo: IdeInfo,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
|
|
@ -111,10 +112,8 @@ async function configYamlToContinueConfig(
|
|||
...(config.prompts?.map(slashFromCustomCommand) ?? []),
|
||||
],
|
||||
models: [],
|
||||
tabAutocompleteModels: [],
|
||||
tools: allTools,
|
||||
systemMessage: config.rules?.join("\n"),
|
||||
embeddingsProvider: new TransformersJsEmbeddingsProvider(),
|
||||
experimental: {
|
||||
modelContextProtocolServers: config.mcpServers?.map((mcpServer) => ({
|
||||
transport: {
|
||||
|
|
@ -188,19 +187,68 @@ async function configYamlToContinueConfig(
|
|||
}
|
||||
|
||||
if (model.roles?.includes("autocomplete")) {
|
||||
continueConfig.tabAutocompleteModels?.push(...llms);
|
||||
continueConfig.modelsByRole.autocomplete.push(...llms);
|
||||
}
|
||||
|
||||
if (model.roles?.includes("embed")) {
|
||||
continueConfig.modelsByRole.embed.push(...llms);
|
||||
const { provider, ...options } = model;
|
||||
const embeddingsProviderClass = allEmbeddingsProviders[provider];
|
||||
if (embeddingsProviderClass) {
|
||||
if (
|
||||
embeddingsProviderClass.name === "_TransformersJsEmbeddingsProvider"
|
||||
) {
|
||||
continueConfig.modelsByRole.embed.push(new embeddingsProviderClass());
|
||||
} else {
|
||||
continueConfig.modelsByRole.embed.push(
|
||||
new embeddingsProviderClass(
|
||||
options,
|
||||
(url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
...options.requestOptions,
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: `Unsupported embeddings model provider found: ${provider}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (model.roles?.includes("rerank")) {
|
||||
continueConfig.modelsByRole.rerank.push(...llms);
|
||||
const { provider, ...options } = model;
|
||||
const rerankerClass = AllRerankers[provider];
|
||||
if (rerankerClass) {
|
||||
continueConfig.modelsByRole.rerank.push(
|
||||
new rerankerClass(options, (url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
...options.requestOptions,
|
||||
}),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: `Unsupported reranking model provider found: ${provider}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add transformers js to the embed models in vs code if not already added
|
||||
if (
|
||||
ideInfo.ideType === "vscode" &&
|
||||
!continueConfig.modelsByRole.embed.find(
|
||||
(m) => m.providerName === "transformers.js",
|
||||
)
|
||||
) {
|
||||
continueConfig.modelsByRole.embed.push(
|
||||
new TransformersJsEmbeddingsProvider(),
|
||||
);
|
||||
}
|
||||
|
||||
if (allowFreeTrial) {
|
||||
// Obtain auth token (iff free trial being used)
|
||||
const freeTrialModels = continueConfig.models.filter(
|
||||
|
|
@ -257,51 +305,6 @@ async function configYamlToContinueConfig(
|
|||
continueConfig.contextProviders.push(new DocsContextProvider({}));
|
||||
}
|
||||
|
||||
// Embeddings Provider
|
||||
// IMPORTANT this currently will grab the first model found with an embed role
|
||||
const embedConfig = config.models?.find((model) =>
|
||||
model.roles?.includes("embed"),
|
||||
);
|
||||
if (embedConfig) {
|
||||
const { provider, ...options } = embedConfig;
|
||||
const embeddingsProviderClass = allEmbeddingsProviders[provider];
|
||||
if (embeddingsProviderClass) {
|
||||
if (
|
||||
embeddingsProviderClass.name === "_TransformersJsEmbeddingsProvider"
|
||||
) {
|
||||
continueConfig.embeddingsProvider = new embeddingsProviderClass();
|
||||
} else {
|
||||
continueConfig.embeddingsProvider = new embeddingsProviderClass(
|
||||
options,
|
||||
(url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
...options.requestOptions,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reranker
|
||||
// IMPORTANT this currently will grab the first model found with a rerank role
|
||||
const rerankConfig = config.models?.find((model) =>
|
||||
model.roles?.includes("rerank"),
|
||||
);
|
||||
if (rerankConfig) {
|
||||
const { provider, ...options } = rerankConfig;
|
||||
const rerankerClass = AllRerankers[provider];
|
||||
|
||||
if (rerankerClass) {
|
||||
continueConfig.reranker = new rerankerClass(
|
||||
options,
|
||||
(url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
...options.requestOptions,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply MCP if specified
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
await Promise.all(
|
||||
|
|
@ -355,7 +358,7 @@ export async function loadContinueConfigFromYaml(
|
|||
ide: IDE,
|
||||
workspaceConfigs: string[],
|
||||
ideSettings: IdeSettings,
|
||||
ideType: IdeType,
|
||||
ideInfo: IdeInfo,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
|
|
@ -365,7 +368,7 @@ export async function loadContinueConfigFromYaml(
|
|||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
const rawYaml =
|
||||
overrideConfigYaml === undefined
|
||||
? fs.readFileSync(getConfigYamlPath(ideType), "utf-8")
|
||||
? fs.readFileSync(getConfigYamlPath(ideInfo.ideType), "utf-8")
|
||||
: "";
|
||||
|
||||
const configYamlResult = await loadConfigYaml(
|
||||
|
|
@ -388,6 +391,7 @@ export async function loadContinueConfigFromYaml(
|
|||
configYamlResult.config,
|
||||
ide,
|
||||
ideSettings,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ async function getContextProviderExtras(
|
|||
fullInput,
|
||||
ide,
|
||||
config,
|
||||
embeddingsProvider: config.embeddingsProvider,
|
||||
embeddingsProvider: config.selectedModelByRole.embed,
|
||||
fetch: fetch,
|
||||
llm: config.models[0],
|
||||
reranker: config.reranker,
|
||||
reranker: config.selectedModelByRole.rerank,
|
||||
selectedCode: [],
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import { FullTextSearchCodebaseIndex } from "../../../indexing/FullTextSearchCod
|
|||
import { LanceDbIndex } from "../../../indexing/LanceDbIndex";
|
||||
import { recentlyEditedFilesCache } from "../recentlyEditedFilesCache";
|
||||
|
||||
const DEFAULT_CHUNK_SIZE = 384;
|
||||
|
||||
export interface RetrievalPipelineOptions {
|
||||
llm: ILLM;
|
||||
config: ContinueConfig;
|
||||
|
|
@ -16,13 +18,13 @@ export interface RetrievalPipelineOptions {
|
|||
nFinal: number;
|
||||
tags: BranchAndDir[];
|
||||
filterDirectory?: string;
|
||||
includeEmbeddings?: boolean; // Used to handle JB w/o an embeddings model
|
||||
}
|
||||
|
||||
export interface RetrievalPipelineRunArguments {
|
||||
query: string;
|
||||
tags: BranchAndDir[];
|
||||
filterDirectory?: string;
|
||||
includeEmbeddings: boolean;
|
||||
}
|
||||
|
||||
export interface IRetrievalPipeline {
|
||||
|
|
@ -35,7 +37,7 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
|
|||
|
||||
constructor(protected readonly options: RetrievalPipelineOptions) {
|
||||
this.lanceDbIndex = new LanceDbIndex(
|
||||
options.config.embeddingsProvider,
|
||||
options.config.selectedModelByRole.embed,
|
||||
(uri) => options.ide.readFile(uri),
|
||||
);
|
||||
}
|
||||
|
|
@ -109,7 +111,7 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
|
|||
filepath,
|
||||
contents,
|
||||
maxChunkSize:
|
||||
this.options.config.embeddingsProvider.maxEmbeddingChunkSize,
|
||||
this.options.config.selectedModelByRole.embed?.maxEmbeddingChunkSize ?? DEFAULT_CHUNK_SIZE,
|
||||
digest: filepath,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import BaseRetrievalPipeline, {
|
|||
|
||||
export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
||||
async run(args: RetrievalPipelineRunArguments): Promise<Chunk[]> {
|
||||
const { input, nFinal, filterDirectory, includeEmbeddings } = this.options;
|
||||
const { input, nFinal, filterDirectory, config } = this.options;
|
||||
|
||||
// We give 1/4 weight to recently edited files, 1/4 to full text search,
|
||||
// and the remaining 1/2 to embeddings
|
||||
|
|
@ -21,7 +21,7 @@ export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
|
||||
const ftsChunks = await this.retrieveFts(args, ftsNFinal);
|
||||
|
||||
const embeddingsChunks = includeEmbeddings
|
||||
const embeddingsChunks = !!config.selectedModelByRole.embed
|
||||
? await this.retrieveEmbeddings(input, embeddingsNFinal)
|
||||
: [];
|
||||
|
||||
|
|
|
|||
|
|
@ -12,13 +12,12 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
private async _retrieveInitial(
|
||||
args: RetrievalPipelineRunArguments,
|
||||
): Promise<Chunk[]> {
|
||||
const { input, nRetrieve, filterDirectory, includeEmbeddings } =
|
||||
this.options;
|
||||
const { input, nRetrieve, filterDirectory, config } = this.options;
|
||||
|
||||
let retrievalResults: Chunk[] = [];
|
||||
|
||||
const ftsChunks = await this.retrieveFts(args, nRetrieve);
|
||||
const embeddingsChunks = includeEmbeddings
|
||||
const embeddingsChunks = !!config.selectedModelByRole.embed
|
||||
? await this.retrieveEmbeddings(input, nRetrieve)
|
||||
: [];
|
||||
const recentlyEditedFilesChunks =
|
||||
|
|
@ -53,17 +52,18 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
}
|
||||
|
||||
private async _rerank(input: string, chunks: Chunk[]): Promise<Chunk[]> {
|
||||
if (!this.options.config.reranker) {
|
||||
throw new Error("No reranker provided");
|
||||
if (!this.options.config.selectedModelByRole.rerank) {
|
||||
throw new Error("No reranker set up");
|
||||
}
|
||||
|
||||
// remove empty chunks -- some APIs fail on that
|
||||
chunks = chunks.filter((chunk) => chunk.content);
|
||||
|
||||
let scores: number[] = await this.options.config.reranker.rerank(
|
||||
input,
|
||||
chunks,
|
||||
);
|
||||
let scores: number[] =
|
||||
await this.options.config.selectedModelByRole.rerank.rerank(
|
||||
input,
|
||||
chunks,
|
||||
);
|
||||
|
||||
// Filter out low-scoring results
|
||||
let results = chunks;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { BranchAndDir, ContextItem, ContextProviderExtras } from "../../";
|
||||
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { getUriDescription } from "../../util/uri";
|
||||
import { INSTRUCTIONS_BASE_ITEM } from "../providers/utils";
|
||||
|
||||
|
|
@ -14,27 +13,16 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
options: any | undefined,
|
||||
filterDirectory: string | undefined,
|
||||
): Promise<ContextItem[]> {
|
||||
if (!extras.embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// transformers.js not supported in JetBrains IDEs right now
|
||||
|
||||
const isJetBrainsAndTransformersJs =
|
||||
extras.embeddingsProvider.providerName ===
|
||||
TransformersJsEmbeddingsProvider.providerName &&
|
||||
(await extras.ide.getIdeInfo()).ideType === "jetbrains";
|
||||
|
||||
if (isJetBrainsAndTransformersJs) {
|
||||
void extras.ide.showToast(
|
||||
"warning",
|
||||
"Codebase retrieval is limited when `embeddingsProvider` is empty or set to `transformers.js` in JetBrains. " +
|
||||
"You can use Ollama to set up local embeddings, use our 'free-trial', " +
|
||||
"or configure your own. See here to learn more: " +
|
||||
"https://docs.continue.dev/customize/model-types/embeddings",
|
||||
);
|
||||
return [];
|
||||
}
|
||||
// Currently you can use codebase without an embeddings provider and it will just skip the embeddings inputs
|
||||
// if (!extras.embeddingsProvider) {
|
||||
// void extras.ide.showToast(
|
||||
// "warning",
|
||||
// "Set up an embeddings model to use this feature. Visit the docs to learn more: " +
|
||||
// "https://docs.continue.dev/customize/model-types/embeddings",
|
||||
// );
|
||||
// return [];
|
||||
// }
|
||||
const includeEmbeddings = !!extras.config.selectedModelByRole.embed;
|
||||
|
||||
// Get tags to retrieve for
|
||||
const workspaceDirs = await extras.ide.getWorkspaceDirs();
|
||||
|
|
@ -79,7 +67,6 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
input: extras.fullInput,
|
||||
llm: extras.llm,
|
||||
config: extras.config,
|
||||
includeEmbeddings: !isJetBrainsAndTransformersJs,
|
||||
};
|
||||
|
||||
const pipeline = new pipelineType(pipelineOptions);
|
||||
|
|
@ -87,16 +74,17 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
tags,
|
||||
filterDirectory,
|
||||
query: extras.fullInput,
|
||||
includeEmbeddings,
|
||||
});
|
||||
|
||||
if (results.length === 0) {
|
||||
if (extras.config.disableIndexing) {
|
||||
void extras.ide.showToast("warning", "No embeddings results found.");
|
||||
void extras.ide.showToast("warning", "No results found.");
|
||||
return [];
|
||||
} else {
|
||||
void extras.ide.showToast(
|
||||
"warning",
|
||||
"No embeddings results found. If you think this is an error, re-index your codebase.",
|
||||
"No results found. If you think this is an error, re-index your codebase.",
|
||||
);
|
||||
// TODO - add "re-index" option to warning message which clears and reindexes codebase
|
||||
}
|
||||
|
|
|
|||
43
core/core.ts
43
core/core.ts
|
|
@ -390,11 +390,11 @@ export class Core {
|
|||
const items = await provider.getContextItems(query, {
|
||||
config,
|
||||
llm,
|
||||
embeddingsProvider: config.embeddingsProvider,
|
||||
embeddingsProvider: config.selectedModelByRole.embed,
|
||||
fullInput,
|
||||
ide,
|
||||
selectedCode,
|
||||
reranker: config.reranker,
|
||||
reranker: config.selectedModelByRole.rerank,
|
||||
fetch: (url, init) =>
|
||||
fetchwithRequestOptions(url, init, config.requestOptions),
|
||||
});
|
||||
|
|
@ -415,26 +415,25 @@ export class Core {
|
|||
let knownError = false;
|
||||
|
||||
if (e instanceof Error) {
|
||||
// A specific error where we're forcing the presence of embeddings provider on the config
|
||||
// But Jetbrains doesn't support transformers JS
|
||||
// So if a context provider needs it it will throw this error when the file isn't found
|
||||
if (e.message.includes("all-MiniLM-L6-v2")) {
|
||||
knownError = true;
|
||||
const toastOption = "See Docs";
|
||||
void this.ide
|
||||
.showToast(
|
||||
"error",
|
||||
`Set up an embeddings model to use @${name}`,
|
||||
toastOption,
|
||||
)
|
||||
.then((userSelection) => {
|
||||
if (userSelection === toastOption) {
|
||||
void this.ide.openUrl(
|
||||
"https://docs.continue.dev/customize/model-types/embeddings",
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
// After removing transformers JS embeddings provider from jetbrains
|
||||
// Should no longer see this error
|
||||
// if (e.message.toLowerCase().includes("embeddings provider")) {
|
||||
// knownError = true;
|
||||
// const toastOption = "See Docs";
|
||||
// void this.ide
|
||||
// .showToast(
|
||||
// "error",
|
||||
// `Set up an embeddings model to use @${name}`,
|
||||
// toastOption,
|
||||
// )
|
||||
// .then((userSelection) => {
|
||||
// if (userSelection === toastOption) {
|
||||
// void this.ide.openUrl(
|
||||
// "https://docs.continue.dev/customize/model-types/embeddings",
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
if (!knownError) {
|
||||
void this.ide.showToast(
|
||||
|
|
|
|||
11
core/index.d.ts
vendored
11
core/index.d.ts
vendored
|
|
@ -60,7 +60,7 @@ export interface IndexingStatus {
|
|||
progress: number;
|
||||
description: string;
|
||||
status: "indexing" | "complete" | "paused" | "failed" | "aborted" | "pending";
|
||||
embeddingsProviderId: string;
|
||||
embeddingsProviderId?: string;
|
||||
isReindexing?: boolean;
|
||||
debugInfo?: string;
|
||||
title: string;
|
||||
|
|
@ -179,8 +179,8 @@ export type FetchFunction = (url: string | URL, init?: any) => Promise<any>;
|
|||
export interface ContextProviderExtras {
|
||||
config: ContinueConfig;
|
||||
fullInput: string;
|
||||
embeddingsProvider: ILLM;
|
||||
reranker: ILLM | undefined;
|
||||
embeddingsProvider: ILLM | null;
|
||||
reranker: ILLM | null;
|
||||
llm: ILLM;
|
||||
ide: IDE;
|
||||
selectedCode: RangeInFile[];
|
||||
|
|
@ -1213,11 +1213,8 @@ export interface ContinueConfig {
|
|||
disableSessionTitles?: boolean;
|
||||
disableIndexing?: boolean;
|
||||
userToken?: string;
|
||||
embeddingsProvider: ILLM;
|
||||
tabAutocompleteModels?: ILLM[];
|
||||
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
ui?: ContinueUIConfig;
|
||||
reranker?: ILLM;
|
||||
experimental?: ExperimentalConfig;
|
||||
analytics?: AnalyticsConfig;
|
||||
docs?: SiteIndexingConfig[];
|
||||
|
|
@ -1237,9 +1234,7 @@ export interface BrowserSerializedContinueConfig {
|
|||
disableIndexing?: boolean;
|
||||
disableSessionTitles?: boolean;
|
||||
userToken?: string;
|
||||
embeddingsProvider?: string;
|
||||
ui?: ContinueUIConfig;
|
||||
reranker?: RerankerDescription;
|
||||
experimental?: ExperimentalConfig;
|
||||
analytics?: AnalyticsConfig;
|
||||
docs?: SiteIndexingConfig[];
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import { IContinueServerClient } from "../continueServer/interface.js";
|
|||
import { IDE, IndexingProgressUpdate, IndexTag } from "../index.js";
|
||||
import { extractMinimalStackTraceInfo } from "../util/extractMinimalStackTraceInfo.js";
|
||||
import { getIndexSqlitePath, getLanceDbPath } from "../util/paths.js";
|
||||
|
||||
import { findUriInDirs, getUriPathBasename } from "../util/uri.js";
|
||||
|
||||
import { ChunkCodebaseIndex } from "./chunk/ChunkCodebaseIndex.js";
|
||||
import { CodeSnippetsCodebaseIndex } from "./CodeSnippetsIndex.js";
|
||||
import { FullTextSearchCodebaseIndex } from "./FullTextSearchCodebaseIndex.js";
|
||||
|
|
@ -80,14 +80,19 @@ export class CodebaseIndexer {
|
|||
return [];
|
||||
}
|
||||
|
||||
const embeddingsModel = config.selectedModelByRole.embed;
|
||||
if (!embeddingsModel) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const indexes = [
|
||||
new ChunkCodebaseIndex(
|
||||
this.ide.readFile.bind(this.ide),
|
||||
this.continueServerClient,
|
||||
config.embeddingsProvider.maxEmbeddingChunkSize,
|
||||
embeddingsModel.maxEmbeddingChunkSize,
|
||||
), // Chunking must come first
|
||||
new LanceDbIndex(
|
||||
config.embeddingsProvider,
|
||||
embeddingsModel,
|
||||
this.ide.readFile.bind(this.ide),
|
||||
this.continueServerClient,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@ import lance from "vectordb";
|
|||
|
||||
import { testConfigHandler, testIde } from "../test/fixtures";
|
||||
import { getLanceDbPath } from "../util/paths";
|
||||
|
||||
import { LanceDbIndex } from "./LanceDbIndex";
|
||||
import { DatabaseConnection, SqliteDb } from "./refreshIndex";
|
||||
import {
|
||||
mockPathAndCacheKey,
|
||||
mockTag,
|
||||
testContinueServerClient,
|
||||
updateIndexAndAwaitGenerator,
|
||||
} from "./test/indexing";
|
||||
|
||||
import { LanceDbIndex } from "./LanceDbIndex";
|
||||
import { DatabaseConnection, SqliteDb } from "./refreshIndex";
|
||||
import { IndexResultType } from "./types";
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
|
@ -30,9 +30,12 @@ describe.skip("ChunkCodebaseIndex", () => {
|
|||
if (!mockConfig) {
|
||||
throw new Error("Failed to load config");
|
||||
}
|
||||
if (!mockConfig.selectedModelByRole.embed) {
|
||||
throw new Error("No embeddings model selected");
|
||||
}
|
||||
|
||||
index = new LanceDbIndex(
|
||||
mockConfig.embeddingsProvider,
|
||||
mockConfig.selectedModelByRole.embed,
|
||||
testIde.readFile.bind(testIde),
|
||||
testContinueServerClient,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ type ChunkMap = Map<string, ItemWithChunks>;
|
|||
export class LanceDbIndex implements CodebaseIndex {
|
||||
relativeExpectedTime: number = 13;
|
||||
get artifactId(): string {
|
||||
return `vectordb::${this.embeddingsProvider.embeddingId}`;
|
||||
return `vectordb::${this.embeddingsProvider?.embeddingId}`;
|
||||
}
|
||||
|
||||
constructor(
|
||||
private readonly embeddingsProvider: ILLM,
|
||||
private readonly embeddingsProvider: ILLM | null,
|
||||
private readonly readFile: (filepath: string) => Promise<string>,
|
||||
private readonly continueServerClient?: IContinueServerClient,
|
||||
) {}
|
||||
|
|
@ -142,6 +142,9 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
item: PathAndCacheKey,
|
||||
content: string,
|
||||
): Promise<Chunk[]> {
|
||||
if (!this.embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
const chunks: Chunk[] = [];
|
||||
|
||||
const chunkParams = {
|
||||
|
|
@ -163,6 +166,9 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
}
|
||||
|
||||
private async getEmbeddings(chunks: Chunk[]): Promise<number[][]> {
|
||||
if (!this.embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
return await this.embeddingsProvider.embed(chunks.map((c) => c.content));
|
||||
} catch (err) {
|
||||
|
|
@ -436,6 +442,9 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
tags: BranchAndDir[],
|
||||
filterDirectory: string | undefined,
|
||||
): Promise<Chunk[]> {
|
||||
if (!this.embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
const [vector] = await this.embeddingsProvider.embed([query]);
|
||||
const db = await lance.connect(getLanceDbPath());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { open, type Database } from "sqlite";
|
||||
import sqlite3 from "sqlite3";
|
||||
import lancedb, { Connection } from "vectordb";
|
||||
|
|
@ -19,6 +20,7 @@ import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbed
|
|||
import { FromCoreProtocol, ToCoreProtocol } from "../../protocol";
|
||||
import { IMessenger } from "../../protocol/messenger";
|
||||
import { fetchFavicon, getFaviconBase64 } from "../../util/fetchFavicon";
|
||||
import { GlobalContext } from "../../util/GlobalContext";
|
||||
import {
|
||||
editConfigJson,
|
||||
getDocsSqlitePath,
|
||||
|
|
@ -26,8 +28,6 @@ import {
|
|||
} from "../../util/paths";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { GlobalContext } from "../../util/GlobalContext";
|
||||
import {
|
||||
ArticleWithChunks,
|
||||
htmlPageToArticleWithChunks,
|
||||
|
|
@ -161,16 +161,22 @@ export default class DocsService {
|
|||
return;
|
||||
}
|
||||
|
||||
const sharedStatus = {
|
||||
type: "docs" as IndexingStatus["type"],
|
||||
const sharedStatus: Omit<
|
||||
IndexingStatus,
|
||||
"progress" | "description" | "status"
|
||||
> = {
|
||||
type: "docs",
|
||||
id: doc.startUrl,
|
||||
embeddingsProviderId: this.config.embeddingsProvider.embeddingId,
|
||||
isReindexing: false,
|
||||
title: doc.title,
|
||||
debugInfo: `max depth: ${doc.maxDepth}`,
|
||||
icon: doc.faviconUrl,
|
||||
url: doc.startUrl,
|
||||
};
|
||||
if (this.config.selectedModelByRole.embed) {
|
||||
sharedStatus.embeddingsProviderId =
|
||||
this.config.selectedModelByRole.embed.embeddingId;
|
||||
}
|
||||
const indexedStatus: IndexingStatus = metadata.find(
|
||||
(meta) => meta.startUrl === doc.startUrl,
|
||||
)
|
||||
|
|
@ -214,7 +220,9 @@ export default class DocsService {
|
|||
}
|
||||
|
||||
// Handle embeddings provider change mid-indexing
|
||||
if (this.config.embeddingsProvider.embeddingId !== startedWithEmbedder) {
|
||||
if (
|
||||
this.config.selectedModelByRole.embed?.embeddingId !== startedWithEmbedder
|
||||
) {
|
||||
this.abort(startUrl);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -234,14 +242,6 @@ export default class DocsService {
|
|||
return true;
|
||||
}
|
||||
|
||||
async isUsingUnsupportedPreIndexedEmbeddingsProvider() {
|
||||
const isPreIndexedDocsProvider =
|
||||
this.config.embeddingsProvider.embeddingId ===
|
||||
DocsService.preIndexedDocsEmbeddingsProvider.embeddingId;
|
||||
const canUsePreindexedDocs = await this.canUsePreindexedDocs();
|
||||
return isPreIndexedDocsProvider && !canUsePreindexedDocs;
|
||||
}
|
||||
|
||||
// Determines if using preIndexed and returns proper embeddings provider
|
||||
async getEmbeddingsProvider(startUrl: string) {
|
||||
// Conditions for using a pre-indexed doc
|
||||
|
|
@ -262,7 +262,7 @@ export default class DocsService {
|
|||
}
|
||||
}
|
||||
return {
|
||||
provider: this.config.embeddingsProvider,
|
||||
provider: this.config.selectedModelByRole.embed,
|
||||
isPreindexed: false,
|
||||
};
|
||||
}
|
||||
|
|
@ -282,9 +282,7 @@ export default class DocsService {
|
|||
|
||||
// Skip docs indexing if not supported
|
||||
// No warning message here because would show on ANY config update
|
||||
const unsupported =
|
||||
await this.isUsingUnsupportedPreIndexedEmbeddingsProvider();
|
||||
if (unsupported) {
|
||||
if (!this.config.selectedModelByRole.embed) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -323,18 +321,21 @@ export default class DocsService {
|
|||
|
||||
// Returns true if startUrl has been indexed with current embeddingsProvider
|
||||
async hasMetadata(startUrl: string): Promise<boolean> {
|
||||
if (!this.config.selectedModelByRole.embed) {
|
||||
return false;
|
||||
}
|
||||
const db = await this.getOrCreateSqliteDb();
|
||||
const title = await db.get(
|
||||
`SELECT title FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`,
|
||||
startUrl,
|
||||
this.config.embeddingsProvider.embeddingId,
|
||||
this.config.selectedModelByRole.embed.embeddingId,
|
||||
);
|
||||
|
||||
return !!title;
|
||||
}
|
||||
|
||||
async listMetadata() {
|
||||
const embeddingsProvider = this.config.embeddingsProvider;
|
||||
const embeddingsProvider = this.config.selectedModelByRole.embed;
|
||||
if (!embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -376,6 +377,11 @@ export default class DocsService {
|
|||
console.warn("Attempted to indexAndAdd pre-indexed doc");
|
||||
return;
|
||||
}
|
||||
if (!provider) {
|
||||
console.warn("@docs indexAndAdd: no embeddings provider found");
|
||||
return;
|
||||
}
|
||||
|
||||
const startedWithEmbedder = provider.embeddingId;
|
||||
|
||||
// Check if doc has been successfully indexed with the given embedder
|
||||
|
|
@ -716,21 +722,18 @@ export default class DocsService {
|
|||
startUrl: string,
|
||||
nRetrieve: number,
|
||||
) {
|
||||
if (await this.isUsingUnsupportedPreIndexedEmbeddingsProvider()) {
|
||||
await this.ide.showToast(
|
||||
"error",
|
||||
`${DocsService.preIndexedDocsEmbeddingsProvider.embeddingId} is configured as ` +
|
||||
"the embeddings provider, but it cannot be used with JetBrains. " + // TODO "with this IDE"
|
||||
"Please select a different embeddings provider to use the '@docs' " +
|
||||
"context provider.",
|
||||
);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
const { isPreindexed, provider } =
|
||||
await this.getEmbeddingsProvider(startUrl);
|
||||
|
||||
if (!provider) {
|
||||
void this.ide.showToast(
|
||||
"error",
|
||||
"Set up an embeddings model to use the @docs context provider. See: " +
|
||||
"https://docs.continue.dev/customize/model-types/embeddings",
|
||||
);
|
||||
return [];
|
||||
}
|
||||
|
||||
if (isPreindexed) {
|
||||
void Telemetry.capture("docs_pre_indexed_doc_used", {
|
||||
doc: preIndexedDocs[startUrl]!["title"],
|
||||
|
|
@ -761,8 +764,10 @@ export default class DocsService {
|
|||
try {
|
||||
const { isPreindexed, provider } =
|
||||
await this.getEmbeddingsProvider(startUrl);
|
||||
const preIndexedDoc = preIndexedDocs[startUrl];
|
||||
const isPreIndexedDoc = !!preIndexedDoc;
|
||||
|
||||
if (!provider) {
|
||||
throw new Error("No embeddings model set");
|
||||
}
|
||||
|
||||
const result = await db.get(
|
||||
`SELECT startUrl, title, favicon FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`,
|
||||
|
|
@ -793,7 +798,7 @@ export default class DocsService {
|
|||
config: siteIndexingConfig,
|
||||
indexingStatus: this.statuses.get(startUrl),
|
||||
chunks: rows.map(this.lanceDBRowToChunk),
|
||||
isPreIndexedDoc,
|
||||
isPreIndexedDoc: isPreindexed,
|
||||
};
|
||||
} catch (e) {
|
||||
console.warn("Error getting details", e);
|
||||
|
|
@ -867,7 +872,7 @@ export default class DocsService {
|
|||
}
|
||||
|
||||
async getFavicon(startUrl: string) {
|
||||
if (!this.config.embeddingsProvider) {
|
||||
if (!this.config.selectedModelByRole.embed) {
|
||||
console.warn(
|
||||
"Attempting to get favicon without embeddings provider specified",
|
||||
);
|
||||
|
|
@ -877,7 +882,7 @@ export default class DocsService {
|
|||
const result = await db.get(
|
||||
`SELECT favicon FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`,
|
||||
startUrl,
|
||||
this.config.embeddingsProvider.embeddingId,
|
||||
this.config.selectedModelByRole.embed.embeddingId,
|
||||
);
|
||||
|
||||
if (!result) {
|
||||
|
|
@ -941,7 +946,7 @@ export default class DocsService {
|
|||
type: "docs",
|
||||
id: doc.startUrl,
|
||||
embeddingsProviderId:
|
||||
this.config.embeddingsProvider.embeddingId,
|
||||
this.config.selectedModelByRole.embed?.embeddingId,
|
||||
isReindexing: false,
|
||||
title: doc.title,
|
||||
debugInfo: "Config sync: not changed",
|
||||
|
|
@ -1033,6 +1038,13 @@ export default class DocsService {
|
|||
const conn = await lancedb.connect(getLanceDbPath());
|
||||
const tableNames = await conn.tableNames();
|
||||
const { provider } = await this.getEmbeddingsProvider(startUrl);
|
||||
|
||||
if (!provider) {
|
||||
throw new Error(
|
||||
"Could not retrieve @docs Lance Table: no embeddings provider specified",
|
||||
);
|
||||
}
|
||||
|
||||
const tableNameFromEmbeddingsProvider =
|
||||
await this.getLanceTableName(provider);
|
||||
|
||||
|
|
@ -1089,13 +1101,19 @@ export default class DocsService {
|
|||
siteIndexingConfig: { title, startUrl },
|
||||
favicon,
|
||||
}: AddParams) {
|
||||
if (!this.config.selectedModelByRole.embed) {
|
||||
console.warn(
|
||||
`Attempting to add metadata for ${startUrl} without embeddings provider specified`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const db = await this.getOrCreateSqliteDb();
|
||||
await db.run(
|
||||
`INSERT INTO ${DocsService.sqlitebTableName} (title, startUrl, favicon, embeddingsProviderId) VALUES (?, ?, ?, ?)`,
|
||||
title,
|
||||
startUrl,
|
||||
favicon,
|
||||
this.config.embeddingsProvider.embeddingId,
|
||||
this.config.selectedModelByRole.embed.embeddingId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1147,7 +1165,7 @@ export default class DocsService {
|
|||
}
|
||||
|
||||
private async deleteMetadataFromSqlite(startUrl: string) {
|
||||
if (!this.config.embeddingsProvider) {
|
||||
if (!this.config.selectedModelByRole.embed) {
|
||||
console.warn(
|
||||
`Attempting to delete metadata for ${startUrl} without embeddings provider specified`,
|
||||
);
|
||||
|
|
@ -1158,7 +1176,7 @@ export default class DocsService {
|
|||
await db.run(
|
||||
`DELETE FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`,
|
||||
startUrl,
|
||||
this.config.embeddingsProvider.embeddingId,
|
||||
this.config.selectedModelByRole.embed.embeddingId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export class TransformersJsEmbeddingsProvider extends BaseLLM {
|
|||
static maxGroupSize: number = 1;
|
||||
static model: string = "all-MiniLM-L6-v2";
|
||||
static mockVector: number[] = Array.from({ length: 384 }).fill(2) as number[];
|
||||
static title: string = "Transformers.js";
|
||||
static title: string = "Transformers.js (Built-In)";
|
||||
|
||||
static defaultOptions: Partial<LLMOptions> | undefined = {
|
||||
model: TransformersJsEmbeddingsProvider.model,
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ export function getContextProviderHelpers(
|
|||
async (helperContext: any) => {
|
||||
const items = await provider.getContextItems(helperContext, {
|
||||
config: context.config,
|
||||
embeddingsProvider: context.config.embeddingsProvider,
|
||||
embeddingsProvider: context.config.selectedModelByRole.embed,
|
||||
fetch: context.fetch,
|
||||
fullInput: context.input,
|
||||
ide: context.ide,
|
||||
llm: context.llm,
|
||||
reranker: context.config.reranker,
|
||||
reranker: context.config.selectedModelByRole.rerank,
|
||||
selectedCode: context.selectedCode,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ export async function getContextProvidersString(
|
|||
return provider.getContextItems("", {
|
||||
config,
|
||||
ide,
|
||||
embeddingsProvider: config.embeddingsProvider,
|
||||
reranker: config.reranker,
|
||||
embeddingsProvider: config.selectedModelByRole.embed,
|
||||
reranker: config.selectedModelByRole.rerank,
|
||||
llm: config.models[0],
|
||||
fullInput: "",
|
||||
selectedCode: [],
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ function AddDocsDialog() {
|
|||
type: "docs",
|
||||
description: "Initializing",
|
||||
id: startUrl,
|
||||
embeddingsProviderId: "mock-embeddings-provider-id",
|
||||
progress: 0,
|
||||
status: "indexing",
|
||||
title,
|
||||
|
|
@ -164,7 +163,6 @@ function AddDocsDialog() {
|
|||
type: "docs",
|
||||
description: "Initializing",
|
||||
id: docsResult.details.docsLink,
|
||||
embeddingsProviderId: "mock-embeddings-provider-id",
|
||||
progress: 0,
|
||||
status: "indexing",
|
||||
title: docsResult.details.title ?? docsResult.packageInfo.name,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { XCircleIcon } from "@heroicons/react/24/outline";
|
||||
import { IndexingProgressUpdate } from "core";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { isJetBrains } from "../../../util";
|
||||
|
||||
export interface IndexingProgressErrorTextProps {
|
||||
update: IndexingProgressUpdate;
|
||||
|
|
@ -9,20 +8,16 @@ export interface IndexingProgressErrorTextProps {
|
|||
|
||||
function IndexingProgressErrorText({ update }: IndexingProgressErrorTextProps) {
|
||||
const embeddingsProvider = useAppSelector(
|
||||
(state) => state.config.config.embeddingsProvider,
|
||||
(state) => state.config.config.selectedModelByRole.embed,
|
||||
);
|
||||
|
||||
const showJbError =
|
||||
(isJetBrains() && embeddingsProvider === "all-MiniLM-L6-v2") || true;
|
||||
|
||||
if (showJbError) {
|
||||
if (!embeddingsProvider) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 italic">
|
||||
<XCircleIcon className="h-4 w-4 min-w-[10%]" />
|
||||
<span className="leading-relaxed">
|
||||
The <code>transformers.js</code> embeddingsProvider is currently
|
||||
unsupported in JetBrains. To enable codebase indexing, you can use any
|
||||
of the other providers described in the docs:{" "}
|
||||
Add an Embeddings model to enable codebase indexing. See the docs for
|
||||
examples:
|
||||
<a
|
||||
href="https://docs.continue.dev/walkthroughs/codebase-embeddings#embeddings-providers"
|
||||
target="_blank"
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ const ModelRoleSelector = ({
|
|||
className={`border-vsc-input-border bg-vsc-background ${!!models.length ? "hover:bg-vsc-input-background cursor-pointer" : ""} text-vsc-foreground relative m-0 flex w-full items-center justify-between rounded-md border border-solid px-2 py-1 text-left`}
|
||||
>
|
||||
{models.length === 0 ? (
|
||||
<span className="text-lightgray italic">{`No ${displayName} models`}</span>
|
||||
<span className="text-lightgray italic">{`No ${displayName} models${["Chat", "Apply", "Edit"].includes(displayName) ? ". Using chat model" : ""}`}</span>
|
||||
) : (
|
||||
<span className="lines lines-1">
|
||||
{selectedModel?.title ?? `Select ${displayName} model`}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue