merge main
This commit is contained in:
commit
df820bd519
94 changed files with 2475 additions and 444 deletions
28
.github/workflows/pr_checks.yaml
vendored
28
.github/workflows/pr_checks.yaml
vendored
|
|
@ -96,7 +96,7 @@ jobs:
|
|||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
|
||||
install-gui:
|
||||
needs: [ install-root, install-core ]
|
||||
needs: [install-root, install-core]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -157,7 +157,7 @@ jobs:
|
|||
npx tsc --noEmit
|
||||
|
||||
binary-checks:
|
||||
needs: [ install-root, install-core ]
|
||||
needs: [install-root, install-core]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -193,7 +193,7 @@ jobs:
|
|||
npx tsc --noEmit
|
||||
|
||||
install-vscode:
|
||||
needs: [ install-root, install-core ]
|
||||
needs: [install-root, install-core]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -274,10 +274,15 @@ jobs:
|
|||
run: |
|
||||
cd core
|
||||
npm test
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
|
||||
|
||||
vscode-get-test-file-matrix:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ install-root, install-vscode ]
|
||||
needs: [install-root, install-vscode]
|
||||
outputs:
|
||||
test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }}
|
||||
steps:
|
||||
|
|
@ -306,7 +311,7 @@ jobs:
|
|||
|
||||
vscode-package-extension:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ install-vscode, install-core ]
|
||||
needs: [install-vscode, install-core]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
|
|
@ -338,7 +343,7 @@ jobs:
|
|||
|
||||
vscode-download-e2e-dependencies:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ install-vscode, install-core ]
|
||||
needs: [install-vscode, install-core]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
|
|
@ -370,7 +375,7 @@ jobs:
|
|||
path: extensions/vscode/e2e/storage
|
||||
|
||||
vscode-e2e-tests:
|
||||
name: ${{ matrix.test_file }}"
|
||||
name: ${{ matrix.test_file }} (${{ matrix.command }})
|
||||
needs:
|
||||
[
|
||||
vscode-download-e2e-dependencies,
|
||||
|
|
@ -384,6 +389,7 @@ jobs:
|
|||
fail-fast: false
|
||||
matrix:
|
||||
test_file: ${{ fromJson(needs.vscode-get-test-file-matrix.outputs.test_file_matrix) }}
|
||||
command: ["e2e:ci:run", "e2e:ci:run-yaml"]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
|
|
@ -432,7 +438,7 @@ jobs:
|
|||
- name: Run e2e tests
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
TEST_FILE="${{ matrix.test_file }}" npm run e2e:ci:run
|
||||
TEST_FILE="${{ matrix.test_file }}" npm run ${{ matrix.command }}
|
||||
|
||||
env:
|
||||
DISPLAY: :99
|
||||
|
|
@ -445,7 +451,7 @@ jobs:
|
|||
path: extensions/vscode/e2e/storage/screenshots
|
||||
|
||||
gui-tests:
|
||||
needs: [ install-gui, install-core ]
|
||||
needs: [install-gui, install-core]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -476,7 +482,7 @@ jobs:
|
|||
npm test
|
||||
|
||||
jetbrains-tests:
|
||||
needs: [ install-root, core-checks ]
|
||||
needs: [install-root, core-checks]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -573,5 +579,3 @@ jobs:
|
|||
name: jb-failure-report
|
||||
path: |
|
||||
${{ github.workspace }}/extensions/intellij/build/reports
|
||||
|
||||
|
||||
|
|
|
|||
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
|
@ -20,10 +20,10 @@
|
|||
"outFiles": ["${workspaceFolder}/extensions/vscode/out/extension.js"],
|
||||
"preLaunchTask": "vscode-extension:build",
|
||||
"env": {
|
||||
// "CONTROL_PLANE_ENV": "local",
|
||||
"CONTINUE_GLOBAL_DIR": "${workspaceFolder}/extensions/.continue-debug"
|
||||
// "staging" for the preview deployment "CONTINUE_GLOBAL_DIR": "${workspaceFolder}/extensions/.continue-debug"
|
||||
// "local" for entirely local development of control plane/proxy
|
||||
// "CONTROL_PLANE_ENV": "staging"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
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.0",
|
||||
"@continuedev/config-yaml": "^1.0.10",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ describe.skip("Test the ConfigHandler and E2E config loading", () => {
|
|||
expect(profiles[0].id).toBe("local");
|
||||
|
||||
const currentProfile = testConfigHandler.currentProfile;
|
||||
expect(currentProfile.profileId).toBe("local");
|
||||
expect(currentProfile.profileDescription.id).toBe("local");
|
||||
});
|
||||
|
||||
test("should load the default config successfully", async () => {
|
||||
|
|
|
|||
|
|
@ -14,18 +14,21 @@ import Ollama from "../llm/llms/Ollama.js";
|
|||
import { GlobalContext } from "../util/GlobalContext.js";
|
||||
import { getConfigJsonPath } from "../util/paths.js";
|
||||
|
||||
import { ConfigResult } from "./load.js";
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { pathToFileURL } from "url";
|
||||
import { controlPlaneEnv } from "../control-plane/env.js";
|
||||
import { usePlatform } from "../control-plane/flags.js";
|
||||
import {
|
||||
LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
} from "./onboarding.js";
|
||||
import ControlPlaneProfileLoader from "./profile/ControlPlaneProfileLoader.js";
|
||||
import LocalProfileLoader from "./profile/LocalProfileLoader.js";
|
||||
import PlatformProfileLoader from "./profile/PlatformProfileLoader.js";
|
||||
import {
|
||||
ProfileDescription,
|
||||
ProfileLifecycleManager,
|
||||
} from "./ProfileLifecycleManager.js";
|
||||
import { pathToFileURL } from "url";
|
||||
|
||||
export type { ProfileDescription };
|
||||
|
||||
|
|
@ -57,7 +60,7 @@ export class ConfigHandler {
|
|||
writeLog,
|
||||
);
|
||||
this.profiles = [new ProfileLifecycleManager(localProfileLoader)];
|
||||
this.selectedProfileId = localProfileLoader.profileId;
|
||||
this.selectedProfileId = localProfileLoader.description.id;
|
||||
|
||||
// Always load local profile immediately in case control plane doesn't load
|
||||
try {
|
||||
|
|
@ -77,13 +80,16 @@ export class ConfigHandler {
|
|||
|
||||
get currentProfile() {
|
||||
return (
|
||||
this.profiles.find((p) => p.profileId === this.selectedProfileId) ??
|
||||
this.fallbackProfile
|
||||
this.profiles.find(
|
||||
(p) => p.profileDescription.id === this.selectedProfileId,
|
||||
) ?? this.fallbackProfile
|
||||
);
|
||||
}
|
||||
|
||||
get inactiveProfiles() {
|
||||
return this.profiles.filter((p) => p.profileId !== this.selectedProfileId);
|
||||
return this.profiles.filter(
|
||||
(p) => p.profileDescription.id !== this.selectedProfileId,
|
||||
);
|
||||
}
|
||||
|
||||
async openConfigProfile(profileId?: string) {
|
||||
|
|
@ -91,25 +97,23 @@ export class ConfigHandler {
|
|||
if (openProfileId === "local") {
|
||||
await this.ide.openFile(pathToFileURL(getConfigJsonPath()).toString());
|
||||
} else {
|
||||
await this.ide.openUrl(
|
||||
"https://app.continue.dev/",
|
||||
// `https://app.continue.dev/workspaces/${openProfileId}/chat`,
|
||||
);
|
||||
await this.ide.openUrl(`${controlPlaneEnv.APP_URL}${openProfileId}`);
|
||||
}
|
||||
}
|
||||
|
||||
private async fetchControlPlaneProfiles() {
|
||||
private async loadPlatformProfiles() {
|
||||
// Get the profiles and create their lifecycle managers
|
||||
this.controlPlaneClient
|
||||
.listWorkspaces()
|
||||
.then(async (workspaces) => {
|
||||
.listAssistants()
|
||||
.then(async (assistants) => {
|
||||
this.profiles = this.profiles.filter(
|
||||
(profile) => profile.profileId === "local",
|
||||
(profile) => profile.profileDescription.id === "local",
|
||||
);
|
||||
workspaces.forEach((workspace) => {
|
||||
const profileLoader = new ControlPlaneProfileLoader(
|
||||
workspace.id,
|
||||
workspace.name,
|
||||
assistants.forEach((assistant) => {
|
||||
const profileLoader = new PlatformProfileLoader(
|
||||
assistant.configResult,
|
||||
assistant.ownerSlug,
|
||||
assistant.packageSlug,
|
||||
this.controlPlaneClient,
|
||||
this.ide,
|
||||
this.ideSettingsPromise,
|
||||
|
|
@ -141,10 +145,67 @@ export class ConfigHandler {
|
|||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
console.error("Failed to list assistants: ", e);
|
||||
});
|
||||
}
|
||||
|
||||
private platformProfilesRefreshInterval: NodeJS.Timeout | undefined;
|
||||
|
||||
private async fetchControlPlaneProfiles() {
|
||||
if (usePlatform()) {
|
||||
clearInterval(this.platformProfilesRefreshInterval);
|
||||
await this.loadPlatformProfiles();
|
||||
this.platformProfilesRefreshInterval = setInterval(
|
||||
this.loadPlatformProfiles.bind(this),
|
||||
PlatformProfileLoader.RELOAD_INTERVAL,
|
||||
);
|
||||
} else {
|
||||
this.controlPlaneClient
|
||||
.listWorkspaces()
|
||||
.then(async (workspaces) => {
|
||||
this.profiles = this.profiles.filter(
|
||||
(profile) => profile.profileDescription.id === "local",
|
||||
);
|
||||
workspaces.forEach((workspace) => {
|
||||
const profileLoader = new ControlPlaneProfileLoader(
|
||||
workspace.id,
|
||||
workspace.name,
|
||||
this.controlPlaneClient,
|
||||
this.ide,
|
||||
this.ideSettingsPromise,
|
||||
this.writeLog,
|
||||
this.reloadConfig.bind(this),
|
||||
);
|
||||
this.profiles.push(new ProfileLifecycleManager(profileLoader));
|
||||
});
|
||||
|
||||
this.notifyProfileListeners(
|
||||
this.profiles.map((profile) => profile.profileDescription),
|
||||
);
|
||||
|
||||
// Check the last selected workspace, and reload if it isn't local
|
||||
const workspaceId = await this.getWorkspaceId();
|
||||
const lastSelectedWorkspaceIds =
|
||||
this.globalContext.get("lastSelectedProfileForWorkspace") ?? {};
|
||||
const selectedWorkspaceId = lastSelectedWorkspaceIds[workspaceId];
|
||||
if (selectedWorkspaceId) {
|
||||
this.selectedProfileId = selectedWorkspaceId;
|
||||
await this.loadConfig();
|
||||
} else {
|
||||
// Otherwise we stick with local profile, and record choice
|
||||
lastSelectedWorkspaceIds[workspaceId] = this.selectedProfileId;
|
||||
this.globalContext.update(
|
||||
"lastSelectedProfileForWorkspace",
|
||||
lastSelectedWorkspaceIds,
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async setSelectedProfile(profileId: string) {
|
||||
this.selectedProfileId = profileId;
|
||||
const result = await this.loadConfig();
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
ContinueConfig,
|
||||
IContextProvider,
|
||||
} from "../index.js";
|
||||
|
||||
import { ConfigResult, finalToBrowserConfig } from "./load.js";
|
||||
import { finalToBrowserConfig } from "./load.js";
|
||||
import { IProfileLoader } from "./profile/IProfileLoader.js";
|
||||
|
||||
export interface ProfileDescription {
|
||||
title: string;
|
||||
id: string;
|
||||
errors: ConfigValidationError[] | undefined;
|
||||
}
|
||||
|
||||
export class ProfileLifecycleManager {
|
||||
|
|
@ -19,19 +21,8 @@ export class ProfileLifecycleManager {
|
|||
|
||||
constructor(private readonly profileLoader: IProfileLoader) {}
|
||||
|
||||
get profileId() {
|
||||
return this.profileLoader.profileId;
|
||||
}
|
||||
|
||||
get profileTitle() {
|
||||
return this.profileLoader.profileTitle;
|
||||
}
|
||||
|
||||
get profileDescription(): ProfileDescription {
|
||||
return {
|
||||
title: this.profileTitle,
|
||||
id: this.profileId,
|
||||
};
|
||||
return this.profileLoader.description;
|
||||
}
|
||||
|
||||
clearConfig() {
|
||||
|
|
@ -71,14 +62,10 @@ export class ProfileLifecycleManager {
|
|||
result.config.contextProviders = (
|
||||
result.config.contextProviders ?? []
|
||||
).concat(additionalContextProviders);
|
||||
|
||||
this.savedConfigResult = result;
|
||||
resolve(result);
|
||||
} else if (result.errors) {
|
||||
reject(
|
||||
`Error in config.json: ${result.errors.map((item) => item.message).join(" | ")}`,
|
||||
);
|
||||
}
|
||||
|
||||
this.savedConfigResult = result;
|
||||
resolve(result);
|
||||
});
|
||||
|
||||
// Wait for the config promise to resolve
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ import {
|
|||
getEsbuildBinaryPath,
|
||||
} from "../util/paths";
|
||||
|
||||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import { usePlatform } from "../control-plane/flags";
|
||||
import {
|
||||
defaultContextProvidersJetBrains,
|
||||
defaultContextProvidersVsCode,
|
||||
|
|
@ -70,13 +72,7 @@ import {
|
|||
} from "./default";
|
||||
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
|
||||
// import { isSupportedLanceDbCpuTarget } from "./util";
|
||||
import { ConfigValidationError, validateConfig } from "./validation.js";
|
||||
|
||||
export interface ConfigResult<T> {
|
||||
config: T | undefined;
|
||||
errors: ConfigValidationError[] | undefined;
|
||||
configLoadInterrupted: boolean;
|
||||
}
|
||||
import { validateConfig } from "./validation.js";
|
||||
|
||||
function resolveSerializedConfig(filepath: string): SerializedContinueConfig {
|
||||
let content = fs.readFileSync(filepath, "utf8");
|
||||
|
|
@ -229,7 +225,7 @@ function isModelDescription(
|
|||
return (llm as ModelDescription).title !== undefined;
|
||||
}
|
||||
|
||||
function isContextProviderWithParams(
|
||||
export function isContextProviderWithParams(
|
||||
contextProvider: CustomContextProvider | ContextProviderWithParams,
|
||||
): contextProvider is ContextProviderWithParams {
|
||||
return (contextProvider as ContextProviderWithParams).name !== undefined;
|
||||
|
|
@ -582,6 +578,7 @@ function finalToBrowserConfig(
|
|||
experimental: final.experimental,
|
||||
docs: final.docs,
|
||||
tools: final.tools,
|
||||
usePlatform: usePlatform(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ import {
|
|||
IdeSettings,
|
||||
SerializedContinueConfig,
|
||||
} from "../../index.js";
|
||||
import { ConfigResult } from "../load.js";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
export default class ControlPlaneProfileLoader implements IProfileLoader {
|
||||
private static RELOAD_INTERVAL = 1000 * 60 * 15; // every 15 minutes
|
||||
|
||||
readonly profileId: string;
|
||||
profileTitle: string;
|
||||
description: ProfileDescription;
|
||||
|
||||
workspaceSettings: ConfigJson | undefined;
|
||||
|
||||
|
|
@ -29,12 +29,17 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
|
|||
private writeLog: (message: string) => Promise<void>,
|
||||
private readonly onReload: () => void,
|
||||
) {
|
||||
this.profileId = workspaceId;
|
||||
this.profileTitle = workspaceTitle;
|
||||
this.description = {
|
||||
id: workspaceId,
|
||||
title: workspaceTitle,
|
||||
errors: undefined,
|
||||
};
|
||||
|
||||
setInterval(async () => {
|
||||
this.workspaceSettings =
|
||||
await this.controlPlaneClient.getSettingsForWorkspace(this.profileId);
|
||||
await this.controlPlaneClient.getSettingsForWorkspace(
|
||||
this.description.id,
|
||||
);
|
||||
this.onReload();
|
||||
}, ControlPlaneProfileLoader.RELOAD_INTERVAL);
|
||||
}
|
||||
|
|
@ -43,7 +48,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
|
|||
const settings =
|
||||
this.workspaceSettings ??
|
||||
((await this.controlPlaneClient.getSettingsForWorkspace(
|
||||
this.profileId,
|
||||
this.description.id,
|
||||
)) as any);
|
||||
const serializedConfig: SerializedContinueConfig = settings;
|
||||
|
||||
|
|
@ -53,6 +58,8 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
|
|||
this.controlPlaneClient,
|
||||
this.writeLog,
|
||||
serializedConfig,
|
||||
undefined,
|
||||
undefined,
|
||||
this.workspaceId,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
// ProfileHandlers manage the loading of a config, allowing us to abstract over different ways of getting to a ContinueConfig
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ContinueConfig } from "../../index.js";
|
||||
import { ConfigResult } from "../load.js";
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
|
||||
// After we have the ContinueConfig, the ConfigHandler takes care of everything else (loading models, lifecycle, etc.)
|
||||
export interface IProfileLoader {
|
||||
profileTitle: string;
|
||||
profileId: string;
|
||||
description: ProfileDescription;
|
||||
doLoadConfig(): Promise<ConfigResult<ContinueConfig>>;
|
||||
setIsActive(isActive: boolean): void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
|
||||
import { ConfigResult } from "../load.js";
|
||||
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
export default class LocalProfileLoader implements IProfileLoader {
|
||||
static ID = "local";
|
||||
profileId = LocalProfileLoader.ID;
|
||||
profileTitle = "Local Config";
|
||||
description: ProfileDescription = {
|
||||
id: LocalProfileLoader.ID,
|
||||
title: "Local Config",
|
||||
errors: undefined,
|
||||
};
|
||||
|
||||
constructor(
|
||||
private ide: IDE,
|
||||
|
|
@ -18,13 +22,19 @@ export default class LocalProfileLoader implements IProfileLoader {
|
|||
) {}
|
||||
|
||||
async doLoadConfig(): Promise<ConfigResult<ContinueConfig>> {
|
||||
return doLoadConfig(
|
||||
const result = await doLoadConfig(
|
||||
this.ide,
|
||||
this.ideSettingsPromise,
|
||||
this.controlPlaneClient,
|
||||
this.writeLog,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
);
|
||||
|
||||
this.description.errors = result.errors;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
setIsActive(isActive: boolean): void {}
|
||||
|
|
|
|||
90
core/config/profile/PlatformProfileLoader.ts
Normal file
90
core/config/profile/PlatformProfileLoader.ts
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js";
|
||||
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
/**
|
||||
* Metadata about the package that is currently being loaded
|
||||
* If this is `undefined`, it's not a config from the platform,
|
||||
* could be local for example.
|
||||
*/
|
||||
export interface PlatformConfigMetadata {
|
||||
ownerSlug: string;
|
||||
packageSlug: string;
|
||||
}
|
||||
|
||||
export default class PlatformProfileLoader implements IProfileLoader {
|
||||
static RELOAD_INTERVAL = 1000 * 60 * 15; // every 15 minutes
|
||||
|
||||
description: ProfileDescription;
|
||||
|
||||
constructor(
|
||||
private configResult: ConfigResult<ClientConfigYaml>,
|
||||
private readonly ownerSlug: string,
|
||||
private readonly packageSlug: 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 = {
|
||||
id: `${ownerSlug}/${packageSlug}`,
|
||||
title: `${ownerSlug}/${packageSlug}`,
|
||||
errors: configResult.errors,
|
||||
};
|
||||
|
||||
setInterval(async () => {
|
||||
const assistants = await this.controlPlaneClient.listAssistants();
|
||||
const newConfigResult = assistants.find(
|
||||
(assistant) =>
|
||||
assistant.packageSlug === this.packageSlug &&
|
||||
assistant.ownerSlug === this.ownerSlug,
|
||||
)?.configResult;
|
||||
if (!newConfigResult) {
|
||||
return;
|
||||
}
|
||||
this.configResult = {
|
||||
config: newConfigResult.config,
|
||||
errors: newConfigResult.errors,
|
||||
configLoadInterrupted: false,
|
||||
};
|
||||
this.onReload();
|
||||
}, PlatformProfileLoader.RELOAD_INTERVAL);
|
||||
}
|
||||
|
||||
async doLoadConfig(): Promise<ConfigResult<ContinueConfig>> {
|
||||
if (this.configResult.errors?.length) {
|
||||
return {
|
||||
config: undefined,
|
||||
errors: this.configResult.errors,
|
||||
configLoadInterrupted: false,
|
||||
};
|
||||
}
|
||||
|
||||
const results = await doLoadConfig(
|
||||
this.ide,
|
||||
this.ideSettingsPromise,
|
||||
this.controlPlaneClient,
|
||||
this.writeLog,
|
||||
undefined,
|
||||
this.configResult.config,
|
||||
{
|
||||
ownerSlug: this.ownerSlug,
|
||||
packageSlug: this.packageSlug,
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
...results,
|
||||
errors: [], // Don't do config validation here, it happens in admin panel
|
||||
};
|
||||
}
|
||||
|
||||
setIsActive(isActive: boolean): void {}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
import fs from "fs";
|
||||
|
||||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas";
|
||||
import {
|
||||
ContinueConfig,
|
||||
ContinueRcJson,
|
||||
|
|
@ -15,9 +17,9 @@ import ContinueProxy from "../../llm/llms/stubs/ContinueProxy";
|
|||
import { getConfigYamlPath } from "../../util/paths";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
import { TTS } from "../../util/tts";
|
||||
import { ConfigResult, loadFullConfigNode } from "../load";
|
||||
import { ConfigValidationError } from "../validation";
|
||||
import { loadFullConfigNode } from "../load";
|
||||
import { loadContinueConfigFromYaml } from "../yaml/loadYaml";
|
||||
import { PlatformConfigMetadata } from "./PlatformProfileLoader";
|
||||
|
||||
export default async function doLoadConfig(
|
||||
ide: IDE,
|
||||
|
|
@ -25,6 +27,8 @@ export default async function doLoadConfig(
|
|||
controlPlaneClient: ControlPlaneClient,
|
||||
writeLog: (message: string) => Promise<void>,
|
||||
overrideConfigJson: SerializedContinueConfig | undefined,
|
||||
overrideConfigYaml: ClientConfigYaml | undefined,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
workspaceId?: string,
|
||||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
const workspaceConfigs = await getWorkspaceConfigs(ide);
|
||||
|
|
@ -39,7 +43,7 @@ export default async function doLoadConfig(
|
|||
let errors: ConfigValidationError[] | undefined;
|
||||
let configLoadInterrupted = false;
|
||||
|
||||
if (fs.existsSync(configYamlPath)) {
|
||||
if (fs.existsSync(configYamlPath) || overrideConfigYaml) {
|
||||
const result = await loadContinueConfigFromYaml(
|
||||
ide,
|
||||
workspaceConfigs.map((c) => JSON.stringify(c)),
|
||||
|
|
@ -48,8 +52,9 @@ export default async function doLoadConfig(
|
|||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
undefined,
|
||||
// overrideConfigYaml, TODO
|
||||
overrideConfigYaml,
|
||||
platformConfigMetadata,
|
||||
controlPlaneClient,
|
||||
);
|
||||
newConfig = result.config;
|
||||
errors = result.errors;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
import { ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import { ModelDescription, SerializedContinueConfig } from "../";
|
||||
import { Telemetry } from "../util/posthog";
|
||||
|
||||
export interface ConfigValidationError {
|
||||
fatal: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a SerializedContinueConfig object to ensure all properties are correctly formed.
|
||||
* @param config The configuration object to validate.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export function convertConfigJsonToConfigYaml(
|
|||
): ConfigYaml {
|
||||
return {
|
||||
name: "Local Config",
|
||||
version: "1.0.0",
|
||||
models: [
|
||||
...configJson.models.map(
|
||||
(model): ModelConfig => ({
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ export const defaultConfigYaml: ConfigYaml = {
|
|||
models: [],
|
||||
context: [],
|
||||
name: "Local Config",
|
||||
version: "1.0.0",
|
||||
};
|
||||
|
||||
export const defaultConfigYamlJetBrains: ConfigYaml = {
|
||||
models: [],
|
||||
context: [],
|
||||
name: "Local Config",
|
||||
version: "1.0.0",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
import fs from "node:fs";
|
||||
import path from "path";
|
||||
|
||||
import {
|
||||
extendConfig,
|
||||
ConfigResult,
|
||||
fillTemplateVariables,
|
||||
resolveSecretsOnClient,
|
||||
validateConfigYaml,
|
||||
} from "@continuedev/config-yaml";
|
||||
import { ConfigYaml } from "@continuedev/config-yaml/dist/schemas";
|
||||
import { ValidationLevel } from "@continuedev/config-yaml/dist/validation";
|
||||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas";
|
||||
import { fetchwithRequestOptions } from "@continuedev/fetch";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
|
|
@ -26,23 +25,17 @@ import { contextProviderClassFromName } from "../../context/providers/index";
|
|||
import { allEmbeddingsProviders } from "../../indexing/allEmbeddingsProviders";
|
||||
import FreeTrial from "../../llm/llms/FreeTrial";
|
||||
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import {
|
||||
getConfigYamlPath,
|
||||
getContinueDotEnv,
|
||||
readAllGlobalPromptFiles,
|
||||
} from "../../util/paths";
|
||||
import { getSystemPromptDotFile } from "../getSystemPromptDotFile";
|
||||
import { ConfigValidationError } from "../validation.js";
|
||||
|
||||
import { llmsFromModelConfig } from "./models";
|
||||
import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles";
|
||||
import { slashCommandFromPromptFileV1 } from "../../promptFiles/v1/slashCommandFromPromptFile";
|
||||
import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles";
|
||||
import { getConfigYamlPath, getContinueDotEnv } from "../../util/paths";
|
||||
import { getSystemPromptDotFile } from "../getSystemPromptDotFile";
|
||||
import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader";
|
||||
|
||||
export interface ConfigResult<T> {
|
||||
config: T | undefined;
|
||||
errors: ConfigValidationError[] | undefined;
|
||||
configLoadInterrupted: boolean;
|
||||
}
|
||||
import CodebaseContextProvider from "../../context/providers/CodebaseContextProvider";
|
||||
import FileContextProvider from "../../context/providers/FileContextProvider";
|
||||
import PromptFilesContextProvider from "../../context/providers/PromptFilesContextProvider";
|
||||
import { ControlPlaneClient } from "../../control-plane/client";
|
||||
import { llmsFromModelConfig } from "./models";
|
||||
|
||||
function renderTemplateVars(configYaml: string): string {
|
||||
const data: Record<string, string> = {};
|
||||
|
|
@ -60,36 +53,28 @@ function renderTemplateVars(configYaml: string): string {
|
|||
|
||||
function loadConfigYaml(
|
||||
workspaceConfigs: string[],
|
||||
ideSettings: IdeSettings,
|
||||
ideType: IdeType,
|
||||
rawYaml: string,
|
||||
): ConfigResult<ConfigYaml> {
|
||||
const renderedYaml = renderTemplateVars(rawYaml);
|
||||
let config = YAML.parse(renderedYaml) as ConfigYaml;
|
||||
overrideConfigYaml: ClientConfigYaml | undefined,
|
||||
): ConfigResult<ClientConfigYaml> {
|
||||
let config =
|
||||
overrideConfigYaml ??
|
||||
(YAML.parse(renderTemplateVars(rawYaml)) as ClientConfigYaml);
|
||||
const errors = validateConfigYaml(config);
|
||||
|
||||
if (errors?.some((error) => error.level === ValidationLevel.Error)) {
|
||||
if (errors?.some((error) => error.fatal)) {
|
||||
return {
|
||||
errors: errors.map((error) => ({
|
||||
message: error.message,
|
||||
fatal: error.level === ValidationLevel.Error,
|
||||
})),
|
||||
errors,
|
||||
config: undefined,
|
||||
configLoadInterrupted: true,
|
||||
};
|
||||
}
|
||||
|
||||
for (const workspaceConfig of workspaceConfigs) {
|
||||
const rendered = renderTemplateVars(workspaceConfig);
|
||||
config = extendConfig(config, YAML.parse(rendered) as ConfigYaml);
|
||||
}
|
||||
|
||||
// Set defaults if undefined (this lets us keep config.json uncluttered for new users)
|
||||
return {
|
||||
config,
|
||||
errors: errors.map((error) => ({
|
||||
message: error.message,
|
||||
fatal: error.level === ValidationLevel.Error,
|
||||
fatal: error.fatal,
|
||||
})),
|
||||
configLoadInterrupted: false,
|
||||
};
|
||||
|
|
@ -113,12 +98,13 @@ async function slashCommandsFromV1PromptFiles(
|
|||
}
|
||||
|
||||
async function configYamlToContinueConfig(
|
||||
config: ConfigYaml,
|
||||
config: ClientConfigYaml,
|
||||
ide: IDE,
|
||||
ideSettings: IdeSettings,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
allowFreeTrial: boolean = true,
|
||||
): Promise<ContinueConfig> {
|
||||
const continueConfig: ContinueConfig = {
|
||||
|
|
@ -126,10 +112,24 @@ async function configYamlToContinueConfig(
|
|||
models: [],
|
||||
tabAutocompleteModels: [],
|
||||
tools: [],
|
||||
systemMessage: config.rules?.join("\n"),
|
||||
embeddingsProvider: new TransformersJsEmbeddingsProvider(),
|
||||
experimental: {
|
||||
modelContextProtocolServers: [],
|
||||
modelContextProtocolServers: config.mcpServers?.map((mcpServer) => ({
|
||||
transport: {
|
||||
type: "stdio",
|
||||
command: mcpServer.command,
|
||||
args: mcpServer.args ?? [],
|
||||
env: mcpServer.env,
|
||||
},
|
||||
})),
|
||||
},
|
||||
docs: config.docs?.map((doc) => ({
|
||||
title: doc.name,
|
||||
startUrl: doc.startUrl,
|
||||
rootUrl: doc.rootUrl,
|
||||
faviconUrl: doc.faviconUrl,
|
||||
})),
|
||||
};
|
||||
|
||||
// Models
|
||||
|
|
@ -146,9 +146,13 @@ async function configYamlToContinueConfig(
|
|||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
continueConfig.systemMessage,
|
||||
);
|
||||
continueConfig.models.push(...llms);
|
||||
} else if (model.roles?.includes("autocomplete")) {
|
||||
}
|
||||
|
||||
if (model.roles?.includes("autocomplete")) {
|
||||
// Autocomplete models array
|
||||
const llms = await llmsFromModelConfig(
|
||||
model,
|
||||
|
|
@ -156,6 +160,8 @@ async function configYamlToContinueConfig(
|
|||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
continueConfig.systemMessage,
|
||||
);
|
||||
continueConfig.tabAutocompleteModels?.push(...llms);
|
||||
}
|
||||
|
|
@ -181,18 +187,33 @@ async function configYamlToContinueConfig(
|
|||
|
||||
// TODO: Split into model roles.
|
||||
|
||||
// Context
|
||||
// Context providers
|
||||
const codebaseContextParams: IContextProvider[] =
|
||||
(config.context || []).find((cp) => cp.uses === "codebase")?.with || {};
|
||||
const DEFAULT_CONTEXT_PROVIDERS = [
|
||||
new FileContextProvider({}),
|
||||
new CodebaseContextProvider(codebaseContextParams),
|
||||
new PromptFilesContextProvider({}),
|
||||
];
|
||||
|
||||
const DEFAULT_CONTEXT_PROVIDERS_TITLES = DEFAULT_CONTEXT_PROVIDERS.map(
|
||||
({ description: { title } }) => title,
|
||||
);
|
||||
|
||||
continueConfig.contextProviders = config.context
|
||||
?.map((context) => {
|
||||
const cls = contextProviderClassFromName(context.uses) as any;
|
||||
if (!cls) {
|
||||
console.warn(`Unknown context provider ${context.uses}`);
|
||||
if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(context.uses)) {
|
||||
console.warn(`Unknown context provider ${context.uses}`);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
const instance: IContextProvider = new cls(context.with ?? {});
|
||||
return instance;
|
||||
})
|
||||
.filter((p) => !!p) as IContextProvider[];
|
||||
continueConfig.contextProviders.push(...DEFAULT_CONTEXT_PROVIDERS);
|
||||
|
||||
// Embeddings Provider
|
||||
const embedConfig = config.models?.find((model) =>
|
||||
|
|
@ -283,16 +304,20 @@ export async function loadContinueConfigFromYaml(
|
|||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
overrideConfigYaml: string | undefined,
|
||||
overrideConfigYaml: ClientConfigYaml | undefined,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
const configYamlPath = getConfigYamlPath(ideType);
|
||||
const rawYaml = fs.readFileSync(configYamlPath, "utf-8");
|
||||
const rawYaml =
|
||||
overrideConfigYaml === undefined
|
||||
? fs.readFileSync(configYamlPath, "utf-8")
|
||||
: "";
|
||||
|
||||
const configYamlResult = await loadConfigYaml(
|
||||
const configYamlResult = loadConfigYaml(
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
ideType,
|
||||
overrideConfigYaml ?? rawYaml,
|
||||
rawYaml,
|
||||
overrideConfigYaml,
|
||||
);
|
||||
|
||||
if (!configYamlResult.config || configYamlResult.configLoadInterrupted) {
|
||||
|
|
@ -303,13 +328,24 @@ export async function loadContinueConfigFromYaml(
|
|||
};
|
||||
}
|
||||
|
||||
const continueConfig = await configYamlToContinueConfig(
|
||||
const configYaml = await resolveSecretsOnClient(
|
||||
configYamlResult.config,
|
||||
ide.readSecrets.bind(ide),
|
||||
async (secretNames: string[]) => {
|
||||
const secretValues = await controlPlaneClient.syncSecrets(secretNames);
|
||||
await ide.writeSecrets(secretValues);
|
||||
return secretValues;
|
||||
},
|
||||
);
|
||||
|
||||
const continueConfig = await configYamlToContinueConfig(
|
||||
configYaml,
|
||||
ide,
|
||||
ideSettings,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
platformConfigMetadata,
|
||||
);
|
||||
|
||||
const systemPromptDotFile = await getSystemPromptDotFile(ide);
|
||||
|
|
|
|||
|
|
@ -3,21 +3,59 @@ import { ModelConfig } from "@continuedev/config-yaml";
|
|||
import { IDE, IdeSettings, LLMOptions } from "../..";
|
||||
import { BaseLLM } from "../../llm";
|
||||
import { LLMClasses } from "../../llm/llms";
|
||||
import ContinueProxy from "../../llm/llms/stubs/ContinueProxy";
|
||||
import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader";
|
||||
|
||||
const AUTODETECT = "AUTODETECT";
|
||||
|
||||
function useContinueProxy(
|
||||
model: ModelConfig,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
): boolean {
|
||||
return !!platformConfigMetadata && model.apiKeySecret !== undefined;
|
||||
}
|
||||
|
||||
function getModelClass(
|
||||
model: ModelConfig,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
): (typeof LLMClasses)[number] | undefined {
|
||||
if (useContinueProxy(model, platformConfigMetadata)) {
|
||||
return ContinueProxy;
|
||||
}
|
||||
return LLMClasses.find((llm) => llm.providerName === model.provider);
|
||||
}
|
||||
|
||||
function getContinueProxyModelName(
|
||||
ownerSlug: string,
|
||||
packageSlug: string,
|
||||
model: ModelConfig,
|
||||
): string {
|
||||
return `${ownerSlug}/${packageSlug}/${model.provider}/${model.model}`;
|
||||
}
|
||||
|
||||
async function modelConfigToBaseLLM(
|
||||
model: ModelConfig,
|
||||
uniqueId: string,
|
||||
ideSettings: IdeSettings,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
systemMessage: string | undefined,
|
||||
): Promise<BaseLLM | undefined> {
|
||||
const cls = LLMClasses.find((llm) => llm.providerName === model.provider);
|
||||
const cls = getModelClass(model, platformConfigMetadata);
|
||||
|
||||
if (!cls) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const usingContinueProxy = useContinueProxy(model, platformConfigMetadata);
|
||||
const modelName = usingContinueProxy
|
||||
? getContinueProxyModelName(
|
||||
platformConfigMetadata!.ownerSlug,
|
||||
platformConfigMetadata!.packageSlug,
|
||||
model,
|
||||
)
|
||||
: model.model;
|
||||
|
||||
let options: LLMOptions = {
|
||||
...model,
|
||||
completionOptions: {
|
||||
|
|
@ -30,6 +68,8 @@ async function modelConfigToBaseLLM(
|
|||
writeLog,
|
||||
uniqueId,
|
||||
title: model.name,
|
||||
model: modelName,
|
||||
systemMessage,
|
||||
};
|
||||
|
||||
const llm = new cls(options);
|
||||
|
|
@ -43,6 +83,8 @@ async function autodetectModels(
|
|||
uniqueId: string,
|
||||
ideSettings: IdeSettings,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
systemMessage: string | undefined,
|
||||
): Promise<BaseLLM[]> {
|
||||
try {
|
||||
const modelNames = await llm.listModels();
|
||||
|
|
@ -62,6 +104,8 @@ async function autodetectModels(
|
|||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
systemMessage,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
|
@ -78,12 +122,16 @@ export async function llmsFromModelConfig(
|
|||
uniqueId: string,
|
||||
ideSettings: IdeSettings,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
systemMessage: string | undefined,
|
||||
): Promise<BaseLLM[]> {
|
||||
const baseLlm = await modelConfigToBaseLLM(
|
||||
model,
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
systemMessage,
|
||||
);
|
||||
if (!baseLlm) {
|
||||
return [];
|
||||
|
|
@ -97,6 +145,8 @@ export async function llmsFromModelConfig(
|
|||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
systemMessage,
|
||||
);
|
||||
return models;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
|
|||
import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js";
|
||||
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
||||
|
||||
import { ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import { ContinueConfig, MCPOptions, SlashCommand, Tool } from "../..";
|
||||
import { constructMcpSlashCommand } from "../../commands/slash/mcp";
|
||||
import { ConfigValidationError } from "../../config/validation";
|
||||
import { encodeMCPToolUri } from "../../tools/callTool";
|
||||
import MCPContextProvider from "../providers/MCPContextProvider";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
import { controlPlaneEnv } from "../env";
|
||||
|
||||
const CLIENT_ID = "client_01J0FW6XN8N2XJAECF7NE0Y65J";
|
||||
// const CLIENT_ID = "client_01J0FW6XCPMJMQ3CG51RB4HBZQ"; // Staging
|
||||
|
||||
|
|
@ -8,7 +10,7 @@ export async function getAuthUrlForTokenPage(): Promise<string> {
|
|||
const params = {
|
||||
response_type: "code",
|
||||
client_id: CLIENT_ID,
|
||||
redirect_uri: "https://app.continue.dev/tokens/callback",
|
||||
redirect_uri: `${controlPlaneEnv.APP_URL}tokens/callback`,
|
||||
// redirect_uri: "http://localhost:3000/tokens/callback",
|
||||
state: uuidv4(),
|
||||
provider: "authkit",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import { ConfigJson } from "@continuedev/config-types";
|
||||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js";
|
||||
import fetch, { RequestInit, Response } from "node-fetch";
|
||||
|
||||
import { ModelDescription } from "../index.js";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { controlPlaneEnv } from "./env.js";
|
||||
|
||||
export interface ControlPlaneSessionInfo {
|
||||
|
|
@ -85,6 +87,29 @@ export class ControlPlaneClient {
|
|||
}
|
||||
}
|
||||
|
||||
public async listAssistants(): Promise<
|
||||
{
|
||||
configResult: ConfigResult<ClientConfigYaml>;
|
||||
ownerSlug: string;
|
||||
packageSlug: string;
|
||||
iconUrl: string;
|
||||
}[]
|
||||
> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await this.request("ide/list-assistants", {
|
||||
method: "GET",
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async getSettingsForWorkspace(workspaceId: string): Promise<ConfigJson> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
|
|
@ -96,4 +121,21 @@ export class ControlPlaneClient {
|
|||
});
|
||||
return ((await resp.json()) as any).settings;
|
||||
}
|
||||
|
||||
async syncSecrets(secretNames: string[]): Promise<Record<string, string>> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
throw new Error("No user id");
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await this.request("ide/sync-secrets", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ secretNames }),
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
import { readUsePlatform } from "../util/paths";
|
||||
import { usePlatform } from "./flags";
|
||||
|
||||
interface ControlPlaneEnv {
|
||||
DEFAULT_CONTROL_PLANE_PROXY_URL: string;
|
||||
CONTROL_PLANE_URL: string;
|
||||
|
|
@ -21,7 +24,7 @@ const PRODUCTION_ENV: ControlPlaneEnv = {
|
|||
"https://control-plane-api-service-i3dqylpbqa-uc.a.run.app/",
|
||||
AUTH_TYPE: WORKOS_ENV_ID_PRODUCTION,
|
||||
WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_PRODUCTION,
|
||||
APP_URL: "https://app.continue.dev",
|
||||
APP_URL: "https://app.continue.dev/",
|
||||
};
|
||||
|
||||
const STAGING_ENV: ControlPlaneEnv = {
|
||||
|
|
@ -31,7 +34,15 @@ const STAGING_ENV: ControlPlaneEnv = {
|
|||
"https://control-plane-api-service-537175798139.us-central1.run.app/",
|
||||
AUTH_TYPE: WORKOS_CLIENT_ID_STAGING,
|
||||
WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING,
|
||||
APP_URL: "https://app-preview.continue.dev",
|
||||
APP_URL: "https://app-preview.continue.dev/",
|
||||
};
|
||||
|
||||
const TEST_ENV: ControlPlaneEnv = {
|
||||
DEFAULT_CONTROL_PLANE_PROXY_URL: "https://api-test.continue.dev/",
|
||||
CONTROL_PLANE_URL: "https://api-test.continue.dev/",
|
||||
AUTH_TYPE: WORKOS_ENV_ID_STAGING,
|
||||
WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING,
|
||||
APP_URL: "https://app-test.continue.dev/",
|
||||
};
|
||||
|
||||
const LOCAL_ENV: ControlPlaneEnv = {
|
||||
|
|
@ -39,12 +50,20 @@ const LOCAL_ENV: ControlPlaneEnv = {
|
|||
CONTROL_PLANE_URL: "http://localhost:3001/",
|
||||
AUTH_TYPE: WORKOS_ENV_ID_STAGING,
|
||||
WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING,
|
||||
APP_URL: "http://localhost:3000",
|
||||
APP_URL: "http://localhost:3000/",
|
||||
};
|
||||
|
||||
export const controlPlaneEnv =
|
||||
process.env.CONTROL_PLANE_ENV === "local"
|
||||
function getControlPlaneEnv(): ControlPlaneEnv {
|
||||
const usePlatformFileEnv = readUsePlatform();
|
||||
const env = usePlatformFileEnv || process.env.CONTROL_PLANE_ENV;
|
||||
|
||||
return env === "local"
|
||||
? LOCAL_ENV
|
||||
: process.env.CONTROL_PLANE_ENV === "staging"
|
||||
: env === "staging"
|
||||
? STAGING_ENV
|
||||
: PRODUCTION_ENV;
|
||||
: env === "test" || usePlatform()
|
||||
? TEST_ENV
|
||||
: PRODUCTION_ENV;
|
||||
}
|
||||
|
||||
export const controlPlaneEnv = getControlPlaneEnv();
|
||||
|
|
|
|||
13
core/control-plane/flags.ts
Normal file
13
core/control-plane/flags.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { readUsePlatform, usePlatformPathExists } from "../util/paths";
|
||||
|
||||
export function usePlatform(): boolean {
|
||||
return usePlatformPathExists();
|
||||
}
|
||||
|
||||
export function getEnvFromUsePlatformFile(): string | undefined {
|
||||
const contents = readUsePlatform();
|
||||
if (contents && contents.trim().length > 0) {
|
||||
return contents.trim();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ import { getSymbolsForManyFiles } from "./util/treeSitter";
|
|||
import { TTS } from "./util/tts";
|
||||
|
||||
import { type ContextItemId, type IDE, type IndexingProgressUpdate } from ".";
|
||||
|
||||
import { usePlatform } from "./control-plane/flags";
|
||||
import type { FromCoreProtocol, ToCoreProtocol } from "./protocol";
|
||||
import type { IMessenger, Message } from "./protocol/messenger";
|
||||
|
||||
|
|
@ -103,6 +103,7 @@ export class Core {
|
|||
const ideSettingsPromise = messenger.request("getIdeSettings", undefined);
|
||||
const sessionInfoPromise = messenger.request("getControlPlaneSessionInfo", {
|
||||
silent: true,
|
||||
useOnboarding: usePlatform(),
|
||||
});
|
||||
|
||||
this.controlPlaneClient = new ControlPlaneClient(sessionInfoPromise);
|
||||
|
|
@ -124,7 +125,7 @@ export class Core {
|
|||
const serializedResult = await this.configHandler.getSerializedConfig();
|
||||
this.messenger.send("configUpdate", {
|
||||
result: serializedResult,
|
||||
profileId: this.configHandler.currentProfile.profileId,
|
||||
profileId: this.configHandler.currentProfile.profileDescription.id,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -378,7 +379,7 @@ export class Core {
|
|||
on("config/getSerializedProfileInfo", async (msg) => {
|
||||
return {
|
||||
result: await this.configHandler.getSerializedConfig(),
|
||||
profileId: this.configHandler.currentProfile.profileId,
|
||||
profileId: this.configHandler.currentProfile.profileDescription.id,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
16
core/index.d.ts
vendored
16
core/index.d.ts
vendored
|
|
@ -454,6 +454,7 @@ export interface LLMOptions {
|
|||
writeLog?: (str: string) => Promise<void>;
|
||||
llmRequestHook?: (model: string, prompt: string) => any;
|
||||
apiKey?: string;
|
||||
apiKeySecret?: string;
|
||||
aiGatewaySlug?: string;
|
||||
apiBase?: string;
|
||||
cacheBehavior?: CacheBehavior;
|
||||
|
|
@ -677,6 +678,11 @@ export interface IDE {
|
|||
|
||||
getGitHubAuthToken(args: GetGhTokenArgs): Promise<string | undefined>;
|
||||
|
||||
// Secret Storage
|
||||
readSecrets(keys: string[]): Promise<Record<string, string>>;
|
||||
|
||||
writeSecrets(secrets: { [key: string]: string }): Promise<void>;
|
||||
|
||||
// LSP
|
||||
gotoDefinition(location: Location): Promise<RangeInFile[]>;
|
||||
|
||||
|
|
@ -848,6 +854,13 @@ export interface Tool {
|
|||
uri?: string;
|
||||
}
|
||||
|
||||
interface ToolChoice {
|
||||
type: "function";
|
||||
function: {
|
||||
name: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface BaseCompletionOptions {
|
||||
temperature?: number;
|
||||
topP?: number;
|
||||
|
|
@ -865,6 +878,7 @@ export interface BaseCompletionOptions {
|
|||
stream?: boolean;
|
||||
prediction?: Prediction;
|
||||
tools?: Tool[];
|
||||
toolChoice?: ToolChoice;
|
||||
}
|
||||
|
||||
export interface ModelCapability {
|
||||
|
|
@ -876,6 +890,7 @@ export interface ModelDescription {
|
|||
provider: string;
|
||||
model: string;
|
||||
apiKey?: string;
|
||||
apiKeySecret?: string;
|
||||
apiBase?: string;
|
||||
contextLength?: number;
|
||||
maxStopWords?: number;
|
||||
|
|
@ -1192,6 +1207,7 @@ export interface BrowserSerializedContinueConfig {
|
|||
analytics?: AnalyticsConfig;
|
||||
docs?: SiteIndexingConfig[];
|
||||
tools: Tool[];
|
||||
usePlatform: boolean;
|
||||
}
|
||||
|
||||
// DOCS SUGGESTIONS AND PACKAGE INFO
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ import {
|
|||
} from "../../util/paths";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
|
||||
import { ConfigResult } from "../../config/load";
|
||||
import {
|
||||
ArticleWithChunks,
|
||||
htmlPageToArticleWithChunks,
|
||||
markdownPageToArticleWithChunks,
|
||||
} from "./article";
|
||||
import DocsCrawler, { PageData } from "./DocsCrawler";
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { runLanceMigrations, runSqliteMigrations } from "./migrations";
|
||||
import {
|
||||
downloadFromS3,
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
writeLog?: (str: string) => Promise<void>;
|
||||
llmRequestHook?: (model: string, prompt: string) => any;
|
||||
apiKey?: string;
|
||||
apiKeySecret?: string;
|
||||
apiBase?: string;
|
||||
cacheBehavior?: CacheBehavior;
|
||||
capabilities?: ModelCapability;
|
||||
|
|
@ -194,6 +195,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
this.writeLog = options.writeLog;
|
||||
this.llmRequestHook = options.llmRequestHook;
|
||||
this.apiKey = options.apiKey;
|
||||
this.apiKeySecret = options.apiKeySecret;
|
||||
this.aiGatewaySlug = options.aiGatewaySlug;
|
||||
this.apiBase = options.apiBase;
|
||||
this.cacheBehavior = options.cacheBehavior;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
import * as dotenv from "dotenv";
|
||||
|
||||
import { CompletionOptions } from "..";
|
||||
import { AssistantChatMessage, CompletionOptions } from "..";
|
||||
|
||||
import { BaseLLM } from ".";
|
||||
import Anthropic from "./llms/Anthropic";
|
||||
import Gemini from "./llms/Gemini";
|
||||
import Mistral from "./llms/Mistral";
|
||||
import OpenAI from "./llms/OpenAI";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const COMPLETION_OPTIONS: Partial<CompletionOptions> = {
|
||||
temperature: 0.5,
|
||||
// temperature: 0.5,
|
||||
topP: 1,
|
||||
topK: 40,
|
||||
presencePenalty: 0,
|
||||
|
|
@ -16,12 +20,23 @@ const COMPLETION_OPTIONS: Partial<CompletionOptions> = {
|
|||
// maxTokens: 5,
|
||||
};
|
||||
|
||||
function testLLM(llm: BaseLLM) {
|
||||
function testLLM(
|
||||
llm: BaseLLM,
|
||||
{
|
||||
skip,
|
||||
testFim,
|
||||
testToolCall,
|
||||
}: { skip?: boolean; testFim?: boolean; testToolCall?: boolean },
|
||||
) {
|
||||
if (skip) {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeAll(() => {
|
||||
llm.completionOptions = { ...llm.completionOptions, ...COMPLETION_OPTIONS };
|
||||
});
|
||||
|
||||
describe(llm.providerName, () => {
|
||||
describe(llm.providerName + "/" + llm.model, () => {
|
||||
test("Stream Chat works", async () => {
|
||||
let total = "";
|
||||
for await (const chunk of llm.streamChat(
|
||||
|
|
@ -54,62 +69,119 @@ function testLLM(llm: BaseLLM) {
|
|||
expect(completion.length).toBeGreaterThan(0);
|
||||
return;
|
||||
});
|
||||
|
||||
if (testFim) {
|
||||
test("FIM works", async () => {
|
||||
let total = "";
|
||||
for await (const chunk of llm.streamFim(
|
||||
"Hi",
|
||||
"name is ChatGPT.",
|
||||
new AbortController().signal,
|
||||
)) {
|
||||
total += chunk;
|
||||
}
|
||||
|
||||
expect(total.length).toBeGreaterThan(0);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
if (testToolCall) {
|
||||
test("Tool Call works", async () => {
|
||||
let args = "";
|
||||
let isFirstChunk = true;
|
||||
for await (const chunk of llm.streamChat(
|
||||
[{ role: "user", content: "Hi, my name is Nate." }],
|
||||
new AbortController().signal,
|
||||
{
|
||||
tools: [
|
||||
{
|
||||
displayTitle: "Say Hello",
|
||||
function: {
|
||||
name: "say_hello",
|
||||
description: "Say Hello",
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: {
|
||||
type: "string",
|
||||
description: "The name of the person to greet",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
type: "function",
|
||||
wouldLikeTo: "Say hello",
|
||||
readonly: true,
|
||||
},
|
||||
],
|
||||
toolChoice: {
|
||||
type: "function",
|
||||
function: {
|
||||
name: "say_hello",
|
||||
},
|
||||
},
|
||||
},
|
||||
)) {
|
||||
const typedChunk = chunk as AssistantChatMessage;
|
||||
if (!typedChunk.toolCalls) {
|
||||
continue;
|
||||
}
|
||||
const toolCall = typedChunk.toolCalls[0];
|
||||
args += toolCall.function?.arguments ?? "";
|
||||
|
||||
expect(chunk.role).toBe("assistant");
|
||||
expect(chunk.content).toBe("");
|
||||
expect(typedChunk.toolCalls).toHaveLength(1);
|
||||
|
||||
if (isFirstChunk) {
|
||||
isFirstChunk = false;
|
||||
expect(toolCall.id).toBeDefined();
|
||||
expect(toolCall.function!.name).toBe("say_hello");
|
||||
}
|
||||
}
|
||||
|
||||
const parsedArgs = JSON.parse(args);
|
||||
expect(parsedArgs.name).toBe("Nate");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
describe.skip("LLM", () => {
|
||||
// testLLM(
|
||||
// new FreeTrial({
|
||||
// model: "gpt-3.5-turbo",
|
||||
// }),
|
||||
// );
|
||||
// testLLM(
|
||||
// new Anthropic({
|
||||
// model: "claude-2",
|
||||
// apiKey: process.env.ANTHROPIC_API_KEY,
|
||||
// }),
|
||||
// );
|
||||
describe("LLM", () => {
|
||||
testLLM(
|
||||
new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "gpt-3.5-turbo" }),
|
||||
new Anthropic({
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
apiKey: process.env.ANTHROPIC_API_KEY,
|
||||
}),
|
||||
{
|
||||
skip: false,
|
||||
testToolCall: true,
|
||||
},
|
||||
);
|
||||
testLLM(new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "gpt-4o" }), {
|
||||
skip: false,
|
||||
testToolCall: true,
|
||||
});
|
||||
testLLM(
|
||||
new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "o1-preview" }),
|
||||
{ skip: false },
|
||||
);
|
||||
testLLM(new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "o1" }), {
|
||||
skip: false,
|
||||
});
|
||||
testLLM(
|
||||
new Gemini({
|
||||
model: "gemini-2.0-flash-exp",
|
||||
apiKey: process.env.GEMINI_API_KEY,
|
||||
}),
|
||||
{ skip: false },
|
||||
);
|
||||
testLLM(
|
||||
new Mistral({
|
||||
apiKey: process.env.MISTRAL_API_KEY,
|
||||
model: "codestral-latest",
|
||||
}),
|
||||
{ testFim: true, skip: false },
|
||||
);
|
||||
// TODO: Fix Replicate
|
||||
// testLLM(
|
||||
// new Replicate({
|
||||
// apiKey: process.env.REPLICATE_API_KEY,
|
||||
// model: "codellama-7b",
|
||||
// })
|
||||
// );
|
||||
// testLLM(new LMStudio({ model: "codellama-7b" }));
|
||||
// testLLM(new Ollama({ model: "codellama-7b" }));
|
||||
// testLLM(
|
||||
// new Together({
|
||||
// apiKey: process.env.TOGETHER_API_KEY,
|
||||
// model: "codellama-7b",
|
||||
// })
|
||||
// );
|
||||
// testLLM(new LlamaCpp({ model: "deepseek-7b" }));
|
||||
// testLLM(new Llamafile({ model: "mistral-7b" }));
|
||||
// TODO: Test these
|
||||
// testLLM(new TextGenWebUI({ model: "codellama-7b" }));
|
||||
// testLLM(new HuggingFaceTGI({ model: "codellama-7b" }));
|
||||
// testLLM(new HuggingFaceInferenceAPI({ model: "codellama-7b" }));
|
||||
// testLLM(
|
||||
// new Gemini({
|
||||
// model: "gemini-pro",
|
||||
// // model: "chat-bison-001",
|
||||
// apiKey: process.env.GOOGLE_PALM_API_KEY,
|
||||
// })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Gemini({ model: "gemini-pro", apiKey: process.env.GOOGLE_PALM_API_KEY })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Mistral({ apiKey: process.env.MISTRAL_API_KEY, model: "mistral-small" })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Flowise({ apiKey: process.env.FLOWISE_API_KEY, model: "gpt-3.5-turbo" })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Nebius({ apiKey: process.env.NEBIUS_API_KEY, model: "llama3.1-8b" })
|
||||
// );
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,6 +30,12 @@ class Anthropic extends BaseLLM {
|
|||
description: tool.function.description,
|
||||
input_schema: tool.function.parameters,
|
||||
})),
|
||||
tool_choice: options.toolChoice
|
||||
? {
|
||||
type: "tool",
|
||||
name: options.toolChoice.function.name,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
|
||||
return finalOptions;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ChatMessage, CompletionOptions, LLMOptions } from "../../index.js";
|
||||
import { BaseLLM } from "../index.js";
|
||||
|
||||
type MockMessage = ChatMessage | "REPEAT_LAST_MSG";
|
||||
type MockMessage = ChatMessage | "REPEAT_LAST_MSG" | "REPEAT_SYSTEM_MSG";
|
||||
|
||||
class MockLLM extends BaseLLM {
|
||||
public completion: string = "Test Completion";
|
||||
|
|
@ -42,6 +42,13 @@ class MockLLM extends BaseLLM {
|
|||
content: messages[messages.length - 1].content,
|
||||
};
|
||||
break;
|
||||
case "REPEAT_SYSTEM_MSG":
|
||||
yield {
|
||||
role: "assistant",
|
||||
content:
|
||||
messages.find((m) => m.role === "system")?.content || "",
|
||||
};
|
||||
break;
|
||||
default:
|
||||
yield message;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,10 @@ class OpenAI extends BaseLLM {
|
|||
};
|
||||
}
|
||||
|
||||
protected extraBodyProperties(): Record<string, any> {
|
||||
return {};
|
||||
}
|
||||
|
||||
protected getMaxStopWords(): number {
|
||||
const url = new URL(this.apiBase!);
|
||||
|
||||
|
|
@ -150,6 +154,10 @@ class OpenAI extends BaseLLM {
|
|||
finalOptions.messages = formatMessageForO1(finalOptions.messages);
|
||||
}
|
||||
|
||||
if (options.model === "o1") {
|
||||
finalOptions.stream = false;
|
||||
}
|
||||
|
||||
if (options.prediction && this.supportsPrediction(options.model)) {
|
||||
if (finalOptions.presence_penalty) {
|
||||
// prediction doesn't support > 0
|
||||
|
|
@ -241,6 +249,11 @@ class OpenAI extends BaseLLM {
|
|||
body.messages = formatMessageForO1(body.messages);
|
||||
}
|
||||
|
||||
if (body.model === "o1") {
|
||||
// o1 doesn't support streaming
|
||||
body.stream = false;
|
||||
}
|
||||
|
||||
if (body.prediction && this.supportsPrediction(body.model)) {
|
||||
if (body.presence_penalty) {
|
||||
// prediction doesn't support > 0
|
||||
|
|
@ -278,6 +291,7 @@ class OpenAI extends BaseLLM {
|
|||
body: JSON.stringify({
|
||||
...args,
|
||||
stream: true,
|
||||
...this.extraBodyProperties(),
|
||||
}),
|
||||
signal,
|
||||
});
|
||||
|
|
@ -319,7 +333,10 @@ class OpenAI extends BaseLLM {
|
|||
const response = await this.fetch(this._getEndpoint("chat/completions"), {
|
||||
method: "POST",
|
||||
headers: this._getHeaders(),
|
||||
body: JSON.stringify(body),
|
||||
body: JSON.stringify({
|
||||
...body,
|
||||
...this.extraBodyProperties(),
|
||||
}),
|
||||
signal,
|
||||
});
|
||||
|
||||
|
|
@ -358,6 +375,7 @@ class OpenAI extends BaseLLM {
|
|||
presence_penalty: options.presencePenalty,
|
||||
stop: options.stop,
|
||||
stream: true,
|
||||
...this.extraBodyProperties(),
|
||||
}),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
|
@ -404,6 +422,7 @@ class OpenAI extends BaseLLM {
|
|||
body: JSON.stringify({
|
||||
input: chunks,
|
||||
model: this.model,
|
||||
...this.extraBodyProperties(),
|
||||
}),
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.apiKey}`,
|
||||
|
|
|
|||
|
|
@ -10,11 +10,33 @@ class ContinueProxy extends OpenAI {
|
|||
this.apiBase = new URL("openai/v1/", value.controlPlaneProxyUrl).toString();
|
||||
}
|
||||
|
||||
// The apiKey and apiBase are set to the values for the proxy,
|
||||
// but we need to keep track of the actual values that the proxy will use
|
||||
// to call whatever LLM API is chosen
|
||||
private actualApiBase?: string;
|
||||
private actualApiKey?: string;
|
||||
|
||||
constructor(options: LLMOptions) {
|
||||
super(options);
|
||||
this.actualApiBase = options.apiBase;
|
||||
this.actualApiKey = options.apiKey;
|
||||
}
|
||||
|
||||
static providerName = "continue-proxy";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
useLegacyCompletionsEndpoint: false,
|
||||
};
|
||||
|
||||
protected extraBodyProperties(): Record<string, any> {
|
||||
return {
|
||||
continueProperties: {
|
||||
apiKey: this.actualApiKey,
|
||||
apiBase: this.actualApiBase,
|
||||
apiKeySecret: this.apiKeySecret,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected _getHeaders() {
|
||||
const headers: any = super._getHeaders();
|
||||
headers["x-continue-unique-id"] = Telemetry.uniqueId;
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ export function toChatBody(
|
|||
stream: options.stream ?? true,
|
||||
stop: options.stop,
|
||||
prediction: options.prediction,
|
||||
tool_choice: options.toolChoice,
|
||||
};
|
||||
|
||||
if (options.tools?.length) {
|
||||
|
|
|
|||
15
core/package-lock.json
generated
15
core/package-lock.json
generated
|
|
@ -13,7 +13,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.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
@ -3030,18 +3030,19 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@continuedev/config-types": {
|
||||
"version": "1.0.13",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.13.tgz",
|
||||
"integrity": "sha512-5Qmy2x58uhW1GYknypFT/7iwxEJSbt8gMgfQReV7d6xjbJ09ISOTki3hIfCilKrTCo0gIY6pzKEfCoQkUTEi6Q==",
|
||||
"version": "1.0.14",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz",
|
||||
"integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==",
|
||||
"dependencies": {
|
||||
"zod": "^3.23.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@continuedev/config-yaml": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.0.tgz",
|
||||
"integrity": "sha512-NwagzzpnPLbMC3delzFSjWiFv5fp8ReFjdMQF0ko0Xg+U0Myja90k/J7JWGegF/SZMABxc/OJchElJFr58TwGA==",
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.11.tgz",
|
||||
"integrity": "sha512-E3RBQfNEPBGBmlnAbCXgeAasDzTjo4ON/HH0hr5g292i+WdAN3i/omjQ6Iusx00L1Fz7klZGJePZ3GVQKOGEUg==",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"yaml": "^2.6.1",
|
||||
"zod": "^3.23.8"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,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.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { AutocompleteInput } from "../autocomplete/util/types";
|
||||
import { ProfileDescription } from "../config/ConfigHandler";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import type {
|
||||
BrowserSerializedContinueConfig,
|
||||
ChatMessage,
|
||||
|
|
@ -21,7 +22,6 @@ import type {
|
|||
SiteIndexingConfig,
|
||||
ToolCall,
|
||||
} from "../";
|
||||
import { ConfigResult } from "../config/load";
|
||||
|
||||
export type ProtocolGeneratorYield<T> = {
|
||||
done?: boolean;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import type {
|
|||
Problem,
|
||||
Range,
|
||||
RangeInFile,
|
||||
TerminalOptions,
|
||||
Thread,
|
||||
TerminalOptions
|
||||
} from "../";
|
||||
|
||||
export interface GetGhTokenArgs {
|
||||
|
|
@ -29,7 +29,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
showVirtualFile: [{ name: string; content: string }, void];
|
||||
openFile: [{ path: string }, void];
|
||||
openUrl: [string, void];
|
||||
runCommand: [{ command: string, options?: TerminalOptions }, void];
|
||||
runCommand: [{ command: string; options?: TerminalOptions }, void];
|
||||
getSearchResults: [{ query: string }, string];
|
||||
subprocess: [{ command: string; cwd?: string }, [string, string]];
|
||||
saveFile: [{ filepath: string }, void];
|
||||
|
|
@ -72,6 +72,8 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
isTelemetryEnabled: [undefined, boolean];
|
||||
getUniqueId: [undefined, string];
|
||||
getTags: [string, IndexTag[]];
|
||||
readSecrets: [{ keys: string[] }, Record<string, string>];
|
||||
writeSecrets: [{ secrets: Record<string, string> }, void];
|
||||
// end methods from IDE type
|
||||
|
||||
getIdeSettings: [undefined, IdeSettings];
|
||||
|
|
@ -92,7 +94,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
|
||||
getGitHubAuthToken: [GetGhTokenArgs, string | undefined];
|
||||
getControlPlaneSessionInfo: [
|
||||
{ silent: boolean },
|
||||
{ silent: boolean; useOnboarding: boolean },
|
||||
ControlPlaneSessionInfo | undefined,
|
||||
];
|
||||
logoutOfControlPlane: [undefined, void];
|
||||
|
|
|
|||
|
|
@ -29,6 +29,14 @@ export class MessageIde implements IDE {
|
|||
) => void,
|
||||
) {}
|
||||
|
||||
async readSecrets(keys: string[]): Promise<Record<string, string>> {
|
||||
return this.request("readSecrets", { keys });
|
||||
}
|
||||
|
||||
async writeSecrets(secrets: { [key: string]: string }): Promise<void> {
|
||||
return this.request("writeSecrets", { secrets });
|
||||
}
|
||||
|
||||
fileExists(fileUri: string): Promise<boolean> {
|
||||
return this.request("fileExists", { filepath: fileUri });
|
||||
}
|
||||
|
|
@ -152,7 +160,7 @@ export class MessageIde implements IDE {
|
|||
await this.request("openUrl", url);
|
||||
}
|
||||
|
||||
async runCommand(command: string, options?: TerminalOptions): Promise<void> {
|
||||
async runCommand(command: string, options?: TerminalOptions): Promise<void> {
|
||||
await this.request("runCommand", { command, options });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
import { ConfigResult } from "../config/load.js";
|
||||
import { ConfigValidationError } from "../config/validation.js";
|
||||
|
||||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import type {
|
||||
BrowserSerializedContinueConfig,
|
||||
ContextItemWithId,
|
||||
ContextProviderName,
|
||||
ContextSubmenuItem,
|
||||
IndexingProgressUpdate,
|
||||
IndexingStatus,
|
||||
PackageDocsResult,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,13 @@ import { GetGhTokenArgs } from "../protocol/ide.js";
|
|||
|
||||
class FileSystemIde implements IDE {
|
||||
constructor(private readonly workspaceDir: string) {}
|
||||
|
||||
async readSecrets(keys: string[]): Promise<Record<string, string>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
async writeSecrets(secrets: { [key: string]: string }): Promise<void> {}
|
||||
|
||||
showToast(
|
||||
type: ToastType,
|
||||
message: string,
|
||||
|
|
|
|||
|
|
@ -301,11 +301,18 @@ export function getPathToRemoteConfig(remoteConfigServerUrl: string): string {
|
|||
return dir;
|
||||
}
|
||||
|
||||
export function internalBetaPathExists(): boolean {
|
||||
const sPath = path.join(getContinueGlobalPath(), ".internal_beta");
|
||||
export function usePlatformPathExists(): boolean {
|
||||
const sPath = path.join(getContinueGlobalPath(), ".use_platform");
|
||||
return fs.existsSync(sPath);
|
||||
}
|
||||
|
||||
export function readUsePlatform(): string | undefined {
|
||||
const sPath = path.join(getContinueGlobalPath(), ".use_platform");
|
||||
if (fs.existsSync(sPath)) {
|
||||
return fs.readFileSync(sPath, "utf8");
|
||||
}
|
||||
}
|
||||
|
||||
export function getConfigJsonPathForRemote(
|
||||
remoteConfigServerUrl: string,
|
||||
): string {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ We recommend configuring **Llama3.1 8B** as your chat model.
|
|||
{
|
||||
"title": "Llama3.1 8B Instruct",
|
||||
"provider": "vllm",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct"
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"apiBase": "http://<vllm chat endpoint>/v1"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ See also
|
|||
- [JSON Continue Config Reference](/reference)
|
||||
- [YAML Continue Config Reference](/yaml-reference)
|
||||
|
||||
### 1. Create YAML file
|
||||
## Create YAML file
|
||||
|
||||
Create a `config.yaml` file in your Continue Global Directory (`~/.continue` on Mac, `%USERPROFILE%\.continue`) alongside your current `config.json` file. If a `config.yaml` file is present, it will be loaded instead of `config.json`.
|
||||
|
||||
|
|
@ -25,14 +25,14 @@ name: my-configuration
|
|||
version: 0.0.1
|
||||
```
|
||||
|
||||
### 2. Map Models
|
||||
### Models
|
||||
|
||||
Add all model configurations in `config.json`, including models in `models`, `tabAutocompleteModel`, `embeddingsProvider`, and `reranker`, to the `models` section of your new YAML config file. A new `roles` YAML field specifies which roles a model can be used for, with possible values `chat`, `autocomplete`, `embed`, `rerank`, `edit`, `apply`, `summarize`.
|
||||
|
||||
- `models` in config should have `roles: chat`
|
||||
- `tabAutocompleteModel`(s) in config should have `roles: autocomplete`
|
||||
- `embeddingsProvider` in config should have `roles: embed`
|
||||
- `reranker` in config should have `roles: rerank`
|
||||
- `models` in config should have `roles: [chat]`
|
||||
- `tabAutocompleteModel`(s) in config should have `roles: [autocomplete]`
|
||||
- `embeddingsProvider` in config should have `roles: [embed]`
|
||||
- `reranker` in config should have `roles: [rerank]`
|
||||
- `experimental.modelRoles` is replaced by simply adding roles to the model
|
||||
- `inlineEdit` -> e.g. `roles: [chat, edit]`
|
||||
- `applyCodeBlock` -> e.g. `roles: [chat, apply]`
|
||||
|
|
@ -103,46 +103,56 @@ models:
|
|||
- name: GPT-4
|
||||
provider: openai
|
||||
model: gpt-4
|
||||
apiKey: <API_KEY>
|
||||
defaultCompletionOptions:
|
||||
temperature: 0.5
|
||||
maxTokens: 2000'
|
||||
roles: [chat, edit]
|
||||
apiKey: <API_KEY>
|
||||
maxTokens: 2000
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
|
||||
- name: My Voyage Reranker
|
||||
provider: voyage
|
||||
roles: rerank
|
||||
apiKey: <API_KEY>
|
||||
roles:
|
||||
- rerank
|
||||
|
||||
- name: My Starcoder
|
||||
provider: ollama
|
||||
model: starcoder2:3b
|
||||
roles: autocomplete
|
||||
roles:
|
||||
- autocomplete
|
||||
|
||||
- name: My Ada Embedder
|
||||
provider: openai
|
||||
roles: embed
|
||||
apiKey: <API_KEY>
|
||||
roles:
|
||||
- embed
|
||||
|
||||
- name: Ollama Autodetect
|
||||
provider: ollama
|
||||
model: AUTODETECT
|
||||
|
||||
- name: My Open AI Compatible Model - Apply
|
||||
provider: openai
|
||||
apiBase: http://3.3.3.3/v1
|
||||
model: my-openai-compatible-model
|
||||
apiBase: http://3.3.3.3/v1
|
||||
requestOptions:
|
||||
headers:
|
||||
X-Auth-Token: <API_KEY>
|
||||
roles: [chat, apply]
|
||||
roles:
|
||||
- chat
|
||||
- apply
|
||||
```
|
||||
|
||||
Note that the `repoMapFileSelection` experimental model role has been deprecated.
|
||||
|
||||
### 3. Map Context Providers
|
||||
### Context Providers
|
||||
|
||||
The JSON `contextProviders` and `docs` fields are replaced by the YAML `context` array.
|
||||
The JSON `contextProviders` field is replaced by the YAML `context` array.
|
||||
|
||||
- JSON `name` maps to `uses`
|
||||
- JSON `params` map to `with`
|
||||
- Use multiple `docs` entries rather than the array of docs in the JSON format
|
||||
<!-- TODO is this docs not correct ?^ -->
|
||||
|
||||
**Before**
|
||||
|
||||
|
|
@ -150,10 +160,7 @@ The JSON `contextProviders` and `docs` fields are replaced by the YAML `context`
|
|||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "docs",
|
||||
"params": {
|
||||
"startUrl": "https://docs.continue.dev/intro"
|
||||
}
|
||||
"name": "docs"
|
||||
},
|
||||
{
|
||||
"name": "codebase",
|
||||
|
|
@ -166,7 +173,86 @@ The JSON `contextProviders` and `docs` fields are replaced by the YAML `context`
|
|||
"name": "diff",
|
||||
"params": {}
|
||||
}
|
||||
],
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```yaml title="config.yaml"
|
||||
context:
|
||||
- uses: docs
|
||||
|
||||
- uses: codebase
|
||||
with:
|
||||
nRetrieve: 30
|
||||
nFinal: 3
|
||||
|
||||
- uses: diff
|
||||
```
|
||||
|
||||
### System Message
|
||||
|
||||
The `systemMessage` property has been replaced with a `rules` property that takes an array of strings.
|
||||
|
||||
**Before**
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"systemMessage": "Always give concise responses"
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```yaml title="config.yaml"
|
||||
rules:
|
||||
- Always give concise responses
|
||||
```
|
||||
|
||||
### Prompts
|
||||
|
||||
Rather than with `customCommands`, you can now use the `prompts` field to define custom prompts.
|
||||
|
||||
**Before**
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"customCommands": [
|
||||
{
|
||||
"name": "check",
|
||||
"description": "Check for mistakes in my code",
|
||||
"prompt": "{{{ input }}}\n\nPlease read the highlighted code and check for any mistakes. You should look for the following, and be extremely vigilant:\n- Syntax errors\n- Logic errors\n- Security vulnerabilities\n- Performance issues\n- Anything else that looks wrong\n\nOnce you find an error, please explain it as clearly as possible, but without using extra words. For example, instead of saying 'I think there is a syntax error on line 5', you should say 'Syntax error on line 5'. Give your answer as one bullet point per mistake found."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```yaml title="config.yaml"
|
||||
prompts:
|
||||
- name: check
|
||||
description: Check for mistakes in my code
|
||||
prompt: |
|
||||
Please read the highlighted code and check for any mistakes. You should look for the following, and be extremely vigilant:
|
||||
- Syntax errors
|
||||
- Logic errors
|
||||
- Security vulnerabilities
|
||||
- Performance issues
|
||||
- Anything else that looks wrong
|
||||
|
||||
Once you find an error, please explain it as clearly as possible, but without using extra words. For example, instead of saying 'I think there is a syntax error on line 5', you should say 'Syntax error on line 5'. Give your answer as one bullet point per mistake found.
|
||||
```
|
||||
|
||||
### Documentation
|
||||
|
||||
Documentation is largely the same, but the `title` property has been replaced with `name`. The `startUrl`, `rootUrl`, and `faviconUrl` properties remain.
|
||||
|
||||
**Before**
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"docs": [
|
||||
{
|
||||
"startUrl": "https://docs.nestjs.com/",
|
||||
|
|
@ -183,23 +269,15 @@ The JSON `contextProviders` and `docs` fields are replaced by the YAML `context`
|
|||
**After**
|
||||
|
||||
```yaml title="config.yaml"
|
||||
context:
|
||||
- uses: docs
|
||||
with:
|
||||
startUrl: https://docs.nestjs.com/
|
||||
title: nest.js
|
||||
- uses: docs
|
||||
with:
|
||||
startUrl: https://mysite.com/docs/
|
||||
title: My Site
|
||||
- uses: codebase
|
||||
with:
|
||||
nRetrieve: 30
|
||||
nFinal: 3
|
||||
- uses: diff
|
||||
docs:
|
||||
- name: nest.js
|
||||
startUrl: https://docs.nestjs.com/
|
||||
|
||||
- name: My site
|
||||
startUrl: https://mysite.com/docs/
|
||||
```
|
||||
|
||||
## Map MCP Servers
|
||||
### MCP Servers
|
||||
|
||||
<!-- TODO this is definitely wrong -->
|
||||
|
||||
|
|
@ -220,7 +298,10 @@ context:
|
|||
"transport": {
|
||||
"type": "stdio",
|
||||
"command": "uvx",
|
||||
"args": ["mcp-server-sqlite", "--db-path", "/Users/NAME/test.db"]
|
||||
"args": ["mcp-server-sqlite", "--db-path", "/Users/NAME/test.db"],
|
||||
"env": {
|
||||
"KEY": "<VALUE>"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -238,13 +319,15 @@ mcpServers:
|
|||
- mcp-server-sqlite
|
||||
- --db-path
|
||||
- /Users/NAME/test.db
|
||||
env:
|
||||
KEY: <VALUE>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Deprecated configuration options
|
||||
|
||||
The following top-level fields from `config.json` have been deprecated
|
||||
The following top-level fields from `config.json` have been deprecated. Most UI-related and user-specific options will move into a settings page in the UI
|
||||
|
||||
- Slash commands (JSON `slashCommands`)
|
||||
- top-level `requestOptions`
|
||||
|
|
@ -257,7 +340,6 @@ The following top-level fields from `config.json` have been deprecated
|
|||
- `allowAnonymousTelemetry` (moved to user/IDE level)
|
||||
- `ui` (moved to user/IDE level)
|
||||
- `userToken`
|
||||
- `systemMessage`
|
||||
- `disableIndexing` (moved to user/IDE level)
|
||||
|
||||
## New Configuration options
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ The top-level properties in the `config.yaml` configuration file are:
|
|||
- [`models`](#models)
|
||||
- [`context`](#context)
|
||||
- [`rules`](#rules)
|
||||
- [`prompts`](#prompts)
|
||||
- [`docs`](#docs)
|
||||
<!-- - [`data`](#data) -->
|
||||
<!-- - [`tools`](#tools) -->
|
||||
|
|
@ -153,6 +154,23 @@ rules:
|
|||
|
||||
---
|
||||
|
||||
### `prompts`
|
||||
|
||||
A list of custom prompts that can be invoked from the chat window. Each prompt has a name, description, and the actual prompt text.
|
||||
|
||||
```yaml title="config.yaml"
|
||||
prompts:
|
||||
- name: check
|
||||
description: Check for mistakes in my code
|
||||
prompt: |
|
||||
Please read the highlighted code and check for any mistakes. You should look for the following, and be extremely vigilant:
|
||||
- Syntax errors
|
||||
- Logic errors
|
||||
- Security vulnerabilities
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `docs`
|
||||
|
||||
List of documentation sites to index.
|
||||
|
|
@ -177,9 +195,7 @@ docs:
|
|||
|
||||
---
|
||||
|
||||
### `tools`
|
||||
|
||||
<!-- TODO how does this actually work -->
|
||||
<!-- ### `tools`
|
||||
|
||||
The `tools` section specifies external tools or APIs that can be used within your configuration.
|
||||
|
||||
|
|
@ -196,7 +212,7 @@ tools:
|
|||
apiKey: YOUR_API_KEY
|
||||
```
|
||||
|
||||
---
|
||||
--- -->
|
||||
|
||||
### `mcpServers`
|
||||
|
||||
|
|
@ -248,6 +264,7 @@ Putting it all together, here's a complete example of a `config.yaml` configurat
|
|||
|
||||
```yaml title="config.yaml"
|
||||
name: MyProject
|
||||
version: 0.0.1
|
||||
|
||||
models:
|
||||
- name: GPT-4
|
||||
|
|
@ -262,6 +279,7 @@ models:
|
|||
requestOptions:
|
||||
headers:
|
||||
Authorization: Bearer YOUR_OPENAI_API_KEY
|
||||
|
||||
- name: Ollama Starcoder
|
||||
provider: ollama
|
||||
model: starcoder
|
||||
|
|
@ -272,17 +290,26 @@ models:
|
|||
stop:
|
||||
- "\n"
|
||||
|
||||
rules:
|
||||
- Give concise responses
|
||||
- Always assume TypeScript rather than JavaScript
|
||||
|
||||
prompts:
|
||||
- name: test
|
||||
description: Unit test a function
|
||||
prompt: |
|
||||
Please write a complete suite of unit tests for this function. You should use the Jest testing framework. The tests should cover all possible edge cases and should be as thorough as possible. You should also include a description of each test case.
|
||||
|
||||
context:
|
||||
- uses: diff
|
||||
- uses: file
|
||||
- uses: codebase
|
||||
- uses: code
|
||||
- uses: docs
|
||||
with:
|
||||
startUrl: https://docs.example.com/introduction
|
||||
maxDepth: 3
|
||||
|
||||
tools:
|
||||
- url: https://api.exampletool.com
|
||||
apiKey: YOUR_TOOL_API_KEY
|
||||
|
||||
mcpServers:
|
||||
- name: DevServer
|
||||
command: npm
|
||||
|
|
|
|||
4
extensions/vscode/.gitignore
vendored
4
extensions/vscode/.gitignore
vendored
|
|
@ -23,4 +23,6 @@ e2e/.test-extensions
|
|||
e2e/storage
|
||||
e2e/vsix
|
||||
e2e/test-continue/*
|
||||
!e2e/test-continue/config.json
|
||||
!e2e/test-continue/config.json
|
||||
e2e/test-continue-yaml/*
|
||||
!e2e/test-continue-yaml/config.yaml
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { By, WebDriver, WebView } from "vscode-extension-tester";
|
||||
|
||||
import { SelectorUtils } from "./SelectorUtils";
|
||||
|
||||
export class GUISelectors {
|
||||
|
|
@ -41,6 +42,24 @@ export class GUISelectors {
|
|||
return SelectorUtils.getElementByDataTestId(view, "model-select-button");
|
||||
}
|
||||
|
||||
public static getFirstContextProviderDropdownItem(view: WebView) {
|
||||
return SelectorUtils.getElementByDataTestId(
|
||||
view,
|
||||
"context-provider-dropdown-item",
|
||||
);
|
||||
}
|
||||
|
||||
public static getContextItemsPeek(view: WebView) {
|
||||
return SelectorUtils.getElementByDataTestId(view, "context-items-peek");
|
||||
}
|
||||
|
||||
public static getFirstContextItemsPeekItem(view: WebView) {
|
||||
return SelectorUtils.getElementByDataTestId(
|
||||
view,
|
||||
"context-items-peek-item",
|
||||
);
|
||||
}
|
||||
|
||||
public static getNthHistoryTableRow(view: WebView, index: number) {
|
||||
return SelectorUtils.getElementByDataTestId(view, `history-row-${index}`);
|
||||
}
|
||||
|
|
|
|||
76
extensions/vscode/e2e/test-continue-yaml/config.yaml
Normal file
76
extensions/vscode/e2e/test-continue-yaml/config.yaml
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
name: Test Config
|
||||
version: 0.0.1
|
||||
|
||||
rules:
|
||||
- TEST_SYS_MSG
|
||||
|
||||
models:
|
||||
- name: TEST LLM
|
||||
provider: test
|
||||
model: this field is not used
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
- apply
|
||||
- autocomplete
|
||||
|
||||
- name: Mock
|
||||
provider: mock
|
||||
model: this field is not used
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
- apply
|
||||
|
||||
- name: TOOL MOCK LLM
|
||||
provider: mock
|
||||
model: claude-3-5-sonnet-latest
|
||||
requestOptions:
|
||||
extraBodyProperties:
|
||||
chatStream:
|
||||
- - role: assistant
|
||||
content: "I'm going to call a tool:"
|
||||
- role: assistant
|
||||
content: ""
|
||||
toolCalls:
|
||||
- id: test_id
|
||||
type: function
|
||||
function:
|
||||
name: builtin_exact_search
|
||||
arguments: '{"query": "test query"}'
|
||||
- REPEAT_LAST_MSG
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
- apply
|
||||
|
||||
- name: SYSTEM MESSAGE MOCK LLM
|
||||
provider: mock
|
||||
model: claude-3-5-sonnet-latest
|
||||
requestOptions:
|
||||
extraBodyProperties:
|
||||
chatStream:
|
||||
- - REPEAT_SYSTEM_MSG
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
- apply
|
||||
|
||||
- name: LAST MESSAGE MOCK LLM
|
||||
provider: mock
|
||||
model: claude-3-5-sonnet-latest
|
||||
requestOptions:
|
||||
extraBodyProperties:
|
||||
chatStream:
|
||||
- - REPEAT_LAST_MSG
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
- apply
|
||||
|
||||
context:
|
||||
- uses: docs
|
||||
- uses: diff
|
||||
- uses: url
|
||||
- uses: folder
|
||||
- uses: terminal
|
||||
|
|
@ -44,8 +44,29 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"provider": "mock",
|
||||
"title": "SYSTEM MESSAGE MOCK LLM",
|
||||
"model": "claude-3-5-sonnet-latest",
|
||||
"requestOptions": {
|
||||
"extraBodyProperties": {
|
||||
"chatStream": [["REPEAT_SYSTEM_MSG"]]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"provider": "mock",
|
||||
"title": "LAST MESSAGE MOCK LLM",
|
||||
"model": "claude-3-5-sonnet-latest",
|
||||
"requestOptions": {
|
||||
"extraBodyProperties": {
|
||||
"chatStream": [["REPEAT_LAST_MSG"]]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"systemMessage": "TEST_SYS_MSG",
|
||||
"analytics": {
|
||||
"provider": "continue-proxy"
|
||||
},
|
||||
|
|
@ -69,6 +90,9 @@
|
|||
},
|
||||
{
|
||||
"name": "folder"
|
||||
},
|
||||
{
|
||||
"name": "terminal"
|
||||
}
|
||||
],
|
||||
"docs": []
|
||||
|
|
|
|||
|
|
@ -207,6 +207,53 @@ describe("GUI Test", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Context providers", () => {
|
||||
it("should successfully use the terminal context provider", async () => {
|
||||
await GUIActions.selectModelFromDropdown(view, "LAST MESSAGE MOCK LLM");
|
||||
|
||||
// Enter just the context provider in the input and send
|
||||
const [messageInput] = await GUISelectors.getMessageInputFields(view);
|
||||
await messageInput.sendKeys("@");
|
||||
await messageInput.sendKeys("terminal");
|
||||
await messageInput.sendKeys(Key.ENTER);
|
||||
await messageInput.sendKeys(Key.ENTER);
|
||||
|
||||
// Open the context items peek
|
||||
const contextItemsPeek = await GUISelectors.getContextItemsPeek(view);
|
||||
await contextItemsPeek.click();
|
||||
|
||||
await TestUtils.waitForSuccess(async () => {
|
||||
const firstContextItemInPeek =
|
||||
await GUISelectors.getFirstContextItemsPeekItem(view);
|
||||
await firstContextItemInPeek.click();
|
||||
|
||||
// Check that item is there with correct name
|
||||
const description = await firstContextItemInPeek.getText();
|
||||
expect(description).to.include("Terminal");
|
||||
});
|
||||
|
||||
// Check that the contents match what we expect (repeated back by the mock LLM)
|
||||
await TestUtils.waitForSuccess(() => {
|
||||
return GUISelectors.getThreadMessageByText(
|
||||
view,
|
||||
"Current terminal contents:",
|
||||
);
|
||||
});
|
||||
}).timeout(DEFAULT_TIMEOUT.MD);
|
||||
});
|
||||
|
||||
describe("Repeat back the system message", () => {
|
||||
it("should repeat back the system message", async () => {
|
||||
await GUIActions.selectModelFromDropdown(view, "SYSTEM MESSAGE MOCK LLM");
|
||||
const [messageInput] = await GUISelectors.getMessageInputFields(view);
|
||||
await messageInput.sendKeys("Hello");
|
||||
await messageInput.sendKeys(Key.ENTER);
|
||||
await TestUtils.waitForSuccess(() =>
|
||||
GUISelectors.getThreadMessageByText(view, "TEST_SYS_MSG"),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Chat Paths", () => {
|
||||
it("Send many messages → chat auto scrolls → go to history → open previous chat → it is scrolled to the bottom", async () => {
|
||||
for (let i = 0; i <= 20; i++) {
|
||||
|
|
|
|||
6
extensions/vscode/package-lock.json
generated
6
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.251",
|
||||
"version": "0.9.252",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.251",
|
||||
"version": "0.9.252",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
|
|
@ -106,7 +106,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.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "0.9.251",
|
||||
"version": "0.9.252",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
@ -628,7 +628,8 @@
|
|||
"e2e:all": "npm run e2e:build && npm run e2e:compile && npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode && npm run e2e:sign-vscode && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:install-extensions && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test && npm run e2e:clean",
|
||||
"e2e:quick": "npm run e2e:compile && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test && npm run e2e:clean",
|
||||
"e2e:ci:download": "npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode",
|
||||
"e2e:ci:run": "npm run e2e:compile && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:install-extensions && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test"
|
||||
"e2e:ci:run": "npm run e2e:compile && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:install-extensions && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test",
|
||||
"e2e:ci:run-yaml": "npm run e2e:compile && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:install-extensions && CONTINUE_GLOBAL_DIR=e2e/test-continue-yaml npm run e2e:test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.6.4",
|
||||
|
|
|
|||
|
|
@ -28,15 +28,41 @@ import type {
|
|||
TerminalOptions,
|
||||
Thread,
|
||||
} from "core";
|
||||
import { SecretStorage } from "./stubs/SecretStorage";
|
||||
|
||||
class VsCodeIde implements IDE {
|
||||
ideUtils: VsCodeIdeUtils;
|
||||
secretStorage: SecretStorage;
|
||||
|
||||
constructor(
|
||||
private readonly vscodeWebviewProtocolPromise: Promise<VsCodeWebviewProtocol>,
|
||||
private readonly context: vscode.ExtensionContext,
|
||||
) {
|
||||
this.ideUtils = new VsCodeIdeUtils();
|
||||
this.secretStorage = new SecretStorage(context);
|
||||
}
|
||||
|
||||
async readSecrets(keys: string[]): Promise<Record<string, string>> {
|
||||
const secretValuePromises = keys.map((key) => this.secretStorage.get(key));
|
||||
const secretValues = await Promise.all(secretValuePromises);
|
||||
|
||||
return keys.reduce(
|
||||
(acc, key, index) => {
|
||||
if (secretValues[index] === undefined) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
acc[key] = secretValues[index];
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, string>,
|
||||
);
|
||||
}
|
||||
|
||||
async writeSecrets(secrets: { [key: string]: string }): Promise<void> {
|
||||
for (const [key, value] of Object.entries(secrets)) {
|
||||
await this.secretStorage.store(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
async fileExists(uri: string): Promise<boolean> {
|
||||
|
|
@ -399,17 +425,22 @@ class VsCodeIde implements IDE {
|
|||
);
|
||||
}
|
||||
|
||||
async runCommand(command: string, options: TerminalOptions = {reuseTerminal: true}): Promise<void> {
|
||||
async runCommand(
|
||||
command: string,
|
||||
options: TerminalOptions = { reuseTerminal: true },
|
||||
): Promise<void> {
|
||||
let terminal: vscode.Terminal | undefined;
|
||||
if (vscode.window.terminals.length && options.reuseTerminal) {
|
||||
if (options.terminalName) {
|
||||
terminal = vscode.window.terminals.find(t => t?.name === options.terminalName);
|
||||
terminal = vscode.window.terminals.find(
|
||||
(t) => t?.name === options.terminalName,
|
||||
);
|
||||
} else {
|
||||
terminal = vscode.window.activeTerminal ?? vscode.window.terminals[0];
|
||||
}
|
||||
}
|
||||
|
||||
if( !terminal) {
|
||||
if (!terminal) {
|
||||
terminal = vscode.window.createTerminal(options?.terminalName);
|
||||
}
|
||||
terminal.show();
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ export class VsCodeExtension {
|
|||
const result = await this.configHandler.getSerializedConfig();
|
||||
this.sidebar.webviewProtocol?.request("configUpdate", {
|
||||
result,
|
||||
profileId: this.configHandler.currentProfile.profileId,
|
||||
profileId: this.configHandler.currentProfile.profileDescription.id,
|
||||
});
|
||||
|
||||
this.tabAutocompleteModel.clearLlm();
|
||||
|
|
@ -301,7 +301,7 @@ export class VsCodeExtension {
|
|||
true,
|
||||
);
|
||||
|
||||
const sessionInfo = await getControlPlaneSessionInfo(true);
|
||||
const sessionInfo = await getControlPlaneSessionInfo(true, false);
|
||||
this.webviewProtocolPromise.then(async (webviewProtocol) => {
|
||||
void webviewProtocol.request("didChangeControlPlaneSessionInfo", {
|
||||
sessionInfo,
|
||||
|
|
|
|||
|
|
@ -446,7 +446,10 @@ export class VsCodeMessenger {
|
|||
ide.getGitHubAuthToken(msg.data),
|
||||
);
|
||||
this.onWebviewOrCore("getControlPlaneSessionInfo", async (msg) => {
|
||||
return getControlPlaneSessionInfo(msg.data.silent);
|
||||
return getControlPlaneSessionInfo(
|
||||
msg.data.silent,
|
||||
msg.data.useOnboarding,
|
||||
);
|
||||
});
|
||||
this.onWebviewOrCore("logoutOfControlPlane", async (msg) => {
|
||||
const sessions = await this.workOsAuthProvider.getSessions();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
import crypto from "crypto";
|
||||
|
||||
import { ControlPlaneSessionInfo } from "core/control-plane/client";
|
||||
import { controlPlaneEnv } from "core/control-plane/env";
|
||||
import fetch from "node-fetch";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import {
|
||||
|
|
@ -16,6 +20,7 @@ import {
|
|||
} from "vscode";
|
||||
|
||||
import { PromiseAdapter, promiseFromEvent } from "./promiseUtils";
|
||||
import { SecretStorage } from "./SecretStorage";
|
||||
|
||||
const AUTH_NAME = "Continue";
|
||||
|
||||
|
|
@ -26,14 +31,6 @@ class UriEventHandler extends EventEmitter<Uri> implements UriHandler {
|
|||
this.fire(uri);
|
||||
}
|
||||
}
|
||||
|
||||
import { ControlPlaneSessionInfo } from "core/control-plane/client";
|
||||
import { controlPlaneEnv } from "core/control-plane/env";
|
||||
|
||||
import crypto from "crypto";
|
||||
|
||||
import { SecretStorage } from "./SecretStorage";
|
||||
|
||||
// Function to generate a random string of specified length
|
||||
function generateRandomString(length: number): string {
|
||||
const possibleCharacters =
|
||||
|
|
@ -163,12 +160,6 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
|||
}
|
||||
|
||||
get ideRedirectUri() {
|
||||
const publisher = this.context.extension.packageJSON.publisher;
|
||||
const name = this.context.extension.packageJSON.name;
|
||||
return `${env.uriScheme}://${publisher}.${name}`;
|
||||
}
|
||||
|
||||
get redirectUri() {
|
||||
if (
|
||||
env.uriScheme === "vscode-insiders" ||
|
||||
env.uriScheme === "vscode" ||
|
||||
|
|
@ -179,6 +170,18 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
|||
url.pathname = `/auth/${env.uriScheme}-redirect`;
|
||||
return url.toString();
|
||||
}
|
||||
const publisher = this.context.extension.packageJSON.publisher;
|
||||
const name = this.context.extension.packageJSON.name;
|
||||
return `${env.uriScheme}://${publisher}.${name}`;
|
||||
}
|
||||
|
||||
public static useOnboardingUri: boolean = false;
|
||||
get redirectUri() {
|
||||
if (WorkOsAuthProvider.useOnboardingUri) {
|
||||
const url = new URL(controlPlaneEnv.APP_URL);
|
||||
url.pathname = `/onboarding/redirect/${env.uriScheme}`;
|
||||
return url.toString();
|
||||
}
|
||||
return this.ideRedirectUri;
|
||||
}
|
||||
|
||||
|
|
@ -407,8 +410,9 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
|||
try {
|
||||
return await Promise.race([
|
||||
codeExchangePromise.promise,
|
||||
new Promise<string>((_, reject) =>
|
||||
setTimeout(() => reject("Cancelled"), 15 * 60 * 1_000),
|
||||
new Promise<string>(
|
||||
(_, reject) =>
|
||||
setTimeout(() => reject("Cancelled"), 60 * 60 * 1_000), // 60min timeout
|
||||
),
|
||||
promiseFromEvent<any, any>(
|
||||
token.onCancellationRequested,
|
||||
|
|
@ -488,20 +492,29 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
|||
|
||||
export async function getControlPlaneSessionInfo(
|
||||
silent: boolean,
|
||||
useOnboarding: boolean,
|
||||
): Promise<ControlPlaneSessionInfo | undefined> {
|
||||
const session = await authentication.getSession(
|
||||
controlPlaneEnv.AUTH_TYPE,
|
||||
[],
|
||||
silent ? { silent: true } : { createIfNone: true },
|
||||
);
|
||||
if (!session) {
|
||||
return undefined;
|
||||
try {
|
||||
if (useOnboarding) {
|
||||
WorkOsAuthProvider.useOnboardingUri = true;
|
||||
}
|
||||
|
||||
const session = await authentication.getSession(
|
||||
controlPlaneEnv.AUTH_TYPE,
|
||||
[],
|
||||
silent ? { silent: true } : { createIfNone: true },
|
||||
);
|
||||
if (!session) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
accessToken: session.accessToken,
|
||||
account: {
|
||||
id: session.account.id,
|
||||
label: session.account.label,
|
||||
},
|
||||
};
|
||||
} finally {
|
||||
WorkOsAuthProvider.useOnboardingUri = false;
|
||||
}
|
||||
return {
|
||||
accessToken: session.accessToken,
|
||||
account: {
|
||||
id: session.account.id,
|
||||
label: session.account.label,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
21
gui/package-lock.json
generated
21
gui/package-lock.json
generated
|
|
@ -7,7 +7,7 @@
|
|||
"name": "gui",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-yaml": "^1.0.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@headlessui/react": "^1.7.17",
|
||||
"@heroicons/react": "^2.0.18",
|
||||
"@reduxjs/toolkit": "^2.3.0",
|
||||
|
|
@ -108,7 +108,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.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
@ -547,11 +547,20 @@
|
|||
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@continuedev/config-yaml": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.0.tgz",
|
||||
"integrity": "sha512-NwagzzpnPLbMC3delzFSjWiFv5fp8ReFjdMQF0ko0Xg+U0Myja90k/J7JWGegF/SZMABxc/OJchElJFr58TwGA==",
|
||||
"node_modules/@continuedev/config-types": {
|
||||
"version": "1.0.14",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz",
|
||||
"integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==",
|
||||
"dependencies": {
|
||||
"zod": "^3.23.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@continuedev/config-yaml": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.11.tgz",
|
||||
"integrity": "sha512-E3RBQfNEPBGBmlnAbCXgeAasDzTjo4ON/HH0hr5g292i+WdAN3i/omjQ6Iusx00L1Fz7klZGJePZ3GVQKOGEUg==",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"yaml": "^2.6.1",
|
||||
"zod": "^3.23.8"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
"test:watch": "vitest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@continuedev/config-yaml": "^1.0.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@headlessui/react": "^1.7.17",
|
||||
"@heroicons/react": "^2.0.18",
|
||||
"@reduxjs/toolkit": "^2.3.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import { ChevronUpDownIcon } from "@heroicons/react/24/outline";
|
||||
import { Fragment, useContext } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
Button,
|
||||
|
|
@ -9,10 +10,9 @@ import {
|
|||
vscListActiveBackground,
|
||||
vscListActiveForeground,
|
||||
} from ".";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { useAuth } from "../context/Auth";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { setSelectedProfileId } from "../redux/slices/sessionSlice";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setDialogMessage, setShowDialog } from "../redux/slices/uiSlice";
|
||||
|
||||
const StyledListboxOption = styled(Listbox.Option)<{ selected: boolean }>`
|
||||
|
|
@ -46,7 +46,7 @@ export default function AccountDialog() {
|
|||
<span className="text-lightgray mb-4 block text-center">
|
||||
Signed out
|
||||
</span>
|
||||
<Button className="w-full" onClick={login}>
|
||||
<Button className="w-full" onClick={() => login(false)}>
|
||||
Sign in
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
import { XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import { useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import { CloseButton, defaultBorderRadius, vscInputBackground } from "../..";
|
||||
import { getLocalStorage, setLocalStorage } from "../../../util/localStorage";
|
||||
import Alert from "../../gui/Alert";
|
||||
import { TabTitle } from "../components/OnboardingCardTabs";
|
||||
import { useOnboardingCard } from "../hooks";
|
||||
import OnboardingLocalTab from "../tabs/OnboardingLocalTab";
|
||||
import MainTab from "./tabs/main";
|
||||
|
||||
const StyledCard = styled.div`
|
||||
margin: auto;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
background-color: ${vscInputBackground};
|
||||
box-shadow:
|
||||
0 20px 25px -5px rgb(0 0 0 / 0.1),
|
||||
0 8px 10px -6px rgb(0 0 0 / 0.1);
|
||||
`;
|
||||
|
||||
export interface OnboardingCardState {
|
||||
show?: boolean;
|
||||
activeTab?: TabTitle;
|
||||
}
|
||||
|
||||
export function PlatformOnboardingCard() {
|
||||
const onboardingCard = useOnboardingCard();
|
||||
|
||||
if (getLocalStorage("onboardingStatus") === undefined) {
|
||||
setLocalStorage("onboardingStatus", "Started");
|
||||
}
|
||||
|
||||
const [currentTab, setCurrentTab] = useState<"main" | "local">("main");
|
||||
|
||||
return (
|
||||
<StyledCard className="xs:py-4 xs:px-4 relative px-2 py-3">
|
||||
<CloseButton onClick={onboardingCard.close}>
|
||||
<XMarkIcon className="mt-1.5 hidden h-5 w-5 hover:brightness-125 sm:flex" />
|
||||
</CloseButton>
|
||||
<div className="content py-4">
|
||||
<div className="flex h-full w-full items-center justify-center">
|
||||
{currentTab === "main" ? (
|
||||
<MainTab onRemainLocal={() => setCurrentTab("local")} />
|
||||
) : (
|
||||
<div className="mt-4">
|
||||
<Alert type="info">
|
||||
By choosing this option, Continue will be configured by a local{" "}
|
||||
<code>config.yaml</code> file. If you're just looking to use
|
||||
Ollama and still want to manage your configuration through
|
||||
Continue, click{" "}
|
||||
<a href="#" onClick={() => setCurrentTab("main")}>
|
||||
here
|
||||
</a>
|
||||
</Alert>
|
||||
|
||||
<OnboardingLocalTab />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</StyledCard>
|
||||
);
|
||||
}
|
||||
26
gui/src/components/OnboardingCard/platform/tabs/local.tsx
Normal file
26
gui/src/components/OnboardingCard/platform/tabs/local.tsx
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { useAuth } from "../../../../context/Auth";
|
||||
import ContinueLogo from "../../../gui/ContinueLogo";
|
||||
import { useOnboardingCard } from "../../hooks";
|
||||
|
||||
export default function LocalTab() {
|
||||
const onboardingCard = useOnboardingCard();
|
||||
const auth = useAuth();
|
||||
|
||||
return (
|
||||
<div className="xs:px-0 flex w-full max-w-full flex-col items-center justify-center px-4 text-center">
|
||||
<div className="xs:flex hidden">
|
||||
<ContinueLogo height={75} />
|
||||
</div>
|
||||
|
||||
<p className="xs:w-3/4 w-full text-sm">
|
||||
Log in to quickly build your first custom AI code assistant
|
||||
</p>
|
||||
|
||||
{/* <p className="xs:w-3/4 w-full text-sm">
|
||||
To prevent abuse, we'll ask you to sign in to GitHub.
|
||||
</p> */}
|
||||
|
||||
<div className="mt-4 w-full"></div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
49
gui/src/components/OnboardingCard/platform/tabs/main.tsx
Normal file
49
gui/src/components/OnboardingCard/platform/tabs/main.tsx
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { ChevronRightIcon } from "@heroicons/react/24/outline";
|
||||
import { Button, ButtonSubtext } from "../../..";
|
||||
import { useAuth } from "../../../../context/Auth";
|
||||
import ContinueLogo from "../../../gui/ContinueLogo";
|
||||
import { useOnboardingCard } from "../../hooks";
|
||||
|
||||
export default function MainTab({
|
||||
onRemainLocal,
|
||||
}: {
|
||||
onRemainLocal: () => void;
|
||||
}) {
|
||||
const onboardingCard = useOnboardingCard();
|
||||
const auth = useAuth();
|
||||
|
||||
function onGetStarted() {
|
||||
auth.login(true).then((success) => {
|
||||
if (success) {
|
||||
onboardingCard.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="xs:px-0 flex w-full max-w-full flex-col items-center justify-center px-4 text-center">
|
||||
<div className="xs:flex hidden">
|
||||
<ContinueLogo height={75} />
|
||||
</div>
|
||||
|
||||
<p className="xs:w-3/4 w-full text-sm">
|
||||
Log in to quickly build your first custom AI code assistant
|
||||
</p>
|
||||
|
||||
<div className="mt-4 w-full">
|
||||
<Button
|
||||
onClick={onGetStarted}
|
||||
className="grid w-full grid-flow-col items-center gap-2"
|
||||
>
|
||||
Get started
|
||||
</Button>
|
||||
<ButtonSubtext onClick={onRemainLocal}>
|
||||
<div className="mt-4 flex cursor-pointer items-center justify-center gap-1">
|
||||
<span>Or, remain local</span>
|
||||
<ChevronRightIcon className="h-3 w-3" />
|
||||
</div>
|
||||
</ButtonSubtext>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import { UserCircleIcon as UserCircleIconSolid } from "@heroicons/react/24/solid
|
|||
import { ProfileDescription } from "core/config/ConfigHandler";
|
||||
import { Fragment, useContext, useEffect, useState } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
|
|
@ -21,11 +21,10 @@ import {
|
|||
import { useAuth } from "../context/Auth";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { useAppSelector } from "../redux/hooks";
|
||||
import { setLastControlServerBetaEnabledStatus } from "../redux/slices/miscSlice";
|
||||
import { RootState } from "../redux/store";
|
||||
import { getFontSize } from "../util";
|
||||
import HeaderButtonWithToolTip from "./gui/HeaderButtonWithToolTip";
|
||||
import { useAppSelector } from "../redux/hooks";
|
||||
|
||||
const StyledListbox = styled(Listbox)`
|
||||
background-color: ${vscBackground};
|
||||
|
|
@ -148,9 +147,6 @@ function ProfileSwitcher() {
|
|||
|
||||
const shouldShowPopup =
|
||||
!lastControlServerBetaEnabledStatus && enableControlServerBeta;
|
||||
if (shouldShowPopup) {
|
||||
ideMessenger.ide.showToast("info", "Continue for Teams enabled");
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
80
gui/src/components/dialogs/AboutAssistantDialog.tsx
Normal file
80
gui/src/components/dialogs/AboutAssistantDialog.tsx
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { RootState } from "../../redux/store";
|
||||
|
||||
export default function AboutAssistantDialog() {
|
||||
const configJson = useAppSelector((store: RootState) => store.config.config);
|
||||
|
||||
const selectedProfileId = useAppSelector(
|
||||
(store) => store.session.selectedProfileId,
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="h-[60vh] space-y-4 overflow-y-scroll px-4 pb-4">
|
||||
<h2>About {selectedProfileId} assistant</h2>
|
||||
{configJson.models?.length > 0 && (
|
||||
<details>
|
||||
<summary>Chat models</summary>
|
||||
<ul>
|
||||
{configJson.models.map((model, index) => (
|
||||
<li key={index}>{model.title}</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
|
||||
{configJson.embeddingsProvider && (
|
||||
<details>
|
||||
<summary>Embedding model</summary>
|
||||
<p>{configJson.embeddingsProvider}</p>
|
||||
</details>
|
||||
)}
|
||||
|
||||
{configJson.reranker?.name && (
|
||||
<details>
|
||||
<summary>Rerank model</summary>
|
||||
<p>{configJson.reranker.name}</p>
|
||||
</details>
|
||||
)}
|
||||
|
||||
{configJson.systemMessage && (
|
||||
<details>
|
||||
<summary>Rules</summary>
|
||||
<p>{configJson.systemMessage}</p>
|
||||
</details>
|
||||
)}
|
||||
|
||||
{configJson.contextProviders?.length ? (
|
||||
<details>
|
||||
<summary>Context</summary>
|
||||
<ul>
|
||||
{configJson.contextProviders.map((provider, index) => (
|
||||
<li key={index}>{provider.title}</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
) : null}
|
||||
|
||||
{configJson.tools.length > 0 && (
|
||||
<details>
|
||||
<summary>Tools</summary>
|
||||
<ul>
|
||||
{configJson.tools.map((tool, index) => (
|
||||
<li key={index}>{tool.displayTitle}</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
|
||||
{configJson.docs?.length ? (
|
||||
<details>
|
||||
<summary>Docs</summary>
|
||||
<ul>
|
||||
{configJson.docs.map((doc, index) => (
|
||||
<li key={index}>{doc.title}</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import styled, { keyframes } from "styled-components";
|
||||
import styled from "styled-components";
|
||||
import { getFontSize, isJetBrains } from "../util";
|
||||
|
||||
export const VSC_INPUT_BACKGROUND_VAR = "--vscode-input-background";
|
||||
|
|
@ -298,11 +298,6 @@ export const HeaderButton = styled.button<{
|
|||
padding: 2px;
|
||||
`;
|
||||
|
||||
export const Divider = styled.div`
|
||||
height: 1px;
|
||||
background-color: ${lightGray};
|
||||
`;
|
||||
|
||||
export const StyledActionButton = styled.div`
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ function ContextItemsPeekItem({ contextItem }: ContextItemsPeekItemProps) {
|
|||
<div
|
||||
onClick={openContextItem}
|
||||
className="group mr-2 flex cursor-pointer items-center overflow-hidden text-ellipsis whitespace-nowrap rounded px-1.5 py-1 text-xs hover:bg-white/10"
|
||||
data-testid="context-items-peek-item"
|
||||
>
|
||||
<div className="flex w-full items-center">
|
||||
{getContextItemIcon()}
|
||||
|
|
@ -161,6 +162,7 @@ function ContextItemsPeek({
|
|||
<div
|
||||
className="flex cursor-pointer items-center justify-start text-xs text-gray-300"
|
||||
onClick={() => setOpen((prev) => !prev)}
|
||||
data-testid="context-items-peek"
|
||||
>
|
||||
<div className="relative mr-1 h-4 w-4">
|
||||
<ChevronRightIcon
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
vscInputBackground,
|
||||
} from "..";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { selectUseActiveFile } from "../../redux/selectors";
|
||||
import { selectUseActiveFile, selectUsePlatform } from "../../redux/selectors";
|
||||
import { selectDefaultModel } from "../../redux/slices/configSlice";
|
||||
import {
|
||||
selectHasCodeToEdit,
|
||||
|
|
@ -26,6 +26,7 @@ import {
|
|||
} from "../../util";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
import ModelSelect from "../modelSelection/ModelSelect";
|
||||
import AssistantAndModelSelect from "../modelSelection/platform/AssistantAndModelSelect";
|
||||
import HoverItem from "./InputToolbar/HoverItem";
|
||||
import ToggleToolsButton from "./InputToolbar/ToggleToolsButton";
|
||||
|
||||
|
|
@ -96,6 +97,8 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
modelSupportsTools(defaultModel.model, defaultModel.provider) &&
|
||||
!props.toolbarOptions?.hideTools;
|
||||
|
||||
const usePlatform = useAppSelector(selectUsePlatform);
|
||||
|
||||
const supportsImages =
|
||||
defaultModel &&
|
||||
modelSupportsImages(
|
||||
|
|
@ -114,7 +117,7 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
className="find-widget-skip flex"
|
||||
>
|
||||
<div className="flex items-center justify-start gap-2 whitespace-nowrap">
|
||||
<ModelSelect />
|
||||
{usePlatform ? <AssistantAndModelSelect /> : <ModelSelect />}
|
||||
<div className="xs:flex -mb-1 hidden items-center text-gray-400 transition-colors duration-200">
|
||||
{props.toolbarOptions?.hideImageUpload ||
|
||||
(supportsImages && (
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
import { Transition } from "@headlessui/react";
|
||||
|
||||
export default function PopoverTransition({
|
||||
children,
|
||||
show,
|
||||
afterLeave,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
show?: boolean;
|
||||
afterLeave?: () => void;
|
||||
}) {
|
||||
return (
|
||||
<Transition
|
||||
show={show}
|
||||
enter="transition duration-100 ease-out"
|
||||
enterFrom="transform scale-95 opacity-0"
|
||||
enterTo="transform scale-100 opacity-100"
|
||||
leave="transition duration-75 ease-out"
|
||||
leaveFrom="transform scale-100 opacity-100"
|
||||
leaveTo="transform scale-95 opacity-0"
|
||||
afterLeave={afterLeave}
|
||||
>
|
||||
{children}
|
||||
</Transition>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import { Listbox } from "@headlessui/react";
|
||||
import {
|
||||
EllipsisHorizontalCircleIcon as EllipsisHorizontalIcon,
|
||||
WrenchScrewdriverIcon as WrenchScrewdriverIconOutline,
|
||||
|
|
@ -7,12 +7,13 @@ import { WrenchScrewdriverIcon as WrenchScrewdriverIconSolid } from "@heroicons/
|
|||
import { useEffect, useRef, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { lightGray, vscForeground } from "../..";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { toggleUseTools } from "../../../redux/slices/uiSlice";
|
||||
import { ToolTip } from "../../gui/Tooltip";
|
||||
import InfoHover from "../../InfoHover";
|
||||
import HoverItem from "./HoverItem";
|
||||
import PopoverTransition from "./PopoverTransition";
|
||||
import ToolDropdownItem from "./ToolDropdownItem";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { ToolTip } from "../../gui/Tooltip";
|
||||
|
||||
export default function ToolDropdown() {
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
|
|
@ -85,14 +86,8 @@ export default function ToolDropdown() {
|
|||
>
|
||||
<EllipsisHorizontalIcon className="h-3 w-3 cursor-pointer hover:brightness-125" />
|
||||
</Listbox.Button>
|
||||
<Transition
|
||||
<PopoverTransition
|
||||
show={open}
|
||||
enter="transition duration-100 ease-out"
|
||||
enterFrom="transform scale-95 opacity-0"
|
||||
enterTo="transform scale-100 opacity-100"
|
||||
leave="transition duration-75 ease-out"
|
||||
leaveFrom="transform scale-100 opacity-100"
|
||||
leaveTo="transform scale-95 opacity-0"
|
||||
afterLeave={() => setDropdownOpen(false)}
|
||||
>
|
||||
<Listbox.Options
|
||||
|
|
@ -151,7 +146,7 @@ export default function ToolDropdown() {
|
|||
))}
|
||||
</div>
|
||||
</Listbox.Options>
|
||||
</Transition>
|
||||
</PopoverTransition>
|
||||
</>
|
||||
)}
|
||||
</Listbox>
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ import FileIcon from "../FileIcon";
|
|||
import SafeImg from "../SafeImg";
|
||||
import AddDocsDialog from "../dialogs/AddDocsDialog";
|
||||
import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip";
|
||||
import { ComboBoxItem, ComboBoxItemType } from "./types";
|
||||
import { DiscordIcon } from "../svg/DiscordIcon";
|
||||
import { GoogleIcon } from "../svg/GoogleIcon";
|
||||
import { GitlabIcon } from "../svg/GitlabIcon";
|
||||
import { GithubIcon } from "../svg/GithubIcon";
|
||||
import { GitlabIcon } from "../svg/GitlabIcon";
|
||||
import { GoogleIcon } from "../svg/GoogleIcon";
|
||||
import { ComboBoxItem, ComboBoxItemType } from "./types";
|
||||
|
||||
const ICONS_FOR_DROPDOWN: { [key: string]: any } = {
|
||||
file: FolderIcon,
|
||||
|
|
@ -414,6 +414,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
|
|||
key={index}
|
||||
onClick={() => selectItem(index)}
|
||||
onMouseEnter={() => setSelectedIndex(index)}
|
||||
data-testid="context-provider-dropdown-item"
|
||||
>
|
||||
<span className="flex w-full items-center justify-between">
|
||||
<div className="flex items-center justify-center">
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@ import {
|
|||
PlusIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { MouseEvent, useContext, useEffect, useRef, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
Divider,
|
||||
lightGray,
|
||||
vscInputBackground,
|
||||
} from "..";
|
||||
import { defaultBorderRadius, lightGray, vscInputBackground } from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import AddModelForm from "../../forms/AddModelForm";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import {
|
||||
selectDefaultModel,
|
||||
setDefaultModel,
|
||||
} from "../../redux/slices/configSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
|
||||
import {
|
||||
getFontSize,
|
||||
|
|
@ -24,11 +24,7 @@ import {
|
|||
isMetaEquivalentKeyPressed,
|
||||
} from "../../util";
|
||||
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import {
|
||||
selectDefaultModel,
|
||||
setDefaultModel,
|
||||
} from "../../redux/slices/configSlice";
|
||||
import { Divider } from "./platform/shared";
|
||||
|
||||
interface ModelOptionProps {
|
||||
option: Option;
|
||||
|
|
@ -144,7 +140,7 @@ function ModelOption({
|
|||
const dispatch = useDispatch();
|
||||
const [hovered, setHovered] = useState(false);
|
||||
|
||||
function onClickDelete(e: MouseEvent) {
|
||||
function onClickDelete(e: any) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
|
|
@ -164,7 +160,7 @@ function ModelOption({
|
|||
);
|
||||
}
|
||||
|
||||
function onClickGear(e: MouseEvent) {
|
||||
function onClickGear(e: any) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
|
|
@ -173,7 +169,7 @@ function ModelOption({
|
|||
});
|
||||
}
|
||||
|
||||
function handleOptionClick(e: MouseEvent) {
|
||||
function handleOptionClick(e: any) {
|
||||
if (showMissingApiKeyMsg) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,194 @@
|
|||
import { Popover } from "@headlessui/react";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
DocumentIcon,
|
||||
SparklesIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, lightGray, vscInputBackground } from "../..";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import AddModelForm from "../../../forms/AddModelForm";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import {
|
||||
cycleDefaultModel,
|
||||
selectDefaultModel,
|
||||
} from "../../../redux/slices/configSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { cycleProfile } from "../../../redux/thunks/cycleProfile";
|
||||
import { getFontSize, isMetaEquivalentKeyPressed } from "../../../util";
|
||||
import PopoverTransition from "../../mainInput/InputToolbar/PopoverTransition";
|
||||
import { AssistantSelect } from "./AssistantSelect";
|
||||
import { ModelSelect, modelSelectTitle } from "./ModelSelect";
|
||||
import { MAX_HEIGHT_PX } from "./shared";
|
||||
|
||||
const StyledPopoverButton = styled(Popover.Button)`
|
||||
font-family: inherit;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: ${getFontSize() - 2}px;
|
||||
background: transparent;
|
||||
color: ${lightGray};
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledPopoverPanel = styled(Popover.Panel)<{ $showabove: boolean }>`
|
||||
margin-top: 4px;
|
||||
position: absolute;
|
||||
padding: 0px;
|
||||
cursor: default;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
border-radius: ${defaultBorderRadius};
|
||||
border: 0.5px solid ${lightGray};
|
||||
background-color: ${vscInputBackground};
|
||||
|
||||
${(props) => (props.$showabove ? "bottom: 100%;" : "top: 100%;")}
|
||||
`;
|
||||
|
||||
function AssistantAndModelSelect() {
|
||||
const dispatch = useAppDispatch();
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const [showAbove, setShowAbove] = useState(false);
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const selectedProfileId = useAppSelector(
|
||||
(store) => store.session.selectedProfileId,
|
||||
);
|
||||
|
||||
const { profiles, selectedProfile } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => calculatePosition();
|
||||
window.addEventListener("resize", handleResize);
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}, []);
|
||||
|
||||
function calculatePosition() {
|
||||
if (!buttonRef.current) {
|
||||
return;
|
||||
}
|
||||
const rect = buttonRef.current.getBoundingClientRect();
|
||||
const spaceBelow = window.innerHeight - rect.bottom;
|
||||
const spaceAbove = rect.top;
|
||||
const dropdownHeight = MAX_HEIGHT_PX;
|
||||
|
||||
setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow);
|
||||
}
|
||||
|
||||
function onClickAddModel(e: any) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
// Close the dropdown
|
||||
if (buttonRef.current) {
|
||||
buttonRef.current.click();
|
||||
}
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<AddModelForm
|
||||
onDone={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let lastToggleTime = 0;
|
||||
const DEBOUNCE_MS = 500;
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === "'" && isMetaEquivalentKeyPressed(event as any)) {
|
||||
const now = Date.now();
|
||||
|
||||
if (event.shiftKey) {
|
||||
dispatch(cycleDefaultModel("next"));
|
||||
} else {
|
||||
if (now - lastToggleTime >= DEBOUNCE_MS) {
|
||||
dispatch(cycleProfile());
|
||||
lastToggleTime = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Popover>
|
||||
<div className="relative">
|
||||
<StyledPopoverButton
|
||||
data-testid="model-select-button"
|
||||
ref={buttonRef}
|
||||
className="h-[18px] overflow-hidden"
|
||||
style={{ padding: 0 }}
|
||||
onClick={calculatePosition}
|
||||
>
|
||||
<div className="flex max-w-[33vw] items-center gap-0.5 text-gray-400 transition-colors duration-200">
|
||||
{selectedProfile?.id === "local" ? (
|
||||
<>
|
||||
<DocumentIcon
|
||||
className="mr-1 h-4 w-4 flex-shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span className="truncate">
|
||||
{modelSelectTitle(defaultModel) || "Select model"}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<SparklesIcon
|
||||
className="mr-1 h-4 w-4 flex-shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span className="truncate">
|
||||
{selectedProfile?.title || "Select assistant"}
|
||||
{" / "}
|
||||
{modelSelectTitle(defaultModel) || "Select model"}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
<ChevronDownIcon
|
||||
className="h-3 w-3 flex-shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
</StyledPopoverButton>
|
||||
<PopoverTransition>
|
||||
<StyledPopoverPanel
|
||||
$showabove={showAbove}
|
||||
className="flex max-w-[90vw] overflow-hidden"
|
||||
style={{ zIndex: 1000 }}
|
||||
>
|
||||
<AssistantSelect
|
||||
onClose={() => {
|
||||
if (buttonRef.current) {
|
||||
buttonRef.current.click();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<ModelSelect
|
||||
selectedProfileId={selectedProfileId}
|
||||
onClickAddModel={onClickAddModel}
|
||||
/>
|
||||
</StyledPopoverPanel>
|
||||
</PopoverTransition>
|
||||
</div>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
export default AssistantAndModelSelect;
|
||||
111
gui/src/components/modelSelection/platform/AssistantSelect.tsx
Normal file
111
gui/src/components/modelSelection/platform/AssistantSelect.tsx
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
import {
|
||||
DocumentIcon,
|
||||
PlusIcon,
|
||||
SparklesIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useContext } from "react";
|
||||
import { lightGray } from "../..";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppDispatch } from "../../../redux/hooks";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { setProfileId } from "../../../redux/thunks/setProfileId";
|
||||
import { getFontSize, getMetaKeyLabel } from "../../../util";
|
||||
import AboutAssistantDialog from "../../dialogs/AboutAssistantDialog";
|
||||
import { Divider, Option, OptionDiv } from "./shared";
|
||||
|
||||
interface AssistantSelectProps {
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export function AssistantSelect(props: AssistantSelectProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { profiles, selectedProfile } = useAuth();
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
function onNewAssistant() {
|
||||
ideMessenger.post("openUrl", "https://app-test.continue.dev/new");
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="border-lightgray flex min-w-0 flex-col overflow-x-hidden border-0 border-r-[0.5px] border-solid pt-0">
|
||||
<div className={`max-h-[300px]`}>
|
||||
{profiles.map((option, idx) => (
|
||||
<Option
|
||||
key={idx}
|
||||
idx={idx}
|
||||
disabled={!!option.errors?.length}
|
||||
showConfigure={true}
|
||||
selected={option.id === selectedProfile?.id}
|
||||
onLink={
|
||||
option.id !== "local"
|
||||
? (e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: option.id,
|
||||
});
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
onConfigure={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
if (option.id === "local") {
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: option.id,
|
||||
});
|
||||
} else {
|
||||
props.onClose();
|
||||
dispatch(setDialogMessage(<AboutAssistantDialog />));
|
||||
dispatch(setShowDialog(true));
|
||||
}
|
||||
}}
|
||||
errors={option.errors}
|
||||
onClickError={() => {
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: option.id,
|
||||
});
|
||||
}}
|
||||
onClick={() => dispatch(setProfileId(option.id))}
|
||||
>
|
||||
<div className="flex min-w-0 items-center">
|
||||
{option.id === "local" ? (
|
||||
<DocumentIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
||||
) : (
|
||||
<SparklesIcon
|
||||
className="mr-2 h-4 w-4 flex-shrink-0"
|
||||
color={
|
||||
option.id === selectedProfile?.id ? "yellow" : undefined
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<span className="flex-1 truncate text-xs">{option.title}</span>
|
||||
</div>
|
||||
</Option>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-auto w-full">
|
||||
<OptionDiv key={profiles.length} onClick={onNewAssistant}>
|
||||
<div className="flex items-center py-0.5">
|
||||
<PlusIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
||||
New Assistant
|
||||
</div>
|
||||
</OptionDiv>
|
||||
|
||||
<Divider className="!my-0" />
|
||||
|
||||
<span
|
||||
className="block px-3 py-2"
|
||||
style={{ color: lightGray, fontSize: getFontSize() - 4 }}
|
||||
>
|
||||
<code>{getMetaKeyLabel()}'</code> toggle assistant
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
121
gui/src/components/modelSelection/platform/ModelSelect.tsx
Normal file
121
gui/src/components/modelSelection/platform/ModelSelect.tsx
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
import { CubeIcon, PlusIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { lightGray } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import {
|
||||
selectDefaultModel,
|
||||
setDefaultModel,
|
||||
} from "../../../redux/slices/configSlice";
|
||||
import { getFontSize, getMetaKeyLabel } from "../../../util";
|
||||
import { Divider, Option, OptionDiv } from "./shared";
|
||||
|
||||
export interface ModelOption {
|
||||
value: string;
|
||||
title: string;
|
||||
apiKey?: string;
|
||||
}
|
||||
|
||||
export function modelSelectTitle(model: any): string {
|
||||
if (model?.title) return model?.title;
|
||||
if (model?.model !== undefined && model?.model.trim() !== "") {
|
||||
if (model?.class_name) {
|
||||
return `${model?.class_name} - ${model?.model}`;
|
||||
}
|
||||
return model?.model;
|
||||
}
|
||||
return model?.class_name;
|
||||
}
|
||||
|
||||
interface ModelSelectProps {
|
||||
selectedProfileId: string;
|
||||
onClickAddModel: (e: any) => void;
|
||||
}
|
||||
|
||||
export function ModelSelect(props: ModelSelectProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const allModels = useAppSelector((state) => state.config.config.models);
|
||||
const [options, setOptions] = useState<ModelOption[]>([]);
|
||||
const [sortedOptions, setSortedOptions] = useState<ModelOption[]>([]);
|
||||
|
||||
// Sort so that options without an API key are at the end
|
||||
useEffect(() => {
|
||||
const enabledOptions = options.filter((option) => option.apiKey !== "");
|
||||
const disabledOptions = options.filter((option) => option.apiKey === "");
|
||||
|
||||
const sorted = [...enabledOptions, ...disabledOptions];
|
||||
|
||||
setSortedOptions(sorted);
|
||||
}, [options]);
|
||||
|
||||
useEffect(() => {
|
||||
setOptions(
|
||||
allModels.map((model) => {
|
||||
return {
|
||||
value: model.title,
|
||||
title: modelSelectTitle(model),
|
||||
apiKey: model.apiKey,
|
||||
};
|
||||
}),
|
||||
);
|
||||
}, [allModels]);
|
||||
|
||||
function onModelChange(modelTitle: string) {
|
||||
if (modelTitle === defaultModel?.title) return;
|
||||
dispatch(setDefaultModel({ title: modelTitle }));
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="xs:flex hidden min-w-0 flex-col">
|
||||
<div className={`max-h-[300px] overflow-y-scroll`}>
|
||||
{sortedOptions.map((option, idx) => (
|
||||
<Option
|
||||
idx={idx}
|
||||
key={idx}
|
||||
onClick={() => onModelChange(option.title)}
|
||||
disabled={option.apiKey === ""}
|
||||
selected={option.title === defaultModel?.title}
|
||||
showConfigure={false}
|
||||
onConfigure={() => {}}
|
||||
>
|
||||
<div className="flex flex-grow items-center">
|
||||
<CubeIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
||||
<span className="flex-grow">
|
||||
{option.title}
|
||||
{option.apiKey === "" && (
|
||||
<span className="ml-2 text-[10px] italic">
|
||||
(Missing API key)
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</Option>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-auto">
|
||||
{props.selectedProfileId === "local" && (
|
||||
<>
|
||||
<OptionDiv key={options.length} onClick={props.onClickAddModel}>
|
||||
<div className="flex items-center py-0.5">
|
||||
<PlusIcon className="mr-2 h-4 w-4" />
|
||||
Add Chat model
|
||||
</div>
|
||||
</OptionDiv>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Divider className="!my-0" />
|
||||
|
||||
<span
|
||||
className="block px-3 py-2"
|
||||
style={{ color: lightGray, fontSize: getFontSize() - 4 }}
|
||||
>
|
||||
<code>{getMetaKeyLabel()}⇧'</code> toggle model
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
151
gui/src/components/modelSelection/platform/shared.tsx
Normal file
151
gui/src/components/modelSelection/platform/shared.tsx
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
import { ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import {
|
||||
ArrowTopRightOnSquareIcon,
|
||||
Cog6ToothIcon,
|
||||
ExclamationTriangleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, lightGray } from "../..";
|
||||
import { ToolTip } from "../../gui/Tooltip";
|
||||
|
||||
export const OptionDiv = styled.div<{
|
||||
isDisabled?: boolean;
|
||||
isSelected?: boolean;
|
||||
}>`
|
||||
border-radius: ${defaultBorderRadius};
|
||||
padding: 6px 12px;
|
||||
|
||||
min-width: 0px;
|
||||
|
||||
${({ isDisabled, isSelected }) =>
|
||||
!isDisabled &&
|
||||
`
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: ${lightGray}33;
|
||||
}
|
||||
|
||||
${
|
||||
isSelected &&
|
||||
`
|
||||
background: ${lightGray}22;
|
||||
`
|
||||
}
|
||||
`}
|
||||
|
||||
${({ isDisabled }) =>
|
||||
isDisabled &&
|
||||
`
|
||||
opacity: 0.5;
|
||||
`}
|
||||
`;
|
||||
|
||||
export const MAX_HEIGHT_PX = 300;
|
||||
|
||||
export const Divider = styled.div`
|
||||
height: 0.5px;
|
||||
background-color: ${lightGray};
|
||||
`;
|
||||
|
||||
interface ModelOptionProps {
|
||||
children: React.ReactNode;
|
||||
idx: number;
|
||||
disabled: boolean;
|
||||
selected: boolean;
|
||||
showConfigure: boolean;
|
||||
onLink?: (e: any) => void;
|
||||
onConfigure: (e: any) => void;
|
||||
onClick: () => void;
|
||||
errors?: ConfigValidationError[];
|
||||
onClickError?: (e: any) => void;
|
||||
}
|
||||
|
||||
const IconBase = styled.div<{ $hovered: boolean }>`
|
||||
width: 1.2em;
|
||||
height: 1.2em;
|
||||
cursor: pointer;
|
||||
padding: 4px;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
opacity: ${(props) => (props.$hovered ? 0.75 : 0)};
|
||||
visibility: ${(props) => (props.$hovered ? "visible" : "hidden")};
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
background-color: ${lightGray}33;
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledCog6ToothIcon = styled(IconBase).attrs({ as: Cog6ToothIcon })``;
|
||||
const StyledArrowTopRightOnSquareIcon = styled(IconBase).attrs({
|
||||
as: ArrowTopRightOnSquareIcon,
|
||||
})``;
|
||||
const StyledExclamationTriangleIcon = styled(IconBase).attrs({
|
||||
as: ExclamationTriangleIcon,
|
||||
})``;
|
||||
|
||||
export function Option({
|
||||
onConfigure,
|
||||
children,
|
||||
idx,
|
||||
disabled,
|
||||
onClick,
|
||||
showConfigure,
|
||||
onLink,
|
||||
selected,
|
||||
errors,
|
||||
onClickError,
|
||||
}: ModelOptionProps) {
|
||||
const [hovered, setHovered] = useState(false);
|
||||
|
||||
function handleOptionClick(e: any) {
|
||||
if (disabled) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
onClick();
|
||||
}
|
||||
|
||||
return (
|
||||
<OptionDiv
|
||||
key={idx}
|
||||
isDisabled={disabled}
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
isSelected={selected}
|
||||
onClick={!disabled ? handleOptionClick : undefined}
|
||||
>
|
||||
<div className="flex w-full flex-col gap-0.5">
|
||||
<div className="flex w-full items-center justify-between">
|
||||
{children}
|
||||
<div className="ml-2 flex items-center">
|
||||
{!errors?.length && showConfigure && (
|
||||
<StyledCog6ToothIcon $hovered={hovered} onClick={onConfigure} />
|
||||
)}
|
||||
{!errors?.length && onLink && (
|
||||
<StyledArrowTopRightOnSquareIcon
|
||||
$hovered={hovered}
|
||||
onClick={onLink}
|
||||
/>
|
||||
)}
|
||||
{errors?.length ? (
|
||||
<>
|
||||
<StyledExclamationTriangleIcon
|
||||
data-tooltip-id={`${idx}-errors-tooltip`}
|
||||
$hovered={hovered}
|
||||
className="cursor-pointer text-red-500"
|
||||
onClick={onClickError}
|
||||
/>
|
||||
<ToolTip id={`${idx}-errors-tooltip`}>
|
||||
<div className="font-semibold">Errors</div>
|
||||
{JSON.stringify(errors, null, 2)}
|
||||
</ToolTip>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</OptionDiv>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,26 +1,30 @@
|
|||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
import { ControlPlaneSessionInfo } from "core/control-plane/client";
|
||||
import React, {
|
||||
createContext,
|
||||
useContext,
|
||||
useState,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import { ControlPlaneSessionInfo } from "core/control-plane/client";
|
||||
import { useDispatch } from "react-redux";
|
||||
import AccountDialog from "../components/AccountDialog";
|
||||
import ConfirmationDialog from "../components/dialogs/ConfirmationDialog";
|
||||
import { IdeMessengerContext } from "./IdeMessenger";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { useAppSelector } from "../redux/hooks";
|
||||
import { setLastControlServerBetaEnabledStatus } from "../redux/slices/miscSlice";
|
||||
import {
|
||||
selectAvailableProfiles,
|
||||
setAvailableProfiles,
|
||||
} from "../redux/slices/sessionSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../redux/slices/uiSlice";
|
||||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
import { setLastControlServerBetaEnabledStatus } from "../redux/slices/miscSlice";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import AccountDialog from "../components/AccountDialog";
|
||||
import { useAppSelector } from "../redux/hooks";
|
||||
import { IdeMessengerContext } from "./IdeMessenger";
|
||||
|
||||
interface AuthContextType {
|
||||
session: ControlPlaneSessionInfo | undefined;
|
||||
logout: () => void;
|
||||
login: () => void;
|
||||
login: (useOnboarding: boolean) => Promise<boolean>;
|
||||
selectedProfile: ProfileDescription | undefined;
|
||||
profiles: ProfileDescription[];
|
||||
controlServerBetaEnabled: boolean;
|
||||
|
|
@ -34,7 +38,9 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
const [session, setSession] = useState<ControlPlaneSessionInfo | undefined>(
|
||||
undefined,
|
||||
);
|
||||
const [profiles, setProfiles] = useState<ProfileDescription[]>([]);
|
||||
|
||||
const profiles = useAppSelector(selectAvailableProfiles);
|
||||
|
||||
const selectedProfileId = useAppSelector(
|
||||
(store) => store.session.selectedProfileId,
|
||||
);
|
||||
|
|
@ -49,33 +55,42 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
(state) => state.misc.lastControlServerBetaEnabledStatus,
|
||||
);
|
||||
|
||||
const login = () => {
|
||||
ideMessenger
|
||||
.request("getControlPlaneSessionInfo", { silent: false })
|
||||
.then((result) => {
|
||||
if (result.status === "error") {
|
||||
return;
|
||||
}
|
||||
const session = result.content;
|
||||
setSession(session);
|
||||
const login: AuthContextType["login"] = (useOnboarding: boolean) => {
|
||||
return new Promise((resolve) => {
|
||||
ideMessenger
|
||||
.request("getControlPlaneSessionInfo", {
|
||||
silent: false,
|
||||
useOnboarding,
|
||||
})
|
||||
.then((result) => {
|
||||
if (result.status === "error") {
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// If this is the first time the user has logged in, explain how profiles work
|
||||
if (!getLocalStorage("shownProfilesIntroduction")) {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
title="Welcome to Continue for Teams!"
|
||||
text="You can switch between your local profile and team profile using the profile icon in the top right. Each profile defines a set of models, slash commands, context providers, and other settings to customize Continue."
|
||||
hideCancelButton={true}
|
||||
confirmText="Ok"
|
||||
onConfirm={() => {}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
setLocalStorage("shownProfilesIntroduction", true);
|
||||
}
|
||||
});
|
||||
const session = result.content;
|
||||
setSession(session);
|
||||
|
||||
// If this is the first time the user has logged in, explain how profiles work
|
||||
if (!getLocalStorage("shownProfilesIntroduction")) {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
title="Welcome to Continue for Teams!"
|
||||
text="You can switch between your local profile and team profile using the profile icon in the top right. Each profile defines a set of models, slash commands, context providers, and other settings to customize Continue."
|
||||
hideCancelButton={true}
|
||||
confirmText="Ok"
|
||||
onConfirm={() => {}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
setLocalStorage("shownProfilesIntroduction", true);
|
||||
}
|
||||
|
||||
resolve(true);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
|
|
@ -102,12 +117,15 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
});
|
||||
|
||||
useWebviewListener("signInToControlPlane", async () => {
|
||||
login();
|
||||
login(false);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
ideMessenger
|
||||
.request("getControlPlaneSessionInfo", { silent: true })
|
||||
.request("getControlPlaneSessionInfo", {
|
||||
silent: true,
|
||||
useOnboarding: false,
|
||||
})
|
||||
.then(
|
||||
(result) => result.status === "success" && setSession(result.content),
|
||||
);
|
||||
|
|
@ -123,9 +141,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
|
||||
const shouldShowPopup =
|
||||
!lastControlServerBetaEnabledStatus && enableControlServerBeta;
|
||||
if (shouldShowPopup) {
|
||||
ideMessenger.ide.showToast("info", "Continue for Teams enabled");
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
|
@ -145,14 +160,16 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
ideMessenger
|
||||
.request("config/listProfiles", undefined)
|
||||
.then(
|
||||
(result) => result.status === "success" && setProfiles(result.content),
|
||||
(result) =>
|
||||
result.status === "success" &&
|
||||
dispatch(setAvailableProfiles(result.content)),
|
||||
);
|
||||
}, []);
|
||||
|
||||
useWebviewListener(
|
||||
"didChangeAvailableProfiles",
|
||||
async (data) => {
|
||||
setProfiles(data.profiles);
|
||||
dispatch(setAvailableProfiles(data.profiles));
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import { useCallback, useContext, useEffect, useRef } from "react";
|
|||
import { VSC_THEME_COLOR_VARS } from "../components";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { BrowserSerializedContinueConfig } from "core";
|
||||
import { ConfigResult } from "core/config/load";
|
||||
import { useAppDispatch, useAppSelector } from "../redux/hooks";
|
||||
import { setConfigError, setConfigResult } from "../redux/slices/configSlice";
|
||||
import { updateIndexingStatus } from "../redux/slices/indexingSlice";
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import {
|
|||
OnboardingCard,
|
||||
useOnboardingCard,
|
||||
} from "../../components/OnboardingCard";
|
||||
import { PlatformOnboardingCard } from "../../components/OnboardingCard/platform/PlatformOnboardingCard";
|
||||
import PageHeader from "../../components/PageHeader";
|
||||
import StepContainer from "../../components/StepContainer";
|
||||
import AcceptRejectAllButtons from "../../components/StepContainer/AcceptRejectAllButtons";
|
||||
|
|
@ -39,6 +40,7 @@ import { IdeMessengerContext } from "../../context/IdeMessenger";
|
|||
import { useTutorialCard } from "../../hooks/useTutorialCard";
|
||||
import { useWebviewListener } from "../../hooks/useWebviewListener";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { selectUsePlatform } from "../../redux/selectors";
|
||||
import { selectCurrentToolCall } from "../../redux/selectors/selectCurrentToolCall";
|
||||
import { selectDefaultModel } from "../../redux/slices/configSlice";
|
||||
import { submitEdit } from "../../redux/slices/editModeState";
|
||||
|
|
@ -57,6 +59,7 @@ import {
|
|||
import { RootState } from "../../redux/store";
|
||||
import { cancelStream } from "../../redux/thunks/cancelStream";
|
||||
import { exitEditMode } from "../../redux/thunks/exitEditMode";
|
||||
import { loadLastSession } from "../../redux/thunks/session";
|
||||
import { streamResponseThunk } from "../../redux/thunks/streamResponse";
|
||||
import {
|
||||
getFontSize,
|
||||
|
|
@ -70,7 +73,6 @@ import ConfigErrorIndicator from "./ConfigError";
|
|||
import { ToolCallDiv } from "./ToolCallDiv";
|
||||
import { ToolCallButtons } from "./ToolCallDiv/ToolCallButtonsDiv";
|
||||
import ToolOutput from "./ToolCallDiv/ToolOutput";
|
||||
import { loadLastSession } from "../../redux/thunks/session";
|
||||
|
||||
const StopButton = styled.div`
|
||||
background-color: ${vscBackground};
|
||||
|
|
@ -215,6 +217,7 @@ export function Chat() {
|
|||
selectIsSingleRangeEditOrInsertion,
|
||||
);
|
||||
const lastSessionId = useAppSelector((state) => state.session.lastSessionId);
|
||||
const usePlatform = useAppSelector(selectUsePlatform);
|
||||
|
||||
useEffect(() => {
|
||||
// Cmd + Backspace to delete current step
|
||||
|
|
@ -539,7 +542,11 @@ export function Chat() {
|
|||
<>
|
||||
{onboardingCard.show && (
|
||||
<div className="mx-2 mt-10">
|
||||
<OnboardingCard />
|
||||
{usePlatform ? (
|
||||
<PlatformOnboardingCard />
|
||||
) : (
|
||||
<OnboardingCard />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,3 +42,8 @@ export const selectUseActiveFile = createSelector(
|
|||
[(state: RootState) => state.config.config.experimental?.defaultContext],
|
||||
(defaultContext) => defaultContext?.includes("activeFile" as any),
|
||||
);
|
||||
|
||||
export const selectUsePlatform = createSelector(
|
||||
[(state: RootState) => state.config.config.usePlatform],
|
||||
(usePlatform) => usePlatform,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { BrowserSerializedContinueConfig } from "core";
|
||||
import { ConfigResult } from "core/config/load";
|
||||
import { ConfigValidationError } from "core/config/validation";
|
||||
import { DEFAULT_MAX_TOKENS } from "core/llm/constants";
|
||||
|
||||
export type ConfigState = {
|
||||
|
|
@ -27,6 +26,7 @@ const initialState: ConfigState = {
|
|||
contextProviders: [],
|
||||
models: [],
|
||||
tools: [],
|
||||
usePlatform: false,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -80,6 +80,20 @@ export const configSlice = createSlice({
|
|||
defaultModelTitle: payload.title,
|
||||
};
|
||||
},
|
||||
cycleDefaultModel: (state, { payload }: PayloadAction<"next" | "prev">) => {
|
||||
const currentIndex = state.config.models.findIndex(
|
||||
(model) => model.title === state.defaultModelTitle,
|
||||
);
|
||||
const nextIndex =
|
||||
(currentIndex +
|
||||
(payload === "next" ? 1 : -1) +
|
||||
state.config.models.length) %
|
||||
state.config.models.length;
|
||||
return {
|
||||
...state,
|
||||
defaultModelTitle: state.config.models[nextIndex].title,
|
||||
};
|
||||
},
|
||||
},
|
||||
selectors: {
|
||||
selectDefaultModel: (state) => {
|
||||
|
|
@ -101,6 +115,7 @@ export const configSlice = createSlice({
|
|||
|
||||
export const {
|
||||
setDefaultModel,
|
||||
cycleDefaultModel,
|
||||
updateConfig,
|
||||
setConfigResult,
|
||||
setConfigError,
|
||||
|
|
|
|||
|
|
@ -21,14 +21,15 @@ import {
|
|||
ToolCallDelta,
|
||||
ToolCallState,
|
||||
} from "core";
|
||||
import { ProfileDescription } from "core/config/ConfigHandler";
|
||||
import { NEW_SESSION_TITLE } from "core/util/constants";
|
||||
import { incrementalParseJson } from "core/util/incrementalParseJson";
|
||||
import { renderChatMessage } from "core/util/messageContent";
|
||||
import { findUriInDirs, getUriPathBasename } from "core/util/uri";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { RootState } from "../store";
|
||||
import { streamResponseThunk } from "../thunks/streamResponse";
|
||||
import { findCurrentToolCall } from "../util";
|
||||
import { findUriInDirs, getUriPathBasename } from "core/util/uri";
|
||||
|
||||
// We need this to handle reorderings (e.g. a mid-array deletion) of the messages array.
|
||||
// The proper fix is adding a UUID to all chat messages, but this is the temp workaround.
|
||||
|
|
@ -44,6 +45,7 @@ type SessionState = {
|
|||
title: string;
|
||||
id: string;
|
||||
selectedProfileId: string;
|
||||
availableProfiles: ProfileDescription[];
|
||||
streamAborter: AbortController;
|
||||
codeToEdit: CodeToEdit[];
|
||||
curCheckpointIndex: number;
|
||||
|
|
@ -83,6 +85,13 @@ const initialState: SessionState = {
|
|||
title: NEW_SESSION_TITLE,
|
||||
id: uuidv4(),
|
||||
selectedProfileId: "local",
|
||||
availableProfiles: [
|
||||
{
|
||||
id: "local",
|
||||
title: "Local",
|
||||
errors: undefined,
|
||||
},
|
||||
],
|
||||
curCheckpointIndex: 0,
|
||||
streamAborter: new AbortController(),
|
||||
codeToEdit: [],
|
||||
|
|
@ -504,8 +513,19 @@ export const sessionSlice = createSlice({
|
|||
selectedProfileId: payload,
|
||||
};
|
||||
},
|
||||
setCurCheckpointIndex: (state, { payload }: PayloadAction<number>) => {
|
||||
state.curCheckpointIndex = payload;
|
||||
setAvailableProfiles: (
|
||||
state,
|
||||
{ payload }: PayloadAction<ProfileDescription[]>,
|
||||
) => {
|
||||
return {
|
||||
...state,
|
||||
availableProfiles: payload,
|
||||
selectedProfileId: payload.find(
|
||||
(profile) => profile.id === state.selectedProfileId,
|
||||
)
|
||||
? state.selectedProfileId
|
||||
: payload[0]?.id,
|
||||
};
|
||||
},
|
||||
updateCurCheckpoint: (
|
||||
state,
|
||||
|
|
@ -516,6 +536,9 @@ export const sessionSlice = createSlice({
|
|||
checkpoint[payload.filepath] = payload.content;
|
||||
}
|
||||
},
|
||||
setCurCheckpointIndex: (state, { payload }: PayloadAction<number>) => {
|
||||
state.curCheckpointIndex = payload;
|
||||
},
|
||||
updateApplyState: (state, { payload }: PayloadAction<ApplyState>) => {
|
||||
const applyState = state.codeBlockApplyStates.states.find(
|
||||
(state) => state.streamId === payload.streamId,
|
||||
|
|
@ -618,6 +641,9 @@ export const sessionSlice = createSlice({
|
|||
selectHasCodeToEdit: (state) => {
|
||||
return state.codeToEdit.length > 0;
|
||||
},
|
||||
selectAvailableProfiles: (state) => {
|
||||
return state.availableProfiles;
|
||||
},
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
addPassthroughCases(builder, [streamResponseThunk]);
|
||||
|
|
@ -681,6 +707,7 @@ export const {
|
|||
removeCodeToEdit,
|
||||
setCalling,
|
||||
cancelToolCall,
|
||||
setAvailableProfiles,
|
||||
acceptToolCall,
|
||||
setToolGenerated,
|
||||
setToolCallOutput,
|
||||
|
|
@ -696,6 +723,7 @@ export const {
|
|||
selectIsInEditMode,
|
||||
selectIsSingleRangeEditOrInsertion,
|
||||
selectHasCodeToEdit,
|
||||
selectAvailableProfiles,
|
||||
} = sessionSlice.selectors;
|
||||
|
||||
export default sessionSlice.reducer;
|
||||
|
|
|
|||
21
gui/src/redux/thunks/cycleProfile.ts
Normal file
21
gui/src/redux/thunks/cycleProfile.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { ThunkApiType } from "../store";
|
||||
import { setProfileId } from "./setProfileId";
|
||||
|
||||
export const cycleProfile = createAsyncThunk<void, undefined, ThunkApiType>(
|
||||
"profile/cycle",
|
||||
async (_, { dispatch, getState, extra }) => {
|
||||
const state = getState();
|
||||
const profileIds = state.session.availableProfiles.map(
|
||||
(profile) => profile.id,
|
||||
);
|
||||
const curIndex = profileIds.indexOf(state.session.selectedProfileId);
|
||||
const nextIndex = (curIndex + 1) % profileIds.length;
|
||||
const nextId = profileIds[nextIndex];
|
||||
dispatch(setProfileId(nextId));
|
||||
|
||||
extra.ideMessenger.post("didChangeSelectedProfile", {
|
||||
id: nextId,
|
||||
});
|
||||
},
|
||||
);
|
||||
13
gui/src/redux/thunks/setProfileId.ts
Normal file
13
gui/src/redux/thunks/setProfileId.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { setSelectedProfileId } from "../slices/sessionSlice";
|
||||
import { ThunkApiType } from "../store";
|
||||
|
||||
export const setProfileId = createAsyncThunk<void, string, ThunkApiType>(
|
||||
"profile/setId",
|
||||
async (id, { dispatch, extra }) => {
|
||||
dispatch(setSelectedProfileId(id));
|
||||
extra.ideMessenger.post("didChangeSelectedProfile", {
|
||||
id,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/config-types",
|
||||
"version": "1.0.13",
|
||||
"version": "1.0.14",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
|
|||
20
packages/config-yaml/package-lock.json
generated
20
packages/config-yaml/package-lock.json
generated
|
|
@ -1,14 +1,15 @@
|
|||
{
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.10",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.10",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"yaml": "^2.6.1",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
|
|
@ -18,6 +19,17 @@
|
|||
"ts-node": "^10.9.2"
|
||||
}
|
||||
},
|
||||
"../config-types": {
|
||||
"name": "@continuedev/config-types",
|
||||
"version": "1.0.14",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.5.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@ampproject/remapping": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
|
||||
|
|
@ -575,6 +587,10 @@
|
|||
"dev": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/@continuedev/config-types": {
|
||||
"resolved": "../config-types",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@cspotcode/source-map-support": {
|
||||
"version": "0.8.1",
|
||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.11",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
@ -13,7 +13,8 @@
|
|||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"yaml": "^2.6.1",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.23.8",
|
||||
"@continuedev/config-types": "^1.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "^7.0.3",
|
||||
|
|
|
|||
142
packages/config-yaml/src/converter.ts
Normal file
142
packages/config-yaml/src/converter.ts
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
import { ConfigJson } from "@continuedev/config-types";
|
||||
import { ConfigYaml } from "./schemas/index.js";
|
||||
import { ModelRoles } from "./schemas/models.js";
|
||||
|
||||
type ModelYaml = NonNullable<ConfigYaml["models"]>[number];
|
||||
type ContextYaml = NonNullable<ConfigYaml["context"]>[number];
|
||||
type PromptYaml = NonNullable<ConfigYaml["prompts"]>[number];
|
||||
|
||||
function convertModel(
|
||||
m: ConfigJson["models"][number],
|
||||
roles: ModelRoles[],
|
||||
): ModelYaml {
|
||||
return {
|
||||
name: m.title,
|
||||
provider: m.provider,
|
||||
model: m.model,
|
||||
apiKey: m.apiKey,
|
||||
apiBase: m.apiBase,
|
||||
roles,
|
||||
requestOptions: m.requestOptions,
|
||||
defaultCompletionOptions: m.completionOptions,
|
||||
};
|
||||
}
|
||||
|
||||
function convertEmbeddingsProvider(
|
||||
m: NonNullable<ConfigJson["embeddingsProvider"]>,
|
||||
): ModelYaml {
|
||||
return {
|
||||
name: "Embeddings Model",
|
||||
provider: m.provider,
|
||||
model: m.model ?? "",
|
||||
apiKey: m.apiKey,
|
||||
apiBase: m.apiBase,
|
||||
roles: ["embed"],
|
||||
};
|
||||
}
|
||||
|
||||
function convertReranker(m: NonNullable<ConfigJson["reranker"]>): ModelYaml {
|
||||
return {
|
||||
name: "Reranker",
|
||||
provider: m.name,
|
||||
model: m.params?.model ?? "",
|
||||
apiKey: m.params?.apiKey,
|
||||
apiBase: m.params?.apiBase,
|
||||
roles: ["rerank"],
|
||||
};
|
||||
}
|
||||
|
||||
function convertContext(configJson: ConfigJson): ContextYaml[] {
|
||||
const context: ContextYaml[] =
|
||||
configJson.contextProviders?.map((ctx) => {
|
||||
return {
|
||||
uses: `builtin/${ctx.name}`,
|
||||
with: ctx.params,
|
||||
};
|
||||
}) ?? [];
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
function convertCustomCommand(
|
||||
cmd: NonNullable<ConfigJson["customCommands"]>[number],
|
||||
): PromptYaml {
|
||||
return {
|
||||
name: cmd.name,
|
||||
description: cmd.description,
|
||||
prompt: (cmd as any).prompt, // The type is wrong in @continuedev/config-types
|
||||
type: "slash-command",
|
||||
};
|
||||
}
|
||||
|
||||
function convertMcp(mcp: any): NonNullable<ConfigYaml["mcpServers"]>[number] {
|
||||
const { transport } = mcp;
|
||||
const { command, args, env } = transport;
|
||||
|
||||
return {
|
||||
command,
|
||||
args,
|
||||
env,
|
||||
name: "MCP Server",
|
||||
};
|
||||
}
|
||||
|
||||
function convertDoc(
|
||||
doc: NonNullable<ConfigJson["docs"]>[number],
|
||||
): NonNullable<ConfigYaml["docs"]>[number] {
|
||||
return {
|
||||
name: doc.title,
|
||||
startUrl: doc.startUrl,
|
||||
rootUrl: doc.rootUrl,
|
||||
faviconUrl: doc.faviconUrl,
|
||||
};
|
||||
}
|
||||
|
||||
export function convertJsonToYamlConfig(configJson: ConfigJson): ConfigYaml {
|
||||
// models
|
||||
const models = configJson.models.map((m) => convertModel(m, ["chat"]));
|
||||
const autocompleteModels = Array.isArray(configJson.tabAutocompleteModel)
|
||||
? configJson.tabAutocompleteModel
|
||||
: configJson.tabAutocompleteModel
|
||||
? [configJson.tabAutocompleteModel]
|
||||
: [];
|
||||
models.push(
|
||||
...autocompleteModels.map((m) => convertModel(m, ["autocomplete"])),
|
||||
);
|
||||
|
||||
if (configJson.embeddingsProvider) {
|
||||
models.push(convertEmbeddingsProvider(configJson.embeddingsProvider));
|
||||
}
|
||||
|
||||
if (configJson.reranker) {
|
||||
models.push(convertReranker(configJson.reranker));
|
||||
}
|
||||
|
||||
// context
|
||||
const context = convertContext(configJson);
|
||||
|
||||
// mcpServers
|
||||
// Types for "experimental" don't exist
|
||||
const mcpServers = (
|
||||
configJson as any
|
||||
).experimental?.modelContextProtocolServers?.map(convertMcp);
|
||||
|
||||
// prompts
|
||||
const prompts = configJson.customCommands?.map(convertCustomCommand);
|
||||
|
||||
// docs
|
||||
const docs = configJson.docs?.map(convertDoc);
|
||||
|
||||
const configYaml: ConfigYaml = {
|
||||
name: "Continue Config",
|
||||
version: "0.0.1",
|
||||
models,
|
||||
context,
|
||||
rules: configJson.systemMessage ? [configJson.systemMessage] : undefined,
|
||||
prompts,
|
||||
mcpServers,
|
||||
docs,
|
||||
};
|
||||
|
||||
return configYaml;
|
||||
}
|
||||
|
|
@ -91,5 +91,17 @@ export function fillTemplateVariables(
|
|||
});
|
||||
}
|
||||
|
||||
export { convertJsonToYamlConfig } from "./converter.js";
|
||||
export { resolveSecretsOnClient } from "./resolveSecretsOnClient.js";
|
||||
export {
|
||||
ClientConfigYaml,
|
||||
clientConfigYamlSchema,
|
||||
ConfigYaml,
|
||||
configYamlSchema,
|
||||
} from "./schemas/index.js";
|
||||
export type { ModelConfig } from "./schemas/models.js";
|
||||
export { validateConfigYaml } from "./validation.js";
|
||||
export {
|
||||
ConfigResult,
|
||||
ConfigValidationError,
|
||||
validateConfigYaml,
|
||||
} from "./validation.js";
|
||||
|
|
|
|||
64
packages/config-yaml/src/resolveSecretsOnClient.ts
Normal file
64
packages/config-yaml/src/resolveSecretsOnClient.ts
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import { ClientConfigYaml, ConfigYaml } from "./schemas/index.js";
|
||||
type SecretProvider = (
|
||||
secretNames: string[],
|
||||
) => Promise<{ [key: string]: string }>;
|
||||
|
||||
/**
|
||||
* Take a ConfigYaml with apiKeySecrets, and look to fill in these secrets
|
||||
* with whatever secret store exists in the client.
|
||||
*/
|
||||
export async function resolveSecretsOnClient(
|
||||
configYaml: ClientConfigYaml,
|
||||
getSecretsFromClientStore: SecretProvider,
|
||||
getSecretsFromServer: SecretProvider,
|
||||
): Promise<ClientConfigYaml> {
|
||||
const requiredSecrets = getRequiredSecretsInClientConfig(configYaml);
|
||||
|
||||
const secretsFoundOnClient = await getSecretsFromClientStore(requiredSecrets);
|
||||
|
||||
const secretsNotFoundOnClient = requiredSecrets.filter(
|
||||
(secret) => !secretsFoundOnClient[secret],
|
||||
);
|
||||
|
||||
let secretsFoundOnServer = {};
|
||||
if (secretsNotFoundOnClient.length > 0) {
|
||||
secretsFoundOnServer = await getSecretsFromServer(secretsNotFoundOnClient);
|
||||
}
|
||||
|
||||
const clientSecrets = {
|
||||
...secretsFoundOnClient,
|
||||
...secretsFoundOnServer,
|
||||
};
|
||||
|
||||
const finalConfigYaml = injectClientSecrets(configYaml, clientSecrets);
|
||||
|
||||
// Anything with an apiKeySecret left over must use proxy
|
||||
return finalConfigYaml;
|
||||
}
|
||||
|
||||
function getRequiredSecretsInClientConfig(
|
||||
configYaml: ClientConfigYaml,
|
||||
): string[] {
|
||||
const secrets = new Set<string>();
|
||||
for (const model of configYaml.models ?? []) {
|
||||
if (model.apiKeySecret) {
|
||||
secrets.add(model.apiKeySecret);
|
||||
}
|
||||
}
|
||||
return Array.from(secrets);
|
||||
}
|
||||
|
||||
function injectClientSecrets(
|
||||
configYaml: ClientConfigYaml,
|
||||
clientSecrets: Record<string, string>,
|
||||
): ConfigYaml {
|
||||
for (const model of configYaml.models ?? []) {
|
||||
if (model.apiKeySecret && clientSecrets[model.apiKeySecret]) {
|
||||
// Remove apiKeySecret and place the client secret in apiKey
|
||||
model.apiKey = clientSecrets[model.apiKeySecret];
|
||||
delete model.apiKeySecret;
|
||||
}
|
||||
}
|
||||
|
||||
return configYaml;
|
||||
}
|
||||
|
|
@ -6,9 +6,13 @@ import { modelSchema } from "./models.js";
|
|||
const packageSchema = z.object({
|
||||
uses: z.string(),
|
||||
with: z.any().optional(),
|
||||
secrets: z.array(z.string()).optional(),
|
||||
});
|
||||
|
||||
const toolSchema = z.object({
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
policy: z.enum(["automatic", "allowed", "disabled"]).optional(),
|
||||
url: z.string(),
|
||||
apiKey: z.string().optional(),
|
||||
});
|
||||
|
|
@ -21,14 +25,36 @@ const mcpServerSchema = z.object({
|
|||
env: z.record(z.string()).optional(),
|
||||
});
|
||||
|
||||
const promptSchema = z.object({
|
||||
name: z.string(),
|
||||
description: z.string().optional(),
|
||||
type: z.enum(["slash-command", "context-provider"]).optional(),
|
||||
prompt: z.string(),
|
||||
});
|
||||
|
||||
const docSchema = z.object({
|
||||
name: z.string(),
|
||||
startUrl: z.string(),
|
||||
rootUrl: z.string().optional(),
|
||||
faviconUrl: z.string().optional(),
|
||||
});
|
||||
|
||||
export const configYamlSchema = z.object({
|
||||
name: z.string(),
|
||||
version: z.string(),
|
||||
packages: z.array(packageSchema).optional(),
|
||||
models: z.array(modelSchema).optional(),
|
||||
context: z.array(contextSchema).optional(),
|
||||
data: z.array(dataSchema).optional(),
|
||||
tools: z.array(toolSchema).optional(),
|
||||
mcpServers: z.array(mcpServerSchema).optional(),
|
||||
rules: z.array(z.string()).optional(),
|
||||
prompts: z.array(promptSchema).optional(),
|
||||
docs: z.array(docSchema).optional(),
|
||||
});
|
||||
|
||||
export type ConfigYaml = z.infer<typeof configYamlSchema>;
|
||||
|
||||
export const clientConfigYamlSchema = configYamlSchema.omit({ packages: true });
|
||||
|
||||
export type ClientConfigYaml = z.infer<typeof clientConfigYamlSchema>;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ export const modelSchema = z.object({
|
|||
name: z.string(),
|
||||
provider: z.string(),
|
||||
model: z.string(),
|
||||
apiKey: z.string().optional(),
|
||||
apiBase: z.string().optional(),
|
||||
apiKeySecret: z.string().optional(),
|
||||
roles: modelRolesSchema.array().optional(),
|
||||
defaultCompletionOptions: completionOptionsSchema.optional(),
|
||||
requestOptions: requestOptionsSchema.optional(),
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
import { ConfigYaml, configYamlSchema } from "./schemas/index.js";
|
||||
|
||||
export enum ValidationLevel {
|
||||
Warning,
|
||||
Error,
|
||||
export interface ConfigValidationError {
|
||||
fatal: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface ConfigValidationError {
|
||||
level: ValidationLevel;
|
||||
message: string;
|
||||
export interface ConfigResult<T> {
|
||||
config: T | undefined;
|
||||
errors: ConfigValidationError[] | undefined;
|
||||
configLoadInterrupted: boolean;
|
||||
}
|
||||
|
||||
export function validateConfigYaml(
|
||||
|
|
@ -20,7 +21,7 @@ export function validateConfigYaml(
|
|||
} catch (e: any) {
|
||||
return [
|
||||
{
|
||||
level: ValidationLevel.Error,
|
||||
fatal: true,
|
||||
message: e.message,
|
||||
},
|
||||
];
|
||||
|
|
@ -38,7 +39,7 @@ export function validateConfigYaml(
|
|||
|
||||
if (difference < 1000) {
|
||||
errors.push({
|
||||
level: ValidationLevel.Warning,
|
||||
fatal: false,
|
||||
message: `Model "${model.name}" has a contextLength of ${model.defaultCompletionOptions?.contextLength} and a maxTokens of ${model.defaultCompletionOptions?.maxTokens}. This leaves only ${difference} tokens for input context and will likely result in your inputs being truncated.`,
|
||||
});
|
||||
}
|
||||
|
|
@ -60,7 +61,7 @@ export function validateConfigYaml(
|
|||
!modelName.toLowerCase().includes("coder")
|
||||
) {
|
||||
errors.push({
|
||||
level: ValidationLevel.Warning,
|
||||
fatal: false,
|
||||
message: `${model.model} is not trained for tab-autocomplete, and will result in low-quality suggestions. See the docs to learn more about why: https://docs.continue.dev/features/tab-autocomplete#i-want-better-completions-should-i-use-gpt-4`,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/openai-adapters",
|
||||
"version": "1.0.10",
|
||||
"version": "1.0.12",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { OpenAI } from "openai/index";
|
|||
import {
|
||||
ChatCompletion,
|
||||
ChatCompletionChunk,
|
||||
ChatCompletionCreateParams,
|
||||
ChatCompletionCreateParamsNonStreaming,
|
||||
ChatCompletionCreateParamsStreaming,
|
||||
Completion,
|
||||
|
|
@ -34,22 +35,46 @@ export class OpenAIApi implements BaseLlmApi {
|
|||
});
|
||||
}
|
||||
|
||||
modifyChatBody<T extends ChatCompletionCreateParams>(body: T): T {
|
||||
// o-series models
|
||||
if (body.model.startsWith("o")) {
|
||||
// a) use max_completion_tokens instead of max_tokens
|
||||
body.max_completion_tokens = body.max_tokens;
|
||||
body.max_tokens = undefined;
|
||||
|
||||
// b) use "developer" message role rather than "system"
|
||||
body.messages = body.messages.map((message) => {
|
||||
if (message.role === "system") {
|
||||
return { ...message, role: "developer" } as any;
|
||||
}
|
||||
return message;
|
||||
});
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
async chatCompletionNonStream(
|
||||
body: ChatCompletionCreateParamsNonStreaming,
|
||||
signal: AbortSignal,
|
||||
): Promise<ChatCompletion> {
|
||||
const response = await this.openai.chat.completions.create(body, {
|
||||
signal,
|
||||
});
|
||||
const response = await this.openai.chat.completions.create(
|
||||
this.modifyChatBody(body),
|
||||
{
|
||||
signal,
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
async *chatCompletionStream(
|
||||
body: ChatCompletionCreateParamsStreaming,
|
||||
signal: AbortSignal,
|
||||
): AsyncGenerator<ChatCompletionChunk, any, unknown> {
|
||||
const response = await this.openai.chat.completions.create(body, {
|
||||
signal,
|
||||
});
|
||||
const response = await this.openai.chat.completions.create(
|
||||
this.modifyChatBody(body),
|
||||
{
|
||||
signal,
|
||||
},
|
||||
);
|
||||
for await (const result of response) {
|
||||
yield result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,3 +103,4 @@ export {
|
|||
|
||||
// export
|
||||
export type { BaseLlmApi } from "./apis/base.js";
|
||||
export type { LLMConfig } from "./types.js";
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ export const OpenAIConfigSchema = BasePlusConfig.extend({
|
|||
z.literal("text-gen-webui"),
|
||||
z.literal("vllm"),
|
||||
z.literal("x-ai"),
|
||||
z.literal("scaleway"),
|
||||
]),
|
||||
});
|
||||
export type OpenAIConfig = z.infer<typeof OpenAIConfigSchema>;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue