Merge branch 'main' into instant-apply-uDiff-3684

This commit is contained in:
Nate 2025-03-09 20:24:59 -07:00
commit 659cd45c4c
34 changed files with 489 additions and 143 deletions

View file

@ -5,4 +5,5 @@ docs/docs/languages
.vscode/
.archive/
**/*.scm
**/*.diff
**/*.diff
.continue/

View file

@ -275,7 +275,7 @@ jobs:
cd core
npm test
env:
IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork == true && github.actor == 'dependabot[bot]' }}
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 }}
@ -460,7 +460,7 @@ jobs:
- name: Run e2e tests
run: |
cd extensions/vscode
IGNORE_SSH_TESTS="${{ github.event.pull_request.head.repo.fork == false && github.actor != 'dependabot[bot]' }}" TEST_FILE="${{ matrix.test_file }}" npm run ${{ matrix.command }}
IGNORE_SSH_TESTS="${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }}" TEST_FILE="${{ matrix.test_file }}" npm run ${{ matrix.command }}
env:
DISPLAY: :99

3
.gitignore vendored
View file

@ -168,4 +168,5 @@ extensions/.continue-debug/
*.vsix
.continuerules
.continuerules
.continue/assistants/

View file

@ -1,5 +1,3 @@
import * as fs from "node:fs";
import { ConfigResult, FullSlug } from "@continuedev/config-yaml";
import {
@ -17,9 +15,8 @@ import {
} from "../index.js";
import Ollama from "../llm/llms/Ollama.js";
import { GlobalContext } from "../util/GlobalContext.js";
import { getConfigJsonPath, getConfigYamlPath } from "../util/paths.js";
import { localPathToUri } from "../util/pathToUri.js";
import { getAllAssistantFiles } from "./getSystemPromptDotFile.js";
import {
LOCAL_ONBOARDING_CHAT_MODEL,
LOCAL_ONBOARDING_PROVIDER_TITLE,
@ -86,6 +83,25 @@ export class ConfigHandler {
});
}
/**
* Users can define as many local assistants as they want in a `.continue/assistants` folder
*/
private async getLocalAssistantProfiles() {
const assistantFiles = await getAllAssistantFiles(this.ide);
const profiles = assistantFiles.map((assistant) => {
return new LocalProfileLoader(
this.ide,
this.ideSettingsPromise,
this.controlPlaneClient,
this.writeLog,
assistant,
);
});
return profiles.map(
(profile) => new ProfileLifecycleManager(profile, this.ide),
);
}
/**
* Retrieves the titles of additional context providers that are of type "submenu".
*
@ -98,13 +114,20 @@ export class ConfigHandler {
}
private async init() {
try {
await this.loadLocalProfilesOnly();
} catch (e) {
console.error("Failed to load local assistants: ", e);
}
try {
await this.fetchControlPlaneProfiles();
} catch (e) {
// If this fails, make sure at least local profile is loaded
console.error("Failed to fetch control plane profiles in init: ", e);
await this.updateAvailableProfiles([this.localProfileManager]);
await this.loadLocalProfilesOnly();
}
try {
const configResult = await this.loadConfig();
this.notifyConfigListeners(configResult);
@ -135,14 +158,12 @@ export class ConfigHandler {
async openConfigProfile(profileId?: string) {
let openProfileId = profileId || this.selectedProfileId;
if (openProfileId === "local") {
const profile = this.profiles?.find(
(p) => p.profileDescription.id === openProfileId,
);
if (profile?.profileDescription.profileType === "local") {
const ideInfo = await this.ide.getIdeInfo();
const configYamlPath = getConfigYamlPath(ideInfo.ideType);
if (fs.existsSync(configYamlPath)) {
await this.ide.openFile(localPathToUri(configYamlPath));
} else {
await this.ide.openFile(localPathToUri(getConfigJsonPath()));
}
await this.ide.openFile(profile.profileDescription.uri);
} else {
const env = await getControlPlaneEnv(this.ide.getIdeSettings());
await this.ide.openUrl(`${env.APP_URL}${openProfileId}`);
@ -167,29 +188,32 @@ export class ConfigHandler {
const assistants =
await this.controlPlaneClient.listAssistants(selectedOrgId);
const hubProfiles = assistants.map((assistant) => {
const profileLoader = new PlatformProfileLoader(
{
...assistant.configResult,
config: assistant.configResult.config,
},
assistant.ownerSlug,
assistant.packageSlug,
assistant.iconUrl,
assistant.configResult.config?.version ?? "latest",
this.controlPlaneClient,
this.ide,
this.ideSettingsPromise,
this.writeLog,
this.reloadConfig.bind(this),
);
const hubProfiles = await Promise.all(
assistants.map(async (assistant) => {
const profileLoader = await PlatformProfileLoader.create(
{
...assistant.configResult,
config: assistant.configResult.config,
},
assistant.ownerSlug,
assistant.packageSlug,
assistant.iconUrl,
assistant.configResult.config?.version ?? "latest",
this.controlPlaneClient,
this.ide,
this.ideSettingsPromise,
this.writeLog,
this.reloadConfig.bind(this),
);
return new ProfileLifecycleManager(profileLoader, this.ide);
});
return new ProfileLifecycleManager(profileLoader, this.ide);
}),
);
if (selectedOrgId === null) {
// Personal
profiles = [...hubProfiles, this.localProfileManager];
const allLocalProfiles = await this.getAllLocalProfiles();
profiles = [...hubProfiles, ...allLocalProfiles];
} else {
// Organization
profiles = hubProfiles;
@ -199,6 +223,16 @@ export class ConfigHandler {
await this.updateAvailableProfiles(profiles);
}
private async getAllLocalProfiles() {
const localAssistantProfiles = await this.getLocalAssistantProfiles();
return [this.localProfileManager, ...localAssistantProfiles];
}
private async loadLocalProfilesOnly() {
const allLocalProfiles = await this.getAllLocalProfiles();
await this.updateAvailableProfiles(allLocalProfiles);
}
private async updateAvailableProfiles(profiles: ProfileLifecycleManager[]) {
this.profiles = profiles;
@ -278,7 +312,7 @@ export class ConfigHandler {
} else {
try {
const workspaces = await this.controlPlaneClient.listWorkspaces();
const profiles = [this.localProfileManager];
const profiles = await this.getAllLocalProfiles();
workspaces.forEach((workspace) => {
const profileLoader = new ControlPlaneProfileLoader(
workspace.id,
@ -296,7 +330,7 @@ export class ConfigHandler {
await this.updateAvailableProfiles(profiles);
} catch (e: any) {
console.error("Failed to load profiles: ", e);
await this.updateAvailableProfiles([this.localProfileManager]);
await this.loadLocalProfilesOnly();
}
}
}
@ -355,7 +389,7 @@ export class ConfigHandler {
);
this.fetchControlPlaneProfiles().catch(async (e) => {
console.error("Failed to fetch control plane profiles: ", e);
await this.updateAvailableProfiles([this.localProfileManager]);
await this.loadLocalProfilesOnly();
await this.reloadConfig();
});
}

View file

@ -21,6 +21,7 @@ export interface ProfileDescription {
id: string;
iconUrl: string;
errors: ConfigValidationError[] | undefined;
uri: string;
}
export interface OrganizationDescription {

View file

@ -1,4 +1,7 @@
import { IDE } from "..";
import { walkDir } from "../indexing/walkDir";
import { getGlobalAssistantsPath } from "../util/paths";
import { localPathToUri } from "../util/pathToUri";
import { joinPathsToUri } from "../util/uri";
export const SYSTEM_PROMPT_DOT_FILE = ".continuerules";
@ -24,3 +27,56 @@ export async function getSystemPromptDotFile(ide: IDE): Promise<string | null> {
return prompts.join("\n\n");
}
export const ASSISTANTS_FOLDER = ".continue/assistants";
export async function getAssistantFilesFromDir(
ide: IDE,
dir: string,
): Promise<{ path: string; content: string }[]> {
try {
const exists = await ide.fileExists(localPathToUri(dir));
if (!exists) {
return [];
}
const uris = await walkDir(dir, ide);
const assistantFilePaths = uris.filter(
(p) => p.endsWith(".yaml") || p.endsWith(".yml"),
);
const results = assistantFilePaths.map(async (uri) => {
const content = await ide.readFile(uri); // make a try catch
return { path: uri, content };
});
return Promise.all(results);
} catch (e) {
console.error(e);
return [];
}
}
export async function getAllAssistantFiles(
ide: IDE,
): Promise<{ path: string; content: string }[]> {
const workspaceDirs = await ide.getWorkspaceDirs();
let assistantFiles: { path: string; content: string }[] = [];
let dirsToCheck = [ASSISTANTS_FOLDER];
const fullDirs = workspaceDirs
.map((dir) => dirsToCheck.map((d) => joinPathsToUri(dir, d)))
.flat();
fullDirs.push(getGlobalAssistantsPath());
assistantFiles = (
await Promise.all(fullDirs.map((dir) => getAssistantFilesFromDir(ide, dir)))
).flat();
return await Promise.all(
assistantFiles.map(async (file) => {
const content = await ide.readFile(file.path);
return { path: file.path, content };
}),
);
}

View file

@ -10,6 +10,7 @@ import {
} from "../../index.js";
import { ProfileDescription } from "../ProfileLifecycleManager.js";
import { PRODUCTION_ENV } from "../../control-plane/env.js";
import doLoadConfig from "./doLoadConfig.js";
import { IProfileLoader } from "./IProfileLoader.js";
@ -40,6 +41,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
},
title: workspaceTitle,
errors: undefined,
uri: `${PRODUCTION_ENV.APP_URL}workspaces/${workspaceId}`,
};
setInterval(async () => {
@ -68,6 +70,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
undefined,
undefined,
this.workspaceId,
undefined,
);
return {

View file

@ -1,33 +1,54 @@
import { ConfigResult } from "@continuedev/config-yaml";
import { ConfigResult, parseConfigYaml } from "@continuedev/config-yaml";
import { ControlPlaneClient } from "../../control-plane/client.js";
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
import { ProfileDescription } from "../ProfileLifecycleManager.js";
import { getPrimaryConfigFilePath } from "../../util/paths.js";
import { localPathToUri } from "../../util/pathToUri.js";
import doLoadConfig from "./doLoadConfig.js";
import { IProfileLoader } from "./IProfileLoader.js";
export default class LocalProfileLoader implements IProfileLoader {
static ID = "local";
description: ProfileDescription = {
id: LocalProfileLoader.ID,
profileType: "local",
fullSlug: {
ownerSlug: "",
packageSlug: "",
versionSlug: "",
},
iconUrl: "",
title: "Local Config",
errors: undefined,
};
constructor(
private ide: IDE,
private ideSettingsPromise: Promise<IdeSettings>,
private controlPlaneClient: ControlPlaneClient,
private writeLog: (message: string) => Promise<void>,
) {}
private overrideAssistantFile?:
| { path: string; content: string }
| undefined,
) {
const description: ProfileDescription = {
id: overrideAssistantFile?.path ?? LocalProfileLoader.ID,
profileType: "local",
fullSlug: {
ownerSlug: "",
packageSlug: "",
versionSlug: "",
},
iconUrl: "",
title: overrideAssistantFile?.path ?? "Local Config",
errors: undefined,
uri:
overrideAssistantFile?.path ??
localPathToUri(getPrimaryConfigFilePath()),
};
this.description = description;
if (overrideAssistantFile?.content) {
try {
const parsedAssistant = parseConfigYaml(
overrideAssistantFile?.content ?? "",
);
this.description.title = parsedAssistant.name;
} catch (e) {
console.error("Failed to parse assistant file: ", e);
}
}
}
description: ProfileDescription;
async doLoadConfig(): Promise<ConfigResult<ContinueConfig>> {
const result = await doLoadConfig(
@ -39,6 +60,7 @@ export default class LocalProfileLoader implements IProfileLoader {
undefined,
undefined,
this.description.id,
this.overrideAssistantFile?.path,
);
this.description.errors = result.errors;

View file

@ -5,6 +5,7 @@ import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
import { ProfileDescription } from "../ProfileLifecycleManager.js";
import { getControlPlaneEnv } from "../../control-plane/env.js";
import doLoadConfig from "./doLoadConfig.js";
import { IProfileLoader } from "./IProfileLoader.js";
@ -21,21 +22,35 @@ export interface PlatformConfigMetadata {
export default class PlatformProfileLoader implements IProfileLoader {
static RELOAD_INTERVAL = 1000 * 5; // 5 seconds
description: ProfileDescription;
constructor(
private constructor(
private configResult: ConfigResult<AssistantUnrolled>,
private readonly ownerSlug: string,
private readonly packageSlug: string,
private readonly iconUrl: string,
versionSlug: string,
private readonly versionSlug: string,
private readonly controlPlaneClient: ControlPlaneClient,
private readonly ide: IDE,
private ideSettingsPromise: Promise<IdeSettings>,
private writeLog: (message: string) => Promise<void>,
private readonly onReload: () => void,
) {
this.description = {
readonly description: ProfileDescription,
) {}
static async create(
configResult: ConfigResult<AssistantUnrolled>,
ownerSlug: string,
packageSlug: string,
iconUrl: string,
versionSlug: string,
controlPlaneClient: ControlPlaneClient,
ide: IDE,
ideSettingsPromise: Promise<IdeSettings>,
writeLog: (message: string) => Promise<void>,
onReload: () => void,
): Promise<PlatformProfileLoader> {
const controlPlaneEnv = await getControlPlaneEnv(ideSettingsPromise);
const description: ProfileDescription = {
id: `${ownerSlug}/${packageSlug}`,
profileType: "platform",
fullSlug: {
@ -45,8 +60,23 @@ export default class PlatformProfileLoader implements IProfileLoader {
},
title: configResult.config?.name ?? `${ownerSlug}/${packageSlug}`,
errors: configResult.errors,
iconUrl: this.iconUrl,
iconUrl: iconUrl,
uri: `${controlPlaneEnv}${ownerSlug}/${packageSlug}`,
};
return new PlatformProfileLoader(
configResult,
ownerSlug,
packageSlug,
iconUrl,
versionSlug,
controlPlaneClient,
ide,
ideSettingsPromise,
writeLog,
onReload,
description,
);
}
async doLoadConfig(): Promise<ConfigResult<ContinueConfig>> {
@ -70,6 +100,7 @@ export default class PlatformProfileLoader implements IProfileLoader {
packageSlug: this.packageSlug,
},
this.description.id,
undefined,
);
return {

View file

@ -19,13 +19,14 @@ import { getControlPlaneEnv } from "../../control-plane/env.js";
import { TeamAnalytics } from "../../control-plane/TeamAnalytics.js";
import ContinueProxy from "../../llm/llms/stubs/ContinueProxy";
import { getConfigJsonPath, getConfigYamlPath } from "../../util/paths";
import { localPathOrUriToPath } from "../../util/pathToUri";
import { Telemetry } from "../../util/posthog";
import { TTS } from "../../util/tts";
import { loadContinueConfigFromJson } from "../load";
import { migrateJsonSharedConfig } from "../migrateSharedConfig";
import { rectifySelectedModelsFromGlobalContext } from "../selectedModels";
import { loadContinueConfigFromYaml } from "../yaml/loadYaml";
import { PlatformConfigMetadata } from "./PlatformProfileLoader";
import { rectifySelectedModelsFromGlobalContext } from "../selectedModels";
export default async function doLoadConfig(
ide: IDE,
@ -36,6 +37,7 @@ export default async function doLoadConfig(
overrideConfigYaml: AssistantUnrolled | undefined,
platformConfigMetadata: PlatformConfigMetadata | undefined,
profileId: string,
overrideConfigYamlByPath: string | undefined,
): Promise<ConfigResult<ContinueConfig>> {
const workspaceConfigs = await getWorkspaceConfigs(ide);
const ideInfo = await ide.getIdeInfo();
@ -50,7 +52,9 @@ export default async function doLoadConfig(
migrateJsonSharedConfig(configJsonPath, ide);
}
const configYamlPath = getConfigYamlPath(ideInfo.ideType);
const configYamlPath = localPathOrUriToPath(
overrideConfigYamlByPath || getConfigYamlPath(ideInfo.ideType),
);
let newConfig: ContinueConfig | undefined;
let errors: ConfigValidationError[] | undefined;
@ -68,6 +72,7 @@ export default async function doLoadConfig(
overrideConfigYaml,
platformConfigMetadata,
controlPlaneClient,
configYamlPath,
);
newConfig = result.config;
errors = result.errors;

View file

@ -366,10 +366,14 @@ export async function loadContinueConfigFromYaml(
overrideConfigYaml: AssistantUnrolled | undefined,
platformConfigMetadata: PlatformConfigMetadata | undefined,
controlPlaneClient: ControlPlaneClient,
configYamlPath: string | undefined,
): Promise<ConfigResult<ContinueConfig>> {
const rawYaml =
overrideConfigYaml === undefined
? fs.readFileSync(getConfigYamlPath(ideInfo.ideType), "utf-8")
? fs.readFileSync(
configYamlPath ?? getConfigYamlPath(ideInfo.ideType),
"utf-8",
)
: "";
const configYamlResult = await loadConfigYaml(

View file

@ -80,24 +80,19 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
args: RetrievalPipelineRunArguments,
n: number,
): Promise<Chunk[]> {
try {
if (args.query.trim() === "") {
return [];
}
const tokensRaw = this.getCleanedTrigrams(args.query).join(" OR ");
const tokens = this.escapeFtsQueryString(tokensRaw);
return await this.ftsIndex.retrieve({
n,
text: tokens,
tags: args.tags,
directory: args.filterDirectory,
});
} catch (e) {
console.warn("Error retrieving from FTS:", e);
if (args.query.trim() === "") {
return [];
}
const tokensRaw = this.getCleanedTrigrams(args.query).join(" OR ");
const tokens = this.escapeFtsQueryString(tokensRaw);
return await this.ftsIndex.retrieve({
n,
text: tokens,
tags: args.tags,
directory: args.filterDirectory,
});
}
protected async retrieveAndChunkRecentlyEditedFiles(

View file

@ -19,22 +19,42 @@ export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline {
let retrievalResults: Chunk[] = [];
const ftsChunks = await this.retrieveFts(args, ftsNFinal);
let ftsChunks: Chunk[] = [];
try {
ftsChunks = await this.retrieveFts(args, ftsNFinal);
} catch (error) {
console.error("Error retrieving FTS chunks:", error);
}
const embeddingsChunks = !!config.selectedModelByRole.embed
? await this.retrieveEmbeddings(input, embeddingsNFinal)
: [];
let embeddingsChunks: Chunk[] = [];
try {
embeddingsChunks = !!config.selectedModelByRole.embed
? await this.retrieveEmbeddings(input, embeddingsNFinal)
: [];
} catch (error) {
console.error("Error retrieving embeddings:", error);
}
const recentlyEditedFilesChunks =
await this.retrieveAndChunkRecentlyEditedFiles(recentlyEditedNFinal);
let recentlyEditedFilesChunks: Chunk[] = [];
try {
recentlyEditedFilesChunks =
await this.retrieveAndChunkRecentlyEditedFiles(recentlyEditedNFinal);
} catch (error) {
console.error("Error retrieving recently edited files:", error);
}
const repoMapChunks = await requestFilesFromRepoMap(
this.options.llm,
this.options.config,
this.options.ide,
input,
filterDirectory,
);
let repoMapChunks: Chunk[] = [];
try {
repoMapChunks = await requestFilesFromRepoMap(
this.options.llm,
this.options.config,
this.options.ide,
input,
filterDirectory,
);
} catch (error) {
console.error("Error retrieving repo map chunks:", error);
}
retrievalResults.push(
...recentlyEditedFilesChunks,

View file

@ -16,20 +16,42 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
let retrievalResults: Chunk[] = [];
const ftsChunks = await this.retrieveFts(args, nRetrieve);
const embeddingsChunks = !!config.selectedModelByRole.embed
? await this.retrieveEmbeddings(input, nRetrieve)
: [];
const recentlyEditedFilesChunks =
await this.retrieveAndChunkRecentlyEditedFiles(nRetrieve);
let ftsChunks: Chunk[] = [];
try {
ftsChunks = await this.retrieveFts(args, nRetrieve);
} catch (error) {
console.error("Error retrieving FTS chunks:", error);
}
const repoMapChunks = await requestFilesFromRepoMap(
this.options.llm,
this.options.config,
this.options.ide,
input,
filterDirectory,
);
let embeddingsChunks: Chunk[] = [];
try {
embeddingsChunks = !!config.selectedModelByRole.embed
? await this.retrieveEmbeddings(input, nRetrieve)
: [];
} catch (error) {
console.error("Error retrieving embeddings chunks:", error);
}
let recentlyEditedFilesChunks: Chunk[] = [];
try {
recentlyEditedFilesChunks =
await this.retrieveAndChunkRecentlyEditedFiles(nRetrieve);
} catch (error) {
console.error("Error retrieving recently edited files chunks:", error);
}
let repoMapChunks: Chunk[] = [];
try {
repoMapChunks = await requestFilesFromRepoMap(
this.options.llm,
this.options.config,
this.options.ide,
input,
filterDirectory,
);
} catch (error) {
console.error("Error retrieving repo map chunks:", error);
}
retrievalResults.push(
...recentlyEditedFilesChunks,
@ -41,7 +63,8 @@ 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]).foundInDir,
(chunk) =>
!!findUriInDirs(chunk.filepath, [filterDirectory]).foundInDir,
);
}

View file

@ -18,7 +18,7 @@ const WORKOS_CLIENT_ID_STAGING = "client_01J0FW6XCPMJMQ3CG51RB4HBZQ";
const WORKOS_ENV_ID_PRODUCTION = "continue";
const WORKOS_ENV_ID_STAGING = "continue-staging";
const PRODUCTION_ENV: ControlPlaneEnv = {
export const PRODUCTION_ENV: ControlPlaneEnv = {
DEFAULT_CONTROL_PLANE_PROXY_URL:
"https://control-plane-api-service-i3dqylpbqa-uc.a.run.app/",
CONTROL_PLANE_URL:

View file

@ -30,12 +30,7 @@ import { ChatDescriber } from "./util/chatDescriber";
import { clipboardCache } from "./util/clipboardCache";
import { GlobalContext } from "./util/GlobalContext";
import historyManager from "./util/history";
import {
editConfigJson,
getConfigJsonPath,
migrateV1DevDataFiles,
} from "./util/paths";
import { localPathToUri } from "./util/pathToUri";
import { editConfigJson, migrateV1DevDataFiles } from "./util/paths";
import { Telemetry } from "./util/posthog";
import { getSymbolsForManyFiles } from "./util/treeSitter";
import { TTS } from "./util/tts";
@ -860,7 +855,10 @@ export class Core {
for (const uri of data.uris) {
// Listen for file changes in the workspace
// URI TODO is this equality statement valid?
if (URI.equal(uri, localPathToUri(getConfigJsonPath()))) {
const currentProfileUri =
this.configHandler.currentProfile?.profileDescription.uri ?? "";
if (URI.equal(uri, currentProfileUri)) {
// Trigger a toast notification to provide UI feedback that config has been updated
const showToast =
this.globalContext.get("showConfigUpdateToast") ?? true;
@ -874,6 +872,8 @@ export class Core {
this.globalContext.update("showConfigUpdateToast", false);
}
}
await this.configHandler.reloadConfig();
continue;
}
if (

View file

@ -24,6 +24,7 @@ import {
} from "./types";
import type * as LanceType from "vectordb";
import { localPathToUri } from "../util/pathToUri";
interface LanceDbRow {
uuid: string;
@ -498,7 +499,7 @@ export class LanceDbIndex implements CodebaseIndex {
return data.map((d) => {
return {
digest: d.cacheKey,
filepath: d.path,
filepath: localPathToUri(d.path),
startLine: d.startLine,
endLine: d.endLine,
index: 0,

View file

@ -192,12 +192,7 @@ describe("walkDir functions", () => {
it("should skip symlinks", async () => {
const filePath = path.join(TEST_DIR_PATH, "real.ts");
addToTestDir([["real.ts", "content"]]);
fs.symlink(
filePath,
path.join(TEST_DIR_PATH, "symlink.ts"),
"file",
() => {},
);
fs.symlinkSync(filePath, path.join(TEST_DIR_PATH, "symlink.ts"), "file");
const files = await walkDirs(testIde);

View file

@ -97,6 +97,10 @@ class OpenAI extends BaseLLM {
return !!model && (model.startsWith("o1") || model.startsWith("o3"));
}
private isFireworksAiModel(model?: string): boolean {
return !!model && model.startsWith("accounts/fireworks/models");
}
protected supportsPrediction(model: string): boolean {
const SUPPORTED_MODELS = ["gpt-4o-mini", "gpt-4o", "mistral-large"];
return SUPPORTED_MODELS.some((m) => model.includes(m));
@ -274,7 +278,13 @@ class OpenAI extends BaseLLM {
body.max_completion_tokens = undefined;
}
if (body.tools?.length && !body.model?.startsWith("o3")) {
if (body.tools?.length) {
if (this.isFireworksAiModel(body.model)) {
// fireworks.ai does not support parallel tool calls, but their api expects this to be true anyway otherwise they return an error.
// tooling works with them as a inference provider once this is set to true.
// https://docs.fireworks.ai/guides/function-calling#openai-compatibility
body.parallel_tool_calls = true;
}
// To ensure schema adherence: https://platform.openai.com/docs/guides/function-calling#parallel-function-calling-and-structured-outputs
// In practice, setting this to true and asking for multiple tool calls
// leads to "arguments" being something like '{"file": "test.ts"}{"file": "test.js"}'

View file

@ -39,6 +39,19 @@ export const PROVIDER_TOOL_SUPPORT: Record<
) {
return true;
}
// firworks-ai https://docs.fireworks.ai/guides/function-calling
if (model.startsWith("accounts/fireworks/models/")) {
switch (model.substring(26)) {
case "llama-v3p1-405b-instruct":
case "llama-v3p1-70b-instruct":
case "qwen2p5-72b-instruct":
case "firefunction-v1":
case "firefunction-v2":
return true;
default:
return false;
}
}
},
gemini: (model) => {
// All gemini models support function calling

View file

@ -103,7 +103,7 @@ export function getConfigJsonPath(ideType: IdeType = "vscode"): string {
return p;
}
export function getConfigYamlPath(ideType: IdeType): string {
export function getConfigYamlPath(ideType?: IdeType): string {
const p = path.join(getContinueGlobalPath(), "config.yaml");
// if (!fs.existsSync(p)) {
// if (ideType === "jetbrains") {
@ -115,6 +115,14 @@ export function getConfigYamlPath(ideType: IdeType): string {
return p;
}
export function getPrimaryConfigFilePath(): string {
const configYamlPath = getConfigYamlPath();
if (fs.existsSync(configYamlPath)) {
return configYamlPath;
}
return getConfigJsonPath();
}
export function getConfigTsPath(): string {
const p = path.join(getContinueGlobalPath(), "config.ts");
if (!fs.existsSync(p)) {
@ -353,6 +361,10 @@ export function getGlobalPromptsPath(): string {
return path.join(getContinueGlobalPath(), "prompts");
}
export function getGlobalAssistantsPath(): string {
return path.join(getContinueGlobalPath(), "assistants");
}
export function readAllGlobalPromptFiles(
folderPath: string = getGlobalPromptsPath(),
): { path: string; content: string }[] {

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "1.1.4",
"version": "1.1.5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "1.1.4",
"version": "1.1.5",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/fetch": "^1.0.3",

View file

@ -2,7 +2,7 @@
"name": "continue",
"icon": "media/icon.png",
"author": "Continue Dev, Inc",
"version": "1.1.5",
"version": "1.1.6",
"repository": {
"type": "git",
"url": "https://github.com/continuedev/continue"

View file

@ -12,7 +12,7 @@ function AddModelButtonSubtext() {
className="cursor-pointer underline"
onClick={() =>
ideMessenger.post("config/openProfile", {
profileId: "local",
profileId: undefined,
})
}
>

View file

@ -19,14 +19,10 @@ import {
setDefaultModel,
} from "../../redux/slices/configSlice";
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
import {
getFontSize,
getMetaKeyLabel,
isMetaEquivalentKeyPressed,
} from "../../util";
import { getFontSize, isMetaEquivalentKeyPressed } from "../../util";
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
import Shortcut from "../gui/Shortcut";
import { Divider } from "./platform/shared";
import Shortcut from '../gui/Shortcut';
interface ModelOptionProps {
option: Option;
@ -166,9 +162,7 @@ function ModelOption({
e.stopPropagation();
e.preventDefault();
ideMessenger.post("config/openProfile", {
profileId: "local",
});
ideMessenger.post("config/openProfile", { profileId: undefined });
}
function handleOptionClick(e: any) {
@ -351,7 +345,7 @@ function ModelSelect() {
<div className="mt-auto">
<Divider className="!my-0" />
{selectedProfile?.id === "local" && (
{selectedProfile?.profileType === "local" && (
<>
<StyledListboxOption
key={options.length}

View file

@ -1,6 +1,5 @@
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
import { isLocalProfile } from "../../../util";
export function getProfileDisplayText(profile: ProfileDescription): string {
return isLocalProfile(profile) ? profile.title : profile.fullSlug.packageSlug;
return profile.title;
}

View file

@ -221,7 +221,7 @@ function AddNewModel() {
disabled={false}
onClick={(e) => {
ideMessenger.post("config/openProfile", {
profileId: "local",
profileId: undefined,
});
}}
>

View file

@ -297,7 +297,7 @@ function ConfigPage() {
</div>
{selectedProfile && (
<SecondaryButton onClick={handleOpenConfig}>
{selectedProfile.id === "local"
{selectedProfile.profileType === "local"
? "Open Config File"
: hubEnabled
? "Open Assistant"

View file

@ -108,5 +108,5 @@ export function updatedObj(old: any, pathToValue: { [key: string]: any }) {
}
export function isLocalProfile(profile: ProfileDescription): boolean {
return profile.id === "local";
return profile.profileType === "local";
}

View file

@ -1,6 +1,6 @@
{
"name": "@continuedev/openai-adapters",
"version": "1.0.15",
"version": "1.0.16",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View file

@ -71,6 +71,32 @@ export class AnthropicApi implements BaseLlmApi {
msgs: OpenAI.Chat.Completions.ChatCompletionMessageParam[],
): any[] {
const messages = msgs.map((message) => {
if (message.role === "tool") {
return {
role: "user",
content: [
{
type: "tool_result",
tool_use_id: message.tool_call_id,
content:
typeof message.content === "string"
? message.content
: message.content.map((part) => part.text).join(""),
},
],
};
} else if (message.role === "assistant" && message.tool_calls) {
return {
role: "assistant",
content: message.tool_calls.map((toolCall) => ({
type: "tool_use",
id: toolCall.id,
name: toolCall.function?.name,
input: JSON.parse(toolCall.function?.arguments || "{}"),
})),
};
}
if (!Array.isArray(message.content)) {
return message;
}

View file

@ -86,11 +86,50 @@ export class GeminiApi implements BaseLlmApi {
}
const isV1API = url.includes("/v1/");
const toolCallIdToNameMap = new Map<string, string>();
const contents = oaiBody.messages
.map((msg) => {
if (msg.role === "system" && !isV1API) {
return null; // Don't include system message in contents
}
if (msg.role == "assistant" && msg.tool_calls?.length) {
for (const toolCall of msg.tool_calls) {
toolCallIdToNameMap.set(toolCall.id, toolCall.function.name);
}
return {
role: "model",
parts: msg.tool_calls.map((toolCall) => ({
functionCall: {
name: toolCall.function.name,
args: JSON.parse(toolCall.function.arguments || "{}"),
},
})),
};
}
if (msg.role === "tool") {
return {
role: "user",
parts: [
{
functionResponse: {
name: msg.tool_call_id,
response: {
name: toolCallIdToNameMap.get(msg.tool_call_id),
content:
typeof msg.content === "string"
? msg.content
: msg.content.map((part) => part.text).join(""),
},
},
},
],
};
}
if (!msg.content) {
return null;
}
@ -246,9 +285,10 @@ export class GeminiApi implements BaseLlmApi {
`models/${body.model}:streamGenerateContent?key=${this.config.apiKey}`,
this.apiBase,
).toString();
const convertedBody = this._convertBody(body, apiURL);
const resp = await customFetch(this.config.requestOptions)(apiURL, {
method: "POST",
body: JSON.stringify(this._convertBody(body, apiURL)),
body: JSON.stringify(convertedBody),
signal,
});

View file

@ -260,6 +260,65 @@ export function testChat(api: BaseLlmApi, model: string) {
const parsedArgs = JSON.parse(args);
expect(parsedArgs.name).toBe("Nate");
});
test("Tool Call second message works", async () => {
let response = "";
for await (const chunk of api.chatCompletionStream(
{
messages: [
{
role: "user",
content:
"Hi, my name is Nate. Please call the say_hello function to respond to me, then respond to me again.",
},
{
role: "assistant",
tool_calls: [
{
function: {
arguments: '{"name":"Nate"}',
name: "say_hello",
},
id: "tool_call_1",
type: "function",
},
],
},
{
role: "tool",
tool_call_id: "tool_call_1",
content: "Nate was greeted",
},
],
tools: [
{
function: {
name: "say_hello",
description: "Say Hello",
parameters: {
type: "object",
properties: {
name: {
type: "string",
description: "The name of the person to greet",
},
},
},
},
type: "function",
},
],
stream: true,
model,
},
new AbortController().signal,
)) {
console.log(JSON.stringify(chunk, null, 2));
response += chunk.choices[0].delta.content ?? "";
}
expect(response.length).toBeGreaterThan(0);
});
}
export function testCompletion(api: BaseLlmApi, model: string) {

View file

@ -54,6 +54,7 @@ export const OpenAIConfigSchema = BasePlusConfig.extend({
z.literal("vllm"),
z.literal("x-ai"),
z.literal("scaleway"),
z.literal("ncompass"),
]),
});
export type OpenAIConfig = z.infer<typeof OpenAIConfigSchema>;