Merge branch 'main' into feat/watsonx_reranker_integration
This commit is contained in:
commit
8cec3fbf8e
103 changed files with 2644 additions and 568 deletions
19
.github/workflows/pr_checks.yaml
vendored
19
.github/workflows/pr_checks.yaml
vendored
|
|
@ -275,7 +275,7 @@ jobs:
|
|||
cd core
|
||||
npm test
|
||||
env:
|
||||
IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork }}
|
||||
IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork == true && github.actor == 'dependabot[bot]' }}
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
|
|
@ -409,6 +409,14 @@ jobs:
|
|||
path: extensions/vscode/node_modules
|
||||
key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
|
||||
|
||||
# We don't want to cache the Continue extension, so it is deleted at the end of the job
|
||||
- uses: actions/cache@v4
|
||||
id: test-extensions-cache
|
||||
with:
|
||||
path: extensions/vscode/e2e/.test-extensions
|
||||
# package.json used as the key because that's where the download script is defined
|
||||
key: vscode-test-extensions-${{ hashFiles('extensions/vscode/package.json') }}
|
||||
|
||||
- name: Download build artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
|
|
@ -436,7 +444,7 @@ jobs:
|
|||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts
|
||||
echo -e "Host ssh-test-container\n\tHostName $SSH_HOST\n\tUser ec2-user\n\tIdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config
|
||||
if: ${{ github.event.pull_request.head.repo.fork == false }}
|
||||
if: ${{ github.event.pull_request.head.repo.fork == false && github.actor != 'dependabot[bot]' }}
|
||||
|
||||
- name: Set up Xvfb
|
||||
run: |
|
||||
|
|
@ -446,10 +454,15 @@ jobs:
|
|||
- name: Run e2e tests
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
IGNORE_SSH_TESTS="${{ github.event.pull_request.head.repo.fork }}" TEST_FILE="${{ matrix.test_file }}" npm run ${{ matrix.command }}
|
||||
IGNORE_SSH_TESTS="${{ github.event.pull_request.head.repo.fork == false && github.actor != 'dependabot[bot]' }}" TEST_FILE="${{ matrix.test_file }}" npm run ${{ matrix.command }}
|
||||
env:
|
||||
DISPLAY: :99
|
||||
|
||||
- name: Delete continue from test extensions
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
rm -rf e2e/.test-extensions/continue*
|
||||
|
||||
- name: Upload e2e test screenshots
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
|
|
|
|||
25
.github/workflows/stale-issue-helper.yaml
vendored
Normal file
25
.github/workflows/stale-issue-helper.yaml
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
name: "Label / close stale issues"
|
||||
on:
|
||||
schedule:
|
||||
- cron: "30 1 * * *"
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
close-issue-message: "This issue was closed because it wasn't updated for 10 days after being marked stale. If it's still important, please reopen + comment and we'll gladly take another look!"
|
||||
stale-issue-message: "This issue hasn't been updated in 90 days and will be closed after an additional 10 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue."
|
||||
days-before-stale: 90
|
||||
days-before-close: 10
|
||||
days-before-pr-stale: -1
|
||||
days-before-pr-close: -1
|
||||
operations-per-run: 1000
|
||||
stale-issue-label: "stale"
|
||||
stale-pr-label: "stale"
|
||||
exempt-issue-labels: "needs-triage,no-stale,high,highest"
|
||||
exempt-pr-labels: "no-stale"
|
||||
6
binary/core-dev-server.js
Normal file
6
binary/core-dev-server.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
const path = require('path');
|
||||
process.env.CONTINUE_DEVELOPMENT = true;
|
||||
|
||||
process.env.CONTINUE_GLOBAL_DIR = path.join(process.env.PROJECT_DIR, 'extensions', '.continue-debug');
|
||||
|
||||
require('./out/index.js');
|
||||
2
binary/package-lock.json
generated
2
binary/package-lock.json
generated
|
|
@ -48,7 +48,7 @@
|
|||
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
|
||||
"@aws-sdk/credential-providers": "^3.620.1",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "^1.0.50",
|
||||
"@continuedev/config-yaml": "^1.0.52",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
20
binary/prompt-logs.js
Normal file
20
binary/prompt-logs.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const logDirPath = path.join(__dirname, '..', 'extensions', '.continue-debug', 'logs');
|
||||
const logFilePath = path.join(logDirPath, "prompt.log");
|
||||
|
||||
if (!fs.existsSync(logDirPath)) {
|
||||
fs.mkdirSync(logDirPath, { recursive: true });
|
||||
}
|
||||
|
||||
if (!fs.existsSync(logFilePath)) {
|
||||
fs.createWriteStream(logFilePath).end();
|
||||
}
|
||||
|
||||
console.log("Watching logs at " + logFilePath)
|
||||
|
||||
fs.watch(logFilePath, () => {
|
||||
// console.clear();
|
||||
fs.createReadStream(logFilePath).pipe(process.stdout);
|
||||
});
|
||||
|
|
@ -134,6 +134,13 @@ export class CompletionProvider {
|
|||
token: AbortSignal | undefined,
|
||||
): Promise<AutocompleteOutcome | undefined> {
|
||||
try {
|
||||
// Create abort signal if not given
|
||||
if (!token) {
|
||||
const controller = this.loggingService.createAbortController(
|
||||
input.completionId,
|
||||
);
|
||||
token = controller.signal;
|
||||
}
|
||||
const startTime = Date.now();
|
||||
const options = await this._getAutocompleteOptions();
|
||||
|
||||
|
|
@ -158,14 +165,6 @@ export class CompletionProvider {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
// Create abort signal if not given
|
||||
if (!token) {
|
||||
const controller = this.loggingService.createAbortController(
|
||||
input.completionId,
|
||||
);
|
||||
token = controller.signal;
|
||||
}
|
||||
|
||||
const [snippetPayload, workspaceDirs] = await Promise.all([
|
||||
getAllSnippets({
|
||||
helper,
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ import ignore from "ignore";
|
|||
|
||||
import type { FileType, IDE, SlashCommand } from "../..";
|
||||
import {
|
||||
defaultIgnoreDir,
|
||||
defaultIgnoreFile,
|
||||
DEFAULT_IGNORE,
|
||||
getGlobalContinueIgArray,
|
||||
gitIgArrayFromFile,
|
||||
} from "../../indexing/ignore";
|
||||
|
|
@ -58,10 +57,7 @@ const OnboardSlashCommand: SlashCommand = {
|
|||
};
|
||||
|
||||
async function getEntriesFilteredByIgnore(dir: string, ide: IDE) {
|
||||
const ig = ignore()
|
||||
.add(defaultIgnoreDir)
|
||||
.add(defaultIgnoreFile)
|
||||
.add(getGlobalContinueIgArray());
|
||||
const ig = ignore().add(DEFAULT_IGNORE).add(getGlobalContinueIgArray());
|
||||
const entries = await ide.listDir(dir);
|
||||
|
||||
const ignoreUri = joinPathsToUri(dir, ".gitignore");
|
||||
|
|
|
|||
|
|
@ -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({})] : []),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ export const sharedConfigSchema = z
|
|||
promptPath: z.string(),
|
||||
|
||||
// `ui` in `ContinueConfig`
|
||||
showSessionTabs: z.boolean(),
|
||||
codeBlockToolbarPosition: z.enum(["top", "bottom"]),
|
||||
fontSize: z.number(),
|
||||
codeWrap: z.boolean(),
|
||||
|
|
@ -134,6 +135,10 @@ export function modifyAnyConfigWithSharedConfig<
|
|||
configCopy.disableSessionTitles = sharedConfig.disableSessionTitles;
|
||||
}
|
||||
|
||||
if (sharedConfig.showSessionTabs !== undefined) {
|
||||
configCopy.ui.showSessionTabs = sharedConfig.showSessionTabs;
|
||||
}
|
||||
|
||||
configCopy.experimental = {
|
||||
...configCopy.experimental,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -415,6 +415,9 @@ export async function loadContinueConfigFromYaml(
|
|||
continueConfig,
|
||||
sharedConfig,
|
||||
);
|
||||
if (withShared.allowAnonymousTelemetry === undefined) {
|
||||
withShared.allowAnonymousTelemetry = true;
|
||||
}
|
||||
|
||||
return {
|
||||
config: withShared,
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider {
|
|||
});
|
||||
}
|
||||
|
||||
private async getRemoteBranchName(
|
||||
private async getRemoteBranchInfo(
|
||||
extras: ContextProviderExtras,
|
||||
): Promise<RemoteBranchInfo> {
|
||||
const subprocess = await getSubprocess(extras);
|
||||
|
|
@ -121,9 +121,16 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider {
|
|||
|
||||
const remoteUrl = await subprocess(`git remote get-url ${branchRemote}`);
|
||||
|
||||
const urlMatches = /:(?<project>.*).git/.exec(remoteUrl);
|
||||
let urlMatches: RegExpExecArray | null;
|
||||
if (/https?.*/.test(remoteUrl)) {
|
||||
const pathname = new URL(remoteUrl).pathname;
|
||||
urlMatches = /\/(?<projectPath>.*?)(?:(?=\.git)|$)/.exec(pathname)
|
||||
} else {
|
||||
// ssh
|
||||
urlMatches = /:(?<projectPath>.*).git/.exec(remoteUrl)
|
||||
}
|
||||
|
||||
const project = urlMatches?.groups?.project ?? null;
|
||||
const project = urlMatches?.groups?.projectPath ?? null;
|
||||
|
||||
return {
|
||||
branch: remoteBranch,
|
||||
|
|
@ -135,7 +142,7 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider {
|
|||
query: string,
|
||||
extras: ContextProviderExtras,
|
||||
): Promise<ContextItem[]> {
|
||||
const { branch, project } = await this.getRemoteBranchName(extras);
|
||||
const { branch, project } = await this.getRemoteBranchInfo(extras);
|
||||
|
||||
const api = await this.getApi();
|
||||
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -62,6 +71,11 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
|
|||
return trigrams;
|
||||
}
|
||||
|
||||
private escapeFtsQueryString(query: string): string {
|
||||
const escapedDoubleQuotes = query.replace(/"/g, '""');
|
||||
return `"${escapedDoubleQuotes}"`;
|
||||
}
|
||||
|
||||
protected async retrieveFts(
|
||||
args: RetrievalPipelineRunArguments,
|
||||
n: number,
|
||||
|
|
@ -71,7 +85,8 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
|
|||
return [];
|
||||
}
|
||||
|
||||
const tokens = this.getCleanedTrigrams(args.query).join(" OR ");
|
||||
const tokensRaw = this.getCleanedTrigrams(args.query).join(" OR ");
|
||||
const tokens = this.escapeFtsQueryString(tokensRaw);
|
||||
|
||||
return await this.ftsIndex.retrieve({
|
||||
n,
|
||||
|
|
@ -111,7 +126,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 +143,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,
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
if (filterDirectory) {
|
||||
// Backup if the individual retrieval methods don't listen
|
||||
retrievalResults = retrievalResults.filter(
|
||||
(chunk) => !!findUriInDirs(chunk.filepath, [filterDirectory]),
|
||||
(chunk) => !!findUriInDirs(chunk.filepath, [filterDirectory]).foundInDir,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,5 +110,8 @@ export async function useHub(
|
|||
ideSettingsPromise: Promise<IdeSettings>,
|
||||
): Promise<boolean> {
|
||||
const ideSettings = await ideSettingsPromise;
|
||||
if (ideSettings.enableControlServerBeta) {
|
||||
return false;
|
||||
}
|
||||
return ideSettings.continueTestEnvironment !== "none";
|
||||
}
|
||||
|
|
|
|||
85
core/core.ts
85
core/core.ts
|
|
@ -1,7 +1,4 @@
|
|||
import path from "path";
|
||||
|
||||
import { fetchwithRequestOptions } from "@continuedev/fetch";
|
||||
import ignore from "ignore";
|
||||
import * as URI from "uri-js";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
|
|
@ -26,7 +23,6 @@ import { streamDiffLines } from "./edit/streamDiffLines";
|
|||
import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer";
|
||||
import DocsService from "./indexing/docs/DocsService";
|
||||
import { getAllSuggestedDocs } from "./indexing/docs/suggestions";
|
||||
import { defaultIgnoreFile } from "./indexing/ignore.js";
|
||||
import Ollama from "./llm/llms/Ollama";
|
||||
import { createNewPromptFileV2 } from "./promptFiles/v2/createNewPromptFile";
|
||||
import { callTool } from "./tools/callTool";
|
||||
|
|
@ -53,6 +49,7 @@ import {
|
|||
type IndexingProgressUpdate,
|
||||
} from ".";
|
||||
|
||||
import { shouldIgnore } from "./indexing/shouldIgnore";
|
||||
import type { FromCoreProtocol, ToCoreProtocol } from "./protocol";
|
||||
import type { IMessenger, Message } from "./protocol/messenger";
|
||||
|
||||
|
|
@ -829,6 +826,10 @@ export class Core {
|
|||
|
||||
// Codebase indexing
|
||||
on("index/forceReIndex", async ({ data }) => {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
if (!config || config.disableIndexing) {
|
||||
return; // TODO silent in case of commands?
|
||||
}
|
||||
if (data?.shouldClearIndexes) {
|
||||
const codebaseIndexer = await this.codebaseIndexerPromise;
|
||||
await codebaseIndexer.clearIndexes();
|
||||
|
|
@ -886,30 +887,51 @@ export class Core {
|
|||
uri.endsWith(".gitignore")
|
||||
) {
|
||||
// Reindex the workspaces
|
||||
this.invoke("index/forceReIndex", undefined);
|
||||
this.invoke("index/forceReIndex", {
|
||||
shouldClearIndexes: true,
|
||||
});
|
||||
} else {
|
||||
// Reindex the file
|
||||
await this.refreshCodebaseIndexFiles([uri]);
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
if (config && !config.disableIndexing) {
|
||||
// Reindex the file
|
||||
const ignore = await shouldIgnore(uri, this.ide);
|
||||
if (!ignore) {
|
||||
await this.refreshCodebaseIndexFiles([uri]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
on("files/created", async ({ data }) => {
|
||||
if (data?.uris?.length) {
|
||||
const refreshIfNotIgnored = async (uris: string[]) => {
|
||||
const toRefresh: string[] = [];
|
||||
for (const uri of uris) {
|
||||
const ignore = await shouldIgnore(uri, ide);
|
||||
if (!ignore) {
|
||||
toRefresh.push(uri);
|
||||
}
|
||||
}
|
||||
if (toRefresh.length > 0) {
|
||||
this.messenger.send("refreshSubmenuItems", {
|
||||
providers: ["file"],
|
||||
});
|
||||
await this.refreshCodebaseIndexFiles(data.uris);
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
if (config && !config.disableIndexing) {
|
||||
await this.refreshCodebaseIndexFiles(toRefresh);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
on("files/created", async ({ data }) => {
|
||||
if (data?.uris?.length) {
|
||||
void refreshIfNotIgnored(data.uris);
|
||||
}
|
||||
});
|
||||
|
||||
on("files/deleted", async ({ data }) => {
|
||||
if (data?.uris?.length) {
|
||||
this.messenger.send("refreshSubmenuItems", {
|
||||
providers: ["file"],
|
||||
});
|
||||
await this.refreshCodebaseIndexFiles(data.uris);
|
||||
void refreshIfNotIgnored(data.uris);
|
||||
}
|
||||
});
|
||||
on("files/opened", async ({ data }) => {
|
||||
|
|
@ -950,15 +972,21 @@ export class Core {
|
|||
});
|
||||
//
|
||||
|
||||
on("didChangeSelectedProfile", (msg) => {
|
||||
void this.configHandler.setSelectedProfile(msg.data.id);
|
||||
void this.configHandler.reloadConfig();
|
||||
on("didChangeSelectedProfile", async (msg) => {
|
||||
await this.configHandler.setSelectedProfile(msg.data.id);
|
||||
await this.configHandler.reloadConfig();
|
||||
});
|
||||
|
||||
on("didChangeSelectedOrg", (msg) => {
|
||||
void this.configHandler.setSelectedOrgId(msg.data.id);
|
||||
void this.configHandler.reloadConfig();
|
||||
void this.configHandler.loadAssistantsForSelectedOrg();
|
||||
on("didChangeSelectedOrg", async (msg) => {
|
||||
await this.configHandler.setSelectedOrgId(msg.data.id);
|
||||
await this.configHandler.loadAssistantsForSelectedOrg();
|
||||
if (msg.data.profileId) {
|
||||
this.invoke("didChangeSelectedProfile", {
|
||||
id: msg.data.profileId,
|
||||
});
|
||||
} else {
|
||||
await this.configHandler.reloadConfig();
|
||||
}
|
||||
});
|
||||
|
||||
on("didChangeControlPlaneSessionInfo", async (msg) => {
|
||||
|
|
@ -975,19 +1003,15 @@ export class Core {
|
|||
});
|
||||
|
||||
on("didChangeActiveTextEditor", async ({ data: { filepath } }) => {
|
||||
const ignoreInstance = ignore().add(defaultIgnoreFile);
|
||||
let rootDirectory = await this.ide.getWorkspaceDirs();
|
||||
const relativeFilePath = path.relative(rootDirectory[0], filepath);
|
||||
try {
|
||||
if (!ignoreInstance.ignores(relativeFilePath)) {
|
||||
const ignore = shouldIgnore(filepath, this.ide);
|
||||
if (!ignore) {
|
||||
recentlyEditedFilesCache.set(filepath, filepath);
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof RangeError) {
|
||||
// do nothing, this can happen when editing a file outside the workspace such as `../extensions/.continue-debug/config.json`
|
||||
} else {
|
||||
console.debug("unhandled ignores error", relativeFilePath, e);
|
||||
}
|
||||
console.error(
|
||||
`didChangeActiveTextEditor: failed to update recentlyEditedFiles cache for ${filepath}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1108,6 +1132,7 @@ export class Core {
|
|||
this.messenger.send("refreshSubmenuItems", {
|
||||
providers: "dependsOnIndexing",
|
||||
});
|
||||
this.indexingCancellationController = undefined;
|
||||
}
|
||||
|
||||
// private
|
||||
|
|
|
|||
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -1033,6 +1033,7 @@ export interface ContinueUIConfig {
|
|||
displayRawMarkdown?: boolean;
|
||||
showChatScrollbar?: boolean;
|
||||
codeWrap?: boolean;
|
||||
showSessionTabs?: boolean;
|
||||
}
|
||||
|
||||
export interface ContextMenuConfig {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { getComputeDeleteAddRemove } from "./refreshIndex.js";
|
|||
import {
|
||||
CodebaseIndex,
|
||||
IndexResultType,
|
||||
PathAndCacheKey,
|
||||
RefreshIndexResults,
|
||||
} from "./types.js";
|
||||
import { walkDirAsync } from "./walkDir.js";
|
||||
|
|
@ -85,24 +86,61 @@ 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,
|
||||
),
|
||||
new FullTextSearchCodebaseIndex(),
|
||||
new CodeSnippetsCodebaseIndex(this.ide),
|
||||
];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private totalIndexOps(results: RefreshIndexResults): number {
|
||||
return (
|
||||
results.compute.length +
|
||||
results.del.length +
|
||||
results.addTag.length +
|
||||
results.removeTag.length
|
||||
);
|
||||
}
|
||||
|
||||
private singleFileIndexOps(
|
||||
results: RefreshIndexResults,
|
||||
lastUpdated: PathAndCacheKey[],
|
||||
filePath: string,
|
||||
): [RefreshIndexResults, PathAndCacheKey[]] {
|
||||
const filterFn = (item: PathAndCacheKey) => item.path === filePath;
|
||||
const compute = results.compute.filter(filterFn);
|
||||
const del = results.del.filter(filterFn);
|
||||
const addTag = results.addTag.filter(filterFn);
|
||||
const removeTag = results.removeTag.filter(filterFn);
|
||||
const newResults = {
|
||||
compute,
|
||||
del,
|
||||
addTag,
|
||||
removeTag,
|
||||
};
|
||||
const newLastUpdated = lastUpdated.filter(filterFn);
|
||||
return [newResults, newLastUpdated];
|
||||
}
|
||||
|
||||
public async refreshFile(
|
||||
file: string,
|
||||
workspaceDirs: string[],
|
||||
|
|
@ -120,26 +158,28 @@ export class CodebaseIndexer {
|
|||
const repoName = await this.ide.getRepoName(foundInDir);
|
||||
const indexesToBuild = await this.getIndexesToBuild();
|
||||
const stats = await this.ide.getFileStats([file]);
|
||||
const filePath = Object.keys(stats)[0];
|
||||
for (const index of indexesToBuild) {
|
||||
const tag = {
|
||||
directory: foundInDir,
|
||||
branch,
|
||||
artifactId: index.artifactId,
|
||||
};
|
||||
const [results, lastUpdated, markComplete] =
|
||||
const [fullResults, fullLastUpdated, markComplete] =
|
||||
await getComputeDeleteAddRemove(
|
||||
tag,
|
||||
{ ...stats },
|
||||
(filepath) => this.ide.readFile(filepath),
|
||||
repoName,
|
||||
);
|
||||
// since this is only a single file update / save we do not want to actualy remove anything, we just want to recompute for our single file
|
||||
results.removeTag = [];
|
||||
results.addTag = [];
|
||||
results.del = [];
|
||||
|
||||
const [results, lastUpdated] = this.singleFileIndexOps(
|
||||
fullResults,
|
||||
fullLastUpdated,
|
||||
filePath,
|
||||
);
|
||||
// Don't update if nothing to update. Some of the indices might do unnecessary setup work
|
||||
if (results.compute.length === 0) {
|
||||
if (this.totalIndexOps(results) + lastUpdated.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -420,11 +460,7 @@ export class CodebaseIndexer {
|
|||
(filepath) => this.ide.readFile(filepath),
|
||||
repoName,
|
||||
);
|
||||
const totalOps =
|
||||
results.compute.length +
|
||||
results.del.length +
|
||||
results.addTag.length +
|
||||
results.removeTag.length;
|
||||
const totalOps = this.totalIndexOps(results);
|
||||
let completedOps = 0;
|
||||
|
||||
// Don't update if nothing to update. Some of the indices might do unnecessary setup work
|
||||
|
|
|
|||
|
|
@ -97,13 +97,15 @@ export class FullTextSearchCodebaseIndex implements CodebaseIndex {
|
|||
|
||||
// Delete
|
||||
for (const item of results.del) {
|
||||
await db.run(`
|
||||
DELETE FROM fts WHERE rowid IN (
|
||||
SELECT id FROM fts_metadata WHERE path = ? AND cacheKey = ?
|
||||
)
|
||||
`,[item.path, item.cacheKey]);
|
||||
await db.run("DELETE FROM fts_metadata WHERE path = ? AND cacheKey = ?", [
|
||||
item.path,
|
||||
item.cacheKey,
|
||||
]);
|
||||
|
||||
await db.run("DELETE FROM fts WHERE path = ?", [item.path]);
|
||||
|
||||
await markComplete([item], IndexResultType.Delete);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,12 +345,10 @@ 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 = ?",
|
||||
"SELECT * FROM lance_db_cache WHERE cacheKey = ? AND artifact_id = ?",
|
||||
cacheKey,
|
||||
path,
|
||||
this.artifactId,
|
||||
);
|
||||
const cachedItems = await stmt.all();
|
||||
|
|
@ -360,7 +387,6 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
};
|
||||
}
|
||||
|
||||
// Delete or remove tag - remove from lance table)
|
||||
if (!needToCreateLanceTable) {
|
||||
const toDel = [...results.removeTag, ...results.del];
|
||||
|
||||
|
|
@ -369,7 +395,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 +410,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 +439,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 +451,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 +465,7 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
tags: BranchAndDir[],
|
||||
filterDirectory: string | undefined,
|
||||
): Promise<Chunk[]> {
|
||||
const lance = LanceDbIndex.lance!;
|
||||
if (!this.embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,9 +80,9 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
|
|||
`
|
||||
INSERT INTO chunk_tags (chunkId, tag)
|
||||
SELECT id, ? FROM chunks
|
||||
WHERE cacheKey = ? AND path = ?
|
||||
WHERE cacheKey = ?
|
||||
`,
|
||||
[tagString, item.cacheKey, item.path],
|
||||
[tagString, item.cacheKey],
|
||||
);
|
||||
await markComplete([item], IndexResultType.AddTag);
|
||||
accumulatedProgress += 1 / results.addTag.length / 4;
|
||||
|
|
@ -158,7 +158,8 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
|
|||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
tag TEXT NOT NULL,
|
||||
chunkId INTEGER NOT NULL,
|
||||
FOREIGN KEY (chunkId) REFERENCES chunks (id)
|
||||
FOREIGN KEY (chunkId) REFERENCES chunks (id),
|
||||
UNIQUE (tag, chunkId)
|
||||
)`);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,10 @@ export const defaultIgnoreDir = ignore().add(DEFAULT_IGNORE_DIRS);
|
|||
export const DEFAULT_IGNORE =
|
||||
DEFAULT_IGNORE_FILETYPES.join("\n") + "\n" + DEFAULT_IGNORE_DIRS.join("\n");
|
||||
|
||||
export const defaultIgnoreFileAndDir = ignore()
|
||||
.add(defaultIgnoreFile)
|
||||
.add(defaultIgnoreDir);
|
||||
|
||||
export function gitIgArrayFromFile(file: string) {
|
||||
return file
|
||||
.split(/\r?\n/) // Split on new line
|
||||
|
|
|
|||
|
|
@ -157,32 +157,64 @@ async function getAddRemoveForTag(
|
|||
const remove: PathAndCacheKey[] = [];
|
||||
const updateLastUpdated: PathAndCacheKey[] = [];
|
||||
|
||||
for (const item of saved) {
|
||||
const { lastUpdated, ...pathAndCacheKey } = item;
|
||||
// First, group items by path and find latest timestamp for each
|
||||
const pathGroups = new Map<string, {
|
||||
latest: { lastUpdated: number, cacheKey: string },
|
||||
allVersions: Array<{ cacheKey: string }>
|
||||
}>();
|
||||
|
||||
if (files[item.path] === undefined) {
|
||||
// Was indexed, but no longer exists. Remove
|
||||
remove.push(pathAndCacheKey);
|
||||
for (const item of saved) {
|
||||
const { lastUpdated, path, cacheKey } = item;
|
||||
|
||||
if (!pathGroups.has(path)) {
|
||||
pathGroups.set(path, {
|
||||
latest: { lastUpdated, cacheKey },
|
||||
allVersions: [{ cacheKey }]
|
||||
});
|
||||
} else {
|
||||
const group = pathGroups.get(path)!;
|
||||
group.allVersions.push({ cacheKey });
|
||||
if (lastUpdated > group.latest.lastUpdated) {
|
||||
group.latest = { lastUpdated, cacheKey };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now process each unique path
|
||||
for (const [path, group] of pathGroups) {
|
||||
if (files[path] === undefined) {
|
||||
// Was indexed, but no longer exists. Remove all versions
|
||||
for (const version of group.allVersions) {
|
||||
remove.push({ path, cacheKey: version.cacheKey });
|
||||
}
|
||||
} else {
|
||||
// Exists in old and new, so determine whether it was updated
|
||||
if (lastUpdated < files[item.path].lastModified) {
|
||||
if (group.latest.lastUpdated < files[path].lastModified) {
|
||||
// Change was made after last update
|
||||
const newHash = calculateHash(await readFile(pathAndCacheKey.path));
|
||||
if (pathAndCacheKey.cacheKey !== newHash) {
|
||||
const newHash = calculateHash(await readFile(path));
|
||||
if (group.latest.cacheKey !== newHash) {
|
||||
updateNewVersion.push({
|
||||
path: pathAndCacheKey.path,
|
||||
path,
|
||||
cacheKey: newHash,
|
||||
});
|
||||
updateOldVersion.push(pathAndCacheKey);
|
||||
for (const version of group.allVersions) {
|
||||
updateOldVersion.push({ path, cacheKey: version.cacheKey });
|
||||
}
|
||||
} else {
|
||||
updateLastUpdated.push(pathAndCacheKey);
|
||||
// File contents did not change
|
||||
updateLastUpdated.push({ path, cacheKey: group.latest.cacheKey });
|
||||
for (const version of group.allVersions) {
|
||||
if (version.cacheKey !== group.latest.cacheKey) {
|
||||
updateOldVersion.push({ path, cacheKey: version.cacheKey });
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Already updated, do nothing
|
||||
}
|
||||
|
||||
// Remove so we can check leftovers afterward
|
||||
delete files[item.path];
|
||||
// Remove path, so that only newly created paths remain
|
||||
delete files[path];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
167
core/indexing/shouldIgnore.test.ts
Normal file
167
core/indexing/shouldIgnore.test.ts
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
// Generated by continue
|
||||
|
||||
import { testIde } from "../test/fixtures";
|
||||
import {
|
||||
TEST_DIR,
|
||||
addToTestDir,
|
||||
setUpTestDir,
|
||||
tearDownTestDir,
|
||||
} from "../test/testDir";
|
||||
|
||||
import { shouldIgnore } from "./shouldIgnore";
|
||||
|
||||
// Test for the shouldIgnore function
|
||||
describe("shouldIgnore", () => {
|
||||
beforeEach(() => {
|
||||
setUpTestDir();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
tearDownTestDir();
|
||||
});
|
||||
|
||||
test("should return true if a file is ignored by .gitignore", async () => {
|
||||
addToTestDir([
|
||||
["ignored-file.txt", "content"],
|
||||
[".gitignore", "ignored-file.txt"],
|
||||
]);
|
||||
const result = await shouldIgnore(TEST_DIR + "/ignored-file.txt", testIde, [
|
||||
TEST_DIR,
|
||||
]);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
test("should return true if a folder is ignored by .continueignore", async () => {
|
||||
addToTestDir([
|
||||
["ignored-folder/file.txt", "content"],
|
||||
[".continueignore", "ignored-folder/"],
|
||||
]);
|
||||
const result = await shouldIgnore(
|
||||
TEST_DIR + "/ignored-folder/file.txt",
|
||||
testIde,
|
||||
[TEST_DIR],
|
||||
);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
test("should return false if a file is not ignored", async () => {
|
||||
addToTestDir([["kept-file.txt", "contents"]]);
|
||||
const result = await shouldIgnore(TEST_DIR + "/kept-file.txt", testIde, [
|
||||
TEST_DIR,
|
||||
]);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
test("should return true if a file is ignored by .gitignore with spaces in file name", async () => {
|
||||
addToTestDir([
|
||||
["ignored file.txt", "content"],
|
||||
[".gitignore", "ignored file.txt"],
|
||||
]);
|
||||
const result = await shouldIgnore(TEST_DIR + "/ignored file.txt", testIde, [
|
||||
TEST_DIR,
|
||||
]);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test("should return true if a .continueignore override ignores file", async () => {
|
||||
addToTestDir([
|
||||
["override-file.txt", "content"],
|
||||
[".gitignore", "override-file.txt"],
|
||||
[".continueignore", "!override-file.txt"],
|
||||
]);
|
||||
const result = await shouldIgnore(
|
||||
TEST_DIR + "/override-file.txt",
|
||||
testIde,
|
||||
[TEST_DIR],
|
||||
);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
test("should return true for deeply nested file ignored by ignore files at multiple levels", async () => {
|
||||
addToTestDir([
|
||||
["level1/level2/level3/ignored-file.txt", "content"],
|
||||
["level1/.gitignore", "level2/"],
|
||||
["level1/level2/.continueignore", "level3/"],
|
||||
]);
|
||||
const result = await shouldIgnore(
|
||||
TEST_DIR + "/level1/level2/level3/ignored-file.txt",
|
||||
testIde,
|
||||
[TEST_DIR],
|
||||
);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test("should return false if a file with spaces is not ignored", async () => {
|
||||
addToTestDir([["kept file.txt", "contents"]]);
|
||||
const result = await shouldIgnore(TEST_DIR + "/kept file.txt", testIde, [
|
||||
TEST_DIR,
|
||||
]);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
test("should handle multiple levels of directories with some files ignored", async () => {
|
||||
addToTestDir([
|
||||
["nested/dir1/.gitignore", "ignored.txt"],
|
||||
["nested/dir1/ignored.txt", "content"],
|
||||
["nested/dir2/kept.txt", "content"],
|
||||
]);
|
||||
const ignoredResult = await shouldIgnore(
|
||||
TEST_DIR + "/nested/dir1/ignored.txt",
|
||||
testIde,
|
||||
[TEST_DIR],
|
||||
);
|
||||
expect(ignoredResult).toBe(true);
|
||||
|
||||
const keptResult = await shouldIgnore(
|
||||
TEST_DIR + "/nested/dir2/kept.txt",
|
||||
testIde,
|
||||
[TEST_DIR],
|
||||
);
|
||||
expect(keptResult).toBe(false);
|
||||
});
|
||||
|
||||
test("should respect default file and folder ignores top level", async () => {
|
||||
addToTestDir([
|
||||
[".env", "contents"],
|
||||
["go.sum", "contents"],
|
||||
".idea/",
|
||||
[".idea/test.xml", "contents"],
|
||||
]);
|
||||
let result = await shouldIgnore(TEST_DIR + "/.env", testIde, [TEST_DIR]);
|
||||
expect(result).toBe(true);
|
||||
|
||||
result = await shouldIgnore(TEST_DIR + "/go.sum", testIde, [TEST_DIR]);
|
||||
expect(result).toBe(true);
|
||||
|
||||
result = await shouldIgnore(TEST_DIR + "/.idea", testIde, [TEST_DIR]);
|
||||
expect(result).toBe(true);
|
||||
|
||||
result = await shouldIgnore(TEST_DIR + "/.idea/test.xml", testIde, [
|
||||
TEST_DIR,
|
||||
]);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test("should respect default file and folder ignores at nested level", async () => {
|
||||
addToTestDir([
|
||||
"nested/.idea/test.xml",
|
||||
["nested/.env", "contents"],
|
||||
["nested/go.sum", "contents"],
|
||||
]);
|
||||
|
||||
let result = await shouldIgnore(TEST_DIR + "/nested/.idea", testIde, [
|
||||
TEST_DIR,
|
||||
]);
|
||||
expect(result).toBe(true);
|
||||
|
||||
result = await shouldIgnore(TEST_DIR + "/nested/.idea/test.xml", testIde, [
|
||||
TEST_DIR,
|
||||
]);
|
||||
expect(result).toBe(true);
|
||||
|
||||
result = await shouldIgnore(TEST_DIR + "/nested/.env", testIde, [TEST_DIR]);
|
||||
expect(result).toBe(true);
|
||||
|
||||
result = await shouldIgnore(TEST_DIR + "/nested/go.sum", testIde, [
|
||||
TEST_DIR,
|
||||
]);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
73
core/indexing/shouldIgnore.ts
Normal file
73
core/indexing/shouldIgnore.ts
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
import ignore from "ignore";
|
||||
import type { FileType, IDE } from "../";
|
||||
import { findUriInDirs, getUriPathBasename } from "../util/uri";
|
||||
import { defaultIgnoreFileAndDir, getGlobalContinueIgArray } from "./ignore";
|
||||
import { getIgnoreContext } from "./walkDir";
|
||||
|
||||
/*
|
||||
Process:
|
||||
1. Check global/default ignores
|
||||
2. Walk UP tree from file, checking ignores at each level
|
||||
|
||||
TODO there might be issues with symlinks here
|
||||
*/
|
||||
export async function shouldIgnore(
|
||||
fileUri: string,
|
||||
ide: IDE,
|
||||
rootDirCandidates?: string[],
|
||||
): Promise<boolean> {
|
||||
const rootDirUris = rootDirCandidates ?? (await ide.getWorkspaceDirs());
|
||||
const { foundInDir: rootDir, uri } = findUriInDirs(fileUri, rootDirUris);
|
||||
|
||||
if (!rootDir) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const defaultAndGlobalIgnores = ignore()
|
||||
.add(defaultIgnoreFileAndDir)
|
||||
.add(getGlobalContinueIgArray());
|
||||
|
||||
let currentDir = uri;
|
||||
let directParent = true;
|
||||
let fileType = 1 as FileType.File as FileType;
|
||||
while (currentDir !== rootDir) {
|
||||
// Go to parent dir of file
|
||||
const splitUri = currentDir.split("/");
|
||||
splitUri.pop();
|
||||
currentDir = splitUri.join("/");
|
||||
|
||||
// Get all files in the dir
|
||||
const dirEntries = await ide.listDir(currentDir);
|
||||
|
||||
// Check if the file is a symbolic link, ignore if so
|
||||
if (directParent) {
|
||||
directParent = false;
|
||||
const baseName = getUriPathBasename(fileUri);
|
||||
const entry = dirEntries.find(([name, _]) => name === baseName);
|
||||
if (entry) {
|
||||
fileType = entry[1];
|
||||
if (fileType === (64 as FileType.SymbolicLink)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ignoreContext = await getIgnoreContext(
|
||||
currentDir,
|
||||
dirEntries,
|
||||
ide,
|
||||
defaultAndGlobalIgnores,
|
||||
);
|
||||
|
||||
let relativePath = uri.substring(currentDir.length + 1);
|
||||
if (fileType === (2 as FileType.Directory)) {
|
||||
relativePath += "/";
|
||||
}
|
||||
|
||||
if (ignoreContext.ignores(relativePath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
// Generated by continue
|
||||
import { testIde } from "../test/fixtures";
|
||||
import {
|
||||
setUpTestDir,
|
||||
tearDownTestDir,
|
||||
addToTestDir,
|
||||
TEST_DIR_PATH,
|
||||
} from "../test/testDir";
|
||||
import { walkDir, walkDirAsync, walkDirs } from "../indexing/walkDir";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { walkDir, walkDirAsync, walkDirs } from "../indexing/walkDir";
|
||||
import { testIde } from "../test/fixtures";
|
||||
import {
|
||||
addToTestDir,
|
||||
setUpTestDir,
|
||||
tearDownTestDir,
|
||||
TEST_DIR_PATH,
|
||||
} from "../test/testDir";
|
||||
|
||||
describe("walkDir functions", () => {
|
||||
beforeEach(async () => {
|
||||
|
|
@ -19,6 +19,27 @@ describe("walkDir functions", () => {
|
|||
tearDownTestDir();
|
||||
});
|
||||
|
||||
// describe.only("test speed", () => {
|
||||
// it("should walk a simple directory structure", async () => {
|
||||
// addToTestDir([
|
||||
// "src/",
|
||||
// ["src/file1.ts", "content1"],
|
||||
// ["src/file2.ts", "content2"],
|
||||
// "src/nested/",
|
||||
// ["src/nested/file3.ts", "content3"],
|
||||
// ]);
|
||||
|
||||
// const dir = await testIde.getWorkspaceDirs();
|
||||
|
||||
// const start = Date.now();
|
||||
// for (let i = 0; i < 10000; i++) {
|
||||
// await walkDir(dir[0], testIde);
|
||||
// }
|
||||
// const passed = Date.now() - start;
|
||||
// console.log(`Test took ${passed} ms`);
|
||||
// });
|
||||
// });
|
||||
|
||||
describe("walkDir", () => {
|
||||
it("should walk a simple directory structure", async () => {
|
||||
addToTestDir([
|
||||
|
|
@ -313,6 +334,9 @@ describe("walkDir functions", () => {
|
|||
["node_modules/package/index.js", "content"],
|
||||
["dist/bundle.js", "content"],
|
||||
["coverage/lcov.env", "content"],
|
||||
["nested/node_modules/package/index.js", "content"],
|
||||
["nested/dist/bundle.js", "content"],
|
||||
["nested/coverage/lcov.env", "content"],
|
||||
]);
|
||||
|
||||
const files = await walkDir(
|
||||
|
|
@ -327,6 +351,9 @@ describe("walkDir functions", () => {
|
|||
expect(files).not.toContain(".git/config");
|
||||
expect(files).not.toContain("node_modules/package/index.js");
|
||||
expect(files).not.toContain("coverage/lcov.info");
|
||||
expect(files).not.toContain("nested/node_modules/package/index.js");
|
||||
expect(files).not.toContain("nested/dist/bundle.js");
|
||||
expect(files).not.toContain("nested/coverage/lcov.env");
|
||||
});
|
||||
|
||||
it("should handle directory-specific ignore patterns correctly", async () => {
|
||||
|
|
|
|||
|
|
@ -2,27 +2,23 @@ import ignore, { Ignore } from "ignore";
|
|||
|
||||
import type { FileType, IDE } from "..";
|
||||
|
||||
import { joinPathsToUri } from "../util/uri";
|
||||
import {
|
||||
DEFAULT_IGNORE_DIRS,
|
||||
DEFAULT_IGNORE_FILETYPES,
|
||||
defaultIgnoreDir,
|
||||
defaultIgnoreFile,
|
||||
defaultIgnoreFileAndDir,
|
||||
getGlobalContinueIgArray,
|
||||
gitIgArrayFromFile,
|
||||
} from "./ignore";
|
||||
import { joinPathsToUri } from "../util/uri";
|
||||
|
||||
export interface WalkerOptions {
|
||||
ignoreFiles?: string[];
|
||||
onlyDirs?: boolean;
|
||||
returnRelativeUrisPaths?: boolean;
|
||||
additionalIgnoreRules?: string[];
|
||||
}
|
||||
|
||||
type Entry = [string, FileType];
|
||||
|
||||
// helper struct used for the DFS walk
|
||||
type WalkableEntry = {
|
||||
name: string;
|
||||
relativeUriPath: string;
|
||||
uri: string;
|
||||
type: FileType;
|
||||
|
|
@ -41,143 +37,110 @@ type IgnoreContext = {
|
|||
};
|
||||
|
||||
class DFSWalker {
|
||||
private readonly ignoreFileNames: Set<string>;
|
||||
|
||||
constructor(
|
||||
private readonly uri: string,
|
||||
private readonly ide: IDE,
|
||||
private readonly options: WalkerOptions,
|
||||
) {
|
||||
this.ignoreFileNames = new Set<string>(options.ignoreFiles);
|
||||
}
|
||||
) {}
|
||||
|
||||
// walk is a depth-first search implementation
|
||||
public async *walk(): AsyncGenerator<string> {
|
||||
const root = this.newRootWalkContext();
|
||||
const stack = [root];
|
||||
for (let cur = stack.pop(); cur; cur = stack.pop()) {
|
||||
const walkableEntries = await this.listDirForWalking(cur.walkableEntry);
|
||||
const ignoreContexts = await this.getIgnoreToApplyInDir(
|
||||
cur,
|
||||
walkableEntries,
|
||||
);
|
||||
for (const w of walkableEntries) {
|
||||
if (!this.shouldInclude(w, ignoreContexts)) {
|
||||
continue;
|
||||
}
|
||||
if (this.entryIsDirectory(w.entry)) {
|
||||
stack.push({
|
||||
walkableEntry: w,
|
||||
ignoreContexts: ignoreContexts,
|
||||
});
|
||||
if (this.options.onlyDirs) {
|
||||
// when onlyDirs is enabled the walker will only return directory names
|
||||
if (this.options.returnRelativeUrisPaths) {
|
||||
yield w.relativeUriPath;
|
||||
} else {
|
||||
yield w.uri;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Note that shouldInclude handles skipping files if options.onlyDirs is true
|
||||
if (this.options.returnRelativeUrisPaths) {
|
||||
yield w.relativeUriPath;
|
||||
} else {
|
||||
yield w.uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const defaultAndGlobalIgnores = ignore()
|
||||
.add(defaultIgnoreFileAndDir)
|
||||
.add(getGlobalContinueIgArray());
|
||||
|
||||
private newRootWalkContext(): WalkContext {
|
||||
const globalIgnoreFile = getGlobalContinueIgArray();
|
||||
return {
|
||||
const rootContext: WalkContext = {
|
||||
walkableEntry: {
|
||||
name: "",
|
||||
relativeUriPath: "",
|
||||
uri: this.uri,
|
||||
type: 2 as FileType.Directory,
|
||||
entry: ["", 2 as FileType.Directory],
|
||||
},
|
||||
ignoreContexts: [
|
||||
ignoreContexts: [],
|
||||
};
|
||||
const stack = [rootContext];
|
||||
|
||||
for (let cur = stack.pop(); cur; cur = stack.pop()) {
|
||||
// Only directories will be added to the stack
|
||||
const entries = await this.ide.listDir(cur.walkableEntry.uri);
|
||||
|
||||
const newIgnore = await getIgnoreContext(
|
||||
cur.walkableEntry.uri,
|
||||
entries,
|
||||
this.ide,
|
||||
defaultAndGlobalIgnores,
|
||||
);
|
||||
|
||||
const ignoreContexts = [
|
||||
...cur.ignoreContexts,
|
||||
{
|
||||
ignore: ignore()
|
||||
.add(defaultIgnoreDir)
|
||||
.add(defaultIgnoreFile)
|
||||
.add(globalIgnoreFile),
|
||||
dirname: "",
|
||||
ignore: newIgnore,
|
||||
dirname: cur.walkableEntry.relativeUriPath,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
private async listDirForWalking(
|
||||
walkableEntry: WalkableEntry,
|
||||
): Promise<WalkableEntry[]> {
|
||||
const entries = await this.ide.listDir(walkableEntry.uri);
|
||||
return entries.map((e) => ({
|
||||
relativeUriPath: `${walkableEntry.relativeUriPath}${walkableEntry.relativeUriPath ? "/" : ""}${e[0]}`,
|
||||
uri: joinPathsToUri(walkableEntry.uri, e[0]),
|
||||
type: e[1],
|
||||
entry: e,
|
||||
}));
|
||||
}
|
||||
for (const entry of entries) {
|
||||
if (this.entryIsSymlink(entry)) {
|
||||
// If called from the root, a symlink either links to a real file in this repository,
|
||||
// and therefore will be walked OR it links to something outside of the repository and
|
||||
// we do not want to index it
|
||||
continue;
|
||||
}
|
||||
const walkableEntry = {
|
||||
name: entry[0],
|
||||
relativeUriPath: `${cur.walkableEntry.relativeUriPath}${cur.walkableEntry.relativeUriPath ? "/" : ""}${entry[0]}`,
|
||||
uri: joinPathsToUri(cur.walkableEntry.uri, entry[0]),
|
||||
type: entry[1],
|
||||
entry: entry,
|
||||
};
|
||||
|
||||
private async getIgnoreToApplyInDir(
|
||||
curDir: WalkContext,
|
||||
entriesInDir: WalkableEntry[],
|
||||
): Promise<IgnoreContext[]> {
|
||||
const ignoreFilesInDir = await this.loadIgnoreFiles(entriesInDir);
|
||||
if (ignoreFilesInDir.length === 0) {
|
||||
return curDir.ignoreContexts;
|
||||
}
|
||||
const patterns = ignoreFilesInDir.map((c) => gitIgArrayFromFile(c)).flat();
|
||||
const newIgnoreContext = {
|
||||
ignore: ignore().add(patterns),
|
||||
dirname: curDir.walkableEntry.relativeUriPath,
|
||||
};
|
||||
return [...curDir.ignoreContexts, newIgnoreContext];
|
||||
}
|
||||
let relPath = walkableEntry.relativeUriPath;
|
||||
if (this.entryIsDirectory(entry)) {
|
||||
relPath = `${relPath}/`;
|
||||
} else {
|
||||
if (this.options.onlyDirs) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let shouldInclude = true;
|
||||
for (const ig of ignoreContexts) {
|
||||
// remove the directory name and path separator from the match path, unless this an ignore file
|
||||
// in the root directory
|
||||
const prefixLength =
|
||||
ig.dirname.length === 0 ? 0 : ig.dirname.length + 1;
|
||||
// The ignore library expects a path relative to the ignore file location
|
||||
const matchPath = relPath.substring(prefixLength);
|
||||
if (ig.ignore.ignores(matchPath)) {
|
||||
shouldInclude = false;
|
||||
}
|
||||
}
|
||||
if (!shouldInclude) {
|
||||
continue;
|
||||
}
|
||||
|
||||
private async loadIgnoreFiles(entries: WalkableEntry[]): Promise<string[]> {
|
||||
const ignoreEntries = entries.filter((w) =>
|
||||
this.entryIsIgnoreFile(w.entry),
|
||||
);
|
||||
const promises = ignoreEntries.map(async (w) => {
|
||||
return await this.ide.readFile(w.uri);
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
private shouldInclude(
|
||||
walkableEntry: WalkableEntry,
|
||||
ignoreContexts: IgnoreContext[],
|
||||
) {
|
||||
if (this.entryIsSymlink(walkableEntry.entry)) {
|
||||
// If called from the root, a symlink either links to a real file in this repository,
|
||||
// and therefore will be walked OR it links to something outside of the repository and
|
||||
// we do not want to index it
|
||||
return false;
|
||||
}
|
||||
let relPath = walkableEntry.relativeUriPath;
|
||||
if (this.entryIsDirectory(walkableEntry.entry)) {
|
||||
relPath = `${relPath}/`;
|
||||
} else {
|
||||
if (this.options.onlyDirs) {
|
||||
return false;
|
||||
if (this.entryIsDirectory(entry)) {
|
||||
stack.push({
|
||||
walkableEntry,
|
||||
ignoreContexts,
|
||||
});
|
||||
if (this.options.onlyDirs) {
|
||||
// when onlyDirs is enabled the walker will only return directory names
|
||||
if (this.options.returnRelativeUrisPaths) {
|
||||
yield walkableEntry.relativeUriPath;
|
||||
} else {
|
||||
yield walkableEntry.uri;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.options.returnRelativeUrisPaths) {
|
||||
yield walkableEntry.relativeUriPath;
|
||||
} else {
|
||||
yield walkableEntry.uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const ig of ignoreContexts) {
|
||||
// remove the directory name and path separator from the match path, unless this an ignore file
|
||||
// in the root directory
|
||||
const prefixLength = ig.dirname.length === 0 ? 0 : ig.dirname.length + 1;
|
||||
// The ignore library expects a path relative to the ignore file location
|
||||
const matchPath = relPath.substring(prefixLength);
|
||||
if (ig.ignore.ignores(matchPath)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private entryIsDirectory(entry: Entry) {
|
||||
|
|
@ -187,21 +150,9 @@ class DFSWalker {
|
|||
private entryIsSymlink(entry: Entry) {
|
||||
return entry[1] === (64 as FileType.SymbolicLink);
|
||||
}
|
||||
|
||||
private entryIsIgnoreFile(e: Entry): boolean {
|
||||
if (
|
||||
e[1] === (2 as FileType.Directory) ||
|
||||
e[1] === (64 as FileType.SymbolicLink)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return this.ignoreFileNames.has(e[0]);
|
||||
}
|
||||
}
|
||||
|
||||
const defaultOptions: WalkerOptions = {
|
||||
ignoreFiles: [".gitignore", ".continueignore"],
|
||||
additionalIgnoreRules: [...DEFAULT_IGNORE_DIRS, ...DEFAULT_IGNORE_FILETYPES],
|
||||
onlyDirs: false,
|
||||
returnRelativeUrisPaths: false,
|
||||
};
|
||||
|
|
@ -238,3 +189,49 @@ export async function walkDirs(
|
|||
);
|
||||
return results.flat();
|
||||
}
|
||||
|
||||
export async function getIgnoreContext(
|
||||
currentDir: string,
|
||||
currentDirEntries: Entry[],
|
||||
ide: IDE,
|
||||
defaultAndGlobalIgnores: Ignore,
|
||||
) {
|
||||
const dirFiles = currentDirEntries
|
||||
.filter(([_, entryType]) => entryType === (1 as FileType.File))
|
||||
.map(([name, _]) => name);
|
||||
|
||||
// Find ignore files and get ignore arrays from their contexts
|
||||
// These are done separately so that .continueignore can override .gitignore
|
||||
const gitIgnoreFile = dirFiles.find((name) => name === ".gitignore");
|
||||
const continueIgnoreFile = dirFiles.find(
|
||||
(name) => name === ".continueignore",
|
||||
);
|
||||
|
||||
const getGitIgnorePatterns = async () => {
|
||||
if (gitIgnoreFile) {
|
||||
const contents = await ide.readFile(`${currentDir}/.gitignore`);
|
||||
return gitIgArrayFromFile(contents);
|
||||
}
|
||||
return [];
|
||||
};
|
||||
const getContinueIgnorePatterns = async () => {
|
||||
if (continueIgnoreFile) {
|
||||
const contents = await ide.readFile(`${currentDir}/.continueignore`);
|
||||
return gitIgArrayFromFile(contents);
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
const ignoreArrays = await Promise.all([
|
||||
getGitIgnorePatterns(),
|
||||
getContinueIgnorePatterns(),
|
||||
]);
|
||||
|
||||
// Note precedence here!
|
||||
const ignoreContext = ignore()
|
||||
.add(ignoreArrays[0]) // gitignore
|
||||
.add(defaultAndGlobalIgnores) // default file/folder ignores followed by global .continueignore - this is combined for speed
|
||||
.add(ignoreArrays[1]); // local .continueignore
|
||||
|
||||
return ignoreContext;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ const PROVIDER_SUPPORTS_IMAGES: string[] = [
|
|||
"sagemaker",
|
||||
"continue-proxy",
|
||||
"openrouter",
|
||||
"sambanova",
|
||||
"vertexai",
|
||||
"azure",
|
||||
"scaleway",
|
||||
|
|
@ -92,6 +93,7 @@ const MODEL_SUPPORTS_IMAGES: string[] = [
|
|||
"haiku",
|
||||
"pixtral",
|
||||
"llama3.2",
|
||||
"llama-3.2",
|
||||
];
|
||||
|
||||
function modelSupportsTools(modelDescription: ModelDescription) {
|
||||
|
|
|
|||
|
|
@ -205,10 +205,11 @@ describe("LLM", () => {
|
|||
});
|
||||
testLLM(
|
||||
new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "o1-preview" }),
|
||||
{ skip: false, timeout: 20000 },
|
||||
{ skip: false, timeout: 60000 },
|
||||
);
|
||||
testLLM(new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "o1" }), {
|
||||
skip: false,
|
||||
timeout: 60000,
|
||||
});
|
||||
testLLM(
|
||||
new Gemini({
|
||||
|
|
|
|||
375
core/llm/llms/Bedrock.test.ts
Normal file
375
core/llm/llms/Bedrock.test.ts
Normal file
|
|
@ -0,0 +1,375 @@
|
|||
import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime";
|
||||
import { fromIni } from "@aws-sdk/credential-providers";
|
||||
import Bedrock from "./Bedrock.js";
|
||||
import { ChatMessage, Chunk, CompletionOptions, UserChatMessage } from "../../index.js";
|
||||
|
||||
// Mock AWS SDK
|
||||
jest.mock("@aws-sdk/client-bedrock-runtime", () => ({
|
||||
BedrockRuntimeClient: jest.fn().mockImplementation(() => ({
|
||||
send: jest.fn(),
|
||||
middlewareStack: { add: jest.fn() },
|
||||
})),
|
||||
ConverseStreamCommand: jest.fn(),
|
||||
InvokeModelCommand: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock credential provider
|
||||
jest.mock("@aws-sdk/credential-providers", () => ({
|
||||
fromIni: jest.fn().mockImplementation(() => async () => ({
|
||||
accessKeyId: "test-access-key",
|
||||
secretAccessKey: "test-secret-key",
|
||||
sessionToken: "test-session-token",
|
||||
})),
|
||||
}));
|
||||
|
||||
// Extend CompletionOptions for testing
|
||||
interface TestCompletionOptions extends CompletionOptions {
|
||||
mockError?: string;
|
||||
mockToolUse?: boolean;
|
||||
}
|
||||
|
||||
// Create a test class that overrides the protected methods
|
||||
class TestBedrock extends Bedrock {
|
||||
// Make _streamChat public for testing
|
||||
public async *streamChat(
|
||||
messages: ChatMessage[],
|
||||
signal: AbortSignal,
|
||||
options: TestCompletionOptions
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
if (options.mockError) {
|
||||
throw new Error(options.mockError);
|
||||
}
|
||||
|
||||
if (options.mockToolUse) {
|
||||
yield {
|
||||
role: "assistant",
|
||||
content: "",
|
||||
toolCalls: [{
|
||||
id: "tool-1",
|
||||
type: "function",
|
||||
function: {
|
||||
name: "test_tool",
|
||||
arguments: '{"arg1":"value1"}'
|
||||
}
|
||||
}],
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
yield { role: "assistant", content: "Hello" };
|
||||
yield { role: "assistant", content: " world" };
|
||||
}
|
||||
|
||||
// Override embed to avoid making real API calls
|
||||
async embed(chunks: string[]): Promise<number[][]> {
|
||||
if (chunks[0] === "error") {
|
||||
throw new Error("Embedding Error");
|
||||
}
|
||||
return [[0.1, 0.2, 0.3]];
|
||||
}
|
||||
|
||||
// Override rerank to avoid making real API calls
|
||||
async rerank(query: string, chunks: Chunk[]): Promise<number[]> {
|
||||
if (!query || !chunks.length) {
|
||||
throw new Error("Query and chunks must not be empty");
|
||||
}
|
||||
|
||||
if (query === "error") {
|
||||
throw new Error("Reranking Error");
|
||||
}
|
||||
|
||||
return chunks.map((_, i) => 0.8 - i * 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
describe("Bedrock", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe("constructor", () => {
|
||||
it("should initialize with default options", () => {
|
||||
const bedrock = new TestBedrock({
|
||||
apiKey: "test-key",
|
||||
model: "anthropic.claude-3-sonnet-20240229-v1:0",
|
||||
region: "us-east-1",
|
||||
});
|
||||
|
||||
expect(bedrock.region).toBe("us-east-1");
|
||||
expect(bedrock.profile).toBe("bedrock");
|
||||
expect(bedrock.apiBase).toBe("https://bedrock-runtime.us-east-1.amazonaws.com");
|
||||
});
|
||||
|
||||
it("should use custom options when provided", () => {
|
||||
const bedrock = new TestBedrock({
|
||||
apiKey: "test-key",
|
||||
model: "anthropic.claude-3-sonnet-20240229-v1:0",
|
||||
region: "us-west-2",
|
||||
profile: "custom-profile",
|
||||
apiBase: "https://custom-endpoint.amazonaws.com/",
|
||||
});
|
||||
|
||||
expect(bedrock.region).toBe("us-west-2");
|
||||
expect(bedrock.profile).toBe("custom-profile");
|
||||
expect(bedrock.apiBase).toBe("https://custom-endpoint.amazonaws.com/");
|
||||
});
|
||||
});
|
||||
|
||||
describe("streamChat", () => {
|
||||
let bedrock: TestBedrock;
|
||||
const mockAbortSignal = new AbortController().signal;
|
||||
const defaultOptions: TestCompletionOptions = {
|
||||
model: "anthropic.claude-3-sonnet-20240229-v1:0",
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
bedrock = new TestBedrock({
|
||||
apiKey: "test-key",
|
||||
model: "anthropic.claude-3-sonnet-20240229-v1:0",
|
||||
region: "us-east-1",
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle text streaming correctly", async () => {
|
||||
const messages: ChatMessage[] = [{
|
||||
role: "user",
|
||||
content: "Hi"
|
||||
} as UserChatMessage];
|
||||
|
||||
const results = [];
|
||||
|
||||
for await (const message of bedrock.streamChat(messages, mockAbortSignal, defaultOptions)) {
|
||||
results.push(message);
|
||||
}
|
||||
|
||||
expect(results).toEqual([
|
||||
{ role: "assistant", content: "Hello" },
|
||||
{ role: "assistant", content: " world" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("should handle tool use streaming correctly", async () => {
|
||||
const messages: ChatMessage[] = [{
|
||||
role: "user",
|
||||
content: "Use a tool"
|
||||
} as UserChatMessage];
|
||||
|
||||
const results = [];
|
||||
const options: TestCompletionOptions = {
|
||||
...defaultOptions,
|
||||
mockToolUse: true
|
||||
};
|
||||
|
||||
for await (const message of bedrock.streamChat(messages, mockAbortSignal, options)) {
|
||||
results.push(message);
|
||||
}
|
||||
|
||||
expect(results).toEqual([
|
||||
{
|
||||
role: "assistant",
|
||||
content: "",
|
||||
toolCalls: [{
|
||||
id: "tool-1",
|
||||
type: "function",
|
||||
function: {
|
||||
name: "test_tool",
|
||||
arguments: '{"arg1":"value1"}'
|
||||
}
|
||||
}],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("should handle API errors", async () => {
|
||||
const messages: ChatMessage[] = [{
|
||||
role: "user",
|
||||
content: "Hi"
|
||||
} as UserChatMessage];
|
||||
|
||||
const options: TestCompletionOptions = {
|
||||
...defaultOptions,
|
||||
mockError: "API Error"
|
||||
};
|
||||
|
||||
await expect(async () => {
|
||||
for await (const _ of bedrock.streamChat(messages, mockAbortSignal, options)) {
|
||||
// consume generator
|
||||
}
|
||||
}).rejects.toThrow("API Error");
|
||||
});
|
||||
});
|
||||
|
||||
describe("embed", () => {
|
||||
let bedrock: TestBedrock;
|
||||
|
||||
beforeEach(() => {
|
||||
bedrock = new TestBedrock({
|
||||
apiKey: "test-key",
|
||||
model: "cohere.embed-english-v3",
|
||||
region: "us-east-1",
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle embedding requests correctly", async () => {
|
||||
const result = await bedrock.embed(["test text"]);
|
||||
expect(result).toEqual([[0.1, 0.2, 0.3]]);
|
||||
});
|
||||
|
||||
it("should handle embedding errors", async () => {
|
||||
await expect(bedrock.embed(["error"])).rejects.toThrow("Embedding Error");
|
||||
});
|
||||
});
|
||||
|
||||
describe("rerank", () => {
|
||||
let bedrock: TestBedrock;
|
||||
|
||||
beforeEach(() => {
|
||||
bedrock = new TestBedrock({
|
||||
apiKey: "test-key",
|
||||
model: "cohere.rerank-english-v2.0",
|
||||
region: "us-east-1",
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle reranking requests correctly", async () => {
|
||||
const chunks: Chunk[] = [
|
||||
{
|
||||
content: "doc1",
|
||||
digest: "digest1",
|
||||
filepath: "file1",
|
||||
index: 0,
|
||||
startLine: 1,
|
||||
endLine: 1
|
||||
},
|
||||
{
|
||||
content: "doc2",
|
||||
digest: "digest2",
|
||||
filepath: "file2",
|
||||
index: 1,
|
||||
startLine: 1,
|
||||
endLine: 1
|
||||
}
|
||||
];
|
||||
|
||||
const result = await bedrock.rerank("query", chunks);
|
||||
expect(result).toEqual([0.8, 0.5]);
|
||||
});
|
||||
|
||||
it("should handle reranking errors", async () => {
|
||||
const chunk: Chunk = {
|
||||
content: "doc1",
|
||||
digest: "digest1",
|
||||
filepath: "file1",
|
||||
index: 0,
|
||||
startLine: 1,
|
||||
endLine: 1
|
||||
};
|
||||
|
||||
await expect(
|
||||
bedrock.rerank("error", [chunk])
|
||||
).rejects.toThrow("Reranking Error");
|
||||
});
|
||||
|
||||
it("should throw error for empty input", async () => {
|
||||
await expect(bedrock.rerank("", [])).rejects.toThrow("Query and chunks must not be empty");
|
||||
});
|
||||
});
|
||||
|
||||
describe("message conversion", () => {
|
||||
let bedrock: TestBedrock;
|
||||
|
||||
beforeEach(() => {
|
||||
bedrock = new TestBedrock({
|
||||
apiKey: "test-key",
|
||||
model: "anthropic.claude-3-sonnet-20240229-v1:0",
|
||||
region: "us-east-1",
|
||||
});
|
||||
});
|
||||
|
||||
it("should convert text messages correctly", () => {
|
||||
const message: ChatMessage = {
|
||||
role: "user",
|
||||
content: "Hello"
|
||||
} as UserChatMessage;
|
||||
const converted = bedrock["_convertMessage"](message);
|
||||
expect(converted).toEqual({
|
||||
role: "user",
|
||||
content: [{ text: "Hello" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("should convert tool responses correctly", () => {
|
||||
const message: ChatMessage = {
|
||||
role: "tool",
|
||||
content: "Tool result",
|
||||
toolCallId: "tool-1",
|
||||
};
|
||||
const converted = bedrock["_convertMessage"](message);
|
||||
expect(converted).toEqual({
|
||||
role: "user",
|
||||
content: [{
|
||||
toolResult: {
|
||||
toolUseId: "tool-1",
|
||||
content: [{ text: "Tool result" }],
|
||||
},
|
||||
}],
|
||||
});
|
||||
});
|
||||
|
||||
it("should convert tool calls correctly", () => {
|
||||
const message: ChatMessage = {
|
||||
role: "assistant",
|
||||
content: "",
|
||||
toolCalls: [{
|
||||
id: "tool-1",
|
||||
type: "function" as const,
|
||||
function: {
|
||||
name: "test_tool",
|
||||
arguments: '{"arg":"value"}',
|
||||
},
|
||||
}],
|
||||
};
|
||||
const converted = bedrock["_convertMessage"](message);
|
||||
expect(converted).toEqual({
|
||||
role: "assistant",
|
||||
content: [{
|
||||
toolUse: {
|
||||
toolUseId: "tool-1",
|
||||
name: "test_tool",
|
||||
input: { arg: "value" },
|
||||
},
|
||||
}],
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle multimodal content correctly", () => {
|
||||
const message: ChatMessage = {
|
||||
role: "user",
|
||||
content: [
|
||||
{ type: "text", text: "Look at this image:" },
|
||||
{
|
||||
type: "imageUrl",
|
||||
imageUrl: {
|
||||
url: "data:image/jpeg;base64,/9j/4AAQSkZJRg==",
|
||||
},
|
||||
},
|
||||
],
|
||||
} as UserChatMessage;
|
||||
const converted = bedrock["_convertMessage"](message);
|
||||
expect(converted).toEqual({
|
||||
role: "user",
|
||||
content: [
|
||||
{ text: "Look at this image:" },
|
||||
{
|
||||
image: {
|
||||
format: "jpeg",
|
||||
source: {
|
||||
bytes: Buffer.from("/9j/4AAQSkZJRg==", "base64"),
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -10,16 +10,25 @@ import {
|
|||
Chunk,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
MessageContent,
|
||||
} from "../../index.js";
|
||||
import { renderChatMessage } from "../../util/messageContent.js";
|
||||
import { BaseLLM } from "../index.js";
|
||||
import { PROVIDER_TOOL_SUPPORT } from "../toolSupport.js";
|
||||
|
||||
interface ModelConfig {
|
||||
formatPayload: (text: string) => any;
|
||||
extractEmbeddings: (responseBody: any) => number[][];
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for tool use state tracking
|
||||
*/
|
||||
interface ToolUseState {
|
||||
toolUseId: string;
|
||||
name: string;
|
||||
input: string;
|
||||
}
|
||||
|
||||
class Bedrock extends BaseLLM {
|
||||
static providerName = "bedrock";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
|
|
@ -29,6 +38,10 @@ class Bedrock extends BaseLLM {
|
|||
profile: "bedrock",
|
||||
};
|
||||
|
||||
private _currentToolResponse: Partial<ToolUseState> | null = null;
|
||||
|
||||
public requestOptions: { region?: string; credentials?: any; headers?: Record<string, string> };
|
||||
|
||||
constructor(options: LLMOptions) {
|
||||
super(options);
|
||||
if (!options.apiBase) {
|
||||
|
|
@ -39,6 +52,10 @@ class Bedrock extends BaseLLM {
|
|||
} else {
|
||||
this.profile = "bedrock";
|
||||
}
|
||||
this.requestOptions = {
|
||||
region: options.region,
|
||||
headers: {},
|
||||
};
|
||||
}
|
||||
|
||||
protected async *_streamComplete(
|
||||
|
|
@ -58,7 +75,6 @@ class Bedrock extends BaseLLM {
|
|||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const credentials = await this._getCredentials();
|
||||
|
||||
const client = new BedrockRuntimeClient({
|
||||
region: this.region,
|
||||
endpoint: this.apiBase,
|
||||
|
|
@ -70,9 +86,9 @@ class Bedrock extends BaseLLM {
|
|||
});
|
||||
|
||||
let config_headers =
|
||||
this.requestOptions && this.requestOptions.headers
|
||||
? this.requestOptions.headers
|
||||
: {};
|
||||
this.requestOptions && this.requestOptions.headers
|
||||
? this.requestOptions.headers
|
||||
: {};
|
||||
// AWS SigV4 requires strict canonicalization of headers.
|
||||
// DO NOT USE "_" in your header name. It will return an error like below.
|
||||
// "The request signature we calculated does not match the signature you provided."
|
||||
|
|
@ -90,32 +106,116 @@ class Bedrock extends BaseLLM {
|
|||
},
|
||||
);
|
||||
|
||||
const input = this._generateConverseInput(messages, options);
|
||||
const input = this._generateConverseInput(messages, { ...options, stream: true });
|
||||
const command = new ConverseStreamCommand(input);
|
||||
const response = await client.send(command, { abortSignal: signal });
|
||||
|
||||
if (response.stream) {
|
||||
let response;
|
||||
try {
|
||||
response = await client.send(command, { abortSignal: signal });
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : "Unknown error";
|
||||
throw new Error(`Failed to communicate with Bedrock API: ${message}`);
|
||||
}
|
||||
|
||||
if (!response?.stream) {
|
||||
throw new Error("No stream received from Bedrock API");
|
||||
}
|
||||
|
||||
try {
|
||||
for await (const chunk of response.stream) {
|
||||
if (chunk.contentBlockDelta?.delta?.text) {
|
||||
yield {
|
||||
role: "assistant",
|
||||
content: chunk.contentBlockDelta.delta.text,
|
||||
};
|
||||
|
||||
console.log(chunk);
|
||||
|
||||
if (chunk.contentBlockDelta?.delta) {
|
||||
|
||||
// Handle text content
|
||||
if (chunk.contentBlockDelta.delta.text) {
|
||||
yield { role: "assistant", content: chunk.contentBlockDelta.delta.text };
|
||||
continue;
|
||||
}
|
||||
|
||||
if (chunk.contentBlockDelta.delta.toolUse?.input && this._currentToolResponse) {
|
||||
// Append the new input to the existing string
|
||||
if (this._currentToolResponse.input === undefined) {
|
||||
this._currentToolResponse.input = "";
|
||||
}
|
||||
this._currentToolResponse.input += chunk.contentBlockDelta.delta.toolUse.input;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (chunk.contentBlockStart?.start) {
|
||||
const toolUse = chunk.contentBlockStart.start.toolUse;
|
||||
if (toolUse?.toolUseId && toolUse?.name) {
|
||||
this._currentToolResponse = {
|
||||
toolUseId: toolUse.toolUseId,
|
||||
name: toolUse.name,
|
||||
input: ""
|
||||
};
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (chunk.contentBlockStop) {
|
||||
if (this._currentToolResponse) {
|
||||
yield {
|
||||
role: "assistant",
|
||||
content: "",
|
||||
toolCalls: [{
|
||||
id: this._currentToolResponse.toolUseId,
|
||||
type: "function",
|
||||
function: {
|
||||
name: this._currentToolResponse.name,
|
||||
arguments: this._currentToolResponse.input
|
||||
}
|
||||
}],
|
||||
};
|
||||
this._currentToolResponse = null;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
this._currentToolResponse = null;
|
||||
if (error instanceof Error) {
|
||||
if ("code" in error) {
|
||||
// AWS SDK specific errors
|
||||
throw new Error(`AWS Bedrock stream error (${(error as any).code}): ${error.message}`);
|
||||
}
|
||||
throw new Error(`Error processing Bedrock stream: ${error.message}`);
|
||||
}
|
||||
throw new Error("Error processing Bedrock stream: Unknown error occurred");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the input payload for the Bedrock Converse API
|
||||
* @param messages - Array of chat messages
|
||||
* @param options - Completion options
|
||||
* @returns Formatted input payload for the API
|
||||
*/
|
||||
private _generateConverseInput(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): any {
|
||||
const convertedMessages = this._convertMessages(messages);
|
||||
|
||||
const supportsTools = PROVIDER_TOOL_SUPPORT.bedrock?.(options.model || "") ?? false;
|
||||
return {
|
||||
modelId: options.model,
|
||||
messages: convertedMessages,
|
||||
system: this.systemMessage ? [{ text: this.systemMessage }] : undefined,
|
||||
toolConfig: supportsTools && options.tools ? {
|
||||
tools: options.tools.map(tool => ({
|
||||
toolSpec: {
|
||||
name: tool.function.name,
|
||||
description: tool.function.description,
|
||||
inputSchema: {
|
||||
json: tool.function.parameters
|
||||
}
|
||||
}
|
||||
}))
|
||||
} : undefined,
|
||||
inferenceConfig: {
|
||||
maxTokens: options.maxTokens,
|
||||
temperature: options.temperature,
|
||||
|
|
@ -135,35 +235,93 @@ class Bedrock extends BaseLLM {
|
|||
};
|
||||
}
|
||||
|
||||
private _convertMessages(messages: ChatMessage[]): any[] {
|
||||
return messages
|
||||
.filter((message) => message.role !== "system")
|
||||
.map((message) => ({
|
||||
private _convertMessage(message: ChatMessage): any {
|
||||
// Handle system messages explicitly
|
||||
if (message.role === "system") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Tool response handling
|
||||
if (message.role === "tool") {
|
||||
return {
|
||||
role: "user",
|
||||
content: [
|
||||
{
|
||||
toolResult: {
|
||||
toolUseId: message.toolCallId,
|
||||
content: [
|
||||
{
|
||||
text: message.content || ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
// Tool calls handling
|
||||
if (message.role === "assistant" && message.toolCalls) {
|
||||
return {
|
||||
role: "assistant",
|
||||
content: message.toolCalls.map((toolCall) => ({
|
||||
toolUse: {
|
||||
toolUseId: toolCall.id,
|
||||
name: toolCall.function?.name,
|
||||
input: JSON.parse(toolCall.function?.arguments || "{}"),
|
||||
}
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
// Standard text message
|
||||
if (typeof message.content === "string") {
|
||||
return {
|
||||
role: message.role,
|
||||
content: this._convertMessageContent(message.content),
|
||||
}));
|
||||
content: [{ text: message.content }]
|
||||
};
|
||||
}
|
||||
|
||||
// Improved multimodal content handling
|
||||
if (Array.isArray(message.content)) {
|
||||
return {
|
||||
role: message.role,
|
||||
content: message.content.map(part => {
|
||||
if (part.type === "text") {
|
||||
return { text: part.text };
|
||||
}
|
||||
if (part.type === "imageUrl" && part.imageUrl) {
|
||||
try {
|
||||
const [mimeType, base64Data] = part.imageUrl.url.split(",");
|
||||
const format = mimeType.split("/")[1]?.split(";")[0] || "jpeg";
|
||||
return {
|
||||
image: {
|
||||
format,
|
||||
source: {
|
||||
bytes: Buffer.from(base64Data, "base64")
|
||||
}
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.warn(`Failed to process image: ${error}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}).filter(Boolean)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private _convertMessageContent(messageContent: MessageContent): any[] {
|
||||
if (typeof messageContent === "string") {
|
||||
return [{ text: messageContent }];
|
||||
}
|
||||
return messageContent
|
||||
.map((part) => {
|
||||
if (part.type === "text") {
|
||||
return { text: part.text };
|
||||
private _convertMessages(messages: ChatMessage[]): any[] {
|
||||
return messages
|
||||
.map((message) => {
|
||||
try {
|
||||
return this._convertMessage(message);
|
||||
} catch (error) {
|
||||
console.error(`Failed to convert message: ${error}`);
|
||||
return null;
|
||||
}
|
||||
if (part.type === "imageUrl" && part.imageUrl) {
|
||||
return {
|
||||
image: {
|
||||
format: "jpeg",
|
||||
source: {
|
||||
bytes: Buffer.from(part.imageUrl.url.split(",")[1], "base64"),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
|
@ -229,6 +387,7 @@ class Bedrock extends BaseLLM {
|
|||
return modelConfig.extractEmbeddings(responseBody);
|
||||
}
|
||||
|
||||
|
||||
private _getModelConfig() {
|
||||
const modelConfigs: { [key: string]: ModelConfig } = {
|
||||
cohere: {
|
||||
|
|
@ -301,9 +460,15 @@ class Bedrock extends BaseLLM {
|
|||
return responseBody.results
|
||||
.sort((a: any, b: any) => a.index - b.index)
|
||||
.map((result: any) => result.relevance_score);
|
||||
} catch (error) {
|
||||
console.error("Error in BedrockReranker.rerank:", error);
|
||||
throw error;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
if ("code" in error) {
|
||||
// AWS SDK specific errors
|
||||
throw new Error(`AWS Bedrock rerank error (${(error as any).code}): ${error.message}`);
|
||||
}
|
||||
throw new Error(`Error in BedrockReranker.rerank: ${error.message}`);
|
||||
}
|
||||
throw new Error("Error in BedrockReranker.rerank: Unknown error occurred");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ class NCompass extends OpenAI {
|
|||
|
||||
private static modelConversion: { [key: string]: string } = {
|
||||
"qwen2.5-coder-7b": "Qwen/Qwen2.5-Coder-7B-Instruct",
|
||||
"qwen2.5-coder:7b": "Qwen/Qwen2.5-Coder-7B-Instruct",
|
||||
"qwen2.5-coder-32b": "Qwen/Qwen2.5-Coder-32B-Instruct",
|
||||
"qwen2.5-coder:32b": "Qwen/Qwen2.5-Coder-32B-Instruct",
|
||||
};
|
||||
protected _convertModelName(model: string): string {
|
||||
return NCompass.modelConversion[model] ?? model;
|
||||
|
|
|
|||
|
|
@ -9,11 +9,20 @@ class SambaNova extends OpenAI {
|
|||
};
|
||||
|
||||
private static MODEL_IDS: { [name: string]: string } = {
|
||||
"qwen2.5-coder-32b": "Qwen2.5-Coder-32B-Instruct",
|
||||
"llama3.3-70b": "Meta-Llama-3.3-70B-Instruct",
|
||||
"llama3.1-8b": "Meta-Llama-3.1-8B-Instruct",
|
||||
"llama3.1-70b": "Meta-Llama-3.1-70B-Instruct",
|
||||
"llama3.1-405b": "Meta-Llama-3.1-405B-Instruct",
|
||||
"llama3.1-1b": "Meta-Llama-3.2-1B-Instruct",
|
||||
"llama3.1-3b": "Meta-Llama-3.2-3B-Instruct",
|
||||
"llama3.1-tulu-405b": "Llama-3.1-Tulu-3-405B",
|
||||
"llama3.2-1b": "Meta-Llama-3.2-1B-Instruct",
|
||||
"llama3.2-3b": "Meta-Llama-3.2-3B-Instruct",
|
||||
"llama3.2-11b": "Llama-3.2-11B-Vision-Instruct",
|
||||
"llama3.2-90b": "Llama-3.2-90B-Vision-Instruct",
|
||||
"qwen2.5-72b": "Qwen2.5-72B-Instruct",
|
||||
"qwq-32b": "QwQ-32B-Preview",
|
||||
"deepseek-r1-distill-llama-70b": "DeepSeek-R1-Distill-Llama-70B",
|
||||
"deepseek-r1": "DeepSeek-R1",
|
||||
};
|
||||
|
||||
protected _convertModelName(model: string) {
|
||||
|
|
|
|||
203
core/llm/toolSupport.test.ts
Normal file
203
core/llm/toolSupport.test.ts
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
// core/llm/toolSupport.test.ts
|
||||
import { PROVIDER_TOOL_SUPPORT } from "./toolSupport";
|
||||
|
||||
describe("PROVIDER_TOOL_SUPPORT", () => {
|
||||
describe("continue-proxy", () => {
|
||||
const supportsFn = PROVIDER_TOOL_SUPPORT["continue-proxy"];
|
||||
|
||||
it("should return true for Claude 3.5 models", () => {
|
||||
expect(supportsFn("claude-3-5-sonnet")).toBe(true);
|
||||
expect(supportsFn("claude-3.5-sonnet")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true for Claude 3.7 models", () => {
|
||||
expect(supportsFn("claude-3-7-haiku")).toBe(true);
|
||||
expect(supportsFn("claude-3.7-sonnet")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true for GPT-4 models", () => {
|
||||
expect(supportsFn("gpt-4-turbo")).toBe(true);
|
||||
expect(supportsFn("gpt-4-1106-preview")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true for O3 models", () => {
|
||||
expect(supportsFn("o3-preview")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true for Gemini models", () => {
|
||||
expect(supportsFn("gemini-pro")).toBe(true);
|
||||
expect(supportsFn("gemini-1.5-pro")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false for unsupported models", () => {
|
||||
expect(supportsFn("gpt-3.5-turbo")).toBe(false);
|
||||
expect(supportsFn("claude-2")).toBe(false);
|
||||
expect(supportsFn("llama-3")).toBe(false);
|
||||
});
|
||||
|
||||
it("should handle case insensitivity", () => {
|
||||
expect(supportsFn("CLAUDE-3-5-sonnet")).toBe(true);
|
||||
expect(supportsFn("GPT-4-turbo")).toBe(true);
|
||||
expect(supportsFn("GEMINI-pro")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("anthropic", () => {
|
||||
const supportsFn = PROVIDER_TOOL_SUPPORT["anthropic"];
|
||||
|
||||
it("should return true for Claude 3.5 models", () => {
|
||||
expect(supportsFn("claude-3-5-sonnet")).toBe(true);
|
||||
expect(supportsFn("claude-3.5-haiku")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true for Claude 3.7 models", () => {
|
||||
expect(supportsFn("claude-3-7-haiku")).toBe(true);
|
||||
expect(supportsFn("claude-3.7-sonnet")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return undefined for unsupported models", () => {
|
||||
expect(supportsFn("claude-2")).toBeUndefined();
|
||||
expect(supportsFn("claude-instant")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should handle case insensitivity", () => {
|
||||
expect(supportsFn("CLAUDE-3-5-sonnet")).toBe(true);
|
||||
expect(supportsFn("CLAUDE-3.7-haiku")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("openai", () => {
|
||||
const supportsFn = PROVIDER_TOOL_SUPPORT["openai"];
|
||||
|
||||
it("should return true for GPT-4 models", () => {
|
||||
expect(supportsFn("gpt-4")).toBe(true);
|
||||
expect(supportsFn("gpt-4-turbo")).toBe(true);
|
||||
expect(supportsFn("gpt-4-1106-preview")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true for O3 models", () => {
|
||||
expect(supportsFn("o3")).toBe(true);
|
||||
expect(supportsFn("o3-preview")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return undefined for unsupported models", () => {
|
||||
expect(supportsFn("gpt-3.5-turbo")).toBeUndefined();
|
||||
expect(supportsFn("davinci")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should handle case insensitivity", () => {
|
||||
expect(supportsFn("GPT-4-turbo")).toBe(true);
|
||||
expect(supportsFn("O3-preview")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("gemini", () => {
|
||||
const supportsFn = PROVIDER_TOOL_SUPPORT["gemini"];
|
||||
|
||||
it("should return true for all Gemini models", () => {
|
||||
expect(supportsFn("gemini-pro")).toBe(true);
|
||||
expect(supportsFn("gemini-1.5-pro")).toBe(true);
|
||||
expect(supportsFn("gemini-ultra")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false for non-Gemini models", () => {
|
||||
expect(supportsFn("gpt-4")).toBe(false);
|
||||
expect(supportsFn("claude-3")).toBe(false);
|
||||
});
|
||||
|
||||
it("should handle case insensitivity", () => {
|
||||
expect(supportsFn("GEMINI-pro")).toBe(true);
|
||||
expect(supportsFn("Gemini-1.5-Pro")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("bedrock", () => {
|
||||
const supportsFn = PROVIDER_TOOL_SUPPORT["bedrock"];
|
||||
|
||||
it("should return true for Claude 3.5 Sonnet models", () => {
|
||||
expect(supportsFn("anthropic.claude-3-5-sonnet-20240620-v1:0")).toBe(true);
|
||||
expect(supportsFn("anthropic.claude-3.5-sonnet-20240620-v1:0")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true for Claude 3.7 Sonnet models", () => {
|
||||
expect(supportsFn("anthropic.claude-3-7-sonnet-20240620-v1:0")).toBe(true);
|
||||
expect(supportsFn("anthropic.claude-3.7-sonnet-20240620-v1:0")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return undefined for Claude Haiku and Opus models", () => {
|
||||
expect(supportsFn("anthropic.claude-3-5-haiku-20240307-v1:0")).toBeUndefined();
|
||||
expect(supportsFn("anthropic.claude-3.5-haiku-20240620-v1:0")).toBeUndefined();
|
||||
expect(supportsFn("anthropic.claude-3-7-haiku-20240620-v1:0")).toBeUndefined();
|
||||
expect(supportsFn("anthropic.claude-3-5-opus-20240620-v1:0")).toBeUndefined();
|
||||
expect(supportsFn("anthropic.claude-3.7-opus-20240620-v1:0")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should return undefined for other unsupported models", () => {
|
||||
expect(supportsFn("anthropic.claude-instant-v1")).toBeUndefined();
|
||||
expect(supportsFn("anthropic.titan-text-express-v1")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should handle case insensitivity", () => {
|
||||
expect(supportsFn("ANTHROPIC.CLAUDE-3-5-SONNET-20240620-v1:0")).toBe(true);
|
||||
expect(supportsFn("ANTHROPIC.CLAUDE-3.7-SONNET-20240620-v1:0")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ollama", () => {
|
||||
const supportsFn = PROVIDER_TOOL_SUPPORT["ollama"];
|
||||
|
||||
it("should return true for supported models", () => {
|
||||
expect(supportsFn("llama3.1")).toBe(true);
|
||||
expect(supportsFn("llama3.2-8b")).toBe(true);
|
||||
expect(supportsFn("llama3.3-70b")).toBe(true);
|
||||
expect(supportsFn("qwen2")).toBe(true);
|
||||
expect(supportsFn("mixtral-8x7b")).toBe(true);
|
||||
expect(supportsFn("command-r")).toBe(true);
|
||||
expect(supportsFn("smollm2")).toBe(true);
|
||||
expect(supportsFn("hermes3")).toBe(true);
|
||||
expect(supportsFn("athene-v2")).toBe(true);
|
||||
expect(supportsFn("nemotron-4-340b")).toBe(true);
|
||||
expect(supportsFn("llama3-groq")).toBe(true);
|
||||
expect(supportsFn("granite3")).toBe(true);
|
||||
expect(supportsFn("aya-expanse")).toBe(true);
|
||||
expect(supportsFn("firefunction-v2")).toBe(true);
|
||||
expect(supportsFn("mistral-7b")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false for explicitly unsupported models", () => {
|
||||
expect(supportsFn("vision")).toBe(false);
|
||||
expect(supportsFn("math")).toBe(false);
|
||||
expect(supportsFn("guard")).toBe(false);
|
||||
expect(supportsFn("mistrallite")).toBe(false);
|
||||
expect(supportsFn("mistral-openorca")).toBe(false);
|
||||
});
|
||||
|
||||
it("should return undefined for other models", () => {
|
||||
expect(supportsFn("llama2")).toBeUndefined();
|
||||
expect(supportsFn("phi-2")).toBeUndefined();
|
||||
expect(supportsFn("falcon")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should handle case insensitivity", () => {
|
||||
expect(supportsFn("LLAMA3.1")).toBe(true);
|
||||
expect(supportsFn("MIXTRAL-8x7b")).toBe(true);
|
||||
expect(supportsFn("VISION")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("edge cases", () => {
|
||||
it("should handle empty model names", () => {
|
||||
expect(PROVIDER_TOOL_SUPPORT["continue-proxy"]("")).toBe(false);
|
||||
expect(PROVIDER_TOOL_SUPPORT["anthropic"]("")).toBeUndefined();
|
||||
expect(PROVIDER_TOOL_SUPPORT["openai"]("")).toBeUndefined();
|
||||
expect(PROVIDER_TOOL_SUPPORT["gemini"]("")).toBe(false);
|
||||
expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBeUndefined();
|
||||
expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should handle non-existent provider", () => {
|
||||
// @ts-ignore - Testing runtime behavior with invalid provider
|
||||
expect(PROVIDER_TOOL_SUPPORT["non-existent"]).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -3,13 +3,28 @@ export const PROVIDER_TOOL_SUPPORT: Record<
|
|||
(model: string) => boolean | undefined
|
||||
> = {
|
||||
"continue-proxy": (model) => {
|
||||
return ["claude-3-5", "claude-3.5", "gpt-4", "o3", "gemini"].some((part) =>
|
||||
model.toLowerCase().startsWith(part),
|
||||
);
|
||||
// see getContinueProxyModelName
|
||||
const provider = model.split("/")[2];
|
||||
const _model = model.split("/")[3];
|
||||
if (provider && _model && provider !== "continue-proxy") {
|
||||
const fn = PROVIDER_TOOL_SUPPORT[provider];
|
||||
if (fn) {
|
||||
return fn(_model);
|
||||
}
|
||||
}
|
||||
return [
|
||||
"claude-3-5",
|
||||
"claude-3.5",
|
||||
"claude-3-7",
|
||||
"claude-3.7",
|
||||
"gpt-4",
|
||||
"o3",
|
||||
"gemini",
|
||||
].some((part) => model.toLowerCase().startsWith(part));
|
||||
},
|
||||
anthropic: (model) => {
|
||||
if (
|
||||
["claude-3-5", "claude-3.5"].some((part) =>
|
||||
["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7"].some((part) =>
|
||||
model.toLowerCase().startsWith(part),
|
||||
)
|
||||
) {
|
||||
|
|
@ -29,6 +44,17 @@ export const PROVIDER_TOOL_SUPPORT: Record<
|
|||
// All gemini models support function calling
|
||||
return model.toLowerCase().includes("gemini");
|
||||
},
|
||||
bedrock: (model) => {
|
||||
// For Bedrock, only support Claude Sonnet models with versions 3.5/3-5 and 3.7/3-7
|
||||
if (
|
||||
model.toLowerCase().includes("sonnet") &&
|
||||
["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7"].some((part) =>
|
||||
model.toLowerCase().includes(part),
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
// https://ollama.com/search?c=tools
|
||||
ollama: (model) => {
|
||||
if (
|
||||
|
|
@ -61,4 +87,12 @@ export const PROVIDER_TOOL_SUPPORT: Record<
|
|||
return true;
|
||||
}
|
||||
},
|
||||
sambanova: (model) => {
|
||||
// https://docs.sambanova.ai/cloud/docs/capabilities/function-calling
|
||||
if (
|
||||
model.toLowerCase().startsWith("meta-llama-3")
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
7
core/package-lock.json
generated
7
core/package-lock.json
generated
|
|
@ -6163,9 +6163,10 @@
|
|||
"integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw=="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.7.9",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
|
||||
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.8.2.tgz",
|
||||
"integrity": "sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
"form-data": "^4.0.0",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export async function getPromptFilesFromDir(
|
|||
return [];
|
||||
}
|
||||
|
||||
const uris = await walkDir(dir, ide, { ignoreFiles: [] });
|
||||
const uris = await walkDir(dir, ide);
|
||||
const promptFilePaths = uris.filter((p) => p.endsWith(".prompt"));
|
||||
const results = promptFilePaths.map(async (uri) => {
|
||||
const content = await ide.readFile(uri); // make a try catch
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import { ToWebviewFromIdeOrCoreProtocol } from "./webview.js";
|
|||
|
||||
export type ToCoreFromWebviewProtocol = ToCoreFromIdeOrWebviewProtocol & {
|
||||
didChangeSelectedProfile: [{ id: string | null }, void];
|
||||
didChangeSelectedOrg: [{ id: string | null }, void];
|
||||
didChangeSelectedOrg: [
|
||||
{ id: string | null; profileId?: string | null },
|
||||
void,
|
||||
];
|
||||
};
|
||||
export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
||||
didChangeAvailableProfiles: [
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import fs from "fs";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
import { localPathToUri, localPathOrUriToPath } from "../util/pathToUri";
|
||||
import { localPathOrUriToPath, localPathToUri } from "../util/pathToUri";
|
||||
|
||||
// Want this outside of the git repository so we can change branches in tests
|
||||
export const TEST_DIR_PATH = path.join(os.tmpdir(), "testWorkspaceDir");
|
||||
|
|
@ -26,7 +26,7 @@ export function tearDownTestDir() {
|
|||
"index/index.ts" creates an empty index/index.ts
|
||||
["index/index.ts", "hello"] creates index/index.ts with contents "hello"
|
||||
*/
|
||||
export function addToTestDir(pathsOrUris: (string | string[])[]) {
|
||||
export function addToTestDir(pathsOrUris: (string | [string, string])[]) {
|
||||
// Allow tests to use URIs or local paths
|
||||
const paths = pathsOrUris.map((val) => {
|
||||
if (Array.isArray(val)) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { ContextItem, Tool, ToolExtras } from "..";
|
||||
import { MCPManagerSingleton } from "../context/mcp";
|
||||
import { canParseUrl } from "../util/url";
|
||||
import { BuiltInToolNames } from "./builtIn";
|
||||
|
||||
import { createNewFileImpl } from "./implementations/createNewFile";
|
||||
|
|
@ -55,9 +56,8 @@ async function callToolFromUri(
|
|||
args: any,
|
||||
extras: ToolExtras,
|
||||
): Promise<ContextItem[]> {
|
||||
// @ts-ignore
|
||||
const canParse = URL.canParse(uri);
|
||||
if (!canParse) {
|
||||
const parseable = canParseUrl(uri);
|
||||
if (!parseable) {
|
||||
throw new Error(`Invalid URI: ${uri}`);
|
||||
}
|
||||
const parsedUri = new URL(uri);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export type GlobalContextType = {
|
|||
hasDismissedConfigTsNoticeJetBrains: boolean;
|
||||
hasAlreadyCreatedAPromptFile: boolean;
|
||||
showConfigUpdateToast: boolean;
|
||||
isSupportedLanceDbCpuTarget: boolean;
|
||||
isSupportedLanceDbCpuTargetForLinux: boolean;
|
||||
sharedConfig: SharedConfigSchema;
|
||||
failedDocs: SiteIndexingConfig[];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import * as path from "path";
|
|||
import * as JSONC from "comment-json";
|
||||
import dotenv from "dotenv";
|
||||
|
||||
import { DevEventName } from "@continuedev/config-yaml";
|
||||
import { IdeType, SerializedContinueConfig } from "../";
|
||||
import { defaultConfig, defaultConfigJetBrains } from "../config/default";
|
||||
import Types from "../config/types";
|
||||
import { DevEventName } from "@continuedev/config-yaml";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
|
|
@ -368,7 +368,7 @@ export function readAllGlobalPromptFiles(
|
|||
if (stats.isDirectory()) {
|
||||
const nestedPromptFiles = readAllGlobalPromptFiles(filepath);
|
||||
promptFiles.push(...nestedPromptFiles);
|
||||
} else {
|
||||
} else if (file.endsWith(".prompt")) {
|
||||
const content = fs.readFileSync(filepath, "utf8");
|
||||
promptFiles.push({ path: filepath, content });
|
||||
}
|
||||
|
|
@ -397,10 +397,6 @@ export function migrateV1DevDataFiles() {
|
|||
if (!fs.existsSync(newFilePath)) {
|
||||
fs.copyFileSync(oldFilePath, newFilePath);
|
||||
fs.unlinkSync(oldFilePath);
|
||||
} else {
|
||||
console.warn(
|
||||
`V1 Dev data migration: ${newFilePath} already exists, skipping ${oldFileName}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,19 +116,23 @@ export function getLastNUriRelativePathParts(
|
|||
}
|
||||
|
||||
export function joinPathsToUri(uri: string, ...pathSegments: string[]) {
|
||||
const components = URI.parse(uri);
|
||||
let baseUri = uri;
|
||||
if (baseUri.at(-1) !== "/") {
|
||||
baseUri += "/";
|
||||
}
|
||||
const segments = pathSegments.map((segment) => pathToUriPathSegment(segment));
|
||||
components.path = `${components.path}/${segments.join("/")}`;
|
||||
return URI.serialize(components);
|
||||
return URI.resolve(baseUri, segments.join("/"));
|
||||
}
|
||||
|
||||
export function joinEncodedUriPathSegmentToUri(
|
||||
uri: string,
|
||||
pathSegment: string,
|
||||
) {
|
||||
const components = URI.parse(uri);
|
||||
components.path = `${components.path}/${pathSegment}`;
|
||||
return URI.serialize(components);
|
||||
let baseUri = uri;
|
||||
if (baseUri.at(-1) !== "/") {
|
||||
baseUri += "/";
|
||||
}
|
||||
return URI.resolve(baseUri, pathSegment);
|
||||
}
|
||||
|
||||
export function getShortestUniqueRelativeUriPaths(
|
||||
|
|
|
|||
11
core/util/url.ts
Normal file
11
core/util/url.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
export function canParseUrl(url: string): boolean {
|
||||
if ((URL as any)?.canParse) {
|
||||
return (URL as any).canParse(url);
|
||||
}
|
||||
try {
|
||||
new URL(url);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ To open your configuration file, you can click the "gear" icon in the bottom rig
|
|||
|
||||
When you save a config file from the IDE, Continue will automatically refresh to take into account your changes. A config file is automatically created the first time you use Continue, and always automatically generated with default values if it doesn't exist.
|
||||
|
||||
See the full reference for `config.yaml` [here](../../reference.md).
|
||||
See the full reference for `config.yaml` [here](../../yaml-reference.md).
|
||||
|
||||
## Deprecated configuration methods
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ You can read more about how development data is generated as a byproduct of LLM-
|
|||
|
||||
You can also configure custom destinations for your data, including remote HTTP endpoints and local file directories.
|
||||
|
||||
For hub assistants, data destinations are configured in `data` blocks. Visit the hub to [explore example data blocks](https://hub.continue.dev/explore/data) or [create your own](https://hub.continue.dev/new?type=block&block=data).
|
||||
For hub assistants, data destinations are configured in `data` blocks. Visit the hub to [explore example data blocks](https://hub.continue.dev/explore/data) or [create your own](https://hub.continue.dev/new?type=block&blockType=data).
|
||||
|
||||
See more details about adding `data` blocks to your configuration files in the [YAML specification](../../yaml-reference.md#data)
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ Pre-indexed docs are only available in VS Code because the VS Code extension shi
|
|||
|
||||
### Hub `docs` Blocks
|
||||
|
||||
@Docs uses [`docs` blocks](../../hub/blocks/block-types.md#docs) in Assistants from the hub. Visit the hub to [explore `docs` blocks](https://hub.continue.dev/explore/docs) or [create your own](https://hub.continue.dev/new?type=block&block=docs).
|
||||
@Docs uses [`docs` blocks](../../hub/blocks/block-types.md#docs) in Assistants from the hub. Visit the hub to [explore `docs` blocks](https://hub.continue.dev/explore/docs) or [create your own](https://hub.continue.dev/new?type=block&blockType=docs).
|
||||
|
||||
### Through the `@Docs` Context Provider
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ title: Prompt files
|
|||
|
||||
Prompt files provide a convenient way to standardize common patterns and share a collection of LLM prompts with your team. They make it easy to build and use these prompts.
|
||||
|
||||
On the [hub](../../hub/introduction.md), prompt files are stored within [prompt blocks](../../hub/blocks/block-types.md#prompts), which show up as [slash commands](../slash-commands.mdx) in Chat. Visit the hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&block=rules).
|
||||
On the [hub](../../hub/introduction.md), prompt files are stored within [prompt blocks](../../hub/blocks/block-types.md#prompts), which show up as [slash commands](../slash-commands.mdx) in Chat. Visit the hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&blockType=rules).
|
||||
|
||||
Prompt files can also be stored within your project's root directory as `.prompt` files. See below.
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Rules are used to provide instructions to **chat** models. They are inserted int
|
|||
|
||||
## Hub `rules` blocks
|
||||
|
||||
Rules can be added to an Assistant on the Continue Hub. Explore available rules [here](https://hub.continue.dev/explore/rules), or [create your own](https://hub.continue.dev/new?type=block&block=rules) in the Hub.
|
||||
Rules can be added to an Assistant on the Continue Hub. Explore available rules [here](https://hub.continue.dev/explore/rules), or [create your own](https://hub.continue.dev/new?type=block&blockType=rules) in the Hub.
|
||||
|
||||
## `.continuerules`
|
||||
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@ import Tabs from "@theme/Tabs";
|
|||
|
||||
# SambaNova Cloud
|
||||
|
||||
The SambaNova Cloud is a cloud platform for running large AI models with the world record Llama 3.1 70B/405B performance. You can follow the instructions in [this blog post](https://sambanova.ai/blog/accelerating-coding-with-sambanova-cloud?ref=blog.continue.dev) to configure your setup.
|
||||
The SambaNova Cloud is a cloud platform for running large AI models with the world record open source models performance. You can follow the instructions in [this blog post](https://sambanova.ai/blog/accelerating-coding-with-sambanova-cloud?ref=blog.continue.dev) to configure your setup.
|
||||
|
||||
<Tabs groupId="config-example">
|
||||
<TabItem value="yaml" label="YAML">
|
||||
```yaml title="config.yaml"
|
||||
models:
|
||||
- name: SambaNova Llama 3.1 405B
|
||||
- name: SambaNova Qwen2.5 coder
|
||||
provider: sambanova
|
||||
model: llama3.1-405b
|
||||
model: qwen2.5-coder-32b
|
||||
apiKey: <YOUR_SAMBANOVA_API_KEY>
|
||||
```
|
||||
</TabItem>
|
||||
|
|
@ -20,9 +20,9 @@ The SambaNova Cloud is a cloud platform for running large AI models with the wor
|
|||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "SambaNova Llama 3.1 405B",
|
||||
"title": "SambaNova Qwen2.5 coder",
|
||||
"provider": "sambanova",
|
||||
"model": "llama3.1-405b",
|
||||
"model": "qwen2.5-coder-32b",
|
||||
"apiKey": "<YOUR_SAMBANOVA_API_KEY>"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ We recommend configuring **GPT-4o** as your chat model.
|
|||
|
||||
## Autocomplete model
|
||||
|
||||
We recommend configuring **Codestral** as your autocomplete model.
|
||||
We recommend configuring **Codestral** as your autocomplete model. If you use Azure AI Foundry to deploy Codestral:
|
||||
|
||||
<Tabs groupId="config-example">
|
||||
<TabItem value="yaml" label="YAML">
|
||||
|
|
@ -60,6 +60,8 @@ We recommend configuring **Codestral** as your autocomplete model.
|
|||
- name: Codestral
|
||||
provider: mistral
|
||||
model: codestral-latest
|
||||
apiBase: https://<YOUR_MODEL_NAME>.<YOUR_REGION>.models.ai.azure.com/v1
|
||||
apiKey: <YOUR_AZURE_API_KEY>
|
||||
roles:
|
||||
- autocomplete
|
||||
```
|
||||
|
|
@ -70,7 +72,9 @@ We recommend configuring **Codestral** as your autocomplete model.
|
|||
"tabAutocompleteModel": {
|
||||
"title": "Codestral",
|
||||
"provider": "mistral",
|
||||
"model": "codestral-latest"
|
||||
"model": "codestral-latest",
|
||||
"apiBase": "https://<YOUR_MODEL_NAME>.<YOUR_REGION>.models.ai.azure.com/v1",
|
||||
"apiKey": "<YOUR_AZURE_API_KEY>"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -45,4 +45,4 @@ In Continue, you can add `edit` to a model's roles to specify that it can be use
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Explore edit models in [the hub](https://hub.continue.dev/explore/models?roles=edit). Generally, we our recommendations for Edit overlap with recommendations for Chat.
|
||||
Explore edit models in [the hub](https://hub.continue.dev/explore/models?roles=edit). Generally, our recommendations for Edit overlap with recommendations for Chat.
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ Currently custom tools can be configured using the [Model Context Protocol](http
|
|||
|
||||
MCP Servers can be added to hub Assistants using `mcpServers` blocks. You can explore available MCP server blocks [here](https://hub.continue.dev/explore/mcp).
|
||||
|
||||
To set up your own MCP server, read the [MCP quickstart](https://modelcontextprotocol.io/quickstart) and then [create an `mcpServers` block](https://hub.continue.dev/new?type=block&block=mcpServers) or add the following to your [config file](../customize/deep-dives/configuration.md):
|
||||
To set up your own MCP server, read the [MCP quickstart](https://modelcontextprotocol.io/quickstart) and then [create an `mcpServers` block](https://hub.continue.dev/new?type=block&blockType=mcpServers) or add the following to your [config file](../customize/deep-dives/configuration.md):
|
||||
|
||||
<Tabs groupId="config-example">
|
||||
<TabItem value="yaml" label="YAML">
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ Parameters that control the behavior of text generation and completion settings.
|
|||
- `topP`: The cumulative probability for nucleus sampling. Lower values limit responses to tokens within the top probability mass.
|
||||
- `topK`: The maximum number of tokens considered at each step. Limits the generated text to tokens within this probability.
|
||||
- `presencePenalty`: Discourages the model from generating tokens that have already appeared in the output.
|
||||
- `frequencePenalty`: Penalizes tokens based on their frequency in the text, reducing repetition.
|
||||
- `frequencyPenalty`: Penalizes tokens based on their frequency in the text, reducing repetition.
|
||||
- `mirostat`: Enables Mirostat sampling, which controls the perplexity during text generation. Supported by Ollama, LM Studio, and llama.cpp providers (default: `0`, where `0` = disabled, `1` = Mirostat, and `2` = Mirostat 2.0).
|
||||
- `stop`: An array of stop tokens that, when encountered, will terminate the completion. Allows specifying multiple end conditions.
|
||||
- `maxTokens`: The maximum number of tokens to generate in a completion (default: `2048`).
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ See also
|
|||
|
||||
- [Intro to YAML](https://yaml.org/)
|
||||
- [JSON Continue Config Reference](/json-reference)
|
||||
- [YAML Continue Config Reference](/reference)
|
||||
- [YAML Continue Config Reference](/yaml-reference)
|
||||
|
||||
## Create YAML file
|
||||
|
||||
|
|
@ -37,9 +37,9 @@ Add all model configurations in `config.json`, including models in `models`, `ta
|
|||
- `inlineEdit` -> e.g. `roles: [chat, edit]`
|
||||
- `applyCodeBlock` -> e.g. `roles: [chat, apply]`
|
||||
|
||||
Model-level `requestOptions` remain, with minor changes. See [YAML Continue Config Reference](/reference#requestoptions)
|
||||
Model-level `requestOptions` remain, with minor changes. See [YAML Continue Config Reference](/yaml-reference#requestoptions)
|
||||
|
||||
Model-level `completionOptions` are replaced by `defaultCompletionOptions`, with minor changes. See [YAML Continue Config Reference](/reference#completionoptions)
|
||||
Model-level `completionOptions` are replaced by `defaultCompletionOptions`, with minor changes. See [YAML Continue Config Reference](/yaml-reference#completionoptions)
|
||||
|
||||
<!-- TODO - ollama autodetect supported? -->
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ description: Reference for the Continue configuration YAML file
|
|||
keywords: [config, yaml, configuration, customize, customization]
|
||||
---
|
||||
|
||||
# confg.yaml Reference
|
||||
# config.yaml Reference
|
||||
|
||||
## Introduction
|
||||
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ Parameters that control the behavior of text generation and completion settings.
|
|||
- `topP`: The cumulative probability for nucleus sampling. Lower values limit responses to tokens within the top probability mass.
|
||||
- `topK`: The maximum number of tokens considered at each step. Limits the generated text to tokens within this probability.
|
||||
- `presencePenalty`: Discourages the model from generating tokens that have already appeared in the output.
|
||||
- `frequencePenalty`: Penalizes tokens based on their frequency in the text, reducing repetition.
|
||||
- `frequencyPenalty`: Penalizes tokens based on their frequency in the text, reducing repetition.
|
||||
- `mirostat`: Enables Mirostat sampling, which controls the perplexity during text generation. Supported by Ollama, LM Studio, and llama.cpp providers (default: `0`, where `0` = disabled, `1` = Mirostat, and `2` = Mirostat 2.0).
|
||||
- `stop`: An array of stop tokens that, when encountered, will terminate the completion. Allows specifying multiple end conditions.
|
||||
- `maxTokens`: The maximum number of tokens to generate in a completion (default: `2048`).
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Prompt Logs" type="ShConfigurationType">
|
||||
<option name="SCRIPT_TEXT" value="mkdir -p ./extensions/.continue-debug/logs && touch ./extensions/.continue-debug/logs/prompt.log && tail -f ./extensions/.continue-debug/logs/prompt.log" />
|
||||
<option name="SCRIPT_TEXT" value="node ./binary/prompt-logs.js" />
|
||||
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
||||
<option name="SCRIPT_PATH" value="" />
|
||||
<option name="SCRIPT_OPTIONS" value="" />
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Start Core Dev Server (CE)" type="ShConfigurationType">
|
||||
<option name="SCRIPT_TEXT" value="export CONTINUE_DEVELOPMENT=true && export CONTINUE_GLOBAL_DIR=$PROJECT_DIR$/extensions/.continue-debug && node out/index.js" />
|
||||
<option name="SCRIPT_TEXT" value="cross-env 'PROJECT_DIR="$PROJECT_DIR$"' node core-dev-server.js" />
|
||||
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
||||
<option name="SCRIPT_PATH" value="" />
|
||||
<option name="SCRIPT_OPTIONS" value="" />
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension
|
|||
pluginName=continue-intellij-extension
|
||||
pluginRepositoryUrl=https://github.com/continuedev/continue
|
||||
# SemVer format -> https://semver.org
|
||||
pluginVersion=1.0.1
|
||||
pluginVersion=1.0.2
|
||||
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
|
||||
pluginSinceBuild=223
|
||||
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.github.continuedev.continueintellijextension.activities
|
||||
|
||||
import IntelliJIDE
|
||||
import com.github.continuedev.continueintellijextension.auth.AuthListener
|
||||
import com.github.continuedev.continueintellijextension.auth.ContinueAuthService
|
||||
import com.github.continuedev.continueintellijextension.auth.ControlPlaneSessionInfo
|
||||
|
|
@ -30,13 +29,13 @@ import java.nio.file.Paths
|
|||
import javax.swing.*
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.module.ModuleManager
|
||||
import com.intellij.openapi.project.guessProjectDir
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
import com.intellij.openapi.vfs.newvfs.BulkFileListener
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent
|
||||
import com.intellij.ide.ui.LafManagerListener
|
||||
|
||||
fun showTutorial(project: Project) {
|
||||
|
|
@ -48,7 +47,7 @@ fun showTutorial(project: Project) {
|
|||
throw IOException("Resource not found: $tutorialFileName")
|
||||
}
|
||||
var content = StreamUtil.readText(`is`, StandardCharsets.UTF_8)
|
||||
|
||||
|
||||
// All jetbrains will use J instead of L
|
||||
content = content.replace("[Cmd + L]", "[Cmd + J]")
|
||||
content = content.replace("[Cmd + Shift + L]", "[Cmd + Shift + J]")
|
||||
|
|
@ -175,7 +174,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware {
|
|||
|
||||
// Send "files/deleted" message if there are any deletions
|
||||
if (deletedURIs.isNotEmpty()) {
|
||||
val data = mapOf("files" to deletedURIs)
|
||||
val data = mapOf("uris" to deletedURIs)
|
||||
continuePluginService.coreMessenger?.request("files/deleted", data, null) { _ -> }
|
||||
}
|
||||
|
||||
|
|
@ -185,9 +184,18 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware {
|
|||
|
||||
// Notify core of content changes
|
||||
if (changedURIs.isNotEmpty()) {
|
||||
val data = mapOf("files" to changedURIs)
|
||||
val data = mapOf("uris" to changedURIs)
|
||||
continuePluginService.coreMessenger?.request("files/changed", data, null) { _ -> }
|
||||
}
|
||||
|
||||
events.filterIsInstance<VFileCreateEvent>()
|
||||
.mapNotNull { event -> event.file?.toUriOrNull() }
|
||||
.takeIf { it.isNotEmpty() }?.let {
|
||||
val data = mapOf("uris" to it)
|
||||
continuePluginService.coreMessenger?.request("files/created", data, null) { _ -> }
|
||||
}
|
||||
|
||||
// TODO: Missing handling of copying files, renaming files, etc.
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -199,7 +207,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware {
|
|||
colors
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
// Listen for clicking settings button to start the auth flow
|
||||
val authService = service<ContinueAuthService>()
|
||||
val initialSessionInfo = authService.loadControlPlaneSessionInfo()
|
||||
|
|
|
|||
|
|
@ -54,17 +54,15 @@ fun Editor.addInlayElement(
|
|||
class AutocompleteService(private val project: Project) {
|
||||
var pendingCompletion: PendingCompletion? = null
|
||||
private val autocompleteLookupListener = project.service<AutocompleteLookupListener>()
|
||||
private var widget: AutocompleteSpinnerWidget? = null
|
||||
private val widget: AutocompleteSpinnerWidget? by lazy {
|
||||
WindowManager.getInstance().getStatusBar(project)
|
||||
?.getWidget(AutocompleteSpinnerWidget.ID) as? AutocompleteSpinnerWidget
|
||||
}
|
||||
|
||||
// To avoid triggering another completion on partial acceptance,
|
||||
// we need to keep track of whether the last change was a partial accept
|
||||
var lastChangeWasPartialAccept = false
|
||||
|
||||
init {
|
||||
val statusBar = WindowManager.getInstance().getStatusBar(project)
|
||||
widget = statusBar.getWidget("AutocompleteSpinnerWidget") as? AutocompleteSpinnerWidget
|
||||
}
|
||||
|
||||
fun triggerCompletion(editor: Editor) {
|
||||
val settings =
|
||||
ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
|
|
@ -80,13 +78,14 @@ class AutocompleteService(private val project: Project) {
|
|||
val completionId = uuid()
|
||||
val offset = editor.caretModel.primaryCaret.offset
|
||||
pendingCompletion = PendingCompletion(editor, offset, completionId, null)
|
||||
widget?.setLoading(true)
|
||||
|
||||
// Request a completion from the core
|
||||
val virtualFile = FileDocumentManager.getInstance().getFile(editor.document)
|
||||
|
||||
val uri = virtualFile?.toUriOrNull() ?: return
|
||||
|
||||
widget?.setLoading(true)
|
||||
|
||||
val line = editor.caretModel.primaryCaret.logicalPosition.line
|
||||
val column = editor.caretModel.primaryCaret.logicalPosition.column
|
||||
val input = mapOf(
|
||||
|
|
@ -106,7 +105,9 @@ class AutocompleteService(private val project: Project) {
|
|||
input,
|
||||
null,
|
||||
({ response ->
|
||||
widget?.setLoading(false)
|
||||
if (pendingCompletion == null || pendingCompletion?.completionId == completionId) {
|
||||
widget?.setLoading(false)
|
||||
}
|
||||
|
||||
val responseObject = response as Map<*, *>
|
||||
val completions = responseObject["content"] as List<*>
|
||||
|
|
@ -299,12 +300,9 @@ class AutocompleteService(private val project: Project) {
|
|||
}
|
||||
|
||||
private fun isInjectedFile(editor: Editor): Boolean {
|
||||
val psiFile = runReadAction { PsiDocumentManager.getInstance(project).getPsiFile(editor.document) }
|
||||
if (psiFile == null) {
|
||||
return false
|
||||
return runReadAction {
|
||||
PsiDocumentManager.getInstance(project).getPsiFile(editor.document)?.isInjectedText() ?: false
|
||||
}
|
||||
val response = runReadAction { psiFile.isInjectedText() }
|
||||
return response
|
||||
}
|
||||
|
||||
fun hideCompletions(editor: Editor) {
|
||||
|
|
|
|||
|
|
@ -23,17 +23,7 @@ class AutocompleteSpinnerWidget(project: Project) : EditorBasedWidget(project),
|
|||
private val iconLabel = JLabel()
|
||||
private var isLoading = false
|
||||
|
||||
private val animatedIcon = AnimatedIcon(
|
||||
100,
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading1(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading2(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading3(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading4(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading5(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading6(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading7(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading8(RiderLight).svg", javaClass),
|
||||
)
|
||||
private val animatedIcon = AnimatedIcon.Default()
|
||||
|
||||
init {
|
||||
Disposer.register(ContinuePluginDisposable.getInstance(project), this)
|
||||
|
|
@ -47,10 +37,10 @@ class AutocompleteSpinnerWidget(project: Project) : EditorBasedWidget(project),
|
|||
override fun dispose() {}
|
||||
|
||||
override fun ID(): String {
|
||||
return "AutocompleteSpinnerWidget"
|
||||
return ID
|
||||
}
|
||||
|
||||
override fun getTooltipText(): String? {
|
||||
override fun getTooltipText(): String {
|
||||
val enabled = service<ContinueExtensionSettings>().state.enableTabAutocomplete
|
||||
return if (enabled) "Continue autocomplete enabled" else "Continue autocomplete disabled"
|
||||
}
|
||||
|
|
@ -80,9 +70,13 @@ class AutocompleteSpinnerWidget(project: Project) : EditorBasedWidget(project),
|
|||
updateIcon()
|
||||
}
|
||||
|
||||
override fun getPresentation(): StatusBarWidget.WidgetPresentation? {
|
||||
override fun getPresentation(): StatusBarWidget.WidgetPresentation {
|
||||
return this
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ID = "AutocompleteSpinnerWidget"
|
||||
}
|
||||
}
|
||||
|
||||
class AutocompleteSpinnerWidgetFactory : StatusBarWidgetFactory {
|
||||
|
|
@ -91,7 +85,7 @@ class AutocompleteSpinnerWidgetFactory : StatusBarWidgetFactory {
|
|||
}
|
||||
|
||||
override fun getId(): String {
|
||||
return "AutocompleteSpinnerWidget"
|
||||
return AutocompleteSpinnerWidget.ID
|
||||
}
|
||||
|
||||
override fun getDisplayName(): String {
|
||||
|
|
@ -103,7 +97,7 @@ class AutocompleteSpinnerWidgetFactory : StatusBarWidgetFactory {
|
|||
}
|
||||
|
||||
override fun createWidget(project: Project): StatusBarWidget {
|
||||
return AutocompleteSpinnerWidget(project)
|
||||
return create(project)
|
||||
}
|
||||
|
||||
override fun disposeWidget(p0: StatusBarWidget) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ import com.intellij.openapi.vfs.VirtualFileManager
|
|||
import kotlinx.coroutines.*
|
||||
import java.awt.Toolkit
|
||||
import java.awt.datatransfer.StringSelection
|
||||
import java.lang.IllegalStateException
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
|
||||
class IdeProtocolClient(
|
||||
|
|
@ -434,7 +436,6 @@ class IdeProtocolClient(
|
|||
return@launch
|
||||
}
|
||||
|
||||
|
||||
val llm: Any = try {
|
||||
suspendCancellableCoroutine { continuation ->
|
||||
continuePluginService.coreMessenger?.request(
|
||||
|
|
@ -442,26 +443,31 @@ class IdeProtocolClient(
|
|||
null,
|
||||
null
|
||||
) { response ->
|
||||
val responseObject = response as Map<*, *>
|
||||
val responseContent = responseObject["content"] as Map<*, *>
|
||||
val result = responseContent["result"] as Map<*, *>
|
||||
val config = result["config"] as Map<String, Any>
|
||||
try {
|
||||
val responseObject = response as Map<*, *>
|
||||
val responseContent = responseObject["content"] as Map<*, *>
|
||||
val result = responseContent["result"] as Map<*, *>
|
||||
val config = result["config"] as Map<*, *>
|
||||
|
||||
val selectedModels = config["selectedModelByRole"] as Map<String, Any>
|
||||
val applyCodeBlockModel = selectedModels["apply"] as Map<String, Any>
|
||||
val selectedModels = config["selectedModelByRole"] as? Map<*, *>
|
||||
val applyCodeBlockModel = selectedModels?.get("apply") as? Map<*, *>
|
||||
|
||||
if (applyCodeBlockModel != null) {
|
||||
continuation.resume(applyCodeBlockModel)
|
||||
}
|
||||
if (applyCodeBlockModel != null) {
|
||||
continuation.resume(applyCodeBlockModel)
|
||||
} else {
|
||||
val models =
|
||||
config["models"] as List<Map<String, Any>>
|
||||
val curSelectedModel =
|
||||
models.find { it["title"] == params.curSelectedModelTitle }
|
||||
|
||||
val models =
|
||||
config["models"] as List<Map<String, Any>>
|
||||
val curSelectedModel = models.find { it["title"] == params.curSelectedModelTitle }
|
||||
|
||||
if (curSelectedModel == null) {
|
||||
return@request
|
||||
} else {
|
||||
continuation.resume(curSelectedModel)
|
||||
if (curSelectedModel == null) {
|
||||
continuation.resumeWithException(IllegalStateException("Model '${params.curSelectedModelTitle}' not found in config."))
|
||||
} else {
|
||||
continuation.resume(curSelectedModel)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
continuation.resumeWithException(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -475,7 +481,6 @@ class IdeProtocolClient(
|
|||
return@launch
|
||||
}
|
||||
|
||||
|
||||
val diffStreamService = project.service<DiffStreamService>()
|
||||
// Clear all diff blocks before running the diff stream
|
||||
diffStreamService.reject(editor)
|
||||
|
|
|
|||
|
|
@ -111,7 +111,10 @@ class OpenedConnection(private val connection: URLConnection?) :
|
|||
) {
|
||||
try {
|
||||
if (connection != null) {
|
||||
val url = connection.url.toString()
|
||||
val fullUrl = connection.url.toString()
|
||||
// Extract only the resource path after the JAR prefix to prevent incorrect mime type matching
|
||||
// (e.g., if a user's home folder contains "js" in the path)
|
||||
val url = fullUrl.substringAfterLast("jar!/", fullUrl)
|
||||
when {
|
||||
url.contains("css") -> cefResponse.mimeType = "text/css"
|
||||
url.contains("js") -> cefResponse.mimeType = "text/javascript"
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
"description": "The presence penalty Aof the completion.",
|
||||
"type": "number"
|
||||
},
|
||||
"frequencePenalty": {
|
||||
"frequencyPenalty": {
|
||||
"title": "Frequency Penalty",
|
||||
"description": "The frequency penalty of the completion.",
|
||||
"type": "number"
|
||||
|
|
@ -246,6 +246,7 @@
|
|||
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/Msty)",
|
||||
"### IBM watsonx\nwatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.",
|
||||
"### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys).",
|
||||
"### SambaNova\n SambaNova provides fast inference of open-source language models with zero data retention. To get started, obtain an API key in [SambaNova Cloud](https://cloud.sambanova.ai/apis).",
|
||||
"### NVIDIA NIMs\nNVIDIA offers a single API to access almost any language model. To find out more, visit the [LLM APIs Documentation](https://docs.api.nvidia.com/nim/reference/llm-apis).\nFor information specific to getting a key, please check out the [docs here](https://docs.nvidia.com/nim/large-language-models/latest/getting-started.html#option-1-from-api-catalog)",
|
||||
"### vLLM\nvLLM is a highly performant way of hosting LLMs for a team. To get started, follow their [quickstart](https://docs.vllm.ai/en/latest/getting_started/quickstart.html) to set up your server.",
|
||||
"### Cerebras\nCerebras Inference uses specialized silicon to provides superfast inference. To get started, get your API keys from [their console](https://cloud.cerebras.ai/).",
|
||||
|
|
@ -1626,7 +1627,22 @@
|
|||
"model": {
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": ["llama3.1-8b", "llama3.1-70b", "llama3.1-405b"]
|
||||
"enum": [
|
||||
"Qwen2.5-Coder-32B-Instruct",
|
||||
"Meta-Llama-3.3-70B-Instruct",
|
||||
"Meta-Llama-3.1-8B-Instruct",
|
||||
"Meta-Llama-3.1-70B-Instruct",
|
||||
"Meta-Llama-3.1-405B-Instruct",
|
||||
"Llama-3.1-Tulu-3-405B",
|
||||
"Meta-Llama-3.2-1B-Instruct",
|
||||
"Meta-Llama-3.2-3B-Instruct",
|
||||
"Llama-3.2-11B-Vision-Instruct",
|
||||
"Llama-3.2-90B-Vision-Instruct",
|
||||
"Qwen2.5-72B-Instruct",
|
||||
"QwQ-32B-Preview",
|
||||
"DeepSeek-R1-Distill-Llama-70B",
|
||||
"DeepSeek-R1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
|
|
|
|||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.5",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
@ -52,6 +52,7 @@
|
|||
"llama"
|
||||
],
|
||||
"activationEvents": [
|
||||
"onUri",
|
||||
"onStartupFinished",
|
||||
"onView:continueGUIView"
|
||||
],
|
||||
|
|
@ -594,7 +595,7 @@
|
|||
"e2e:compile": "tsc -p ./tsconfig.e2e.json",
|
||||
"e2e:build": "npm --prefix ../../gui run build && npm run package",
|
||||
"e2e:create-storage": "mkdir -p ./e2e/storage",
|
||||
"e2e:get-chromedriver": "extest get-chromedriver --storage ./e2e/storage",
|
||||
"e2e:get-chromedriver": "CODE_VERSION=\"1.95.0\" extest get-chromedriver --storage ./e2e/storage",
|
||||
"e2e:get-vscode": "CODE_VERSION=\"1.95.0\" extest get-vscode --storage ./e2e/storage",
|
||||
"e2e:sign-vscode": "codesign --entitlements entitlements.plist --deep --force -s - './e2e/storage/Visual Studio Code.app'",
|
||||
"e2e:copy-vsix": "chmod +x ./e2e/get-latest-vsix.sh && bash ./e2e/get-latest-vsix.sh",
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ import { ContinueServerClient } from "core/continueServer/stubs/client";
|
|||
import { EXTENSION_NAME } from "core/control-plane/env";
|
||||
import { Core } from "core/core";
|
||||
import { walkDirAsync } from "core/indexing/walkDir";
|
||||
import { GlobalContext } from "core/util/GlobalContext";
|
||||
import { getConfigJsonPath, getDevDataFilePath } from "core/util/paths";
|
||||
import { getDevDataFilePath } from "core/util/paths";
|
||||
import { Telemetry } from "core/util/posthog";
|
||||
import readLastLines from "read-last-lines";
|
||||
import * as vscode from "vscode";
|
||||
|
|
@ -918,9 +917,6 @@ const getCommandsMap: (
|
|||
{
|
||||
label: quickPickStatusText(targetStatus),
|
||||
},
|
||||
{
|
||||
label: "$(gear) Configure autocomplete options",
|
||||
},
|
||||
{
|
||||
label: "$(feedback) Give feedback",
|
||||
},
|
||||
|
|
@ -945,10 +941,6 @@ const getCommandsMap: (
|
|||
targetStatus === StatusBarStatus.Enabled,
|
||||
vscode.ConfigurationTarget.Global,
|
||||
);
|
||||
} else if (
|
||||
selectedOption === "$(gear) Configure autocomplete options"
|
||||
) {
|
||||
ide.openFile(vscode.Uri.file(getConfigJsonPath()).toString());
|
||||
} else if (
|
||||
autocompleteModels.some((model) => model.title === selectedOption)
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import { registerAllPromptFilesCompletionProviders } from "../lang-server/prompt
|
|||
import EditDecorationManager from "../quickEdit/EditDecorationManager";
|
||||
import { QuickEdit } from "../quickEdit/QuickEditQuickPick";
|
||||
import { setupRemoteConfigSync } from "../stubs/activation";
|
||||
import { UriEventHandler } from "../stubs/uriHandler";
|
||||
import {
|
||||
getControlPlaneSessionInfo,
|
||||
WorkOsAuthProvider,
|
||||
|
|
@ -55,10 +56,11 @@ export class VsCodeExtension {
|
|||
private battery: Battery;
|
||||
private workOsAuthProvider: WorkOsAuthProvider;
|
||||
private fileSearch: FileSearch;
|
||||
private uriHandler = new UriEventHandler();
|
||||
|
||||
constructor(context: vscode.ExtensionContext) {
|
||||
// Register auth provider
|
||||
this.workOsAuthProvider = new WorkOsAuthProvider(context);
|
||||
this.workOsAuthProvider = new WorkOsAuthProvider(context, this.uriHandler);
|
||||
this.workOsAuthProvider.refreshSessions();
|
||||
context.subscriptions.push(this.workOsAuthProvider);
|
||||
|
||||
|
|
@ -193,6 +195,41 @@ export class VsCodeExtension {
|
|||
),
|
||||
);
|
||||
|
||||
// Handle uri events
|
||||
this.uriHandler.event((uri) => {
|
||||
const queryParams = new URLSearchParams(uri.query);
|
||||
let profileId = queryParams.get("profile_id");
|
||||
let orgId = queryParams.get("org_id");
|
||||
|
||||
if (orgId) {
|
||||
if (orgId === "null") {
|
||||
orgId = null;
|
||||
}
|
||||
// In case org id is passed with profile id
|
||||
// Make sure org is updated before profile is set
|
||||
if (profileId) {
|
||||
if (profileId === "null") {
|
||||
profileId = null;
|
||||
}
|
||||
this.core.invoke("didChangeSelectedOrg", {
|
||||
id: orgId,
|
||||
profileId,
|
||||
});
|
||||
} else {
|
||||
this.core.invoke("didChangeSelectedOrg", {
|
||||
id: orgId,
|
||||
});
|
||||
}
|
||||
} else if (profileId) {
|
||||
if (profileId === "null") {
|
||||
profileId = null;
|
||||
}
|
||||
this.core.invoke("didChangeSelectedProfile", {
|
||||
id: profileId,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Battery
|
||||
this.battery = new Battery();
|
||||
context.subscriptions.push(this.battery);
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ import {
|
|||
ExtensionContext,
|
||||
ProgressLocation,
|
||||
Uri,
|
||||
UriHandler,
|
||||
window,
|
||||
workspace,
|
||||
} from "vscode";
|
||||
|
||||
import { PromiseAdapter, promiseFromEvent } from "./promiseUtils";
|
||||
import { SecretStorage } from "./SecretStorage";
|
||||
import { UriEventHandler } from "./uriHandler";
|
||||
|
||||
const AUTH_NAME = "Continue";
|
||||
|
||||
|
|
@ -35,11 +35,6 @@ const controlPlaneEnv = getControlPlaneEnvSync(
|
|||
|
||||
const SESSIONS_SECRET_KEY = `${controlPlaneEnv.AUTH_TYPE}.sessions`;
|
||||
|
||||
class UriEventHandler extends EventEmitter<Uri> implements UriHandler {
|
||||
public handleUri(uri: Uri) {
|
||||
this.fire(uri);
|
||||
}
|
||||
}
|
||||
// Function to generate a random string of specified length
|
||||
function generateRandomString(length: number): string {
|
||||
const possibleCharacters =
|
||||
|
|
@ -83,13 +78,15 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
|||
string,
|
||||
{ promise: Promise<string>; cancel: EventEmitter<void> }
|
||||
>();
|
||||
private _uriHandler = new UriEventHandler();
|
||||
|
||||
private static EXPIRATION_TIME_MS = 1000 * 60 * 15; // 15 minutes
|
||||
|
||||
private secretStorage: SecretStorage;
|
||||
|
||||
constructor(private readonly context: ExtensionContext) {
|
||||
constructor(
|
||||
private readonly context: ExtensionContext,
|
||||
private readonly _uriHandler: UriEventHandler,
|
||||
) {
|
||||
this._disposable = Disposable.from(
|
||||
authentication.registerAuthenticationProvider(
|
||||
controlPlaneEnv.AUTH_TYPE,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { EXTENSION_NAME } from "core/control-plane/env";
|
|||
import { getConfigJsonPathForRemote } from "core/util/paths";
|
||||
import * as vscode from "vscode";
|
||||
|
||||
import { canParseUrl } from "core/util/url";
|
||||
import { CONTINUE_WORKSPACE_KEY } from "../util/workspaceConfig";
|
||||
|
||||
export class RemoteConfigSync {
|
||||
|
|
@ -66,18 +67,6 @@ export class RemoteConfigSync {
|
|||
};
|
||||
}
|
||||
|
||||
private canParse(url: string): boolean {
|
||||
if ((URL as any).canParse) {
|
||||
return (URL as any).canParse(url);
|
||||
}
|
||||
try {
|
||||
new URL(url);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async setup() {
|
||||
if (
|
||||
this.userToken === null ||
|
||||
|
|
@ -86,7 +75,7 @@ export class RemoteConfigSync {
|
|||
) {
|
||||
return;
|
||||
}
|
||||
if (!this.canParse(this.remoteConfigServerUrl)) {
|
||||
if (!canParseUrl(this.remoteConfigServerUrl)) {
|
||||
vscode.window.showErrorMessage(
|
||||
"The value set for 'remoteConfigServerUrl' is not valid: ",
|
||||
this.remoteConfigServerUrl,
|
||||
|
|
|
|||
10
extensions/vscode/src/stubs/uriHandler.ts
Normal file
10
extensions/vscode/src/stubs/uriHandler.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import * as vscode from "vscode";
|
||||
|
||||
export class UriEventHandler
|
||||
extends vscode.EventEmitter<vscode.Uri>
|
||||
implements vscode.UriHandler
|
||||
{
|
||||
public handleUri(uri: vscode.Uri) {
|
||||
this.fire(uri);
|
||||
}
|
||||
}
|
||||
BIN
gui/public/fonts/Inter/InterDisplay-Light.woff2
Normal file
BIN
gui/public/fonts/Inter/InterDisplay-Light.woff2
Normal file
Binary file not shown.
92
gui/public/fonts/Inter/LICENSE.txt
Normal file
92
gui/public/fonts/Inter/LICENSE.txt
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION AND CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
10
gui/public/fonts/JetBrainsMono/AUTHORS.txt
Normal file
10
gui/public/fonts/JetBrainsMono/AUTHORS.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# This is the official list of project authors for copyright purposes.
|
||||
# This file is distinct from the CONTRIBUTORS.txt file.
|
||||
# See the latter for an explanation.
|
||||
#
|
||||
# Names should be added to this file as:
|
||||
# Name or Organization <email address>
|
||||
|
||||
JetBrains <>
|
||||
Philipp Nurullin <philipp.nurullin@jetbrains.com>
|
||||
Konstantin Bulenkov <kb@jetbrains.com>
|
||||
BIN
gui/public/fonts/JetBrainsMono/JetBrainsMono-Light.woff2
Normal file
BIN
gui/public/fonts/JetBrainsMono/JetBrainsMono-Light.woff2
Normal file
Binary file not shown.
93
gui/public/fonts/JetBrainsMono/OFL.txt
Normal file
93
gui/public/fonts/JetBrainsMono/OFL.txt
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
BIN
gui/public/logos/allenai.png
Normal file
BIN
gui/public/logos/allenai.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
|
|
@ -1,6 +1,7 @@
|
|||
import { SessionMetadata } from "core";
|
||||
import MiniSearch from "minisearch";
|
||||
import React, { Fragment, useEffect, useMemo, useRef, useState } from "react";
|
||||
import Shortcut from '../gui/Shortcut';
|
||||
|
||||
import { getFontSize, getMetaKeyLabel } from "../../util";
|
||||
import { HistoryTableRow } from "./HistoryTableRow";
|
||||
|
|
@ -99,10 +100,9 @@ export function History() {
|
|||
{filteredAndSortedSessions.length === 0 && (
|
||||
<div className="m-4 text-center">
|
||||
No past sessions found. To start a new session, either click the "+"
|
||||
button or use the keyboard shortcut: <code>{getMetaKeyLabel()}</code>
|
||||
{` `}
|
||||
<code>L</code>
|
||||
button or use the keyboard shortcut: <Shortcut>meta L</Shortcut>
|
||||
</div>
|
||||
|
||||
)}
|
||||
|
||||
<table className="w-full border-collapse border-spacing-0">
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
import { PlusIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import { useCallback, useEffect } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius } from "..";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { AppDispatch, RootState } from "../../redux/store";
|
||||
import { loadSession, saveCurrentSession } from "../../redux/thunks/session";
|
||||
import { newSession } from "../../redux/slices/sessionSlice";
|
||||
import {
|
||||
addTab,
|
||||
handleSessionChange,
|
||||
removeTab,
|
||||
setActiveTab,
|
||||
setTabs,
|
||||
handleSessionChange,
|
||||
} from "../../redux/slices/tabsSlice";
|
||||
import { AppDispatch, RootState } from "../../redux/store";
|
||||
import { loadSession, saveCurrentSession } from "../../redux/thunks/session";
|
||||
|
||||
const TabBarContainer = styled.div`
|
||||
display: flex;
|
||||
|
|
@ -22,7 +22,7 @@ const TabBarContainer = styled.div`
|
|||
background-color: var(--vscode-tab-inactiveBackground);
|
||||
border-bottom: none;
|
||||
position: relative;
|
||||
margin-top: 7px;
|
||||
margin-top: 2px;
|
||||
|
||||
/* Hide scrollbar but keep functionality */
|
||||
scrollbar-width: none;
|
||||
|
|
@ -155,10 +155,6 @@ export function TabBar() {
|
|||
);
|
||||
const tabs = useSelector((state: RootState) => state.tabs.tabs);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("session", currentSession);
|
||||
}, [currentSession.id]);
|
||||
|
||||
// Simple UUID generator for our needs
|
||||
const generateId = useCallback(() => {
|
||||
return Date.now().toString(36) + Math.random().toString(36).substring(2);
|
||||
|
|
|
|||
23
gui/src/components/gui/Shortcut.css
Normal file
23
gui/src/components/gui/Shortcut.css
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
.keyboard-key {
|
||||
letter-spacing: 0.06rem;
|
||||
color: var(--vscode-editor-foreground);
|
||||
padding: 1px 4px;
|
||||
margin: 0.08rem 0.08rem;
|
||||
}
|
||||
|
||||
.keyboard-key-normal {
|
||||
font-family: "JetBrains Mono", "SF Mono", Monaco, Menlo, Consolas, "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.keyboard-key-special {
|
||||
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "HelveticaNeue-Light", system-ui, "Ubuntu", "Droid Sans", sans-serif;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.separator {
|
||||
position: relative;
|
||||
top: 0.1rem;
|
||||
margin: 0 0.1rem;
|
||||
color: var(--vscode-editor-foreground);
|
||||
}
|
||||
127
gui/src/components/gui/Shortcut.test.tsx
Normal file
127
gui/src/components/gui/Shortcut.test.tsx
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
import { render } from "@testing-library/react";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import * as util from "../../util";
|
||||
import { Platform } from "../../util";
|
||||
import Shortcut from "./Shortcut";
|
||||
|
||||
vi.mock("../../util", () => ({
|
||||
...vi.importActual("../../util"),
|
||||
getPlatform: vi.fn(),
|
||||
getMetaKeyLabel: vi.fn(),
|
||||
getAltKeyLabel: vi.fn(),
|
||||
getFontSize: vi.fn(),
|
||||
}));
|
||||
|
||||
describe("Shortcut component", () => {
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
vi.mocked(util.getPlatform).mockReturnValue("windows");
|
||||
vi.mocked(util.getFontSize).mockReturnValue(14);
|
||||
});
|
||||
describe("Meta key rendering across platforms", () => {
|
||||
const metaKeyInputs = ["meta", "cmd", "ctrl", "^", "⌘"];
|
||||
const platforms: Platform[] = ["windows", "mac", "linux"];
|
||||
|
||||
platforms.forEach((platform) => {
|
||||
metaKeyInputs.forEach((metaKey) => {
|
||||
it(`should render "${metaKey}" as "${
|
||||
platform === "mac" ? "⌘" : "Ctrl"
|
||||
}" on ${platform}`, () => {
|
||||
vi.mocked(util.getPlatform).mockReturnValue(platform);
|
||||
vi.mocked(util.getMetaKeyLabel).mockImplementation(() => {
|
||||
if (platform === "mac") return "⌘";
|
||||
return "Ctrl";
|
||||
});
|
||||
const { container } = render(<Shortcut>{metaKey}</Shortcut>);
|
||||
const kbdElement = container.querySelector("kbd");
|
||||
expect(kbdElement?.textContent).toBe(
|
||||
platform === "mac" ? "⌘" : "Ctrl",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Font class application", () => {
|
||||
it("should apply 'keyboard-key-normal' class for single characters", () => {
|
||||
const { container } = render(<Shortcut>a</Shortcut>);
|
||||
const kbdElement = container.querySelector("kbd");
|
||||
expect(kbdElement).toHaveClass("keyboard-key-normal");
|
||||
});
|
||||
|
||||
it("should apply 'keyboard-key-special' class for special keys", () => {
|
||||
const { container } = render(<Shortcut>Enter</Shortcut>);
|
||||
const kbdElement = container.querySelector("kbd");
|
||||
expect(kbdElement).toHaveClass("keyboard-key-special");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Delete key rendering across platforms", () => {
|
||||
const deleteKeyInputs = ["backspace", "delete", "⌫"];
|
||||
const platforms: Platform[] = ["windows", "mac", "linux"];
|
||||
|
||||
platforms.forEach((platform) => {
|
||||
deleteKeyInputs.forEach((deleteKey) => {
|
||||
it(`should render "${deleteKey}" correctly on ${platform}`, () => {
|
||||
vi.mocked(util.getPlatform).mockReturnValue(platform);
|
||||
const { container } = render(<Shortcut>{deleteKey}</Shortcut>);
|
||||
const kbdElement = container.querySelector("kbd");
|
||||
const expectedText = platform === "mac" ? "Delete ⌫" : "Backspace ⌫";
|
||||
expect(kbdElement?.textContent).toBe(expectedText);
|
||||
expect(kbdElement).toHaveClass("keyboard-key-special");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Invalid input handling", () => {
|
||||
it("should render error for empty shortcut string", () => {
|
||||
const { container } = render(<Shortcut>{""}</Shortcut>);
|
||||
expect(container.textContent).toBe("Error: Invalid shortcut key");
|
||||
});
|
||||
|
||||
it("should render error for null input", () => {
|
||||
const { container } = render(<Shortcut>{null as any}</Shortcut>);
|
||||
expect(container.textContent).toBe("Error: Invalid shortcut key");
|
||||
});
|
||||
|
||||
it("should gracefully handle invalid formatted input", () => {
|
||||
const { container } = render(<Shortcut>{"abc ,, def"}</Shortcut>);
|
||||
expect(container.querySelectorAll("kbd").length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Option/Alt key rendering across platforms", () => {
|
||||
const optionKeyInputs = ["⌥", "option", "opt", "alt"];
|
||||
const platforms: util.Platform[] = ["windows", "mac"];
|
||||
|
||||
platforms.forEach((platform) => {
|
||||
optionKeyInputs.forEach((optionKey) => {
|
||||
it(`should render "${optionKey}" correctly on ${platform}`, () => {
|
||||
vi.mocked(util.getPlatform).mockReturnValue(platform);
|
||||
vi.mocked(util.getAltKeyLabel).mockImplementation(() => {
|
||||
return platform === "mac" ? "Option ⌥" : "Alt";
|
||||
});
|
||||
|
||||
const { container } = render(<Shortcut>{optionKey}</Shortcut>);
|
||||
const kbdElement = container.querySelector("kbd");
|
||||
|
||||
const expectedText = platform === "mac" ? "Option ⌥" : "Alt";
|
||||
expect(kbdElement?.textContent).toBe(expectedText);
|
||||
expect(kbdElement).toHaveClass("keyboard-key-special");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Font class application for option/alt key", () => {
|
||||
it("should apply 'keyboard-key-special' class for option/alt key", () => {
|
||||
vi.mocked(util.getPlatform).mockReturnValue("windows");
|
||||
vi.mocked(util.getFontSize).mockReturnValue(14);
|
||||
vi.mocked(util.getAltKeyLabel).mockImplementation(() => "Alt");
|
||||
const { container } = render(<Shortcut>alt</Shortcut>);
|
||||
const kbdElement = container.querySelector("kbd");
|
||||
expect(kbdElement).toHaveClass("keyboard-key-special");
|
||||
});
|
||||
});
|
||||
});
|
||||
108
gui/src/components/gui/Shortcut.tsx
Normal file
108
gui/src/components/gui/Shortcut.tsx
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
import React from "react";
|
||||
import "../../../src/index.css";
|
||||
import {
|
||||
getAltKeyLabel,
|
||||
getFontSize,
|
||||
getMetaKeyLabel,
|
||||
getPlatform,
|
||||
} from "../../util";
|
||||
import "./Shortcut.css";
|
||||
|
||||
interface ShortcutProps {
|
||||
children: string;
|
||||
}
|
||||
|
||||
const fontSize = getFontSize();
|
||||
|
||||
const metaKeys = ["meta", "⌘", "ctrl", "cmd", "^"];
|
||||
const altKeys = ["alt", "option", "opt", "⌥"];
|
||||
const modifierKeys = [...metaKeys, ...altKeys];
|
||||
|
||||
const getSpecialKeyMap = (platform: string): Record<string, string> => ({
|
||||
uparrow: "UpArrow ↑",
|
||||
downarrow: "DownArrow ↓",
|
||||
leftarrow: "LeftArrow ←",
|
||||
rightarrow: "RightArrow →",
|
||||
enter: "Enter ⏎",
|
||||
esc: "Esc",
|
||||
backspace: platform === "mac" ? "Delete ⌫" : "Backspace ⌫",
|
||||
delete: platform === "mac" ? "Delete ⌫" : "Backspace ⌫",
|
||||
"⌫": platform === "mac" ? "Delete ⌫" : "Backspace ⌫",
|
||||
});
|
||||
|
||||
const parseShortcut = (shortcut: string, platform: string) => {
|
||||
if (!shortcut || typeof shortcut !== "string") {
|
||||
console.warn("Invalid shortcut provided:", shortcut);
|
||||
return [];
|
||||
}
|
||||
|
||||
const specialKeyMap = getSpecialKeyMap(platform);
|
||||
return shortcut
|
||||
.split(",")
|
||||
.map((combo) =>
|
||||
combo
|
||||
.trim()
|
||||
.split(" ")
|
||||
.filter((key) => key)
|
||||
.map((key) => {
|
||||
const lowerKey = key.toLowerCase();
|
||||
if (metaKeys.includes(lowerKey)) return getMetaKeyLabel();
|
||||
if (altKeys.includes(lowerKey)) return getAltKeyLabel();
|
||||
return specialKeyMap[lowerKey] || capitalizeKey(key);
|
||||
}),
|
||||
)
|
||||
.filter((combo) => combo.length > 0);
|
||||
};
|
||||
|
||||
const capitalizeKey = (key: string) =>
|
||||
key.charAt(0).toUpperCase() + key.slice(1).toLowerCase();
|
||||
|
||||
const isSingleCharNonModifier = (key: string) =>
|
||||
key && key.length === 1 && /^[a-zA-Z0-9]$/.test(key);
|
||||
|
||||
const Shortcut: React.FC<ShortcutProps> = ({ children }) => {
|
||||
const platform = getPlatform();
|
||||
if (!children || typeof children !== "string") {
|
||||
return <span>Error: Invalid shortcut key</span>;
|
||||
}
|
||||
|
||||
const shortcuts = parseShortcut(children, platform);
|
||||
|
||||
return (
|
||||
<>
|
||||
{shortcuts.map((combo, comboIndex) => (
|
||||
<React.Fragment key={comboIndex}>
|
||||
{combo.map((key, keyIndex) => (
|
||||
<React.Fragment key={keyIndex}>
|
||||
<kbd
|
||||
className={`keyboard-key ${
|
||||
!isSingleCharNonModifier(key) || key === "⌫"
|
||||
? "keyboard-key-special"
|
||||
: "keyboard-key-normal"
|
||||
}`}
|
||||
style={{
|
||||
fontSize:
|
||||
key &&
|
||||
modifierKeys.includes(key.toLowerCase()) &&
|
||||
platform === "mac"
|
||||
? `${fontSize - 2}px`
|
||||
: `${fontSize - 3}px`,
|
||||
}}
|
||||
>
|
||||
{key || "?"}
|
||||
</kbd>
|
||||
{keyIndex < combo.length - 1 && (
|
||||
<span className="separator">+</span>
|
||||
)}
|
||||
</React.Fragment>
|
||||
))}
|
||||
{comboIndex < shortcuts.length - 1 && (
|
||||
<span className="separator">,</span>
|
||||
)}
|
||||
</React.Fragment>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Shortcut;
|
||||
|
|
@ -6,10 +6,11 @@ import {
|
|||
PencilSquareIcon,
|
||||
XMarkIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { lightGray } from "..";
|
||||
import { getMetaKeyLabel, isJetBrains } from "../../util";
|
||||
import { useContext } from "react";
|
||||
import { lightGray } from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { isJetBrains } from "../../util";
|
||||
import Shortcut from "../gui/Shortcut";
|
||||
|
||||
interface TutorialCardProps {
|
||||
onClose: () => void;
|
||||
|
|
@ -56,8 +57,8 @@ export function TutorialCard({ onClose }: TutorialCardProps) {
|
|||
<PencilSquareIcon className="h-4 w-4 pr-3 align-middle" />
|
||||
</div>
|
||||
<span>
|
||||
Highlight code and press <kbd>{getMetaKeyLabel()}</kbd> +{" "}
|
||||
<kbd>I</kbd> to quickly make natural language edits
|
||||
Highlight code and press <Shortcut>meta I</Shortcut> to quickly make
|
||||
natural language edits
|
||||
</span>
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
|
|
@ -65,8 +66,8 @@ export function TutorialCard({ onClose }: TutorialCardProps) {
|
|||
<ClipboardDocumentIcon className="h-4 w-4 pr-3 align-middle" />
|
||||
</div>
|
||||
<span>
|
||||
Highlight code and press <kbd>{getMetaKeyLabel()}</kbd> +{" "}
|
||||
<kbd>{jetbrains ? "J" : "L"}</kbd> to add it to the chat window
|
||||
Highlight code and press <Shortcut>meta L</Shortcut> to add it to
|
||||
the chat window
|
||||
</span>
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
|
|
@ -74,8 +75,7 @@ export function TutorialCard({ onClose }: TutorialCardProps) {
|
|||
<Cog6ToothIcon className="h-4 w-4 pr-3 align-middle" />
|
||||
</div>
|
||||
<span>
|
||||
Click the gear icon at the top of the chat window to configure
|
||||
Continue
|
||||
Click the gear icon in the upper right to configure Continue
|
||||
</span>
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import {
|
|||
} from "../../util";
|
||||
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
|
||||
import { Divider } from "./platform/shared";
|
||||
import Shortcut from '../gui/Shortcut';
|
||||
|
||||
interface ModelOptionProps {
|
||||
option: Option;
|
||||
|
|
@ -368,7 +369,7 @@ function ModelSelect() {
|
|||
<Divider className="!my-0" />
|
||||
|
||||
<span className="block px-3 py-3" style={{ color: lightGray }}>
|
||||
<code>{getMetaKeyLabel()} + '</code> to toggle
|
||||
<Shortcut>meta '</Shortcut> to toggle model
|
||||
</span>
|
||||
</div>
|
||||
</StyledListboxOptions>
|
||||
|
|
|
|||
|
|
@ -274,10 +274,12 @@ export const SubmenuContextProvidersProvider = ({
|
|||
}
|
||||
const submenuItems = result.content;
|
||||
const providerTitle = description.title;
|
||||
const renderInlineAs = description.renderInlineAs;
|
||||
|
||||
const itemsWithProvider = submenuItems.map((item) => ({
|
||||
...item,
|
||||
providerTitle,
|
||||
renderInlineAs
|
||||
}));
|
||||
|
||||
const minisearch = new MiniSearch<ContextSubmenuItemWithProvider>(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import posthog from "posthog-js";
|
||||
import { PostHogProvider } from "posthog-js/react";
|
||||
import React, { PropsWithChildren, useEffect } from "react";
|
||||
import { PropsWithChildren, useEffect } from "react";
|
||||
import { useAppSelector } from "../redux/hooks";
|
||||
|
||||
const CustomPostHogProvider = ({ children }: PropsWithChildren) => {
|
||||
|
|
@ -8,8 +8,6 @@ const CustomPostHogProvider = ({ children }: PropsWithChildren) => {
|
|||
(store) => store?.config?.config?.allowAnonymousTelemetry,
|
||||
);
|
||||
|
||||
const [client, setClient] = React.useState<any>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
if (allowAnonymousTelemetry) {
|
||||
posthog.init("phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs", {
|
||||
|
|
@ -22,17 +20,12 @@ const CustomPostHogProvider = ({ children }: PropsWithChildren) => {
|
|||
});
|
||||
posthog.identify(window.vscMachineId);
|
||||
posthog.opt_in_capturing();
|
||||
setClient(client);
|
||||
} else {
|
||||
setClient(undefined);
|
||||
posthog.opt_out_capturing();
|
||||
}
|
||||
}, [allowAnonymousTelemetry]);
|
||||
|
||||
return allowAnonymousTelemetry ? (
|
||||
<PostHogProvider client={client}>{children}</PostHogProvider>
|
||||
) : (
|
||||
<>{children}</>
|
||||
);
|
||||
return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
|
||||
};
|
||||
|
||||
export default CustomPostHogProvider;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,20 @@
|
|||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
src: url("/fonts/Inter/InterDisplay-Light.woff2") format("woff2");
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "JetBrains Mono";
|
||||
src: url("/fonts/JetBrainsMono/JetBrainsMono-Light.woff2") format("woff2");
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
:root {
|
||||
--example-var: rgb(30, 30, 30);
|
||||
}
|
||||
|
|
@ -10,6 +24,7 @@ html,
|
|||
body,
|
||||
#root {
|
||||
height: 100%;
|
||||
line-height: 1.3;
|
||||
background-color: var(--vscode-editor-background);
|
||||
font-family:
|
||||
system-ui,
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
"together",
|
||||
"llama.cpp",
|
||||
"replicate",
|
||||
"sambanova",
|
||||
"cerebras",
|
||||
"nebius",
|
||||
"scaleway",
|
||||
|
|
@ -874,6 +873,20 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
providerOptions: ["gemini"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
gemini20Flash: {
|
||||
title: "Gemini 2.0 Flash",
|
||||
description:
|
||||
"Google's powerful workhorse model with low latency and enhanced performance.",
|
||||
params: {
|
||||
title: "Gemini 2.0 Flash",
|
||||
model: "gemini-2.0-flash",
|
||||
contextLength: 1_000_000,
|
||||
apiKey: "<API_KEY>",
|
||||
},
|
||||
icon: "gemini.png",
|
||||
providerOptions: ["gemini"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
commandR: {
|
||||
title: "Command R",
|
||||
description:
|
||||
|
|
@ -1510,6 +1523,187 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
providerOptions: ["siliconflow"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
llama3370BInstruct: {
|
||||
title: "Llama 3.3 70B Instruct",
|
||||
description: "A model from Meta, fine-tuned for chat",
|
||||
params: {
|
||||
title: "Llama 3.3 70B instruct",
|
||||
model: "Meta-Llama-3.3-70B-Instruct",
|
||||
contextLength: 16_000,
|
||||
},
|
||||
icon: "meta.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
llama318BInstruct: {
|
||||
title: "Llama3.1 8B",
|
||||
description: "A model from Meta, fine-tuned for chat",
|
||||
refUrl: "",
|
||||
params: {
|
||||
title: "Llama 3.1 8B Instruct",
|
||||
model: "Meta-Llama-3.1-8B-Instruct",
|
||||
contextLength: 16_000,
|
||||
},
|
||||
icon: "meta.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
llama3170BInstruct: {
|
||||
title: "Llama3.1 70B",
|
||||
description: "A model from Meta, fine-tuned for chat",
|
||||
refUrl: "",
|
||||
params: {
|
||||
title: "Llama 3.1 70B Instruct",
|
||||
model: "Meta-Llama-3.1-70B-Instruct",
|
||||
contextLength: 128_000,
|
||||
},
|
||||
icon: "meta.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
llama31405BInstruct: {
|
||||
title: "Llama3.1 405B",
|
||||
description: "A model from Meta, fine-tuned for chat",
|
||||
refUrl: "",
|
||||
params: {
|
||||
title: "Llama 3.1 405B Instruct",
|
||||
model: "Meta-Llama-3.1-405B-Instruct",
|
||||
contextLength: 16_000,
|
||||
},
|
||||
icon: "meta.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
llama31Tulu3405B: {
|
||||
title: "Llama3.1 Tulu 3405B",
|
||||
description: "A model from Meta, fine-tuned for chat",
|
||||
refUrl: "",
|
||||
params: {
|
||||
title: "Llama 3.1 Tulu 3 405B",
|
||||
model: "Llama-3.1-Tulu-3-405B",
|
||||
contextLength: 16_000,
|
||||
},
|
||||
icon: "allenai.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
llama321BInstruct: {
|
||||
title: "Llama3.2 1B",
|
||||
description: "A model from Meta, fine-tuned for chat",
|
||||
refUrl: "",
|
||||
params: {
|
||||
title: "Llama 3.2 1B Instruct",
|
||||
model: "Meta-Llama-3.2-1B-Instruct",
|
||||
contextLength: 16_000,
|
||||
},
|
||||
icon: "meta.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
llama323BInstruct: {
|
||||
title: "Llama3.2 3B",
|
||||
description: "A model from Meta, fine-tuned for chat",
|
||||
refUrl: "",
|
||||
params: {
|
||||
title: "Llama 3.2 3B Instruct",
|
||||
model: "Meta-Llama-3.2-3B-Instruct",
|
||||
contextLength: 8192,
|
||||
},
|
||||
icon: "meta.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
llama3211BInstruct: {
|
||||
title: "Llama3.2 11B",
|
||||
description: "A model from Meta, fine-tuned for multimodal chat with images",
|
||||
refUrl: "",
|
||||
params: {
|
||||
title: "Llama 3.2 11B Vision Instruct",
|
||||
model: "Llama-3.2-11B-Vision-Instruct",
|
||||
contextLength: 4096,
|
||||
},
|
||||
icon: "meta.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
llama3290BInstruct: {
|
||||
title: "Llama3.2 90B",
|
||||
description: "A model from Meta, fine-tuned for multimodal chat with images",
|
||||
refUrl: "",
|
||||
params: {
|
||||
title: "Llama 3.2 90B Vision Instruct",
|
||||
model: "Llama-3.2-90B-Vision-Instruct",
|
||||
contextLength: 4096,
|
||||
},
|
||||
icon: "meta.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
qwen25Coder32BInstruct: {
|
||||
title: "Qwen 2.5 Coder 32B",
|
||||
description:
|
||||
"Qwen 2.5 coder is an auto-regressive language model that uses an optimized transformer architecture, fine-tuned for coding tasks.",
|
||||
params: {
|
||||
title: "Qwen2.5 Coder 32B Instruct",
|
||||
model: "Qwen2.5-Coder-32B-Instruct",
|
||||
contextLength: 16_000,
|
||||
},
|
||||
icon: "qwen.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
qwen2572BInstruct: {
|
||||
title: "Qwen 2.5 72B",
|
||||
description:
|
||||
"Qwen 2.5 is an auto-regressive language model that uses an optimized transformer architecture.",
|
||||
params: {
|
||||
title: "Qwen2.5 72B Instruct",
|
||||
model: "Qwen2.5-72B-Instruct",
|
||||
contextLength: 16_000,
|
||||
},
|
||||
icon: "qwen.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
qwq32BPreview: {
|
||||
title: "QwQ 32B Preview",
|
||||
description:
|
||||
"QwQ-32B-Preview is Qwen's latest experimental research model, focusing on improving AI reasoning capabilities.",
|
||||
params: {
|
||||
title: "QwQ 32B Preview",
|
||||
model: "QwQ-32B-Preview",
|
||||
contextLength: 16_000,
|
||||
},
|
||||
icon: "qwen.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
deepseekR1DistillLlama70B: {
|
||||
title: "DeepSeek R1 Distill Llama 70B",
|
||||
description:
|
||||
"A llama 3.1 70 model distilled from deekseek R1",
|
||||
params: {
|
||||
title: "DeepSeek R1 Distill Llama 70B",
|
||||
model: "DeepSeek-R1-Distill-Llama-70B",
|
||||
contextLength: 32_000,
|
||||
},
|
||||
icon: "deepseek.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
deepseekR1: {
|
||||
title: "DeepSeek R1",
|
||||
description:
|
||||
"DeekSeek R1 reasoning model from DeepSeek",
|
||||
params: {
|
||||
title: "DeepSeek R1",
|
||||
model: "DeepSeek-R1",
|
||||
contextLength: 8192,
|
||||
},
|
||||
icon: "deepseek.png",
|
||||
providerOptions: ["sambanova"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
AUTODETECT: {
|
||||
title: "Autodetect",
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -493,7 +493,12 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
|
|||
required: true,
|
||||
},
|
||||
],
|
||||
packages: [models.gemini15Pro, models.geminiPro, models.gemini15Flash],
|
||||
packages: [
|
||||
models.gemini20Flash,
|
||||
models.gemini15Pro,
|
||||
models.geminiPro,
|
||||
models.gemini15Flash,
|
||||
],
|
||||
apiKeyUrl: "https://aistudio.google.com/app/apikey",
|
||||
},
|
||||
xAI: {
|
||||
|
|
@ -735,12 +740,12 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
|
|||
collectInputFor: [...completionParamsInputsConfigs],
|
||||
},
|
||||
sambanova: {
|
||||
title: "SambaNova Cloud",
|
||||
title: "SambaNova",
|
||||
provider: "sambanova",
|
||||
refPage: "sambanova",
|
||||
description: "Use SambaNova Cloud for fast inference performance",
|
||||
icon: "sambanova.png",
|
||||
longDescription: `The SambaNova Cloud is a cloud platform for running large AI models with the world record Llama 3.1 70B/405B performance. You can sign up [here](https://cloud.sambanova.ai/)`,
|
||||
longDescription: `The SambaNova Cloud is a cloud platform for running large open source AI models with the world record performance and zero data retention. You can sign up [here](https://cloud.sambanova.ai/)`,
|
||||
tags: [ModelProviderTags.RequiresApiKey, ModelProviderTags.OpenSource],
|
||||
params: {
|
||||
apiKey: "",
|
||||
|
|
@ -755,10 +760,22 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
|
|||
},
|
||||
...completionParamsInputsConfigs,
|
||||
],
|
||||
packages: [models.llama31Chat].map((p) => {
|
||||
p.params.contextLength = 4096;
|
||||
return p;
|
||||
}),
|
||||
packages:[
|
||||
models.qwen25Coder32BInstruct,
|
||||
models.llama3370BInstruct,
|
||||
models.llama318BInstruct,
|
||||
models.llama3170BInstruct,
|
||||
models.llama31405BInstruct,
|
||||
models.llama31Tulu3405B,
|
||||
models.llama321BInstruct,
|
||||
models.llama323BInstruct,
|
||||
models.llama3211BInstruct,
|
||||
models.llama3290BInstruct,
|
||||
models.qwen2572BInstruct,
|
||||
models.qwq32BPreview,
|
||||
models.deepseekR1DistillLlama70B,
|
||||
models.deepseekR1,
|
||||
],
|
||||
apiKeyUrl: "https://cloud.sambanova.ai/apis",
|
||||
},
|
||||
cerebras: {
|
||||
|
|
|
|||
|
|
@ -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 />
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ function ConfigPage() {
|
|||
}
|
||||
|
||||
// TODO defaults are in multiple places, should be consolidated and probably not explicit here
|
||||
const showSessionTabs = config.ui?.showSessionTabs ?? false;
|
||||
const codeWrap = config.ui?.codeWrap ?? false;
|
||||
const showChatScrollbar = config.ui?.showChatScrollbar ?? false;
|
||||
const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false;
|
||||
|
|
@ -380,6 +381,15 @@ function ConfigPage() {
|
|||
</div>
|
||||
|
||||
<div className="flex flex-col gap-4">
|
||||
<ToggleSwitch
|
||||
isToggled={showSessionTabs}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
showSessionTabs: !showSessionTabs,
|
||||
})
|
||||
}
|
||||
text="Show Session Tabs"
|
||||
/>
|
||||
<ToggleSwitch
|
||||
isToggled={codeWrap}
|
||||
onToggle={() =>
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import { PlatformOnboardingCard } from "../../components/OnboardingCard/platform
|
|||
import PageHeader from "../../components/PageHeader";
|
||||
import StepContainer from "../../components/StepContainer";
|
||||
import AcceptRejectAllButtons from "../../components/StepContainer/AcceptRejectAllButtons";
|
||||
import { TabBar } from "../../components/TabBar/TabBar";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useTutorialCard } from "../../hooks/useTutorialCard";
|
||||
import { useWebviewListener } from "../../hooks/useWebviewListener";
|
||||
|
|
@ -196,6 +197,9 @@ export function Chat() {
|
|||
const selectedModelTitle = useAppSelector(
|
||||
(store) => store.config.defaultModelTitle,
|
||||
);
|
||||
const showSessionTabs = useAppSelector(
|
||||
(store) => store.config.config.ui?.showSessionTabs,
|
||||
);
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const ttsActive = useAppSelector((state) => state.ui.ttsActive);
|
||||
const isStreaming = useAppSelector((state) => state.session.isStreaming);
|
||||
|
|
@ -389,6 +393,8 @@ export function Chat() {
|
|||
|
||||
{widget}
|
||||
|
||||
{!!showSessionTabs && <TabBar />}
|
||||
|
||||
<StepsDiv
|
||||
ref={stepsDivRef}
|
||||
className={`overflow-y-scroll ${showPageHeader ? "" : "pt-[8px]"} ${showScrollbar ? "thin-scrollbar" : "no-scrollbar"} ${history.length > 0 ? "flex-1" : ""}`}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ export default function GUI() {
|
|||
<History />
|
||||
</aside>
|
||||
<main className="no-scrollbar flex flex-1 flex-col overflow-y-auto">
|
||||
{/* Temporarily commenting out until a near-term release when we can at least add an option for users to disable the tab bar */}
|
||||
{/* <TabBar /> */}
|
||||
<Chat />
|
||||
</main>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import _ from "lodash";
|
||||
import { getLocalStorage } from "./localStorage";
|
||||
import { KeyboardEvent } from "react";
|
||||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
import _ from "lodash";
|
||||
import { KeyboardEvent } from "react";
|
||||
import { getLocalStorage } from "./localStorage";
|
||||
|
||||
type Platform = "mac" | "linux" | "windows" | "unknown";
|
||||
export type Platform = "mac" | "linux" | "windows" | "unknown";
|
||||
|
||||
export function getPlatform(): Platform {
|
||||
const platform = window.navigator.platform.toUpperCase();
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue