merge staging
This commit is contained in:
commit
bdf2c5f40a
97 changed files with 7097 additions and 4215 deletions
|
|
@ -4,7 +4,7 @@ description: Generate unit tests for core utilities
|
|||
Write jest tests for the provided code.
|
||||
Use jest version ^29 (e.g. jest 29.7.0)
|
||||
|
||||
Use best practices. Be clear and consise.
|
||||
Use best practices. Be clear and concise.
|
||||
Aim for 100% code coverage where reasonable.
|
||||
Multiple tests can be written, split up tests for best clarity and readability.
|
||||
Only use typescript, and if the file/code is not typescript, warn the user.
|
||||
|
|
@ -15,7 +15,7 @@ Use double quotes (or backticks if needed) for strings
|
|||
The code being tested is used in IDE extensions, and it:
|
||||
- accesses code workspaces through the IDE ("workspace directories")
|
||||
- persists extension-related data to the the local machine of the user ("global directory"), and
|
||||
- uses configuration via a `ConfigHandler`, which is stored in either the global directory (default) or accesed via a remote "control plane" using the `ControlPlaneClient`
|
||||
- uses configuration via a `ConfigHandler`, which is stored in either the global directory (default) or accessed via a remote "control plane" using the `ControlPlaneClient`
|
||||
|
||||
Jest testing setup includes
|
||||
- @core/test/jest.global-setup.ts initializes a temporary global directory, which is where files that store persisted extension data live.
|
||||
|
|
@ -31,7 +31,7 @@ Jest testing setup includes
|
|||
|
||||
Do NOT write tests for any files in `core/test`, only use them as helpers for testing other files. If no other files are provided, warn the user and write no tests.
|
||||
|
||||
IMPORTANT: Do NOT mock the fixtures above other than using `jest.spyOn`. DO mock 3rd party modules, etc. when sensible.
|
||||
IMPORTANT: Do NOT mock the fixtures above other than using `jest.spyOn`. DO mock 3rd party modules, etc. when sensible.
|
||||
Instead, generate actual mock files and data for operations
|
||||
Pure mocks should only be used to emulate specific network responses/error or hard-to-duplicate errors, or to prevent long-duration tests
|
||||
|
||||
|
|
|
|||
2
.github/workflows/pr_checks.yaml
vendored
2
.github/workflows/pr_checks.yaml
vendored
|
|
@ -4,10 +4,12 @@ on:
|
|||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- staging
|
||||
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- staging
|
||||
|
||||
jobs:
|
||||
install-root:
|
||||
|
|
|
|||
4
.github/workflows/preview.yaml
vendored
4
.github/workflows/preview.yaml
vendored
|
|
@ -217,8 +217,8 @@ jobs:
|
|||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
|
||||
- name: Pull latest changes
|
||||
run: git pull origin main
|
||||
- name: Pull latest changes from release
|
||||
run: git fetch origin ${{ github.ref }} && git checkout ${{ github.ref }}
|
||||
|
||||
# 1. Download the artifacts
|
||||
- uses: actions/download-artifact@v4
|
||||
|
|
|
|||
19
.vscode/launch.json
vendored
19
.vscode/launch.json
vendored
|
|
@ -138,6 +138,25 @@
|
|||
"env": {
|
||||
"NODE_OPTIONS": "--experimental-vm-modules"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "[config-yaml] Jest Test Debugger, Current Open File",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeArgs": [
|
||||
"--inspect-brk",
|
||||
"${workspaceRoot}/packages/config-yaml/node_modules/jest/bin/jest.js",
|
||||
"--runInBand",
|
||||
"--config",
|
||||
"${workspaceRoot}/packages/config-yaml/jest.config.mjs",
|
||||
"${relativeFile}"
|
||||
],
|
||||
"cwd": "${workspaceRoot}/packages/config-yaml",
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"env": {
|
||||
"NODE_OPTIONS": "--experimental-vm-modules"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
22
.vscode/tasks.json
vendored
22
.vscode/tasks.json
vendored
|
|
@ -71,7 +71,27 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
// Build the React app. It gets bundled into the extension as a file resource and has a seprate build step
|
||||
{
|
||||
"label": "vscode-extension:package",
|
||||
"dependsOn": ["vscode-extension:esbuild"],
|
||||
"type": "npm",
|
||||
"script": "package",
|
||||
"path": "extensions/vscode",
|
||||
"problemMatcher": [
|
||||
{
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "> (.*?):([0-9]+):([0-9]+): (warning|error): (.+)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"severity": 4,
|
||||
"message": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "vscode-extension:continue-ui:build",
|
||||
"type": "shell",
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ nvm use
|
|||
1. The new VS Code window with the extension is referred to as the _Host VS Code_
|
||||
2. The window you started debugging from is referred to as the _Main VS Code_
|
||||
|
||||
3. To package the extension, run `npm run package` in the `extensions/vscode` directory. This will generate `extensions/vscode/build/continue-{VERSION}.vsix`, which you can install by right-clicking and selecting "Install Extension VSIX".
|
||||
3. To package the extension, run `npm run package` in the `extensions/vscode` directory, select `Tasks: Run Task` and then select `vscode-extension:package`. This will generate `extensions/vscode/build/continue-{VERSION}.vsix`, which you can install by right-clicking and selecting "Install Extension VSIX".
|
||||
|
||||
##### Debugging
|
||||
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
|
||||
// Informs the `continue-binary` of where to look for node_sqlite3.node
|
||||
// https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found
|
||||
// fs.writeFileSync(`${targetDir}/package.json`, "");
|
||||
fs.writeFileSync(`${targetDir}/package.json`, "");
|
||||
}
|
||||
|
||||
// Cleanup - this is needed when running locally
|
||||
|
|
|
|||
6
binary/package-lock.json
generated
6
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.28",
|
||||
"@continuedev/config-yaml": "^1.0.49",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
@ -107,7 +107,7 @@
|
|||
"wink-nlp-utils": "^2.1.0",
|
||||
"workerpool": "^9.1.3",
|
||||
"yaml": "^2.4.2",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.24.7",
|
||||
|
|
@ -128,7 +128,7 @@
|
|||
"@types/uuid": "^9.0.7",
|
||||
"@types/win-ca": "^3.5.4",
|
||||
"cross-env": "^7.0.3",
|
||||
"esbuild": "0.24.0",
|
||||
"esbuild": "0.17.19",
|
||||
"eslint": "^8",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
|
|
|
|||
|
|
@ -240,6 +240,14 @@ export const Solidity = {
|
|||
endOfLine: [";"],
|
||||
};
|
||||
|
||||
// Lua
|
||||
export const Lua = {
|
||||
name: "Lua",
|
||||
topLevelKeywords: ["function"],
|
||||
singleLineComment: "--",
|
||||
endOfLine: [],
|
||||
};
|
||||
|
||||
// YAML
|
||||
export const YAML: AutocompleteLanguageInfo = {
|
||||
name: "YAML",
|
||||
|
|
@ -367,6 +375,8 @@ export const LANGUAGES: { [extension: string]: AutocompleteLanguageInfo } = {
|
|||
yaml: YAML,
|
||||
yml: YAML,
|
||||
md: Markdown,
|
||||
lua: Lua,
|
||||
luau: Lua,
|
||||
};
|
||||
|
||||
export function languageForFilepath(fileUri: string): AutocompleteLanguageInfo {
|
||||
|
|
|
|||
|
|
@ -399,7 +399,8 @@ export function getTemplateForModel(model: string): AutocompleteTemplate {
|
|||
lowerCaseModel.includes("gpt") ||
|
||||
lowerCaseModel.includes("davinci-002") ||
|
||||
lowerCaseModel.includes("claude") ||
|
||||
lowerCaseModel.includes("granite3")
|
||||
lowerCaseModel.includes("granite3") ||
|
||||
lowerCaseModel.includes("granite-3")
|
||||
) {
|
||||
return holeFillerTemplate;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export function slashFromCustomCommand(
|
|||
return {
|
||||
name: customCommand.name,
|
||||
description: customCommand.description ?? "",
|
||||
run: async function* ({ input, llm, history, ide }) {
|
||||
run: async function* ({ input, llm, history, ide, completionOptions }) {
|
||||
// Remove slash command prefix from input
|
||||
let userInput = input;
|
||||
if (userInput.startsWith(`/${customCommand.name}`)) {
|
||||
|
|
@ -20,11 +20,16 @@ export function slashFromCustomCommand(
|
|||
}
|
||||
|
||||
// Render prompt template
|
||||
const promptUserInput = await renderTemplatedString(
|
||||
customCommand.prompt,
|
||||
ide.readFile.bind(ide),
|
||||
{ input: userInput },
|
||||
);
|
||||
let promptUserInput: string;
|
||||
if (customCommand.prompt.includes("{{{ input }}}")) {
|
||||
promptUserInput = await renderTemplatedString(
|
||||
customCommand.prompt,
|
||||
ide.readFile.bind(ide),
|
||||
{ input: userInput },
|
||||
);
|
||||
} else {
|
||||
promptUserInput = customCommand.prompt + "\n\n" + userInput;
|
||||
}
|
||||
|
||||
const messages = [...history];
|
||||
// Find the last chat message with this slash command and replace it with the user input
|
||||
|
|
@ -67,6 +72,7 @@ export function slashFromCustomCommand(
|
|||
for await (const chunk of llm.streamChat(
|
||||
messages,
|
||||
new AbortController().signal,
|
||||
completionOptions,
|
||||
)) {
|
||||
yield renderChatMessage(chunk);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
import * as fs from "node:fs";
|
||||
|
||||
import {
|
||||
AssistantUnrolled,
|
||||
ConfigResult,
|
||||
FullSlug,
|
||||
} from "@continuedev/config-yaml";
|
||||
import * as YAML from "yaml";
|
||||
import { ConfigResult, FullSlug } from "@continuedev/config-yaml";
|
||||
|
||||
import {
|
||||
ControlPlaneClient,
|
||||
|
|
@ -36,7 +31,6 @@ import {
|
|||
ProfileDescription,
|
||||
ProfileLifecycleManager,
|
||||
} from "./ProfileLifecycleManager.js";
|
||||
import { clientRenderHelper } from "./yaml/clientRender.js";
|
||||
|
||||
export type { ProfileDescription };
|
||||
|
||||
|
|
@ -99,8 +93,8 @@ export class ConfigHandler {
|
|||
*/
|
||||
getAdditionalSubmenuContextProviders(): string[] {
|
||||
return this.additionalContextProviders
|
||||
.filter(provider => provider.description.type === "submenu")
|
||||
.map(provider => provider.description.title);
|
||||
.filter((provider) => provider.description.type === "submenu")
|
||||
.map((provider) => provider.description.title);
|
||||
}
|
||||
|
||||
private async init() {
|
||||
|
|
@ -108,7 +102,7 @@ export class ConfigHandler {
|
|||
await this.fetchControlPlaneProfiles();
|
||||
} catch (e) {
|
||||
// If this fails, make sure at least local profile is loaded
|
||||
console.error("Failed to fetch control plane profiles: ", e);
|
||||
console.error("Failed to fetch control plane profiles in init: ", e);
|
||||
await this.updateAvailableProfiles([this.localProfileManager]);
|
||||
}
|
||||
try {
|
||||
|
|
@ -172,37 +166,26 @@ export class ConfigHandler {
|
|||
// Logged in
|
||||
const assistants =
|
||||
await this.controlPlaneClient.listAssistants(selectedOrgId);
|
||||
const hubProfiles = await Promise.all(
|
||||
assistants.map(async (assistant) => {
|
||||
let renderedConfig: AssistantUnrolled | undefined = undefined;
|
||||
if (assistant.configResult.config) {
|
||||
renderedConfig = await clientRenderHelper(
|
||||
{
|
||||
ownerSlug: assistant.ownerSlug,
|
||||
packageSlug: assistant.packageSlug,
|
||||
},
|
||||
YAML.stringify(assistant.configResult.config),
|
||||
this.ide,
|
||||
this.controlPlaneClient,
|
||||
);
|
||||
}
|
||||
|
||||
const profileLoader = new PlatformProfileLoader(
|
||||
{ ...assistant.configResult, config: renderedConfig },
|
||||
assistant.ownerSlug,
|
||||
assistant.packageSlug,
|
||||
assistant.iconUrl,
|
||||
assistant.configResult.config?.version ?? "latest",
|
||||
this.controlPlaneClient,
|
||||
this.ide,
|
||||
this.ideSettingsPromise,
|
||||
this.writeLog,
|
||||
this.reloadConfig.bind(this),
|
||||
);
|
||||
const hubProfiles = assistants.map((assistant) => {
|
||||
const profileLoader = new PlatformProfileLoader(
|
||||
{
|
||||
...assistant.configResult,
|
||||
config: assistant.configResult.config,
|
||||
},
|
||||
assistant.ownerSlug,
|
||||
assistant.packageSlug,
|
||||
assistant.iconUrl,
|
||||
assistant.configResult.config?.version ?? "latest",
|
||||
this.controlPlaneClient,
|
||||
this.ide,
|
||||
this.ideSettingsPromise,
|
||||
this.writeLog,
|
||||
this.reloadConfig.bind(this),
|
||||
);
|
||||
|
||||
return new ProfileLifecycleManager(profileLoader, this.ide);
|
||||
}),
|
||||
);
|
||||
return new ProfileLifecycleManager(profileLoader, this.ide);
|
||||
});
|
||||
|
||||
if (selectedOrgId === null) {
|
||||
// Personal
|
||||
|
|
@ -223,8 +206,16 @@ export class ConfigHandler {
|
|||
// Otherwise, choose the first profile
|
||||
const previouslySelectedProfileId =
|
||||
await this.getPersistedSelectedProfileId();
|
||||
const selectedProfileId =
|
||||
previouslySelectedProfileId ?? profiles[0].profileDescription.id ?? null;
|
||||
|
||||
// Check if the previously selected profile exists in the current profiles
|
||||
const profileExists = profiles.some(
|
||||
(profile) =>
|
||||
profile.profileDescription.id === previouslySelectedProfileId,
|
||||
);
|
||||
|
||||
const selectedProfileId = profileExists
|
||||
? previouslySelectedProfileId
|
||||
: (profiles[0]?.profileDescription.id ?? null);
|
||||
|
||||
// Notify listeners
|
||||
const profileDescriptions = profiles.map(
|
||||
|
|
@ -362,8 +353,10 @@ export class ConfigHandler {
|
|||
Promise.resolve(sessionInfo),
|
||||
this.ideSettingsPromise,
|
||||
);
|
||||
this.fetchControlPlaneProfiles().catch((e) => {
|
||||
this.fetchControlPlaneProfiles().catch(async (e) => {
|
||||
console.error("Failed to fetch control plane profiles: ", e);
|
||||
await this.updateAvailableProfiles([this.localProfileManager]);
|
||||
await this.reloadConfig();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import {
|
|||
EmbeddingsProviderDescription,
|
||||
IContextProvider,
|
||||
IDE,
|
||||
IdeInfo,
|
||||
IdeSettings,
|
||||
IdeType,
|
||||
ILLM,
|
||||
|
|
@ -62,7 +63,11 @@ import {
|
|||
getEsbuildBinaryPath,
|
||||
} from "../util/paths";
|
||||
|
||||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import {
|
||||
ConfigResult,
|
||||
ConfigValidationError,
|
||||
ModelRole,
|
||||
} from "@continuedev/config-yaml";
|
||||
import { useHub } from "../control-plane/env";
|
||||
import { localPathToUri } from "../util/pathToUri";
|
||||
import {
|
||||
|
|
@ -72,7 +77,8 @@ import {
|
|||
defaultSlashCommandsVscode,
|
||||
} from "./default";
|
||||
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
|
||||
import { modifyContinueConfigWithSharedConfig } from "./sharedConfig";
|
||||
import { modifyAnyConfigWithSharedConfig } from "./sharedConfig";
|
||||
import { getModelByRole } from "./util";
|
||||
import { validateConfig } from "./validation.js";
|
||||
|
||||
export function resolveSerializedConfig(
|
||||
|
|
@ -238,6 +244,7 @@ async function intermediateToFinalConfig(
|
|||
config: Config,
|
||||
ide: IDE,
|
||||
ideSettings: IdeSettings,
|
||||
ideInfo: IdeInfo,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
|
|
@ -326,7 +333,7 @@ async function intermediateToFinalConfig(
|
|||
...model.requestOptions,
|
||||
...config.requestOptions,
|
||||
};
|
||||
model.roles = model.roles ?? ["chat"]; // Default to chat role if not specified
|
||||
model.roles = model.roles ?? ["chat", "apply", "edit", "summarize"]; // Default to chat role if not specified
|
||||
}
|
||||
|
||||
if (allowFreeTrial) {
|
||||
|
|
@ -436,23 +443,28 @@ async function intermediateToFinalConfig(
|
|||
}
|
||||
|
||||
// Embeddings Provider
|
||||
const embeddingsProviderDescription = config.embeddingsProvider as
|
||||
| EmbeddingsProviderDescription
|
||||
| undefined;
|
||||
if (embeddingsProviderDescription?.provider) {
|
||||
const { provider, ...options } = embeddingsProviderDescription;
|
||||
function getEmbeddingsILLM(
|
||||
embedConfig: EmbeddingsProviderDescription | ILLM | undefined,
|
||||
): ILLM | null {
|
||||
if (!embedConfig) {
|
||||
return null;
|
||||
}
|
||||
if ("providerName" in embedConfig) {
|
||||
return embedConfig;
|
||||
}
|
||||
const { provider, ...options } = embedConfig;
|
||||
const embeddingsProviderClass = allEmbeddingsProviders[provider];
|
||||
if (embeddingsProviderClass) {
|
||||
if (
|
||||
embeddingsProviderClass.name === "_TransformersJsEmbeddingsProvider"
|
||||
) {
|
||||
config.embeddingsProvider = new embeddingsProviderClass();
|
||||
return new embeddingsProviderClass();
|
||||
} else {
|
||||
const llmOptions: LLMOptions = {
|
||||
model: options.model ?? "UNSPECIFIED",
|
||||
...options,
|
||||
};
|
||||
config.embeddingsProvider = new embeddingsProviderClass(
|
||||
return new embeddingsProviderClass(
|
||||
llmOptions,
|
||||
(url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
|
|
@ -461,42 +473,74 @@ async function intermediateToFinalConfig(
|
|||
}),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: `Embeddings provider ${provider} not found. Using default`,
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!config.embeddingsProvider) {
|
||||
config.embeddingsProvider = new TransformersJsEmbeddingsProvider();
|
||||
}
|
||||
const newEmbedder = getEmbeddingsILLM(config.embeddingsProvider);
|
||||
|
||||
// Reranker
|
||||
if (config.reranker && !(config.reranker as ILLM | undefined)?.rerank) {
|
||||
function getRerankingILLM(
|
||||
rerankingConfig: ILLM | RerankerDescription | undefined,
|
||||
): ILLM | null {
|
||||
if (!rerankingConfig) {
|
||||
return null;
|
||||
}
|
||||
if ("providerName" in rerankingConfig) {
|
||||
return rerankingConfig;
|
||||
}
|
||||
const { name, params } = config.reranker as RerankerDescription;
|
||||
const rerankerClass = AllRerankers[name];
|
||||
|
||||
if (name === "llm") {
|
||||
const llm = models.find((model) => model.title === params?.modelTitle);
|
||||
if (!llm) {
|
||||
console.warn(`Unknown model ${params?.modelTitle}`);
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: `Unknown reranking model ${params?.modelTitle}`,
|
||||
});
|
||||
return null;
|
||||
} else {
|
||||
config.reranker = new LLMReranker(llm);
|
||||
return new LLMReranker(llm);
|
||||
}
|
||||
} else if (rerankerClass) {
|
||||
const llmOptions: LLMOptions = {
|
||||
model: "rerank-2",
|
||||
...params,
|
||||
};
|
||||
config.reranker = new rerankerClass(llmOptions);
|
||||
return new rerankerClass(llmOptions);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const newReranker = getRerankingILLM(config.reranker);
|
||||
|
||||
let continueConfig: ContinueConfig = {
|
||||
const continueConfig: ContinueConfig = {
|
||||
...config,
|
||||
contextProviders,
|
||||
models,
|
||||
embeddingsProvider: config.embeddingsProvider as any,
|
||||
tabAutocompleteModels,
|
||||
reranker: config.reranker as any,
|
||||
tools: allTools,
|
||||
modelsByRole: {
|
||||
chat: models,
|
||||
edit: models,
|
||||
apply: models,
|
||||
summarize: models,
|
||||
autocomplete: [...tabAutocompleteModels],
|
||||
embed: newEmbedder ? [newEmbedder] : [],
|
||||
rerank: newReranker ? [newReranker] : [],
|
||||
},
|
||||
selectedModelByRole: {
|
||||
chat: null, // Not implemented (uses GUI defaultModel)
|
||||
edit: null,
|
||||
apply: null,
|
||||
embed: newEmbedder ?? null,
|
||||
autocomplete: null,
|
||||
rerank: newReranker ?? null,
|
||||
summarize: null, // Not implemented
|
||||
},
|
||||
};
|
||||
|
||||
// Apply MCP if specified
|
||||
|
|
@ -538,49 +582,112 @@ async function intermediateToFinalConfig(
|
|||
);
|
||||
}
|
||||
|
||||
// Handle experimental modelRole config values for apply and edit
|
||||
const inlineEditModel = getModelByRole(continueConfig, "inlineEdit")?.title;
|
||||
if (inlineEditModel) {
|
||||
const match = continueConfig.models.find(
|
||||
(m) => m.title === inlineEditModel,
|
||||
);
|
||||
if (match) {
|
||||
continueConfig.selectedModelByRole.edit = match;
|
||||
continueConfig.modelsByRole.edit = [match]; // The only option if inlineEdit role is set
|
||||
} else {
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: `experimental.modelRoles.inlineEdit model title ${inlineEditModel} not found in models array`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const applyBlockModel = getModelByRole(
|
||||
continueConfig,
|
||||
"applyCodeBlock",
|
||||
)?.title;
|
||||
if (applyBlockModel) {
|
||||
const match = continueConfig.models.find(
|
||||
(m) => m.title === applyBlockModel,
|
||||
);
|
||||
if (match) {
|
||||
continueConfig.selectedModelByRole.apply = match;
|
||||
continueConfig.modelsByRole.apply = [match]; // The only option if applyCodeBlock role is set
|
||||
} else {
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: `experimental.modelRoles.applyCodeBlock model title ${inlineEditModel} not found in models array`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Add transformers JS to the embed models list if not already added
|
||||
if (
|
||||
ideInfo.ideType === "vscode" &&
|
||||
!continueConfig.modelsByRole.embed.find(
|
||||
(m) => m.providerName === "transformers.js",
|
||||
)
|
||||
) {
|
||||
continueConfig.modelsByRole.embed.push(
|
||||
new TransformersJsEmbeddingsProvider(),
|
||||
);
|
||||
}
|
||||
|
||||
return { config: continueConfig, errors };
|
||||
}
|
||||
|
||||
function llmToSerializedModelDescription(llm: ILLM): ModelDescription {
|
||||
return {
|
||||
provider: llm.providerName,
|
||||
model: llm.model,
|
||||
title: llm.title ?? llm.model,
|
||||
apiKey: llm.apiKey,
|
||||
apiBase: llm.apiBase,
|
||||
contextLength: llm.contextLength,
|
||||
template: llm.template,
|
||||
completionOptions: llm.completionOptions,
|
||||
systemMessage: llm.systemMessage,
|
||||
requestOptions: llm.requestOptions,
|
||||
promptTemplates: llm.promptTemplates as any,
|
||||
capabilities: llm.capabilities,
|
||||
roles: llm.roles,
|
||||
};
|
||||
}
|
||||
|
||||
async function finalToBrowserConfig(
|
||||
final: ContinueConfig,
|
||||
ide: IDE,
|
||||
): Promise<BrowserSerializedContinueConfig> {
|
||||
return {
|
||||
allowAnonymousTelemetry: final.allowAnonymousTelemetry,
|
||||
models: final.models.map((m) => ({
|
||||
provider: m.providerName,
|
||||
model: m.model,
|
||||
title: m.title ?? m.model,
|
||||
apiKey: m.apiKey,
|
||||
apiBase: m.apiBase,
|
||||
contextLength: m.contextLength,
|
||||
template: m.template,
|
||||
completionOptions: m.completionOptions,
|
||||
systemMessage: m.systemMessage,
|
||||
requestOptions: m.requestOptions,
|
||||
promptTemplates: m.promptTemplates as any,
|
||||
capabilities: m.capabilities,
|
||||
roles: m.roles,
|
||||
})),
|
||||
models: final.models.map(llmToSerializedModelDescription),
|
||||
systemMessage: final.systemMessage,
|
||||
completionOptions: final.completionOptions,
|
||||
slashCommands: final.slashCommands?.map((s) => ({
|
||||
name: s.name,
|
||||
description: s.description,
|
||||
params: s.params, //PZTODO: is this why params aren't referenced properly by slash commands?
|
||||
params: s.params, // TODO: is this why params aren't referenced properly by slash commands?
|
||||
})),
|
||||
contextProviders: final.contextProviders?.map((c) => c.description),
|
||||
disableIndexing: final.disableIndexing,
|
||||
disableSessionTitles: final.disableSessionTitles,
|
||||
userToken: final.userToken,
|
||||
embeddingsProvider: final.embeddingsProvider?.embeddingId,
|
||||
ui: final.ui,
|
||||
experimental: final.experimental,
|
||||
docs: final.docs,
|
||||
tools: final.tools,
|
||||
tabAutocompleteOptions: final.tabAutocompleteOptions,
|
||||
usePlatform: await useHub(ide.getIdeSettings()),
|
||||
// data not included here
|
||||
modelsByRole: Object.fromEntries(
|
||||
Object.entries(final.modelsByRole).map(([k, v]) => [
|
||||
k,
|
||||
v.map(llmToSerializedModelDescription),
|
||||
]),
|
||||
) as Record<ModelRole, ModelDescription[]>, // TODO better types here
|
||||
selectedModelByRole: Object.fromEntries(
|
||||
Object.entries(final.selectedModelByRole).map(([k, v]) => [
|
||||
k,
|
||||
v ? llmToSerializedModelDescription(v) : null,
|
||||
]),
|
||||
) as Record<ModelRole, ModelDescription | null>, // TODO better types here
|
||||
// data not included here because client doesn't need
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -768,7 +875,7 @@ async function loadContinueConfigFromJson(
|
|||
ide: IDE,
|
||||
workspaceConfigs: ContinueRcJson[],
|
||||
ideSettings: IdeSettings,
|
||||
ideType: IdeType,
|
||||
ideInfo: IdeInfo,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
|
|
@ -782,7 +889,7 @@ async function loadContinueConfigFromJson(
|
|||
} = loadSerializedConfig(
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
ideType,
|
||||
ideInfo.ideType,
|
||||
overrideConfigJson,
|
||||
ide,
|
||||
);
|
||||
|
|
@ -799,16 +906,16 @@ async function loadContinueConfigFromJson(
|
|||
// Apply shared config
|
||||
// TODO: override several of these values with user/org shared config
|
||||
const sharedConfig = new GlobalContext().getSharedConfig();
|
||||
const withShared = modifyContinueConfigWithSharedConfig(
|
||||
serialized,
|
||||
sharedConfig,
|
||||
);
|
||||
const withShared = modifyAnyConfigWithSharedConfig(serialized, sharedConfig);
|
||||
|
||||
// Convert serialized to intermediate config
|
||||
let intermediate = await serializedToIntermediateConfig(withShared, ide);
|
||||
|
||||
// Apply config.ts to modify intermediate config
|
||||
const configJsContents = await buildConfigTsandReadConfigJs(ide, ideType);
|
||||
const configJsContents = await buildConfigTsandReadConfigJs(
|
||||
ide,
|
||||
ideInfo.ideType,
|
||||
);
|
||||
if (configJsContents) {
|
||||
try {
|
||||
// Try config.ts first
|
||||
|
|
@ -868,6 +975,7 @@ async function loadContinueConfigFromJson(
|
|||
intermediate,
|
||||
ide,
|
||||
ideSettings,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ export default class LocalProfileLoader implements IProfileLoader {
|
|||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
this.description.id,
|
||||
);
|
||||
|
||||
this.description.errors = result.errors;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export default class PlatformProfileLoader implements IProfileLoader {
|
|||
packageSlug,
|
||||
versionSlug,
|
||||
},
|
||||
title: `${ownerSlug}/${packageSlug}@${versionSlug}`,
|
||||
title: configResult.config?.name ?? `${ownerSlug}/${packageSlug}`,
|
||||
errors: configResult.errors,
|
||||
iconUrl: this.iconUrl,
|
||||
};
|
||||
|
|
@ -69,6 +69,7 @@ export default class PlatformProfileLoader implements IProfileLoader {
|
|||
ownerSlug: this.ownerSlug,
|
||||
packageSlug: this.packageSlug,
|
||||
},
|
||||
this.description.id,
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {
|
|||
AssistantUnrolled,
|
||||
ConfigResult,
|
||||
ConfigValidationError,
|
||||
ModelRole,
|
||||
} from "@continuedev/config-yaml";
|
||||
import {
|
||||
ContinueConfig,
|
||||
|
|
@ -24,6 +25,7 @@ import { loadContinueConfigFromJson } from "../load";
|
|||
import { migrateJsonSharedConfig } from "../migrateSharedConfig";
|
||||
import { loadContinueConfigFromYaml } from "../yaml/loadYaml";
|
||||
import { PlatformConfigMetadata } from "./PlatformProfileLoader";
|
||||
import { rectifySelectedModelsFromGlobalContext } from "../selectedModels";
|
||||
|
||||
export default async function doLoadConfig(
|
||||
ide: IDE,
|
||||
|
|
@ -33,7 +35,7 @@ export default async function doLoadConfig(
|
|||
overrideConfigJson: SerializedContinueConfig | undefined,
|
||||
overrideConfigYaml: AssistantUnrolled | undefined,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
workspaceId?: string,
|
||||
profileId: string,
|
||||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
const workspaceConfigs = await getWorkspaceConfigs(ide);
|
||||
const ideInfo = await ide.getIdeInfo();
|
||||
|
|
@ -59,7 +61,7 @@ export default async function doLoadConfig(
|
|||
ide,
|
||||
workspaceConfigs.map((c) => JSON.stringify(c)),
|
||||
ideSettings,
|
||||
ideInfo.ideType,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
|
|
@ -75,7 +77,7 @@ export default async function doLoadConfig(
|
|||
ide,
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
ideInfo.ideType,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
|
|
@ -86,6 +88,11 @@ export default async function doLoadConfig(
|
|||
configLoadInterrupted = result.configLoadInterrupted;
|
||||
}
|
||||
|
||||
// Rectify model selections for each role
|
||||
if (newConfig) {
|
||||
newConfig = rectifySelectedModelsFromGlobalContext(newConfig, profileId);
|
||||
}
|
||||
|
||||
if (configLoadInterrupted || !newConfig) {
|
||||
return { errors, config: newConfig, configLoadInterrupted: true };
|
||||
}
|
||||
|
|
@ -117,7 +124,7 @@ export default async function doLoadConfig(
|
|||
controlPlaneProxyUrl += "/";
|
||||
}
|
||||
const controlPlaneProxyInfo = {
|
||||
workspaceId,
|
||||
profileId,
|
||||
controlPlaneProxyUrl,
|
||||
workOsAccessToken,
|
||||
};
|
||||
|
|
@ -147,21 +154,26 @@ async function injectControlPlaneProxyInfo(
|
|||
config: ContinueConfig,
|
||||
info: ControlPlaneProxyInfo,
|
||||
): Promise<ContinueConfig> {
|
||||
[...config.models, ...(config.tabAutocompleteModels ?? [])].forEach(
|
||||
async (model) => {
|
||||
Object.keys(config.modelsByRole).forEach((key) => {
|
||||
config.modelsByRole[key as ModelRole].forEach((model) => {
|
||||
if (model.providerName === "continue-proxy") {
|
||||
(model as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
if (config.embeddingsProvider?.providerName === "continue-proxy") {
|
||||
(config.embeddingsProvider as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
Object.keys(config.selectedModelByRole).forEach((key) => {
|
||||
const model = config.selectedModelByRole[key as ModelRole];
|
||||
if (model?.providerName === "continue-proxy") {
|
||||
(model as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
});
|
||||
|
||||
if (config.reranker?.providerName === "continue-proxy") {
|
||||
(config.reranker as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
config.models.forEach((model) => {
|
||||
if (model.providerName === "continue-proxy") {
|
||||
(model as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
67
core/config/selectedModels.ts
Normal file
67
core/config/selectedModels.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { ModelRole } from "@continuedev/config-yaml";
|
||||
|
||||
import { ContinueConfig, ILLM } from "..";
|
||||
import {
|
||||
GlobalContext,
|
||||
GlobalContextModelSelections,
|
||||
} from "../util/GlobalContext";
|
||||
|
||||
export function rectifySelectedModelsFromGlobalContext(
|
||||
continueConfig: ContinueConfig,
|
||||
profileId: string,
|
||||
): ContinueConfig {
|
||||
const configCopy = { ...continueConfig };
|
||||
|
||||
const globalContext = new GlobalContext();
|
||||
const currentSelectedModels = globalContext.get("selectedModelsByProfileId");
|
||||
const currentForProfile: GlobalContextModelSelections =
|
||||
currentSelectedModels?.[profileId] ?? {};
|
||||
|
||||
let fellBack = false;
|
||||
|
||||
// chat and summarize not implemented yet
|
||||
// default chat model is stored in GUI still
|
||||
|
||||
const roles: ModelRole[] = [
|
||||
"autocomplete",
|
||||
"apply",
|
||||
"edit",
|
||||
"embed",
|
||||
"rerank",
|
||||
];
|
||||
for (const role of roles) {
|
||||
let newModel: ILLM | null = null;
|
||||
const currentSelection = currentForProfile[role] ?? null;
|
||||
if (currentSelection) {
|
||||
const match = continueConfig.modelsByRole[role].find(
|
||||
(m) => m.title === currentSelection,
|
||||
);
|
||||
if (match) {
|
||||
newModel = match;
|
||||
}
|
||||
}
|
||||
if (!newModel && continueConfig.modelsByRole[role].length > 0) {
|
||||
newModel = continueConfig.modelsByRole[role][0];
|
||||
}
|
||||
if (!(currentSelection === (newModel?.title ?? null))) {
|
||||
fellBack = true;
|
||||
}
|
||||
configCopy.selectedModelByRole[role] = newModel;
|
||||
}
|
||||
|
||||
// In the case shared config wasn't respected,
|
||||
// Rewrite the shared config
|
||||
if (fellBack) {
|
||||
globalContext.update("selectedModelsByProfileId", {
|
||||
...currentSelectedModels,
|
||||
[profileId]: Object.fromEntries(
|
||||
Object.entries(configCopy.selectedModelByRole).map(([key, value]) => [
|
||||
key,
|
||||
value?.title ?? null,
|
||||
]),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
return configCopy;
|
||||
}
|
||||
|
|
@ -1,13 +1,22 @@
|
|||
import {
|
||||
ModelRole,
|
||||
modelRolesSchema,
|
||||
} from "@continuedev/config-yaml/dist/schemas/models";
|
||||
import z from "zod";
|
||||
|
||||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
ContinueConfig,
|
||||
Config,
|
||||
SerializedContinueConfig,
|
||||
} from "..";
|
||||
import { GlobalContext } from "../util/GlobalContext";
|
||||
|
||||
const selectedModelsSchema = z.record(modelRolesSchema, z.string().nullable());
|
||||
|
||||
export const sharedConfigSchema = z
|
||||
.object({
|
||||
// boolean fields in config.json
|
||||
allowAnonymousTelemetry: z.boolean(),
|
||||
disableIndexing: z.boolean(),
|
||||
disableSessionTitles: z.boolean(),
|
||||
|
|
@ -65,7 +74,19 @@ export function salvageSharedConfig(sharedConfig: object): SharedConfigSchema {
|
|||
return salvagedConfig;
|
||||
}
|
||||
|
||||
export function modifyContinueConfigWithSharedConfig<
|
||||
// Apply shared config to all forms of config
|
||||
// - SerializedContinueConfig (config.json)
|
||||
// - Config ("intermediate") - passed to config.ts
|
||||
// - ContinueConfig
|
||||
// - BrowserSerializedContinueConfig (final converted to be passed to GUI)
|
||||
|
||||
// This modify function is split into two steps
|
||||
// - rectifySharedModelsFromSharedConfig - includes boolean flags like allowAnonymousTelemetry which
|
||||
// must be added BEFORE config.ts and remote server config apply for JSON
|
||||
// for security reasons
|
||||
// - setSharedModelsFromSharedConfig - exists because of selectedModelsByRole
|
||||
// Which don't exist on SerializedContinueConfig/Config types, so must be added after the fact
|
||||
export function modifyAnyConfigWithSharedConfig<
|
||||
T extends
|
||||
| ContinueConfig
|
||||
| BrowserSerializedContinueConfig
|
||||
|
|
@ -92,6 +113,7 @@ export function modifyContinueConfigWithSharedConfig<
|
|||
configCopy.ui = {
|
||||
...configCopy.ui,
|
||||
};
|
||||
|
||||
if (sharedConfig.codeBlockToolbarPosition !== undefined) {
|
||||
configCopy.ui.codeBlockToolbarPosition =
|
||||
sharedConfig.codeBlockToolbarPosition;
|
||||
|
|
@ -135,28 +157,3 @@ export function modifyContinueConfigWithSharedConfig<
|
|||
|
||||
return configCopy;
|
||||
}
|
||||
|
||||
// continueConfig.tabAutocompleteOptions = {
|
||||
// ...continueConfig.tabAutocompleteOptions,
|
||||
// useCache: sharedConfig.useAutocompleteCache,
|
||||
// disableInFiles: sharedConfig.disableAutocompleteInFiles,
|
||||
// multilineCompletions: sharedConfig.useAutocompleteMultilineCompletions,
|
||||
// };
|
||||
// continueConfig.ui = {
|
||||
// ...continueConfig.ui,
|
||||
// codeBlockToolbarPosition: sharedConfig.codeBlockToolbarPosition,
|
||||
// fontSize: sharedConfig.fontSize,
|
||||
// codeWrap: sharedConfig.codeWrap,
|
||||
// displayRawMarkdown: sharedConfig.displayRawMarkdown,
|
||||
// showChatScrollbar: sharedConfig.showChatScrollbar,
|
||||
// };
|
||||
// continueConfig.allowAnonymousTelemetry = sharedConfig.allowAnonymousTelemetry;
|
||||
// continueConfig.disableIndexing = sharedConfig.disableIndexing;
|
||||
// continueConfig.disableIndexing = sharedConfig.disableIndexing;
|
||||
// continueConfig.disableSessionTitles = sharedConfig.disableSessionTitles;
|
||||
// continueConfig.experimental = {
|
||||
// ...continueConfig.experimental,
|
||||
// useChromiumForDocsCrawling: sharedConfig.useChromiumForDocsCrawling,
|
||||
// readResponseTTS: sharedConfig.readResponseTTS,
|
||||
// promptPath: sharedConfig.promptPath,
|
||||
// };
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
import {
|
||||
clientRender,
|
||||
PackageSlug,
|
||||
PlatformClient,
|
||||
SecretStore,
|
||||
} from "@continuedev/config-yaml";
|
||||
|
||||
import { IDE } from "../..";
|
||||
import { ControlPlaneClient } from "../../control-plane/client";
|
||||
|
||||
export async function clientRenderHelper(
|
||||
packageSlug: PackageSlug,
|
||||
unrolledAssistant: string,
|
||||
ide: IDE,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
) {
|
||||
const ideSecretStore: SecretStore = {
|
||||
get: async function (secretName: string): Promise<string | undefined> {
|
||||
const results = await ide.readSecrets([secretName]);
|
||||
return results[secretName];
|
||||
},
|
||||
set: async function (
|
||||
secretName: string,
|
||||
secretValue: string,
|
||||
): Promise<void> {
|
||||
return await ide.writeSecrets({
|
||||
[secretName]: secretValue,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const platformClient: PlatformClient = {
|
||||
resolveFQSNs: controlPlaneClient.resolveFQSNs.bind(controlPlaneClient),
|
||||
};
|
||||
|
||||
const userId = await controlPlaneClient.userId;
|
||||
return await clientRender(
|
||||
packageSlug,
|
||||
unrolledAssistant,
|
||||
ideSecretStore,
|
||||
userId ? platformClient : undefined,
|
||||
);
|
||||
}
|
||||
|
|
@ -15,10 +15,11 @@ export function convertConfigJsonToConfigYaml(
|
|||
name: model.title,
|
||||
// defaultCompletionOptions: model.completionOptions,
|
||||
provider: model.provider,
|
||||
roles: ["chat"],
|
||||
roles: ["chat", "edit", "apply", "summarize"],
|
||||
}),
|
||||
),
|
||||
// ... tabAutocompleteModels
|
||||
// TODO
|
||||
// tabAutocompleteModels
|
||||
// embeddingsModels
|
||||
// rerankModels
|
||||
],
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import {
|
|||
ContinueConfig,
|
||||
IContextProvider,
|
||||
IDE,
|
||||
IdeInfo,
|
||||
IdeSettings,
|
||||
IdeType,
|
||||
SlashCommand,
|
||||
} from "../..";
|
||||
import { slashFromCustomCommand } from "../../commands";
|
||||
|
|
@ -37,7 +37,7 @@ import { GlobalContext } from "../../util/GlobalContext";
|
|||
import { getConfigYamlPath } from "../../util/paths";
|
||||
import { getSystemPromptDotFile } from "../getSystemPromptDotFile";
|
||||
import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader";
|
||||
import { modifyContinueConfigWithSharedConfig } from "../sharedConfig";
|
||||
import { modifyAnyConfigWithSharedConfig } from "../sharedConfig";
|
||||
|
||||
import { llmsFromModelConfig } from "./models";
|
||||
|
||||
|
|
@ -98,6 +98,7 @@ async function configYamlToContinueConfig(
|
|||
config: AssistantUnrolled,
|
||||
ide: IDE,
|
||||
ideSettings: IdeSettings,
|
||||
ideInfo: IdeInfo,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
|
|
@ -111,10 +112,8 @@ async function configYamlToContinueConfig(
|
|||
...(config.prompts?.map(slashFromCustomCommand) ?? []),
|
||||
],
|
||||
models: [],
|
||||
tabAutocompleteModels: [],
|
||||
tools: allTools,
|
||||
systemMessage: config.rules?.join("\n"),
|
||||
embeddingsProvider: new TransformersJsEmbeddingsProvider(),
|
||||
experimental: {
|
||||
modelContextProtocolServers: config.mcpServers?.map((mcpServer) => ({
|
||||
transport: {
|
||||
|
|
@ -132,60 +131,125 @@ async function configYamlToContinueConfig(
|
|||
faviconUrl: doc.faviconUrl,
|
||||
})),
|
||||
contextProviders: [],
|
||||
modelsByRole: {
|
||||
chat: [],
|
||||
edit: [],
|
||||
apply: [],
|
||||
embed: [],
|
||||
autocomplete: [],
|
||||
rerank: [],
|
||||
summarize: [],
|
||||
},
|
||||
selectedModelByRole: {
|
||||
chat: null, // not currently used - defaultModel on GUI is used
|
||||
edit: null, // not currently used
|
||||
apply: null,
|
||||
embed: null,
|
||||
autocomplete: null,
|
||||
rerank: null,
|
||||
summarize: null,
|
||||
},
|
||||
data: config.data,
|
||||
};
|
||||
|
||||
// Models
|
||||
const modelsArrayRoles: ModelRole[] = ["chat", "summarize", "apply", "edit"];
|
||||
for (const model of config.models ?? []) {
|
||||
model.roles = model.roles ?? ["chat"]; // Default to chat role if not specified
|
||||
model.roles = model.roles ?? modelsArrayRoles; // Default to all 4 chat-esque roles if not specified
|
||||
const llms = await llmsFromModelConfig(
|
||||
model,
|
||||
ide,
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
continueConfig.systemMessage,
|
||||
);
|
||||
|
||||
//
|
||||
if (modelsArrayRoles.some((role) => model.roles?.includes(role))) {
|
||||
// Main model array
|
||||
const llms = await llmsFromModelConfig(
|
||||
model,
|
||||
ide,
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
continueConfig.systemMessage,
|
||||
);
|
||||
continueConfig.models.push(...llms);
|
||||
}
|
||||
|
||||
if (model.roles?.includes("chat")) {
|
||||
continueConfig.modelsByRole.chat.push(...llms);
|
||||
}
|
||||
|
||||
if (model.roles?.includes("summarize")) {
|
||||
continueConfig.modelsByRole.summarize.push(...llms);
|
||||
}
|
||||
|
||||
if (model.roles?.includes("apply")) {
|
||||
continueConfig.modelsByRole.apply.push(...llms);
|
||||
}
|
||||
|
||||
if (model.roles?.includes("edit")) {
|
||||
continueConfig.modelsByRole.edit.push(...llms);
|
||||
}
|
||||
|
||||
if (model.roles?.includes("autocomplete")) {
|
||||
// Autocomplete models array
|
||||
const llms = await llmsFromModelConfig(
|
||||
model,
|
||||
ide,
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
continueConfig.systemMessage,
|
||||
);
|
||||
continueConfig.tabAutocompleteModels?.push(...llms);
|
||||
continueConfig.modelsByRole.autocomplete.push(...llms);
|
||||
}
|
||||
|
||||
if (
|
||||
model.roles?.includes("apply") &&
|
||||
!continueConfig.experimental?.modelRoles?.applyCodeBlock
|
||||
) {
|
||||
continueConfig.experimental ??= {};
|
||||
continueConfig.experimental!.modelRoles ??= {};
|
||||
continueConfig.experimental!.modelRoles!.applyCodeBlock = model.name;
|
||||
if (model.roles?.includes("embed")) {
|
||||
const { provider, ...options } = model;
|
||||
const embeddingsProviderClass = allEmbeddingsProviders[provider];
|
||||
if (embeddingsProviderClass) {
|
||||
if (
|
||||
embeddingsProviderClass.name === "_TransformersJsEmbeddingsProvider"
|
||||
) {
|
||||
continueConfig.modelsByRole.embed.push(new embeddingsProviderClass());
|
||||
} else {
|
||||
continueConfig.modelsByRole.embed.push(
|
||||
new embeddingsProviderClass(
|
||||
options,
|
||||
(url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
...options.requestOptions,
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: `Unsupported embeddings model provider found: ${provider}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
model.roles?.includes("edit") &&
|
||||
!continueConfig.experimental?.modelRoles?.inlineEdit
|
||||
) {
|
||||
continueConfig.experimental ??= {};
|
||||
continueConfig.experimental!.modelRoles ??= {};
|
||||
continueConfig.experimental!.modelRoles!.inlineEdit = model.name;
|
||||
if (model.roles?.includes("rerank")) {
|
||||
const { provider, ...options } = model;
|
||||
const rerankerClass = AllRerankers[provider];
|
||||
if (rerankerClass) {
|
||||
continueConfig.modelsByRole.rerank.push(
|
||||
new rerankerClass(options, (url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
...options.requestOptions,
|
||||
}),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: `Unsupported reranking model provider found: ${provider}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add transformers js to the embed models in vs code if not already added
|
||||
if (
|
||||
ideInfo.ideType === "vscode" &&
|
||||
!continueConfig.modelsByRole.embed.find(
|
||||
(m) => m.providerName === "transformers.js",
|
||||
)
|
||||
) {
|
||||
continueConfig.modelsByRole.embed.push(
|
||||
new TransformersJsEmbeddingsProvider(),
|
||||
);
|
||||
}
|
||||
|
||||
if (allowFreeTrial) {
|
||||
// Obtain auth token (iff free trial being used)
|
||||
const freeTrialModels = continueConfig.models.filter(
|
||||
|
|
@ -204,8 +268,6 @@ async function configYamlToContinueConfig(
|
|||
);
|
||||
}
|
||||
|
||||
// TODO: Split into model roles.
|
||||
|
||||
// Context providers
|
||||
const codebaseContextParams: IContextProvider[] =
|
||||
(config.context || []).find((cp) => cp.provider === "codebase")?.params ||
|
||||
|
|
@ -244,51 +306,6 @@ async function configYamlToContinueConfig(
|
|||
continueConfig.contextProviders.push(new DocsContextProvider({}));
|
||||
}
|
||||
|
||||
// Embeddings Provider
|
||||
// IMPORTANT this currently will grab the first model found with an embed role
|
||||
const embedConfig = config.models?.find((model) =>
|
||||
model.roles?.includes("embed"),
|
||||
);
|
||||
if (embedConfig) {
|
||||
const { provider, ...options } = embedConfig;
|
||||
const embeddingsProviderClass = allEmbeddingsProviders[provider];
|
||||
if (embeddingsProviderClass) {
|
||||
if (
|
||||
embeddingsProviderClass.name === "_TransformersJsEmbeddingsProvider"
|
||||
) {
|
||||
continueConfig.embeddingsProvider = new embeddingsProviderClass();
|
||||
} else {
|
||||
continueConfig.embeddingsProvider = new embeddingsProviderClass(
|
||||
options,
|
||||
(url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
...options.requestOptions,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reranker
|
||||
// IMPORTANT this currently will grab the first model found with a rerank role
|
||||
const rerankConfig = config.models?.find((model) =>
|
||||
model.roles?.includes("rerank"),
|
||||
);
|
||||
if (rerankConfig) {
|
||||
const { provider, ...options } = rerankConfig;
|
||||
const rerankerClass = AllRerankers[provider];
|
||||
|
||||
if (rerankerClass) {
|
||||
continueConfig.reranker = new rerankerClass(
|
||||
options,
|
||||
(url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
...options.requestOptions,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply MCP if specified
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
await Promise.all(
|
||||
|
|
@ -342,7 +359,7 @@ export async function loadContinueConfigFromYaml(
|
|||
ide: IDE,
|
||||
workspaceConfigs: string[],
|
||||
ideSettings: IdeSettings,
|
||||
ideType: IdeType,
|
||||
ideInfo: IdeInfo,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
|
|
@ -352,7 +369,7 @@ export async function loadContinueConfigFromYaml(
|
|||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
const rawYaml =
|
||||
overrideConfigYaml === undefined
|
||||
? fs.readFileSync(getConfigYamlPath(ideType), "utf-8")
|
||||
? fs.readFileSync(getConfigYamlPath(ideInfo.ideType), "utf-8")
|
||||
: "";
|
||||
|
||||
const configYamlResult = await loadConfigYaml(
|
||||
|
|
@ -375,6 +392,7 @@ export async function loadContinueConfigFromYaml(
|
|||
configYamlResult.config,
|
||||
ide,
|
||||
ideSettings,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
|
|
@ -393,7 +411,7 @@ export async function loadContinueConfigFromYaml(
|
|||
// Apply shared config
|
||||
// TODO: override several of these values with user/org shared config
|
||||
const sharedConfig = new GlobalContext().getSharedConfig();
|
||||
const withShared = modifyContinueConfigWithSharedConfig(
|
||||
const withShared = modifyAnyConfigWithSharedConfig(
|
||||
continueConfig,
|
||||
sharedConfig,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ async function getContextProviderExtras(
|
|||
fullInput,
|
||||
ide,
|
||||
config,
|
||||
embeddingsProvider: config.embeddingsProvider,
|
||||
embeddingsProvider: config.selectedModelByRole.embed,
|
||||
fetch: fetch,
|
||||
llm: config.models[0],
|
||||
reranker: config.reranker,
|
||||
reranker: config.selectedModelByRole.rerank,
|
||||
selectedCode: [],
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import { FullTextSearchCodebaseIndex } from "../../../indexing/FullTextSearchCod
|
|||
import { LanceDbIndex } from "../../../indexing/LanceDbIndex";
|
||||
import { recentlyEditedFilesCache } from "../recentlyEditedFilesCache";
|
||||
|
||||
const DEFAULT_CHUNK_SIZE = 384;
|
||||
|
||||
export interface RetrievalPipelineOptions {
|
||||
llm: ILLM;
|
||||
config: ContinueConfig;
|
||||
|
|
@ -16,13 +18,13 @@ export interface RetrievalPipelineOptions {
|
|||
nFinal: number;
|
||||
tags: BranchAndDir[];
|
||||
filterDirectory?: string;
|
||||
includeEmbeddings?: boolean; // Used to handle JB w/o an embeddings model
|
||||
}
|
||||
|
||||
export interface RetrievalPipelineRunArguments {
|
||||
query: string;
|
||||
tags: BranchAndDir[];
|
||||
filterDirectory?: string;
|
||||
includeEmbeddings: boolean;
|
||||
}
|
||||
|
||||
export interface IRetrievalPipeline {
|
||||
|
|
@ -35,7 +37,7 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
|
|||
|
||||
constructor(protected readonly options: RetrievalPipelineOptions) {
|
||||
this.lanceDbIndex = new LanceDbIndex(
|
||||
options.config.embeddingsProvider,
|
||||
options.config.selectedModelByRole.embed,
|
||||
(uri) => options.ide.readFile(uri),
|
||||
);
|
||||
}
|
||||
|
|
@ -109,7 +111,7 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
|
|||
filepath,
|
||||
contents,
|
||||
maxChunkSize:
|
||||
this.options.config.embeddingsProvider.maxEmbeddingChunkSize,
|
||||
this.options.config.selectedModelByRole.embed?.maxEmbeddingChunkSize ?? DEFAULT_CHUNK_SIZE,
|
||||
digest: filepath,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import BaseRetrievalPipeline, {
|
|||
|
||||
export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
||||
async run(args: RetrievalPipelineRunArguments): Promise<Chunk[]> {
|
||||
const { input, nFinal, filterDirectory, includeEmbeddings } = this.options;
|
||||
const { input, nFinal, filterDirectory, config } = this.options;
|
||||
|
||||
// We give 1/4 weight to recently edited files, 1/4 to full text search,
|
||||
// and the remaining 1/2 to embeddings
|
||||
|
|
@ -21,7 +21,7 @@ export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
|
||||
const ftsChunks = await this.retrieveFts(args, ftsNFinal);
|
||||
|
||||
const embeddingsChunks = includeEmbeddings
|
||||
const embeddingsChunks = !!config.selectedModelByRole.embed
|
||||
? await this.retrieveEmbeddings(input, embeddingsNFinal)
|
||||
: [];
|
||||
|
||||
|
|
|
|||
|
|
@ -12,13 +12,12 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
private async _retrieveInitial(
|
||||
args: RetrievalPipelineRunArguments,
|
||||
): Promise<Chunk[]> {
|
||||
const { input, nRetrieve, filterDirectory, includeEmbeddings } =
|
||||
this.options;
|
||||
const { input, nRetrieve, filterDirectory, config } = this.options;
|
||||
|
||||
let retrievalResults: Chunk[] = [];
|
||||
|
||||
const ftsChunks = await this.retrieveFts(args, nRetrieve);
|
||||
const embeddingsChunks = includeEmbeddings
|
||||
const embeddingsChunks = !!config.selectedModelByRole.embed
|
||||
? await this.retrieveEmbeddings(input, nRetrieve)
|
||||
: [];
|
||||
const recentlyEditedFilesChunks =
|
||||
|
|
@ -53,17 +52,18 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
}
|
||||
|
||||
private async _rerank(input: string, chunks: Chunk[]): Promise<Chunk[]> {
|
||||
if (!this.options.config.reranker) {
|
||||
throw new Error("No reranker provided");
|
||||
if (!this.options.config.selectedModelByRole.rerank) {
|
||||
throw new Error("No reranker set up");
|
||||
}
|
||||
|
||||
// remove empty chunks -- some APIs fail on that
|
||||
chunks = chunks.filter((chunk) => chunk.content);
|
||||
|
||||
let scores: number[] = await this.options.config.reranker.rerank(
|
||||
input,
|
||||
chunks,
|
||||
);
|
||||
let scores: number[] =
|
||||
await this.options.config.selectedModelByRole.rerank.rerank(
|
||||
input,
|
||||
chunks,
|
||||
);
|
||||
|
||||
// Filter out low-scoring results
|
||||
let results = chunks;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { Chunk, ContinueConfig, IDE, ILLM } from "../..";
|
|||
import { getModelByRole } from "../../config/util";
|
||||
import generateRepoMap from "../../util/generateRepoMap";
|
||||
import { renderChatMessage } from "../../util/messageContent";
|
||||
import { getUriPathBasename } from "../../util/uri";
|
||||
|
||||
const SUPPORTED_MODEL_TITLE_FAMILIES = [
|
||||
"claude-3",
|
||||
|
|
@ -16,7 +15,7 @@ function isSupportedModel(
|
|||
config: ContinueConfig,
|
||||
modelTitle?: string,
|
||||
): boolean {
|
||||
if (config.experimental?.modelRoles?.applyCodeBlock) {
|
||||
if (config.experimental?.modelRoles?.repoMapFileSelection) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { BranchAndDir, ContextItem, ContextProviderExtras } from "../../";
|
||||
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { getUriDescription } from "../../util/uri";
|
||||
import { INSTRUCTIONS_BASE_ITEM } from "../providers/utils";
|
||||
|
||||
|
|
@ -14,26 +13,16 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
options: any | undefined,
|
||||
filterDirectory: string | undefined,
|
||||
): Promise<ContextItem[]> {
|
||||
if (!extras.embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// transformers.js not supported in JetBrains IDEs right now
|
||||
|
||||
const isJetBrainsAndTransformersJs =
|
||||
extras.embeddingsProvider.providerName ===
|
||||
TransformersJsEmbeddingsProvider.providerName &&
|
||||
(await extras.ide.getIdeInfo()).ideType === "jetbrains";
|
||||
|
||||
if (isJetBrainsAndTransformersJs) {
|
||||
void extras.ide.showToast(
|
||||
"warning",
|
||||
"Codebase retrieval is limited when `embeddingsProvider` is empty or set to `transformers.js` in JetBrains. " +
|
||||
"You can use Ollama to set up local embeddings, use our 'free-trial', " +
|
||||
"or configure your own. See here to learn more: " +
|
||||
"https://docs.continue.dev/customize/model-types/embeddings",
|
||||
);
|
||||
}
|
||||
// Currently you can use codebase without an embeddings provider and it will just skip the embeddings inputs
|
||||
// if (!extras.embeddingsProvider) {
|
||||
// void extras.ide.showToast(
|
||||
// "warning",
|
||||
// "Set up an embeddings model to use this feature. Visit the docs to learn more: " +
|
||||
// "https://docs.continue.dev/customize/model-types/embeddings",
|
||||
// );
|
||||
// return [];
|
||||
// }
|
||||
const includeEmbeddings = !!extras.config.selectedModelByRole.embed;
|
||||
|
||||
// Get tags to retrieve for
|
||||
const workspaceDirs = await extras.ide.getWorkspaceDirs();
|
||||
|
|
@ -78,7 +67,6 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
input: extras.fullInput,
|
||||
llm: extras.llm,
|
||||
config: extras.config,
|
||||
includeEmbeddings: !isJetBrainsAndTransformersJs,
|
||||
};
|
||||
|
||||
const pipeline = new pipelineType(pipelineOptions);
|
||||
|
|
@ -86,16 +74,17 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
tags,
|
||||
filterDirectory,
|
||||
query: extras.fullInput,
|
||||
includeEmbeddings,
|
||||
});
|
||||
|
||||
if (results.length === 0) {
|
||||
if (extras.config.disableIndexing) {
|
||||
void extras.ide.showToast("warning", "No embeddings results found.");
|
||||
void extras.ide.showToast("warning", "No results found.");
|
||||
return [];
|
||||
} else {
|
||||
void extras.ide.showToast(
|
||||
"warning",
|
||||
"No embeddings results found. If you think this is an error, re-index your codebase.",
|
||||
"No results found. If you think this is an error, re-index your codebase.",
|
||||
);
|
||||
// TODO - add "re-index" option to warning message which clears and reindexes codebase
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,10 @@ export class ControlPlaneClient {
|
|||
private readonly ideSettingsPromise: Promise<IdeSettings>,
|
||||
) {}
|
||||
|
||||
async resolveFQSNs(fqsns: FQSN[]): Promise<(SecretResult | undefined)[]> {
|
||||
async resolveFQSNs(
|
||||
fqsns: FQSN[],
|
||||
orgScopeId: string | null,
|
||||
): Promise<(SecretResult | undefined)[]> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
throw new Error("No user id");
|
||||
|
|
@ -48,7 +51,7 @@ export class ControlPlaneClient {
|
|||
|
||||
const resp = await this.request("ide/sync-secrets", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ fqsns }),
|
||||
body: JSON.stringify({ fqsns, orgScopeId }),
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
}
|
||||
|
|
@ -183,21 +186,4 @@ 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 {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
84
core/core.ts
84
core/core.ts
|
|
@ -14,10 +14,14 @@ import {
|
|||
setupQuickstartConfig,
|
||||
} from "./config/onboarding";
|
||||
import { addContextProvider, addModel, deleteModel } from "./config/util";
|
||||
import CodebaseContextProvider from "./context/providers/CodebaseContextProvider";
|
||||
import CurrentFileContextProvider from "./context/providers/CurrentFileContextProvider";
|
||||
import { recentlyEditedFilesCache } from "./context/retrieval/recentlyEditedFilesCache";
|
||||
import { ContinueServerClient } from "./continueServer/stubs/client";
|
||||
import { getAuthUrlForTokenPage } from "./control-plane/auth/index";
|
||||
import { getControlPlaneEnv } from "./control-plane/env";
|
||||
import { DevDataSqliteDb } from "./data/devdataSqlite";
|
||||
import { DataLogger } from "./data/log";
|
||||
import { streamDiffLines } from "./edit/streamDiffLines";
|
||||
import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer";
|
||||
import DocsService from "./indexing/docs/DocsService";
|
||||
|
|
@ -28,8 +32,6 @@ import { createNewPromptFileV2 } from "./promptFiles/v2/createNewPromptFile";
|
|||
import { callTool } from "./tools/callTool";
|
||||
import { ChatDescriber } from "./util/chatDescriber";
|
||||
import { clipboardCache } from "./util/clipboardCache";
|
||||
import { DataLogger } from "./data/log";
|
||||
import { DevDataSqliteDb } from "./data/devdataSqlite";
|
||||
import { GlobalContext } from "./util/GlobalContext";
|
||||
import historyManager from "./util/history";
|
||||
import {
|
||||
|
|
@ -51,8 +53,6 @@ import {
|
|||
type IndexingProgressUpdate,
|
||||
} from ".";
|
||||
|
||||
import CodebaseContextProvider from "./context/providers/CodebaseContextProvider";
|
||||
import CurrentFileContextProvider from "./context/providers/CurrentFileContextProvider";
|
||||
import type { FromCoreProtocol, ToCoreProtocol } from "./protocol";
|
||||
import type { IMessenger, Message } from "./protocol/messenger";
|
||||
|
||||
|
|
@ -131,7 +131,8 @@ export class Core {
|
|||
});
|
||||
|
||||
// update additional submenu context providers registered via VSCode API
|
||||
const additionalProviders = this.configHandler.getAdditionalSubmenuContextProviders();
|
||||
const additionalProviders =
|
||||
this.configHandler.getAdditionalSubmenuContextProviders();
|
||||
if (additionalProviders.length > 0) {
|
||||
this.messenger.send("refreshSubmenuItems", {
|
||||
providers: additionalProviders,
|
||||
|
|
@ -199,12 +200,10 @@ export class Core {
|
|||
|
||||
const getLlm = async () => {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
const selected = this.globalContext.get("selectedTabAutocompleteModel");
|
||||
return (
|
||||
config?.tabAutocompleteModels?.find(
|
||||
(model) => model.title === selected,
|
||||
) ?? config?.tabAutocompleteModels?.[0]
|
||||
);
|
||||
if (!config) {
|
||||
return undefined;
|
||||
}
|
||||
return config.selectedModelByRole.autocomplete ?? undefined;
|
||||
};
|
||||
this.completionProvider = new CompletionProvider(
|
||||
this.configHandler,
|
||||
|
|
@ -238,11 +237,6 @@ export class Core {
|
|||
}
|
||||
});
|
||||
|
||||
on("update/selectTabAutocompleteModel", async (msg) => {
|
||||
this.globalContext.update("selectedTabAutocompleteModel", msg.data);
|
||||
void this.configHandler.reloadConfig();
|
||||
});
|
||||
|
||||
// Special
|
||||
on("abort", (msg) => {
|
||||
this.abortedMessageIds.add(msg.messageId);
|
||||
|
|
@ -317,8 +311,19 @@ export class Core {
|
|||
});
|
||||
|
||||
on("config/updateSharedConfig", async (msg) => {
|
||||
this.globalContext.updateSharedConfig(msg.data);
|
||||
const newSharedConfig = this.globalContext.updateSharedConfig(msg.data);
|
||||
await this.configHandler.reloadConfig();
|
||||
return newSharedConfig;
|
||||
});
|
||||
|
||||
on("config/updateSelectedModel", async (msg) => {
|
||||
const newSelectedModels = this.globalContext.updateSelectedModel(
|
||||
msg.data.profileId,
|
||||
msg.data.role,
|
||||
msg.data.title,
|
||||
);
|
||||
await this.configHandler.reloadConfig();
|
||||
return newSelectedModels;
|
||||
});
|
||||
|
||||
on("controlPlane/openUrl", async (msg) => {
|
||||
|
|
@ -398,11 +403,11 @@ export class Core {
|
|||
const items = await provider.getContextItems(query, {
|
||||
config,
|
||||
llm,
|
||||
embeddingsProvider: config.embeddingsProvider,
|
||||
embeddingsProvider: config.selectedModelByRole.embed,
|
||||
fullInput,
|
||||
ide,
|
||||
selectedCode,
|
||||
reranker: config.reranker,
|
||||
reranker: config.selectedModelByRole.rerank,
|
||||
fetch: (url, init) =>
|
||||
fetchwithRequestOptions(url, init, config.requestOptions),
|
||||
});
|
||||
|
|
@ -423,26 +428,25 @@ export class Core {
|
|||
let knownError = false;
|
||||
|
||||
if (e instanceof Error) {
|
||||
// A specific error where we're forcing the presence of embeddings provider on the config
|
||||
// But Jetbrains doesn't support transformers JS
|
||||
// So if a context provider needs it it will throw this error when the file isn't found
|
||||
if (e.message.includes("all-MiniLM-L6-v2")) {
|
||||
knownError = true;
|
||||
const toastOption = "See Docs";
|
||||
void this.ide
|
||||
.showToast(
|
||||
"error",
|
||||
`Set up an embeddings model to use @${name}`,
|
||||
toastOption,
|
||||
)
|
||||
.then((userSelection) => {
|
||||
if (userSelection === toastOption) {
|
||||
void this.ide.openUrl(
|
||||
"https://docs.continue.dev/customize/model-types/embeddings",
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
// After removing transformers JS embeddings provider from jetbrains
|
||||
// Should no longer see this error
|
||||
// if (e.message.toLowerCase().includes("embeddings provider")) {
|
||||
// knownError = true;
|
||||
// const toastOption = "See Docs";
|
||||
// void this.ide
|
||||
// .showToast(
|
||||
// "error",
|
||||
// `Set up an embeddings model to use @${name}`,
|
||||
// toastOption,
|
||||
// )
|
||||
// .then((userSelection) => {
|
||||
// if (userSelection === toastOption) {
|
||||
// void this.ide.openUrl(
|
||||
// "https://docs.continue.dev/customize/model-types/embeddings",
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
if (!knownError) {
|
||||
void this.ide.showToast(
|
||||
|
|
@ -648,6 +652,7 @@ export class Core {
|
|||
params,
|
||||
historyIndex,
|
||||
selectedCode,
|
||||
completionOptions,
|
||||
} = msg.data;
|
||||
|
||||
const { config } = await configHandler.loadConfig();
|
||||
|
|
@ -696,6 +701,7 @@ export class Core {
|
|||
config,
|
||||
fetch: (url, init) =>
|
||||
fetchwithRequestOptions(url, init, config.requestOptions),
|
||||
completionOptions,
|
||||
})) {
|
||||
if (abortedMessageIds.has(msg.messageId)) {
|
||||
abortedMessageIds.delete(msg.messageId);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ export async function applyCodeBlock(
|
|||
llm: ILLM,
|
||||
fastLlm: ILLM,
|
||||
): Promise<[boolean, AsyncGenerator<DiffLine>]> {
|
||||
if (canUseInstantApply(filename)) {
|
||||
// This was buggy, removed for now, maybe forever
|
||||
if (false && canUseInstantApply(filename)) {
|
||||
const diffLines = await deterministicApplyLazyEdit(
|
||||
oldFile,
|
||||
newFile,
|
||||
|
|
|
|||
32
core/index.d.ts
vendored
32
core/index.d.ts
vendored
|
|
@ -60,7 +60,7 @@ export interface IndexingStatus {
|
|||
progress: number;
|
||||
description: string;
|
||||
status: "indexing" | "complete" | "paused" | "failed" | "aborted" | "pending";
|
||||
embeddingsProviderId: string;
|
||||
embeddingsProviderId?: string;
|
||||
isReindexing?: boolean;
|
||||
debugInfo?: string;
|
||||
title: string;
|
||||
|
|
@ -179,8 +179,8 @@ export type FetchFunction = (url: string | URL, init?: any) => Promise<any>;
|
|||
export interface ContextProviderExtras {
|
||||
config: ContinueConfig;
|
||||
fullInput: string;
|
||||
embeddingsProvider: ILLM;
|
||||
reranker: ILLM | undefined;
|
||||
embeddingsProvider: ILLM | null;
|
||||
reranker: ILLM | null;
|
||||
llm: ILLM;
|
||||
ide: IDE;
|
||||
selectedCode: RangeInFile[];
|
||||
|
|
@ -478,9 +478,15 @@ export interface LLMOptions {
|
|||
writeLog?: (str: string) => Promise<void>;
|
||||
llmRequestHook?: (model: string, prompt: string) => any;
|
||||
apiKey?: string;
|
||||
|
||||
// continueProperties
|
||||
apiKeyLocation?: string;
|
||||
aiGatewaySlug?: string;
|
||||
apiBase?: string;
|
||||
orgScopeId?: string | null;
|
||||
|
||||
onPremProxyUrl?: string | null;
|
||||
|
||||
aiGatewaySlug?: string;
|
||||
cacheBehavior?: CacheBehavior;
|
||||
capabilities?: ModelCapability;
|
||||
roles?: ModelRole[];
|
||||
|
|
@ -730,6 +736,7 @@ export interface ContinueSDK {
|
|||
selectedCode: RangeInFile[];
|
||||
config: ContinueConfig;
|
||||
fetch: FetchFunction;
|
||||
completionOptions?: LLMFullCompletionOptions;
|
||||
}
|
||||
|
||||
export interface SlashCommand {
|
||||
|
|
@ -920,8 +927,14 @@ export interface ModelDescription {
|
|||
provider: string;
|
||||
model: string;
|
||||
apiKey?: string;
|
||||
|
||||
// continueProperties
|
||||
apiKeyLocation?: string;
|
||||
apiBase?: string;
|
||||
orgScopeId?: string | null;
|
||||
|
||||
onPremProxyUrl?: string | null;
|
||||
|
||||
contextLength?: number;
|
||||
maxStopWords?: number;
|
||||
template?: TemplateType;
|
||||
|
|
@ -1028,9 +1041,9 @@ export interface ContextMenuConfig {
|
|||
}
|
||||
|
||||
export interface ExperimentalModelRoles {
|
||||
repoMapFileSelection?: string;
|
||||
inlineEdit?: string;
|
||||
applyCodeBlock?: string;
|
||||
repoMapFileSelection?: string;
|
||||
}
|
||||
|
||||
export type EditStatus =
|
||||
|
|
@ -1215,15 +1228,14 @@ export interface ContinueConfig {
|
|||
disableSessionTitles?: boolean;
|
||||
disableIndexing?: boolean;
|
||||
userToken?: string;
|
||||
embeddingsProvider: ILLM;
|
||||
tabAutocompleteModels?: ILLM[];
|
||||
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
ui?: ContinueUIConfig;
|
||||
reranker?: ILLM;
|
||||
experimental?: ExperimentalConfig;
|
||||
analytics?: AnalyticsConfig;
|
||||
docs?: SiteIndexingConfig[];
|
||||
tools: Tool[];
|
||||
modelsByRole: Record<ModelRole, ILLM[]>;
|
||||
selectedModelByRole: Record<ModelRole, ILLM | null>;
|
||||
data?: DataDestination[];
|
||||
}
|
||||
|
||||
|
|
@ -1238,15 +1250,15 @@ export interface BrowserSerializedContinueConfig {
|
|||
disableIndexing?: boolean;
|
||||
disableSessionTitles?: boolean;
|
||||
userToken?: string;
|
||||
embeddingsProvider?: string;
|
||||
ui?: ContinueUIConfig;
|
||||
reranker?: RerankerDescription;
|
||||
experimental?: ExperimentalConfig;
|
||||
analytics?: AnalyticsConfig;
|
||||
docs?: SiteIndexingConfig[];
|
||||
tools: Tool[];
|
||||
usePlatform: boolean;
|
||||
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
modelsByRole: Record<ModelRole, ModelDescription[]>;
|
||||
selectedModelByRole: Record<ModelRole, ModelDescription | null>;
|
||||
}
|
||||
|
||||
// DOCS SUGGESTIONS AND PACKAGE INFO
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import { IContinueServerClient } from "../continueServer/interface.js";
|
|||
import { IDE, IndexingProgressUpdate, IndexTag } from "../index.js";
|
||||
import { extractMinimalStackTraceInfo } from "../util/extractMinimalStackTraceInfo.js";
|
||||
import { getIndexSqlitePath, getLanceDbPath } from "../util/paths.js";
|
||||
|
||||
import { findUriInDirs, getUriPathBasename } from "../util/uri.js";
|
||||
|
||||
import { ChunkCodebaseIndex } from "./chunk/ChunkCodebaseIndex.js";
|
||||
import { CodeSnippetsCodebaseIndex } from "./CodeSnippetsIndex.js";
|
||||
import { FullTextSearchCodebaseIndex } from "./FullTextSearchCodebaseIndex.js";
|
||||
|
|
@ -80,14 +80,19 @@ export class CodebaseIndexer {
|
|||
return [];
|
||||
}
|
||||
|
||||
const embeddingsModel = config.selectedModelByRole.embed;
|
||||
if (!embeddingsModel) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const indexes = [
|
||||
new ChunkCodebaseIndex(
|
||||
this.ide.readFile.bind(this.ide),
|
||||
this.continueServerClient,
|
||||
config.embeddingsProvider.maxEmbeddingChunkSize,
|
||||
embeddingsModel.maxEmbeddingChunkSize,
|
||||
), // Chunking must come first
|
||||
new LanceDbIndex(
|
||||
config.embeddingsProvider,
|
||||
embeddingsModel,
|
||||
this.ide.readFile.bind(this.ide),
|
||||
this.continueServerClient,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@ import lance from "vectordb";
|
|||
|
||||
import { testConfigHandler, testIde } from "../test/fixtures";
|
||||
import { getLanceDbPath } from "../util/paths";
|
||||
|
||||
import { LanceDbIndex } from "./LanceDbIndex";
|
||||
import { DatabaseConnection, SqliteDb } from "./refreshIndex";
|
||||
import {
|
||||
mockPathAndCacheKey,
|
||||
mockTag,
|
||||
testContinueServerClient,
|
||||
updateIndexAndAwaitGenerator,
|
||||
} from "./test/indexing";
|
||||
|
||||
import { LanceDbIndex } from "./LanceDbIndex";
|
||||
import { DatabaseConnection, SqliteDb } from "./refreshIndex";
|
||||
import { IndexResultType } from "./types";
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
|
@ -30,9 +30,12 @@ describe.skip("ChunkCodebaseIndex", () => {
|
|||
if (!mockConfig) {
|
||||
throw new Error("Failed to load config");
|
||||
}
|
||||
if (!mockConfig.selectedModelByRole.embed) {
|
||||
throw new Error("No embeddings model selected");
|
||||
}
|
||||
|
||||
index = new LanceDbIndex(
|
||||
mockConfig.embeddingsProvider,
|
||||
mockConfig.selectedModelByRole.embed,
|
||||
testIde.readFile.bind(testIde),
|
||||
testContinueServerClient,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ type ChunkMap = Map<string, ItemWithChunks>;
|
|||
export class LanceDbIndex implements CodebaseIndex {
|
||||
relativeExpectedTime: number = 13;
|
||||
get artifactId(): string {
|
||||
return `vectordb::${this.embeddingsProvider.embeddingId}`;
|
||||
return `vectordb::${this.embeddingsProvider?.embeddingId}`;
|
||||
}
|
||||
|
||||
constructor(
|
||||
private readonly embeddingsProvider: ILLM,
|
||||
private readonly embeddingsProvider: ILLM | null,
|
||||
private readonly readFile: (filepath: string) => Promise<string>,
|
||||
private readonly continueServerClient?: IContinueServerClient,
|
||||
) {}
|
||||
|
|
@ -142,6 +142,9 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
item: PathAndCacheKey,
|
||||
content: string,
|
||||
): Promise<Chunk[]> {
|
||||
if (!this.embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
const chunks: Chunk[] = [];
|
||||
|
||||
const chunkParams = {
|
||||
|
|
@ -163,6 +166,9 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
}
|
||||
|
||||
private async getEmbeddings(chunks: Chunk[]): Promise<number[][]> {
|
||||
if (!this.embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
return await this.embeddingsProvider.embed(chunks.map((c) => c.content));
|
||||
} catch (err) {
|
||||
|
|
@ -436,6 +442,9 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
tags: BranchAndDir[],
|
||||
filterDirectory: string | undefined,
|
||||
): Promise<Chunk[]> {
|
||||
if (!this.embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
const [vector] = await this.embeddingsProvider.embed([query]);
|
||||
const db = await lance.connect(getLanceDbPath());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { open, type Database } from "sqlite";
|
||||
import sqlite3 from "sqlite3";
|
||||
import lancedb, { Connection } from "vectordb";
|
||||
|
|
@ -19,6 +20,7 @@ import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbed
|
|||
import { FromCoreProtocol, ToCoreProtocol } from "../../protocol";
|
||||
import { IMessenger } from "../../protocol/messenger";
|
||||
import { fetchFavicon, getFaviconBase64 } from "../../util/fetchFavicon";
|
||||
import { GlobalContext } from "../../util/GlobalContext";
|
||||
import {
|
||||
editConfigJson,
|
||||
getDocsSqlitePath,
|
||||
|
|
@ -26,8 +28,6 @@ import {
|
|||
} from "../../util/paths";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { GlobalContext } from "../../util/GlobalContext";
|
||||
import {
|
||||
ArticleWithChunks,
|
||||
htmlPageToArticleWithChunks,
|
||||
|
|
@ -161,16 +161,22 @@ export default class DocsService {
|
|||
return;
|
||||
}
|
||||
|
||||
const sharedStatus = {
|
||||
type: "docs" as IndexingStatus["type"],
|
||||
const sharedStatus: Omit<
|
||||
IndexingStatus,
|
||||
"progress" | "description" | "status"
|
||||
> = {
|
||||
type: "docs",
|
||||
id: doc.startUrl,
|
||||
embeddingsProviderId: this.config.embeddingsProvider.embeddingId,
|
||||
isReindexing: false,
|
||||
title: doc.title,
|
||||
debugInfo: `max depth: ${doc.maxDepth}`,
|
||||
icon: doc.faviconUrl,
|
||||
url: doc.startUrl,
|
||||
};
|
||||
if (this.config.selectedModelByRole.embed) {
|
||||
sharedStatus.embeddingsProviderId =
|
||||
this.config.selectedModelByRole.embed.embeddingId;
|
||||
}
|
||||
const indexedStatus: IndexingStatus = metadata.find(
|
||||
(meta) => meta.startUrl === doc.startUrl,
|
||||
)
|
||||
|
|
@ -214,7 +220,9 @@ export default class DocsService {
|
|||
}
|
||||
|
||||
// Handle embeddings provider change mid-indexing
|
||||
if (this.config.embeddingsProvider.embeddingId !== startedWithEmbedder) {
|
||||
if (
|
||||
this.config.selectedModelByRole.embed?.embeddingId !== startedWithEmbedder
|
||||
) {
|
||||
this.abort(startUrl);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -234,14 +242,6 @@ export default class DocsService {
|
|||
return true;
|
||||
}
|
||||
|
||||
async isUsingUnsupportedPreIndexedEmbeddingsProvider() {
|
||||
const isPreIndexedDocsProvider =
|
||||
this.config.embeddingsProvider.embeddingId ===
|
||||
DocsService.preIndexedDocsEmbeddingsProvider.embeddingId;
|
||||
const canUsePreindexedDocs = await this.canUsePreindexedDocs();
|
||||
return isPreIndexedDocsProvider && !canUsePreindexedDocs;
|
||||
}
|
||||
|
||||
// Determines if using preIndexed and returns proper embeddings provider
|
||||
async getEmbeddingsProvider(startUrl: string) {
|
||||
// Conditions for using a pre-indexed doc
|
||||
|
|
@ -262,7 +262,7 @@ export default class DocsService {
|
|||
}
|
||||
}
|
||||
return {
|
||||
provider: this.config.embeddingsProvider,
|
||||
provider: this.config.selectedModelByRole.embed,
|
||||
isPreindexed: false,
|
||||
};
|
||||
}
|
||||
|
|
@ -282,9 +282,7 @@ export default class DocsService {
|
|||
|
||||
// Skip docs indexing if not supported
|
||||
// No warning message here because would show on ANY config update
|
||||
const unsupported =
|
||||
await this.isUsingUnsupportedPreIndexedEmbeddingsProvider();
|
||||
if (unsupported) {
|
||||
if (!this.config.selectedModelByRole.embed) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -323,18 +321,21 @@ export default class DocsService {
|
|||
|
||||
// Returns true if startUrl has been indexed with current embeddingsProvider
|
||||
async hasMetadata(startUrl: string): Promise<boolean> {
|
||||
if (!this.config.selectedModelByRole.embed) {
|
||||
return false;
|
||||
}
|
||||
const db = await this.getOrCreateSqliteDb();
|
||||
const title = await db.get(
|
||||
`SELECT title FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`,
|
||||
startUrl,
|
||||
this.config.embeddingsProvider.embeddingId,
|
||||
this.config.selectedModelByRole.embed.embeddingId,
|
||||
);
|
||||
|
||||
return !!title;
|
||||
}
|
||||
|
||||
async listMetadata() {
|
||||
const embeddingsProvider = this.config.embeddingsProvider;
|
||||
const embeddingsProvider = this.config.selectedModelByRole.embed;
|
||||
if (!embeddingsProvider) {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -376,6 +377,11 @@ export default class DocsService {
|
|||
console.warn("Attempted to indexAndAdd pre-indexed doc");
|
||||
return;
|
||||
}
|
||||
if (!provider) {
|
||||
console.warn("@docs indexAndAdd: no embeddings provider found");
|
||||
return;
|
||||
}
|
||||
|
||||
const startedWithEmbedder = provider.embeddingId;
|
||||
|
||||
// Check if doc has been successfully indexed with the given embedder
|
||||
|
|
@ -716,21 +722,18 @@ export default class DocsService {
|
|||
startUrl: string,
|
||||
nRetrieve: number,
|
||||
) {
|
||||
if (await this.isUsingUnsupportedPreIndexedEmbeddingsProvider()) {
|
||||
await this.ide.showToast(
|
||||
"error",
|
||||
`${DocsService.preIndexedDocsEmbeddingsProvider.embeddingId} is configured as ` +
|
||||
"the embeddings provider, but it cannot be used with JetBrains. " + // TODO "with this IDE"
|
||||
"Please select a different embeddings provider to use the '@docs' " +
|
||||
"context provider.",
|
||||
);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
const { isPreindexed, provider } =
|
||||
await this.getEmbeddingsProvider(startUrl);
|
||||
|
||||
if (!provider) {
|
||||
void this.ide.showToast(
|
||||
"error",
|
||||
"Set up an embeddings model to use the @docs context provider. See: " +
|
||||
"https://docs.continue.dev/customize/model-types/embeddings",
|
||||
);
|
||||
return [];
|
||||
}
|
||||
|
||||
if (isPreindexed) {
|
||||
void Telemetry.capture("docs_pre_indexed_doc_used", {
|
||||
doc: preIndexedDocs[startUrl]!["title"],
|
||||
|
|
@ -761,8 +764,10 @@ export default class DocsService {
|
|||
try {
|
||||
const { isPreindexed, provider } =
|
||||
await this.getEmbeddingsProvider(startUrl);
|
||||
const preIndexedDoc = preIndexedDocs[startUrl];
|
||||
const isPreIndexedDoc = !!preIndexedDoc;
|
||||
|
||||
if (!provider) {
|
||||
throw new Error("No embeddings model set");
|
||||
}
|
||||
|
||||
const result = await db.get(
|
||||
`SELECT startUrl, title, favicon FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`,
|
||||
|
|
@ -793,7 +798,7 @@ export default class DocsService {
|
|||
config: siteIndexingConfig,
|
||||
indexingStatus: this.statuses.get(startUrl),
|
||||
chunks: rows.map(this.lanceDBRowToChunk),
|
||||
isPreIndexedDoc,
|
||||
isPreIndexedDoc: isPreindexed,
|
||||
};
|
||||
} catch (e) {
|
||||
console.warn("Error getting details", e);
|
||||
|
|
@ -867,7 +872,7 @@ export default class DocsService {
|
|||
}
|
||||
|
||||
async getFavicon(startUrl: string) {
|
||||
if (!this.config.embeddingsProvider) {
|
||||
if (!this.config.selectedModelByRole.embed) {
|
||||
console.warn(
|
||||
"Attempting to get favicon without embeddings provider specified",
|
||||
);
|
||||
|
|
@ -877,7 +882,7 @@ export default class DocsService {
|
|||
const result = await db.get(
|
||||
`SELECT favicon FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`,
|
||||
startUrl,
|
||||
this.config.embeddingsProvider.embeddingId,
|
||||
this.config.selectedModelByRole.embed.embeddingId,
|
||||
);
|
||||
|
||||
if (!result) {
|
||||
|
|
@ -941,7 +946,7 @@ export default class DocsService {
|
|||
type: "docs",
|
||||
id: doc.startUrl,
|
||||
embeddingsProviderId:
|
||||
this.config.embeddingsProvider.embeddingId,
|
||||
this.config.selectedModelByRole.embed?.embeddingId,
|
||||
isReindexing: false,
|
||||
title: doc.title,
|
||||
debugInfo: "Config sync: not changed",
|
||||
|
|
@ -1033,6 +1038,13 @@ export default class DocsService {
|
|||
const conn = await lancedb.connect(getLanceDbPath());
|
||||
const tableNames = await conn.tableNames();
|
||||
const { provider } = await this.getEmbeddingsProvider(startUrl);
|
||||
|
||||
if (!provider) {
|
||||
throw new Error(
|
||||
"Could not retrieve @docs Lance Table: no embeddings provider specified",
|
||||
);
|
||||
}
|
||||
|
||||
const tableNameFromEmbeddingsProvider =
|
||||
await this.getLanceTableName(provider);
|
||||
|
||||
|
|
@ -1089,13 +1101,19 @@ export default class DocsService {
|
|||
siteIndexingConfig: { title, startUrl },
|
||||
favicon,
|
||||
}: AddParams) {
|
||||
if (!this.config.selectedModelByRole.embed) {
|
||||
console.warn(
|
||||
`Attempting to add metadata for ${startUrl} without embeddings provider specified`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const db = await this.getOrCreateSqliteDb();
|
||||
await db.run(
|
||||
`INSERT INTO ${DocsService.sqlitebTableName} (title, startUrl, favicon, embeddingsProviderId) VALUES (?, ?, ?, ?)`,
|
||||
title,
|
||||
startUrl,
|
||||
favicon,
|
||||
this.config.embeddingsProvider.embeddingId,
|
||||
this.config.selectedModelByRole.embed.embeddingId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1147,7 +1165,7 @@ export default class DocsService {
|
|||
}
|
||||
|
||||
private async deleteMetadataFromSqlite(startUrl: string) {
|
||||
if (!this.config.embeddingsProvider) {
|
||||
if (!this.config.selectedModelByRole.embed) {
|
||||
console.warn(
|
||||
`Attempting to delete metadata for ${startUrl} without embeddings provider specified`,
|
||||
);
|
||||
|
|
@ -1158,7 +1176,7 @@ export default class DocsService {
|
|||
await db.run(
|
||||
`DELETE FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`,
|
||||
startUrl,
|
||||
this.config.embeddingsProvider.embeddingId,
|
||||
this.config.selectedModelByRole.embed.embeddingId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,24 +139,35 @@ export async function htmlPageToArticleWithChunks(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const title = readability.title || subpath;
|
||||
|
||||
const titles = Array.from(dom.window.document.querySelectorAll("h2"));
|
||||
const article_components = titles.map((titleElement) => {
|
||||
const title = titleElement.textContent || "";
|
||||
let body = "";
|
||||
let nextSibling = titleElement.nextElementSibling;
|
||||
|
||||
while (nextSibling && nextSibling.tagName !== "H2") {
|
||||
body += nextSibling.textContent || "";
|
||||
nextSibling = nextSibling.nextElementSibling;
|
||||
}
|
||||
const article_components =
|
||||
titles.length > 0
|
||||
? titles.map((titleElement) => {
|
||||
const title = titleElement.textContent || "";
|
||||
let body = "";
|
||||
let nextSibling = titleElement.nextElementSibling;
|
||||
|
||||
return { title, body };
|
||||
});
|
||||
while (nextSibling && nextSibling.tagName !== "H2") {
|
||||
body += nextSibling.textContent || "";
|
||||
nextSibling = nextSibling.nextElementSibling;
|
||||
}
|
||||
|
||||
return { title, body };
|
||||
})
|
||||
: [
|
||||
{
|
||||
title: title,
|
||||
body: readability.textContent,
|
||||
},
|
||||
];
|
||||
|
||||
const article = {
|
||||
url,
|
||||
subpath,
|
||||
title: readability.title,
|
||||
title: title,
|
||||
article_components,
|
||||
};
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -358,6 +358,11 @@ const preIndexedDocs: Record<
|
|||
startUrl: "https://angular.dev/",
|
||||
rootUrl: "https://angular.dev/",
|
||||
},
|
||||
"https://docs.djangoproject.com/": {
|
||||
title: "Django",
|
||||
startUrl: "https://docs.djangoproject.com/",
|
||||
rootUrl: "https://docs.djangoproject.com/",
|
||||
}
|
||||
};
|
||||
|
||||
export default preIndexedDocs;
|
||||
|
|
|
|||
|
|
@ -8,66 +8,6 @@ import { normalizeToMessageParts } from "../util/messageContent";
|
|||
|
||||
import { modelSupportsTools } from "./autodetect";
|
||||
|
||||
const CUSTOM_SYS_MSG_MODEL_FAMILIES = ["sonnet"];
|
||||
|
||||
const SYSTEM_MESSAGE = `When generating new code:
|
||||
|
||||
1. Always produce a single code block.
|
||||
2. Never separate the code into multiple code blocks.
|
||||
3. Only include the code that is being added.
|
||||
4. Replace existing code with a "lazy" comment like this: "// ... existing code ..."
|
||||
5. The "lazy" comment must always be a valid comment in the current context (e.g. "<!-- ... existing code ... -->" for HTML, "// ... existing code ..." for JavaScript, "{/* ... existing code */}" for TSX, etc.)
|
||||
6. You must always provide 1-2 lines of context above and below a "lazy" comment
|
||||
7. If the user submits a code block that contains a filename in the language specifier, always include the filename in any code block you generate based on that file. The filename should be on the same line as the language specifier in your code block.
|
||||
|
||||
Example 1:
|
||||
Input:
|
||||
\`\`\`test.js
|
||||
import addition from "addition"
|
||||
|
||||
class Calculator {
|
||||
constructor() {
|
||||
this.result = 0;
|
||||
}
|
||||
|
||||
add(number) {
|
||||
this.result += number;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
\`\`\`
|
||||
User request: Add a subtract method
|
||||
|
||||
Output:
|
||||
\`\`\`javascript test.js
|
||||
// ... existing code ...
|
||||
import subtraction from "subtraction"
|
||||
|
||||
class Calculator {
|
||||
// ... existing code ...
|
||||
|
||||
subtract(number) {
|
||||
this.result -= number;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
Example 2:
|
||||
Input:
|
||||
\`\`\`javascript test.js (6-9)
|
||||
function helloWorld() {}
|
||||
\`\`\`
|
||||
|
||||
Output:
|
||||
\`\`\`javascript test.js
|
||||
function helloWorld() {
|
||||
// New code here
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
Always follow these guidelines when generating code responses.`;
|
||||
|
||||
const TOOL_USE_RULES = `When using tools, follow the following guidelines:
|
||||
- Avoid calling tools unless they are absolutely necessary. For example, if you are asked a simple programming question you do not need web search. As another example, if the user asks you to explain something about code, do not create a new file.`;
|
||||
|
||||
|
|
@ -75,21 +15,12 @@ function constructSystemPrompt(
|
|||
modelDescription: ModelDescription,
|
||||
useTools: boolean,
|
||||
): string | null {
|
||||
let systemMessage = "";
|
||||
if (
|
||||
CUSTOM_SYS_MSG_MODEL_FAMILIES.some((family) =>
|
||||
modelDescription.model.includes(family),
|
||||
)
|
||||
) {
|
||||
systemMessage = SYSTEM_MESSAGE;
|
||||
}
|
||||
let systemMessage =
|
||||
"Always include the language and file name in the info string when you write code blocks, for example '```python file.py'.";
|
||||
if (useTools && modelSupportsTools(modelDescription)) {
|
||||
if (systemMessage) {
|
||||
systemMessage += "\n\n";
|
||||
}
|
||||
systemMessage += TOOL_USE_RULES;
|
||||
systemMessage += "\n\n" + TOOL_USE_RULES;
|
||||
}
|
||||
return systemMessage || null;
|
||||
return systemMessage;
|
||||
}
|
||||
|
||||
const CANCELED_TOOL_CALL_MESSAGE =
|
||||
|
|
|
|||
|
|
@ -118,8 +118,14 @@ export abstract class BaseLLM implements ILLM {
|
|||
writeLog?: (str: string) => Promise<void>;
|
||||
llmRequestHook?: (model: string, prompt: string) => any;
|
||||
apiKey?: string;
|
||||
|
||||
// continueProperties
|
||||
apiKeyLocation?: string;
|
||||
apiBase?: string;
|
||||
orgScopeId?: string | null;
|
||||
|
||||
onPremProxyUrl?: string | null;
|
||||
|
||||
cacheBehavior?: CacheBehavior;
|
||||
capabilities?: ModelCapability;
|
||||
roles?: ModelRole[];
|
||||
|
|
@ -198,9 +204,15 @@ export abstract class BaseLLM implements ILLM {
|
|||
this.writeLog = options.writeLog;
|
||||
this.llmRequestHook = options.llmRequestHook;
|
||||
this.apiKey = options.apiKey;
|
||||
|
||||
// continueProperties
|
||||
this.apiKeyLocation = options.apiKeyLocation;
|
||||
this.aiGatewaySlug = options.aiGatewaySlug;
|
||||
this.orgScopeId = options.orgScopeId;
|
||||
this.apiBase = options.apiBase;
|
||||
|
||||
this.onPremProxyUrl = options.onPremProxyUrl;
|
||||
|
||||
this.aiGatewaySlug = options.aiGatewaySlug;
|
||||
this.cacheBehavior = options.cacheBehavior;
|
||||
|
||||
// watsonx deploymentId
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ export class TransformersJsEmbeddingsProvider extends BaseLLM {
|
|||
static maxGroupSize: number = 1;
|
||||
static model: string = "all-MiniLM-L6-v2";
|
||||
static mockVector: number[] = Array.from({ length: 384 }).fill(2) as number[];
|
||||
static title: string = "Transformers.js (Built-In)";
|
||||
|
||||
static defaultOptions: Partial<LLMOptions> | undefined = {
|
||||
model: TransformersJsEmbeddingsProvider.model,
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ class VertexAI extends BaseLLM {
|
|||
}
|
||||
|
||||
const resp = await this.fetch(
|
||||
new URL(this.apiBase + `/publishers/google/models/${this.model}:predict`),
|
||||
new URL(`publishers/google/models/${this.model}:predict`, this.apiBase),
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { ContinueProperties } from "@continuedev/config-yaml";
|
||||
|
||||
import { ControlPlaneProxyInfo } from "../../../control-plane/analytics/IAnalyticsProvider.js";
|
||||
import { Telemetry } from "../../../util/posthog.js";
|
||||
import OpenAI from "../OpenAI.js";
|
||||
|
|
@ -7,7 +9,12 @@ import type { Chunk, LLMOptions } from "../../../index.js";
|
|||
class ContinueProxy extends OpenAI {
|
||||
set controlPlaneProxyInfo(value: ControlPlaneProxyInfo) {
|
||||
this.apiKey = value.workOsAccessToken;
|
||||
this.apiBase = new URL("openai/v1/", value.controlPlaneProxyUrl).toString();
|
||||
if (!this.onPremProxyUrl) {
|
||||
this.apiBase = new URL(
|
||||
"openai/v1/",
|
||||
value.controlPlaneProxyUrl,
|
||||
).toString();
|
||||
}
|
||||
}
|
||||
|
||||
// The apiKey and apiBase are set to the values for the proxy,
|
||||
|
|
@ -19,6 +26,11 @@ class ContinueProxy extends OpenAI {
|
|||
super(options);
|
||||
this.actualApiBase = options.apiBase;
|
||||
this.apiKeyLocation = options.apiKeyLocation;
|
||||
this.orgScopeId = options.orgScopeId;
|
||||
this.onPremProxyUrl = options.onPremProxyUrl;
|
||||
if (this.onPremProxyUrl) {
|
||||
this.apiBase = new URL("openai/v1/", this.onPremProxyUrl).toString();
|
||||
}
|
||||
}
|
||||
|
||||
static providerName = "continue-proxy";
|
||||
|
|
@ -27,11 +39,13 @@ class ContinueProxy extends OpenAI {
|
|||
};
|
||||
|
||||
protected extraBodyProperties(): Record<string, any> {
|
||||
const continueProperties: ContinueProperties = {
|
||||
apiKeyLocation: this.apiKeyLocation,
|
||||
apiBase: this.actualApiBase,
|
||||
orgScopeId: this.orgScopeId ?? null,
|
||||
};
|
||||
return {
|
||||
continueProperties: {
|
||||
apiKeyLocation: this.apiKeyLocation,
|
||||
apiBase: this.actualApiBase,
|
||||
},
|
||||
continueProperties,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
3453
core/package-lock.json
generated
3453
core/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -52,7 +52,7 @@
|
|||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
"@modelcontextprotocol/sdk": "^1.5.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.0.2",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
||||
"@xenova/transformers": "2.14.0",
|
||||
"adf-to-md": "^1.1.0",
|
||||
|
|
@ -105,7 +105,7 @@
|
|||
"wink-nlp-utils": "^2.1.0",
|
||||
"workerpool": "^9.1.3",
|
||||
"yaml": "^2.4.2",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"engine-strict": true,
|
||||
"engines": {
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ export function getContextProviderHelpers(
|
|||
async (helperContext: any) => {
|
||||
const items = await provider.getContextItems(helperContext, {
|
||||
config: context.config,
|
||||
embeddingsProvider: context.config.embeddingsProvider,
|
||||
embeddingsProvider: context.config.selectedModelByRole.embed,
|
||||
fetch: context.fetch,
|
||||
fullInput: context.input,
|
||||
ide: context.ide,
|
||||
llm: context.llm,
|
||||
reranker: context.config.reranker,
|
||||
reranker: context.config.selectedModelByRole.rerank,
|
||||
selectedCode: context.selectedCode,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ConfigResult, ModelRole } from "@continuedev/config-yaml";
|
||||
|
||||
import { AutocompleteInput } from "../autocomplete/util/types";
|
||||
import { ProfileDescription } from "../config/ConfigHandler";
|
||||
import { OrganizationDescription } from "../config/ProfileLifecycleManager";
|
||||
import { SharedConfigSchema } from "../config/sharedConfig";
|
||||
|
||||
import { DevDataLogEvent } from "@continuedev/config-yaml";
|
||||
import type {
|
||||
BrowserSerializedContinueConfig,
|
||||
ChatMessage,
|
||||
|
|
@ -27,7 +28,7 @@ import type {
|
|||
SiteIndexingConfig,
|
||||
ToolCall,
|
||||
} from "../";
|
||||
import { DevDataLogEvent } from "../../packages/config-yaml/src/schemas/data";
|
||||
import { GlobalContextModelSelections } from "../util/GlobalContext";
|
||||
|
||||
export type OnboardingModes = "Local" | "Best" | "Custom" | "Quickstart";
|
||||
|
||||
|
|
@ -37,8 +38,6 @@ export interface ListHistoryOptions {
|
|||
}
|
||||
|
||||
export type ToCoreFromIdeOrWebviewProtocol = {
|
||||
"update/selectTabAutocompleteModel": [string, void];
|
||||
|
||||
// Special
|
||||
ping: [string, string];
|
||||
abort: [undefined, void];
|
||||
|
|
@ -71,7 +70,15 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
"config/reload": [undefined, ConfigResult<BrowserSerializedContinueConfig>];
|
||||
"config/listProfiles": [undefined, ProfileDescription[] | null];
|
||||
"config/openProfile": [{ profileId: string | undefined }, void];
|
||||
"config/updateSharedConfig": [SharedConfigSchema, void];
|
||||
"config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema];
|
||||
"config/updateSelectedModel": [
|
||||
{
|
||||
profileId: string;
|
||||
role: ModelRole;
|
||||
title: string | null;
|
||||
},
|
||||
GlobalContextModelSelections,
|
||||
];
|
||||
"context/getContextItems": [
|
||||
{
|
||||
name: string;
|
||||
|
|
@ -100,6 +107,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
params: any;
|
||||
historyIndex: number;
|
||||
selectedCode: RangeInFile[];
|
||||
completionOptions?: LLMFullCompletionOptions;
|
||||
},
|
||||
AsyncGenerator<string>,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"config/listProfiles",
|
||||
"config/openProfile",
|
||||
"config/updateSharedConfig",
|
||||
"config/updateSelectedModel",
|
||||
"context/getContextItems",
|
||||
"context/getSymbolsForFiles",
|
||||
"context/loadSubmenuItems",
|
||||
|
|
|
|||
|
|
@ -29,12 +29,6 @@ describe("GlobalContext", () => {
|
|||
expect(value).toBe(true);
|
||||
});
|
||||
|
||||
it("should update and get a string value correctly", () => {
|
||||
globalContext.update("selectedTabAutocompleteModel", "test-model");
|
||||
const value = globalContext.get("selectedTabAutocompleteModel");
|
||||
expect(value).toBe("test-model");
|
||||
});
|
||||
|
||||
it("should update and get an object value correctly", () => {
|
||||
const workspaceIdentifier = "workspace-1";
|
||||
globalContext.update("lastSelectedProfileForWorkspace", {
|
||||
|
|
@ -108,13 +102,9 @@ describe("GlobalContext", () => {
|
|||
|
||||
it("should update and retrieve multiple values correctly", () => {
|
||||
globalContext.update("indexingPaused", true);
|
||||
globalContext.update("selectedTabAutocompleteModel", "test-model");
|
||||
globalContext.update("hasDismissedConfigTsNoticeJetBrains", false);
|
||||
|
||||
expect(globalContext.get("indexingPaused")).toBe(true);
|
||||
expect(globalContext.get("selectedTabAutocompleteModel")).toBe(
|
||||
"test-model",
|
||||
);
|
||||
expect(globalContext.get("hasDismissedConfigTsNoticeJetBrains")).toBe(
|
||||
false,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import fs from "node:fs";
|
||||
|
||||
import { ModelRole } from "@continuedev/config-yaml";
|
||||
|
||||
import { SiteIndexingConfig } from "..";
|
||||
import {
|
||||
salvageSharedConfig,
|
||||
sharedConfigSchema,
|
||||
|
|
@ -7,17 +10,22 @@ import {
|
|||
} from "../config/sharedConfig";
|
||||
|
||||
import { getGlobalContextFilePath } from "./paths";
|
||||
import { SiteIndexingConfig } from "..";
|
||||
|
||||
export type GlobalContextModelSelections = Partial<
|
||||
Record<ModelRole, string | null>
|
||||
>;
|
||||
|
||||
export type GlobalContextType = {
|
||||
indexingPaused: boolean;
|
||||
selectedTabAutocompleteModel: string;
|
||||
lastSelectedProfileForWorkspace: {
|
||||
[workspaceIdentifier: string]: string | null;
|
||||
};
|
||||
lastSelectedOrgIdForWorkspace: {
|
||||
[workspaceIdentifier: string]: string | null;
|
||||
};
|
||||
selectedModelsByProfileId: {
|
||||
[profileId: string]: GlobalContextModelSelections;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is needed to handle the case where a JetBrains user has created
|
||||
|
|
@ -113,4 +121,23 @@ export class GlobalContext {
|
|||
this.update("sharedConfig", updatedSharedConfig);
|
||||
return updatedSharedConfig;
|
||||
}
|
||||
|
||||
updateSelectedModel(
|
||||
profileId: string,
|
||||
role: ModelRole,
|
||||
title: string | null,
|
||||
): GlobalContextModelSelections {
|
||||
const currentSelections = this.get("selectedModelsByProfileId") ?? {};
|
||||
const forProfile = currentSelections[profileId] ?? {};
|
||||
const newSelections = {
|
||||
...forProfile,
|
||||
[role]: title,
|
||||
};
|
||||
|
||||
this.update("selectedModelsByProfileId", {
|
||||
...currentSelections,
|
||||
[profileId]: newSelections,
|
||||
});
|
||||
return newSelections;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import dotenv from "dotenv";
|
|||
import { IdeType, SerializedContinueConfig } from "../";
|
||||
import { defaultConfig, defaultConfigJetBrains } from "../config/default";
|
||||
import Types from "../config/types";
|
||||
import { DevEventName } from "../../packages/config-yaml/src/schemas/data";
|
||||
import { DevEventName } from "@continuedev/config-yaml";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ export const supportedLanguages: { [key: string]: LanguageName } = {
|
|||
htm: LanguageName.HTML,
|
||||
java: LanguageName.JAVA,
|
||||
lua: LanguageName.LUA,
|
||||
luau: LanguageName.LUA,
|
||||
ocaml: LanguageName.OCAML,
|
||||
ml: LanguageName.OCAML,
|
||||
mli: LanguageName.OCAML,
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ models:
|
|||
- apply
|
||||
```
|
||||
|
||||
Note that the `repoMapFileSelection` experimental model role has been deprecated.
|
||||
Note that the `repoMapFileSelection` experimental model role has been deprecated and is only available in `config.json`.
|
||||
|
||||
### Context Providers
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension
|
|||
pluginName=continue-intellij-extension
|
||||
pluginRepositoryUrl=https://github.com/continuedev/continue
|
||||
# SemVer format -> https://semver.org
|
||||
pluginVersion=0.0.91
|
||||
pluginVersion=0.0.93
|
||||
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
|
||||
pluginSinceBuild=223
|
||||
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ class MessageTypes {
|
|||
"config/listProfiles",
|
||||
"config/openProfile",
|
||||
"config/updateSharedConfig",
|
||||
"config/updateSelectedModel",
|
||||
"context/getContextItems",
|
||||
"context/getSymbolsForFiles",
|
||||
"context/loadSubmenuItems",
|
||||
|
|
|
|||
|
|
@ -447,7 +447,8 @@ class IdeProtocolClient(
|
|||
val result = responseContent["result"] as Map<*, *>
|
||||
val config = result["config"] as Map<String, Any>
|
||||
|
||||
val applyCodeBlockModel = getModelByRole(config, "applyCodeBlock")
|
||||
val selectedModels = config["selectedModelByRole"] as Map<String, Any>
|
||||
val applyCodeBlockModel = selectedModels["apply"] as Map<String, Any>
|
||||
|
||||
if (applyCodeBlockModel != null) {
|
||||
continuation.resume(applyCodeBlockModel)
|
||||
|
|
@ -588,19 +589,4 @@ class IdeProtocolClient(
|
|||
fun deleteAtIndex(index: Int) {
|
||||
continuePluginService.sendToWebview("deleteAtIndex", DeleteAtIndex(index), uuid())
|
||||
}
|
||||
|
||||
private fun getModelByRole(
|
||||
config: Any,
|
||||
role: Any
|
||||
): Any? {
|
||||
val experimental = (config as? Map<*, *>)?.get("experimental") as? Map<*, *>
|
||||
val roleTitle = (experimental?.get("modelRoles") as? Map<*, *>)?.get(role) as? String ?: return null
|
||||
|
||||
val models = (config as? Map<*, *>)?.get("models") as? List<*>
|
||||
val matchingModel = models?.find { model ->
|
||||
(model as? Map<*, *>)?.get("title") == roleTitle
|
||||
}
|
||||
|
||||
return matchingModel
|
||||
}
|
||||
}
|
||||
|
|
@ -192,10 +192,12 @@ class VerticalDiffBlock(
|
|||
|
||||
private fun revertDiff() {
|
||||
WriteCommandAction.runWriteCommandAction(project) {
|
||||
// Delete the added lines
|
||||
val startOffset = editor.document.getLineStartOffset(startLine)
|
||||
val endOffset = editor.document.getLineEndOffset(startLine + addedLines.size - 1) + 1
|
||||
editor.document.deleteString(startOffset, endOffset)
|
||||
// Delete the added lines
|
||||
if (addedLines.isNotEmpty()) {
|
||||
val endOffset = editor.document.getLineEndOffset(startLine + addedLines.size - 1) + 1
|
||||
editor.document.deleteString(startOffset, endOffset)
|
||||
}
|
||||
|
||||
// Add the deleted lines back
|
||||
if (deletedLines.isNotEmpty()) {
|
||||
|
|
|
|||
10
extensions/vscode/package-lock.json
generated
10
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.269",
|
||||
"version": "0.9.270",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.269",
|
||||
"version": "0.9.270",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
|
|
@ -106,13 +106,13 @@
|
|||
"@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.35",
|
||||
"@continuedev/config-yaml": "^1.0.50",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
"@modelcontextprotocol/sdk": "^1.5.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.0.2",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
||||
"@xenova/transformers": "2.14.0",
|
||||
"adf-to-md": "^1.1.0",
|
||||
|
|
@ -165,7 +165,7 @@
|
|||
"wink-nlp-utils": "^2.1.0",
|
||||
"workerpool": "^9.1.3",
|
||||
"yaml": "^2.4.2",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.24.7",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "0.9.269",
|
||||
"version": "0.9.271",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
|
|||
|
|
@ -504,21 +504,11 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
async function copyScripts() {
|
||||
process.chdir(path.join(continueDir, "extensions", "vscode"));
|
||||
console.log("[info] Copying scripts from core");
|
||||
await new Promise((resolve, reject) => {
|
||||
ncp(
|
||||
path.join(__dirname, "../../../core/scripts"),
|
||||
path.join(__dirname, "../out"),
|
||||
{ dereference: true },
|
||||
(error) => {
|
||||
if (error) {
|
||||
console.warn("[error] Error copying script files", error);
|
||||
reject(error);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, "../../../core/util/start_ollama.sh"),
|
||||
path.join(__dirname, "../out/start_ollama.sh"),
|
||||
);
|
||||
console.log("[info] Copied script files");
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import {
|
|||
stopStatusBarLoading,
|
||||
} from "./statusBar";
|
||||
|
||||
import type { TabAutocompleteModel } from "../util/loadAutocompleteModel";
|
||||
import { startLocalOllama } from "core/util/ollamaHelper";
|
||||
import type { IDE } from "core";
|
||||
|
||||
|
|
@ -41,7 +40,8 @@ interface VsCodeCompletionInput {
|
|||
}
|
||||
|
||||
export class ContinueCompletionProvider
|
||||
implements vscode.InlineCompletionItemProvider {
|
||||
implements vscode.InlineCompletionItemProvider
|
||||
{
|
||||
private onError(e: any) {
|
||||
let options = ["Documentation"];
|
||||
if (e.message.includes("Ollama may not be installed")) {
|
||||
|
|
@ -82,13 +82,19 @@ export class ContinueCompletionProvider
|
|||
constructor(
|
||||
private readonly configHandler: ConfigHandler,
|
||||
private readonly ide: IDE,
|
||||
private readonly tabAutocompleteModel: TabAutocompleteModel,
|
||||
private readonly webviewProtocol: VsCodeWebviewProtocol,
|
||||
) {
|
||||
async function getAutocompleteModel() {
|
||||
const { config } = await configHandler.loadConfig();
|
||||
if (!config) {
|
||||
return;
|
||||
}
|
||||
return config.selectedModelByRole.autocomplete ?? undefined;
|
||||
}
|
||||
this.completionProvider = new CompletionProvider(
|
||||
this.configHandler,
|
||||
this.ide,
|
||||
this.tabAutocompleteModel.get.bind(this.tabAutocompleteModel),
|
||||
getAutocompleteModel,
|
||||
this.onError.bind(this),
|
||||
getDefinitionsFromLsp,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import * as os from "node:os";
|
|||
import { ContextMenuConfig, RangeInFileWithContents } from "core";
|
||||
import { CompletionProvider } from "core/autocomplete/CompletionProvider";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { getModelByRole } from "core/config/util";
|
||||
import { ContinueServerClient } from "core/continueServer/stubs/client";
|
||||
import { EXTENSION_NAME } from "core/control-plane/env";
|
||||
import { Core } from "core/core";
|
||||
|
|
@ -349,7 +348,7 @@ const getCommandsMap: (
|
|||
);
|
||||
|
||||
const modelTitle =
|
||||
getModelByRole(config, "inlineEdit")?.title ?? defaultModelTitle;
|
||||
config.selectedModelByRole.edit?.title ?? defaultModelTitle;
|
||||
|
||||
void sidebar.webviewProtocol.request("incrementFtc", undefined);
|
||||
|
||||
|
|
@ -873,16 +872,12 @@ const getCommandsMap: (
|
|||
|
||||
const config = vscode.workspace.getConfiguration(EXTENSION_NAME);
|
||||
const quickPick = vscode.window.createQuickPick();
|
||||
const autocompleteModels =
|
||||
(await configHandler.loadConfig()).config?.tabAutocompleteModels ?? [];
|
||||
|
||||
let selected = new GlobalContext().get("selectedTabAutocompleteModel");
|
||||
if (
|
||||
!selected ||
|
||||
!autocompleteModels.some((model) => model.title === selected)
|
||||
) {
|
||||
selected = autocompleteModels[0]?.title;
|
||||
}
|
||||
const { config: continueConfig } = await configHandler.loadConfig();
|
||||
const autocompleteModels =
|
||||
continueConfig?.modelsByRole.autocomplete ?? [];
|
||||
const selected =
|
||||
continueConfig?.selectedModelByRole?.autocomplete?.title ?? undefined;
|
||||
|
||||
// Toggle between Disabled, Paused, and Enabled
|
||||
const pauseOnBattery =
|
||||
|
|
@ -957,11 +952,14 @@ const getCommandsMap: (
|
|||
} else if (
|
||||
autocompleteModels.some((model) => model.title === selectedOption)
|
||||
) {
|
||||
new GlobalContext().update(
|
||||
"selectedTabAutocompleteModel",
|
||||
selectedOption,
|
||||
);
|
||||
configHandler.reloadConfig();
|
||||
if (core.configHandler.currentProfile?.profileDescription.id) {
|
||||
core.invoke("config/updateSelectedModel", {
|
||||
profileId:
|
||||
core.configHandler.currentProfile?.profileDescription.id,
|
||||
role: "autocomplete",
|
||||
title: selectedOption,
|
||||
});
|
||||
}
|
||||
} else if (selectedOption === "$(feedback) Give feedback") {
|
||||
vscode.commands.executeCommand("continue.giveAutocompleteFeedback");
|
||||
} else if (selectedOption === "$(comment) Open chat (Cmd+L)") {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import {
|
|||
} from "../stubs/WorkOsAuthProvider";
|
||||
import { Battery } from "../util/battery";
|
||||
import { FileSearch } from "../util/FileSearch";
|
||||
import { TabAutocompleteModel } from "../util/loadAutocompleteModel";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
|
||||
import { VsCodeMessenger } from "./VsCodeMessenger";
|
||||
|
|
@ -47,7 +46,6 @@ export class VsCodeExtension {
|
|||
private configHandler: ConfigHandler;
|
||||
private extensionContext: vscode.ExtensionContext;
|
||||
private ide: VsCodeIde;
|
||||
private tabAutocompleteModel: TabAutocompleteModel;
|
||||
private sidebar: ContinueGUIWebviewViewProvider;
|
||||
private windowId: string;
|
||||
private editDecorationManager: EditDecorationManager;
|
||||
|
|
@ -143,7 +141,6 @@ export class VsCodeExtension {
|
|||
this.editDecorationManager,
|
||||
);
|
||||
resolveVerticalDiffManager?.(this.verticalDiffManager);
|
||||
this.tabAutocompleteModel = new TabAutocompleteModel(this.configHandler);
|
||||
|
||||
setupRemoteConfigSync(
|
||||
this.configHandler.reloadConfig.bind(this.configHandler),
|
||||
|
|
@ -168,8 +165,6 @@ export class VsCodeExtension {
|
|||
} else if (newConfig) {
|
||||
setupStatusBar(undefined, undefined, false);
|
||||
|
||||
this.tabAutocompleteModel.clearLlm();
|
||||
|
||||
registerAllCodeLensProviders(
|
||||
context,
|
||||
this.verticalDiffManager.fileUriToCodeLens,
|
||||
|
|
@ -193,7 +188,6 @@ export class VsCodeExtension {
|
|||
new ContinueCompletionProvider(
|
||||
this.configHandler,
|
||||
this.ide,
|
||||
this.tabAutocompleteModel,
|
||||
this.sidebar.webviewProtocol,
|
||||
),
|
||||
),
|
||||
|
|
@ -347,7 +341,8 @@ export class VsCodeExtension {
|
|||
|
||||
// Register a content provider for the readonly virtual documents
|
||||
const documentContentProvider = new (class
|
||||
implements vscode.TextDocumentContentProvider {
|
||||
implements vscode.TextDocumentContentProvider
|
||||
{
|
||||
// emitter and its event
|
||||
onDidChangeEmitter = new vscode.EventEmitter<vscode.Uri>();
|
||||
onDidChange = this.onDidChangeEmitter.event;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import { showTutorial } from "../util/tutorial";
|
|||
import { getExtensionUri } from "../util/vscode";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
import { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
import { ILLM } from "core";
|
||||
|
||||
/**
|
||||
* A shared messenger class between Core and Webview
|
||||
|
|
@ -177,7 +178,7 @@ export class VsCodeMessenger {
|
|||
return;
|
||||
}
|
||||
|
||||
let llm = getModelByRole(config, "applyCodeBlock");
|
||||
let llm: ILLM | null | undefined = config.selectedModelByRole.apply;
|
||||
|
||||
if (!llm) {
|
||||
llm = config.models.find(
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ export async function getContextProvidersString(
|
|||
return provider.getContextItems("", {
|
||||
config,
|
||||
ide,
|
||||
embeddingsProvider: config.embeddingsProvider,
|
||||
reranker: config.reranker,
|
||||
embeddingsProvider: config.selectedModelByRole.embed,
|
||||
reranker: config.selectedModelByRole.rerank,
|
||||
llm: config.models[0],
|
||||
fullInput: "",
|
||||
selectedCode: [],
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { IDE } from "core";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { getModelByRole } from "core/config/util";
|
||||
import { Telemetry } from "core/util/posthog";
|
||||
import * as vscode from "vscode";
|
||||
|
||||
|
|
@ -9,10 +8,10 @@ import { VerticalDiffManager } from "../diff/vertical/manager";
|
|||
import { FileSearch } from "../util/FileSearch";
|
||||
import { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
|
||||
import { DataLogger } from "core/data/log";
|
||||
import { getContextProviderQuickPickVal } from "./ContextProvidersQuickPick";
|
||||
import { appendToHistory, getHistoryQuickPickVal } from "./HistoryQuickPick";
|
||||
import { getModelQuickPickVal } from "./ModelSelectionQuickPick";
|
||||
import { DataLogger } from "core/data/log";
|
||||
|
||||
// @ts-ignore - error finding typings
|
||||
// @ts-ignore
|
||||
|
|
@ -278,7 +277,7 @@ export class QuickEdit {
|
|||
}
|
||||
|
||||
return (
|
||||
getModelByRole(config, "inlineEdit")?.title ??
|
||||
config.selectedModelByRole.edit?.title ??
|
||||
(await this.webviewProtocol.request(
|
||||
"getDefaultModelTitle",
|
||||
undefined,
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import Ollama from "core/llm/llms/Ollama";
|
||||
import { GlobalContext } from "core/util/GlobalContext";
|
||||
|
||||
import type { ILLM } from "core";
|
||||
|
||||
export class TabAutocompleteModel {
|
||||
private _llm: ILLM | undefined;
|
||||
private defaultTag = "qwen2.5-coder:1.5b";
|
||||
private globalContext: GlobalContext = new GlobalContext();
|
||||
|
||||
constructor(private configHandler: ConfigHandler) {}
|
||||
|
||||
clearLlm() {
|
||||
this._llm = undefined;
|
||||
}
|
||||
|
||||
async getDefaultTabAutocompleteModel() {
|
||||
const llm = new Ollama({
|
||||
model: this.defaultTag,
|
||||
});
|
||||
|
||||
try {
|
||||
const models = await llm.listModels();
|
||||
if (!models.includes(this.defaultTag)) {
|
||||
return undefined;
|
||||
}
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return llm;
|
||||
}
|
||||
|
||||
async get() {
|
||||
if (!this._llm) {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
if (!config) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (config.tabAutocompleteModels?.length) {
|
||||
const selected = this.globalContext.get("selectedTabAutocompleteModel");
|
||||
if (selected) {
|
||||
this._llm =
|
||||
config.tabAutocompleteModels?.find(
|
||||
(model) => model.title === selected,
|
||||
) ?? config.tabAutocompleteModels?.[0];
|
||||
} else {
|
||||
if (config.tabAutocompleteModels[0].title) {
|
||||
this.globalContext.update(
|
||||
"selectedTabAutocompleteModel",
|
||||
config.tabAutocompleteModels[0].title,
|
||||
);
|
||||
}
|
||||
this._llm = config.tabAutocompleteModels[0];
|
||||
}
|
||||
} else {
|
||||
this._llm = await this.getDefaultTabAutocompleteModel();
|
||||
}
|
||||
}
|
||||
|
||||
return this._llm;
|
||||
}
|
||||
}
|
||||
4660
gui/package-lock.json
generated
4660
gui/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -5,6 +5,7 @@ import { CustomScrollbarDiv, defaultBorderRadius } from ".";
|
|||
import { AuthProvider } from "../context/Auth";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { useAppDispatch, useAppSelector } from "../redux/hooks";
|
||||
import { selectUseHub } from "../redux/selectors";
|
||||
import { focusEdit, setEditStatus } from "../redux/slices/editModeState";
|
||||
import {
|
||||
addCodeToEdit,
|
||||
|
|
@ -244,6 +245,21 @@ const Layout = () => {
|
|||
}
|
||||
}, [location]);
|
||||
|
||||
const useHub = useAppSelector(selectUseHub);
|
||||
|
||||
// Existing users that have already seen the onboarding card
|
||||
// should be shown an intro card for hub.continue.dev
|
||||
// useEffect(() => {
|
||||
// if (useHub !== true) {
|
||||
// return;
|
||||
// }
|
||||
// const seenHubIntro = getLocalStorage("seenHubIntro");
|
||||
// if (!onboardingCard.show && !seenHubIntro) {
|
||||
// onboardingCard.setActiveTab("ExistingUserHubIntro");
|
||||
// }
|
||||
// setLocalStorage("seenHubIntro", true);
|
||||
// }, [onboardingCard.show, useHub]);
|
||||
|
||||
return (
|
||||
<AuthProvider>
|
||||
<LayoutTopDiv>
|
||||
|
|
@ -278,9 +294,7 @@ const Layout = () => {
|
|||
onClick={() => navigate(ROUTES.CONFIG_ERROR)}
|
||||
>
|
||||
<strong className="font-bold">Error!</strong>{" "}
|
||||
<span className="block sm:inline">
|
||||
Could not load config.json
|
||||
</span>
|
||||
<span className="block sm:inline">Could not load config</span>
|
||||
<div className="mt-2 underline">Learn More</div>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ interface OnboardingCardTabsProps {
|
|||
onTabClick: (tabName: TabTitle) => void;
|
||||
}
|
||||
|
||||
export type TabTitle = "Quickstart" | "Best" | "Local";
|
||||
export type TabTitle = "Quickstart" | "Best" | "Local" | "ExistingUserHubIntro";
|
||||
|
||||
export const TabTitles: { [k in TabTitle]: { md: string; default: string } } = {
|
||||
Quickstart: {
|
||||
|
|
@ -22,6 +22,10 @@ export const TabTitles: { [k in TabTitle]: { md: string; default: string } } = {
|
|||
md: "Local",
|
||||
default: "Local with Ollama",
|
||||
},
|
||||
ExistingUserHubIntro: {
|
||||
md: "Try out hub.continue.dev",
|
||||
default: "Try out hub.continue.dev",
|
||||
},
|
||||
};
|
||||
|
||||
const StyledSelect = styled.select`
|
||||
|
|
|
|||
|
|
@ -55,6 +55,20 @@ export default function MainTab({
|
|||
Go to Continue Platform
|
||||
</Button>
|
||||
</>
|
||||
) : onboardingCard.activeTab === "ExistingUserHubIntro" ? (
|
||||
<>
|
||||
<p className="xs:w-3/4 w-full text-sm">
|
||||
You can now browse and create custom AI code assistants at{" "}
|
||||
<code>hub.continue.dev</code>
|
||||
</p>
|
||||
|
||||
<Button
|
||||
onClick={onGetStarted}
|
||||
className="mt-4 grid w-full grid-flow-col items-center gap-2"
|
||||
>
|
||||
Get started
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<p className="xs:w-3/4 w-full text-sm">
|
||||
|
|
@ -70,12 +84,21 @@ export default function MainTab({
|
|||
</>
|
||||
)}
|
||||
|
||||
<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>
|
||||
{onboardingCard.activeTab === "ExistingUserHubIntro" ? (
|
||||
<ButtonSubtext onClick={() => onboardingCard.close(isDialog)}>
|
||||
<div className="mt-4 flex cursor-pointer items-center justify-center gap-1">
|
||||
<span>Or, use Continue as usual</span>
|
||||
<ChevronRightIcon className="h-3 w-3" />
|
||||
</div>
|
||||
</ButtonSubtext>
|
||||
) : (
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ function AddDocsDialog() {
|
|||
type: "docs",
|
||||
description: "Initializing",
|
||||
id: startUrl,
|
||||
embeddingsProviderId: "mock-embeddings-provider-id",
|
||||
progress: 0,
|
||||
status: "indexing",
|
||||
title,
|
||||
|
|
@ -164,7 +163,6 @@ function AddDocsDialog() {
|
|||
type: "docs",
|
||||
description: "Initializing",
|
||||
id: docsResult.details.docsLink,
|
||||
embeddingsProviderId: "mock-embeddings-provider-id",
|
||||
progress: 0,
|
||||
status: "indexing",
|
||||
title: docsResult.details.title ?? docsResult.packageInfo.name,
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
|
|||
}) => {
|
||||
return (
|
||||
<div className="flex cursor-pointer select-none items-center justify-between gap-3">
|
||||
<span className="truncate-right text-right">{text}</span>
|
||||
<span className="truncate-right">{text}</span>
|
||||
<div>
|
||||
<div
|
||||
className={`border-vsc-input-border bg-vsc-input-background flex h-5 w-10 items-center rounded-full border border-solid p-0.5`}
|
||||
className={`border-vsc-input-border bg-vsc-input-background flex h-4 w-8 items-center rounded-full border border-solid p-0.5`}
|
||||
onClick={onToggle}
|
||||
>
|
||||
<div className="relative h-full w-full">
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ export function AssistantSelectOptions({
|
|||
onClose,
|
||||
}: AssistantSelectOptionsProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { profiles, selectedProfile, selectedOrganization } = useAuth();
|
||||
const { profiles, selectedProfile, selectedOrganization, session, login } =
|
||||
useAuth();
|
||||
const dispatch = useAppDispatch();
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
|
@ -85,7 +86,10 @@ export function AssistantSelectOptions({
|
|||
</div>
|
||||
|
||||
<div className="mt-auto w-full">
|
||||
<OptionDiv key={profiles.length} onClick={onNewAssistant}>
|
||||
<OptionDiv
|
||||
key={"new-assistant"}
|
||||
onClick={session ? onNewAssistant : () => login(true)}
|
||||
>
|
||||
<div
|
||||
className="flex items-center py-0.5"
|
||||
style={{ fontSize: getFontSize() - 2 }}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
useEffect(() => {
|
||||
ideMessenger.request("config/listProfiles", undefined).then((result) => {
|
||||
if (result.status === "success") {
|
||||
console.log("PROFILES: ", result.content);
|
||||
dispatch(
|
||||
updateProfilesThunk({
|
||||
profiles: result.content,
|
||||
|
|
@ -179,7 +178,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
useWebviewListener(
|
||||
"didChangeAvailableProfiles",
|
||||
async (data) => {
|
||||
console.log("AVAILABLE: ", data.profiles, data.selectedProfileId);
|
||||
dispatch(
|
||||
updateProfilesThunk({
|
||||
profiles: data.profiles,
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ function useSetup() {
|
|||
}
|
||||
hasLoadedConfig.current = true;
|
||||
dispatch(setConfigResult(configResult));
|
||||
console.log("selecting 1", profileId);
|
||||
dispatch(selectProfileThunk(profileId));
|
||||
|
||||
// Perform any actions needed with the config
|
||||
|
|
@ -95,7 +94,6 @@ function useSetup() {
|
|||
useWebviewListener(
|
||||
"configUpdate",
|
||||
async (update) => {
|
||||
console.log("CONFIG UPDATE: ", update);
|
||||
if (!update) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { XCircleIcon } from "@heroicons/react/24/outline";
|
||||
import { IndexingProgressUpdate } from "core";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { isJetBrains } from "../../../util";
|
||||
|
||||
export interface IndexingProgressErrorTextProps {
|
||||
update: IndexingProgressUpdate;
|
||||
|
|
@ -9,20 +8,16 @@ export interface IndexingProgressErrorTextProps {
|
|||
|
||||
function IndexingProgressErrorText({ update }: IndexingProgressErrorTextProps) {
|
||||
const embeddingsProvider = useAppSelector(
|
||||
(state) => state.config.config.embeddingsProvider,
|
||||
(state) => state.config.config.selectedModelByRole.embed,
|
||||
);
|
||||
|
||||
const showJbError =
|
||||
(isJetBrains() && embeddingsProvider === "all-MiniLM-L6-v2") || true;
|
||||
|
||||
if (showJbError) {
|
||||
if (!embeddingsProvider) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 italic">
|
||||
<XCircleIcon className="h-4 w-4 min-w-[10%]" />
|
||||
<span className="leading-relaxed">
|
||||
The <code>transformers.js</code> embeddingsProvider is currently
|
||||
unsupported in JetBrains. To enable codebase indexing, you can use any
|
||||
of the other providers described in the docs:{" "}
|
||||
Add an Embeddings model to enable codebase indexing. See the docs for
|
||||
examples:
|
||||
<a
|
||||
href="https://docs.continue.dev/walkthroughs/codebase-embeddings#embeddings-providers"
|
||||
target="_blank"
|
||||
|
|
|
|||
95
gui/src/pages/config/ModelRoleSelector.tsx
Normal file
95
gui/src/pages/config/ModelRoleSelector.tsx
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
import { Fragment } from "react";
|
||||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import {
|
||||
ChevronUpDownIcon,
|
||||
InformationCircleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { type ModelDescription } from "core";
|
||||
import { ToolTip } from "../../components/gui/Tooltip";
|
||||
|
||||
interface ModelRoleSelectorProps {
|
||||
models: ModelDescription[];
|
||||
selectedModel: ModelDescription | null;
|
||||
onSelect: (model: ModelDescription | null) => void;
|
||||
displayName: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
const ModelRoleSelector = ({
|
||||
models,
|
||||
selectedModel,
|
||||
onSelect,
|
||||
displayName,
|
||||
description,
|
||||
}: ModelRoleSelectorProps) => {
|
||||
function handleSelect(title: string | null) {
|
||||
onSelect(models.find((m) => m.title === title) ?? null);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mt-2 flex flex-row items-center gap-1 sm:mt-0">
|
||||
<span className="text-sm">{displayName}</span>
|
||||
<InformationCircleIcon
|
||||
className="h-3 w-3"
|
||||
data-tooltip-id={`${displayName}-description`}
|
||||
/>
|
||||
<ToolTip id={`${displayName}-description`} place={"bottom"}>
|
||||
{description}
|
||||
</ToolTip>
|
||||
</div>
|
||||
<Listbox value={selectedModel?.title ?? null} onChange={handleSelect}>
|
||||
{({ open }) => (
|
||||
<div className="relative">
|
||||
<Listbox.Button
|
||||
className={`border-vsc-input-border bg-vsc-background ${!!models.length ? "hover:bg-vsc-input-background cursor-pointer" : ""} text-vsc-foreground relative m-0 flex w-full items-center justify-between rounded-md border border-solid px-2 py-1 text-left`}
|
||||
>
|
||||
{models.length === 0 ? (
|
||||
<span className="text-lightgray italic">{`No ${displayName} models${["Chat", "Apply", "Edit"].includes(displayName) ? ". Using chat model" : ""}`}</span>
|
||||
) : (
|
||||
<span className="lines lines-1">
|
||||
{selectedModel?.title ?? `Select ${displayName} model`}
|
||||
</span>
|
||||
)}
|
||||
{models.length ? (
|
||||
<div className="pointer-events-none flex items-center">
|
||||
<ChevronUpDownIcon
|
||||
className="h-3.5 w-3.5"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
</Listbox.Button>
|
||||
|
||||
<Transition
|
||||
as={Fragment}
|
||||
show={open}
|
||||
enter="transition ease-out duration-100"
|
||||
enterFrom="transform opacity-0 scale-95"
|
||||
enterTo="transform opacity-100 scale-100"
|
||||
leave="transition ease-in duration-75"
|
||||
leaveFrom="transform opacity-100 scale-100"
|
||||
leaveTo="transform opacity-0 scale-95"
|
||||
>
|
||||
<Listbox.Options className="bg-vsc-background max-h-80vh absolute z-[800] mt-0.5 w-full overflow-y-scroll rounded-sm p-0">
|
||||
{models.map((option, idx) => (
|
||||
<Listbox.Option
|
||||
key={idx}
|
||||
value={option.title}
|
||||
className={`text-vsc-foreground hover:text-list-active-foreground flex cursor-pointer flex-row items-center gap-3 px-2 py-1 ${option?.title === selectedModel?.title ? "bg-list-active" : "bg-vsc-input-background"}`}
|
||||
>
|
||||
<span className="lines lines-1 relative flex h-5 items-center justify-between gap-3 pr-2 text-xs">
|
||||
{option.title}
|
||||
</span>
|
||||
</Listbox.Option>
|
||||
))}
|
||||
</Listbox.Options>
|
||||
</Transition>
|
||||
</div>
|
||||
)}
|
||||
</Listbox>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelRoleSelector;
|
||||
|
|
@ -1,322 +0,0 @@
|
|||
import { useContext, useEffect, useState } from "react";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
|
||||
import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import {
|
||||
SharedConfigSchema,
|
||||
modifyContinueConfigWithSharedConfig,
|
||||
} from "core/config/sharedConfig";
|
||||
import { Input } from "../../components";
|
||||
import NumberInput from "../../components/gui/NumberInput";
|
||||
import { Select } from "../../components/gui/Select";
|
||||
import ToggleSwitch from "../../components/gui/Switch";
|
||||
import { updateConfig } from "../../redux/slices/configSlice";
|
||||
import { getFontSize } from "../../util";
|
||||
|
||||
function UserSettingsUI() {
|
||||
const dispatch = useAppDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const config = useAppSelector((state) => state.config.config);
|
||||
|
||||
function handleUpdate(sharedConfig: Partial<SharedConfigSchema>) {
|
||||
dispatch(
|
||||
updateConfig(modifyContinueConfigWithSharedConfig(config, sharedConfig)),
|
||||
);
|
||||
ideMessenger.post("config/updateSharedConfig", sharedConfig);
|
||||
}
|
||||
|
||||
// TODO defaults are in multiple places, should be consolidated and probably not explicit here
|
||||
const codeWrap = config.ui?.codeWrap ?? false;
|
||||
const showChatScrollbar = config.ui?.showChatScrollbar ?? false;
|
||||
const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false;
|
||||
const disableSessionTitles = config.disableSessionTitles ?? false;
|
||||
const readResponseTTS = config.experimental?.readResponseTTS ?? false;
|
||||
|
||||
const allowAnonymousTelemetry = config.allowAnonymousTelemetry ?? true;
|
||||
const disableIndexing = config.disableIndexing ?? false;
|
||||
|
||||
const useAutocompleteCache = config.tabAutocompleteOptions?.useCache ?? false;
|
||||
const useChromiumForDocsCrawling =
|
||||
config.experimental?.useChromiumForDocsCrawling ?? false;
|
||||
const codeBlockToolbarPosition = config.ui?.codeBlockToolbarPosition ?? "top";
|
||||
const useAutocompleteMultilineCompletions =
|
||||
config.tabAutocompleteOptions?.multilineCompletions ?? "auto";
|
||||
const fontSize = getFontSize();
|
||||
|
||||
// Disable autocomplete
|
||||
const disableAutocompleteInFiles = (
|
||||
config.tabAutocompleteOptions?.disableInFiles ?? []
|
||||
).join(", ");
|
||||
const [formDisableAutocomplete, setFormDisableAutocomplete] = useState(
|
||||
disableAutocompleteInFiles,
|
||||
);
|
||||
const cancelChangeDisableAutocomplete = () => {
|
||||
setFormDisableAutocomplete(disableAutocompleteInFiles);
|
||||
};
|
||||
const handleDisableAutocompleteSubmit = () => {
|
||||
handleUpdate({
|
||||
disableAutocompleteInFiles: formDisableAutocomplete
|
||||
.split(",")
|
||||
.map((val) => val.trim())
|
||||
.filter((val) => !!val),
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Necessary so that reformatted/trimmed values don't cause dirty state
|
||||
setFormDisableAutocomplete(disableAutocompleteInFiles);
|
||||
}, [disableAutocompleteInFiles]);
|
||||
|
||||
// Workspace prompts
|
||||
const promptPath = config.experimental?.promptPath || "";
|
||||
const [formPromptPath, setFormPromptPath] = useState(promptPath);
|
||||
const cancelChangePromptPath = () => {
|
||||
setFormPromptPath(promptPath);
|
||||
};
|
||||
const handleSubmitPromptPath = () => {
|
||||
handleUpdate({
|
||||
promptPath: formPromptPath || "",
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Necessary so that reformatted/trimmed values don't cause dirty state
|
||||
setFormPromptPath(promptPath);
|
||||
}, [promptPath]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4 py-6">
|
||||
<div>
|
||||
<h2 className="mb-2 mt-0">User settings</h2>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-4">
|
||||
<ToggleSwitch
|
||||
isToggled={codeWrap}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
codeWrap: !codeWrap,
|
||||
})
|
||||
}
|
||||
text="Wrap Codeblocks"
|
||||
/>
|
||||
<ToggleSwitch
|
||||
isToggled={displayRawMarkdown}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
displayRawMarkdown: !displayRawMarkdown,
|
||||
})
|
||||
}
|
||||
text="Display Raw Markdown"
|
||||
/>
|
||||
<ToggleSwitch
|
||||
isToggled={allowAnonymousTelemetry}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
allowAnonymousTelemetry: !allowAnonymousTelemetry,
|
||||
})
|
||||
}
|
||||
text="Allow Anonymous Telemetry"
|
||||
/>
|
||||
<ToggleSwitch
|
||||
isToggled={disableIndexing}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
disableIndexing: !disableIndexing,
|
||||
})
|
||||
}
|
||||
text="Disable Indexing"
|
||||
/>
|
||||
|
||||
<ToggleSwitch
|
||||
isToggled={disableSessionTitles}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
disableSessionTitles: !disableSessionTitles,
|
||||
})
|
||||
}
|
||||
text="Disable Session Titles"
|
||||
/>
|
||||
<ToggleSwitch
|
||||
isToggled={readResponseTTS}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
readResponseTTS: !readResponseTTS,
|
||||
})
|
||||
}
|
||||
text="Response Text to Speech"
|
||||
/>
|
||||
|
||||
<ToggleSwitch
|
||||
isToggled={showChatScrollbar}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
showChatScrollbar: !showChatScrollbar,
|
||||
})
|
||||
}
|
||||
text="Show Chat Scrollbar"
|
||||
/>
|
||||
|
||||
<ToggleSwitch
|
||||
isToggled={useAutocompleteCache}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
useAutocompleteCache: !useAutocompleteCache,
|
||||
})
|
||||
}
|
||||
text="Use Autocomplete Cache"
|
||||
/>
|
||||
|
||||
<ToggleSwitch
|
||||
isToggled={useChromiumForDocsCrawling}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
useChromiumForDocsCrawling: !useChromiumForDocsCrawling,
|
||||
})
|
||||
}
|
||||
text="Use Chromium for Docs Crawling"
|
||||
/>
|
||||
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="text-right">Codeblock Actions Position</span>
|
||||
<Select
|
||||
value={codeBlockToolbarPosition}
|
||||
onChange={(e) =>
|
||||
handleUpdate({
|
||||
codeBlockToolbarPosition: e.target.value as "top" | "bottom",
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="top">Top</option>
|
||||
<option value="bottom">Bottom</option>
|
||||
</Select>
|
||||
</label>
|
||||
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="text-right">Multiline Autocompletions</span>
|
||||
<Select
|
||||
value={useAutocompleteMultilineCompletions}
|
||||
onChange={(e) =>
|
||||
handleUpdate({
|
||||
useAutocompleteMultilineCompletions: e.target.value as
|
||||
| "auto"
|
||||
| "always"
|
||||
| "never",
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="auto">Auto</option>
|
||||
<option value="always">Always</option>
|
||||
<option value="never">Never</option>
|
||||
</Select>
|
||||
</label>
|
||||
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="text-right">Font Size</span>
|
||||
<NumberInput
|
||||
value={fontSize}
|
||||
onChange={(val) =>
|
||||
handleUpdate({
|
||||
fontSize: val,
|
||||
})
|
||||
}
|
||||
min={7}
|
||||
max={50}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<form
|
||||
className="flex flex-col gap-1"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
handleSubmitPromptPath();
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between">
|
||||
<span>Workspace prompts path</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
value={formPromptPath}
|
||||
className="max-w-[100px]"
|
||||
onChange={(e) => {
|
||||
setFormPromptPath(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<div className="flex h-full flex-col">
|
||||
{formPromptPath !== promptPath ? (
|
||||
<>
|
||||
<div
|
||||
onClick={handleSubmitPromptPath}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
|
||||
</div>
|
||||
<div
|
||||
onClick={cancelChangePromptPath}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div>
|
||||
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form
|
||||
className="flex flex-col gap-1"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
handleDisableAutocompleteSubmit();
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between">
|
||||
<span>Disable autocomplete in files</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
value={formDisableAutocomplete}
|
||||
className="max-w-[100px]"
|
||||
onChange={(e) => {
|
||||
setFormDisableAutocomplete(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<div className="flex h-full flex-col">
|
||||
{formDisableAutocomplete !== disableAutocompleteInFiles ? (
|
||||
<>
|
||||
<div
|
||||
onClick={handleDisableAutocompleteSubmit}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
|
||||
</div>
|
||||
<div
|
||||
onClick={cancelChangeDisableAutocomplete}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div>
|
||||
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span className="text-vsc-foreground-muted self-end text-xs">
|
||||
Comma-separated list of path matchers
|
||||
</span>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default UserSettingsUI;
|
||||
|
|
@ -1,16 +1,32 @@
|
|||
import { ModelRole } from "@continuedev/config-yaml";
|
||||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import { ChevronUpDownIcon, PlusCircleIcon } from "@heroicons/react/24/outline";
|
||||
import {
|
||||
CheckIcon,
|
||||
ChevronUpDownIcon,
|
||||
PlusCircleIcon,
|
||||
XMarkIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { ModelDescription } from "core";
|
||||
import {
|
||||
SharedConfigSchema,
|
||||
modifyAnyConfigWithSharedConfig,
|
||||
} from "core/config/sharedConfig";
|
||||
import { Fragment, useContext, useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { SecondaryButton } from "../../components";
|
||||
import { Input, SecondaryButton } from "../../components";
|
||||
import NumberInput from "../../components/gui/NumberInput";
|
||||
import { Select } from "../../components/gui/Select";
|
||||
import ToggleSwitch from "../../components/gui/Switch";
|
||||
import PageHeader from "../../components/PageHeader";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useNavigationListener } from "../../hooks/useNavigationListener";
|
||||
import { useAppDispatch } from "../../redux/hooks";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { setDefaultModel, updateConfig } from "../../redux/slices/configSlice";
|
||||
import { selectProfileThunk } from "../../redux/thunks/profileAndOrg";
|
||||
import { getFontSize, isJetBrains } from "../../util";
|
||||
import ModelRoleSelector from "./ModelRoleSelector";
|
||||
import { ScopeSelect } from "./ScopeSelect";
|
||||
import UserSettingsUI from "./UserSettings";
|
||||
|
||||
function ConfigPage() {
|
||||
useNavigationListener();
|
||||
|
|
@ -29,7 +45,6 @@ function ConfigPage() {
|
|||
} = useAuth();
|
||||
|
||||
const changeProfileId = (id: string) => {
|
||||
console.log("selecting 2", id);
|
||||
dispatch(selectProfileThunk(id));
|
||||
};
|
||||
|
||||
|
|
@ -52,48 +67,157 @@ function ConfigPage() {
|
|||
// NOTE Hub takes priority over Continue for Teams
|
||||
// Since teams will be moving to hub, not vice versa
|
||||
|
||||
/////// User settings section //////
|
||||
const config = useAppSelector((state) => state.config.config);
|
||||
const selectedChatModel = useAppSelector(
|
||||
(store) => store.config.defaultModelTitle,
|
||||
);
|
||||
|
||||
function handleUpdate(sharedConfig: SharedConfigSchema) {
|
||||
// Optimistic update
|
||||
const updatedConfig = modifyAnyConfigWithSharedConfig(config, sharedConfig);
|
||||
dispatch(updateConfig(updatedConfig));
|
||||
// IMPORTANT no need for model role updates (separate logic for selected model roles)
|
||||
// simply because this function won't be used to update model roles
|
||||
|
||||
// Actual update to core which propagates back with config update event
|
||||
ideMessenger.post("config/updateSharedConfig", sharedConfig);
|
||||
}
|
||||
|
||||
function handleRoleUpdate(role: ModelRole, model: ModelDescription | null) {
|
||||
if (!selectedProfile) {
|
||||
return;
|
||||
}
|
||||
// Optimistic update
|
||||
dispatch(
|
||||
updateConfig({
|
||||
...config,
|
||||
selectedModelByRole: {
|
||||
...config.selectedModelByRole,
|
||||
[role]: model,
|
||||
},
|
||||
}),
|
||||
);
|
||||
ideMessenger.post("config/updateSelectedModel", {
|
||||
profileId: selectedProfile.id,
|
||||
role,
|
||||
title: model?.title ?? null,
|
||||
});
|
||||
}
|
||||
|
||||
// TODO use handleRoleUpdate for chat
|
||||
function handleChatModelSelection(model: ModelDescription | null) {
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
dispatch(setDefaultModel({ title: model.title }));
|
||||
}
|
||||
|
||||
// TODO defaults are in multiple places, should be consolidated and probably not explicit here
|
||||
const codeWrap = config.ui?.codeWrap ?? false;
|
||||
const showChatScrollbar = config.ui?.showChatScrollbar ?? false;
|
||||
const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false;
|
||||
const disableSessionTitles = config.disableSessionTitles ?? false;
|
||||
const readResponseTTS = config.experimental?.readResponseTTS ?? false;
|
||||
|
||||
const allowAnonymousTelemetry = config.allowAnonymousTelemetry ?? true;
|
||||
const disableIndexing = config.disableIndexing ?? false;
|
||||
|
||||
const useAutocompleteCache = config.tabAutocompleteOptions?.useCache ?? false;
|
||||
const useChromiumForDocsCrawling =
|
||||
config.experimental?.useChromiumForDocsCrawling ?? false;
|
||||
const codeBlockToolbarPosition = config.ui?.codeBlockToolbarPosition ?? "top";
|
||||
const useAutocompleteMultilineCompletions =
|
||||
config.tabAutocompleteOptions?.multilineCompletions ?? "auto";
|
||||
const fontSize = getFontSize();
|
||||
|
||||
// Disable autocomplete
|
||||
const disableAutocompleteInFiles = (
|
||||
config.tabAutocompleteOptions?.disableInFiles ?? []
|
||||
).join(", ");
|
||||
const [formDisableAutocomplete, setFormDisableAutocomplete] = useState(
|
||||
disableAutocompleteInFiles,
|
||||
);
|
||||
const cancelChangeDisableAutocomplete = () => {
|
||||
setFormDisableAutocomplete(disableAutocompleteInFiles);
|
||||
};
|
||||
const handleDisableAutocompleteSubmit = () => {
|
||||
handleUpdate({
|
||||
disableAutocompleteInFiles: formDisableAutocomplete
|
||||
.split(",")
|
||||
.map((val) => val.trim())
|
||||
.filter((val) => !!val),
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Necessary so that reformatted/trimmed values don't cause dirty state
|
||||
setFormDisableAutocomplete(disableAutocompleteInFiles);
|
||||
}, [disableAutocompleteInFiles]);
|
||||
|
||||
// Workspace prompts
|
||||
const promptPath = config.experimental?.promptPath || "";
|
||||
const [formPromptPath, setFormPromptPath] = useState(promptPath);
|
||||
const cancelChangePromptPath = () => {
|
||||
setFormPromptPath(promptPath);
|
||||
};
|
||||
const handleSubmitPromptPath = () => {
|
||||
handleUpdate({
|
||||
promptPath: formPromptPath || "",
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Necessary so that reformatted/trimmed values don't cause dirty state
|
||||
setFormPromptPath(promptPath);
|
||||
}, [promptPath]);
|
||||
|
||||
const jetbrains = isJetBrains();
|
||||
|
||||
return (
|
||||
<div className="overflow-y-scroll">
|
||||
<PageHeader onTitleClick={() => navigate("/")} title="Chat" />
|
||||
|
||||
<div className="divide-x-0 divide-y-2 divide-solid divide-zinc-700 px-4">
|
||||
<div className="flex flex-col">
|
||||
<div className="flex max-w-[400px] flex-col gap-4 py-4">
|
||||
<h2 className="mb-1 mt-0">Account</h2>
|
||||
{!session ? (
|
||||
<div className="flex flex-col gap-2">
|
||||
<span>You are not signed in.</span>
|
||||
<SecondaryButton onClick={() => login(false)}>
|
||||
Sign in
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col gap-4">
|
||||
{hubEnabled ? (
|
||||
// Hub: show org selector
|
||||
<div className="flex flex-col gap-1.5">
|
||||
<span className="text-lightgray">{`Organization`}</span>
|
||||
<ScopeSelect />
|
||||
</div>
|
||||
) : (
|
||||
// Continue for teams: show org text
|
||||
<div>You are using Continue for Teams</div>
|
||||
)}
|
||||
<div className="flex flex-row items-center gap-2">
|
||||
<span className="text-lightgray">
|
||||
{session.account.label === ""
|
||||
? "Signed in"
|
||||
: `Signed in as ${session.account.label}`}
|
||||
</span>
|
||||
<span
|
||||
onClick={logout}
|
||||
className="text-lightgray cursor-pointer underline"
|
||||
>{`Sign out`}</span>
|
||||
{(session || hubEnabled || controlServerBetaEnabled) && (
|
||||
<div className="flex flex-col">
|
||||
<div className="flex max-w-[400px] flex-col gap-4 py-4">
|
||||
<h2 className="mb-1 mt-0">Account</h2>
|
||||
{!session ? (
|
||||
<div className="flex flex-col gap-2">
|
||||
<span>You are not signed in.</span>
|
||||
<SecondaryButton onClick={() => login(false)}>
|
||||
Sign in
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
) : (
|
||||
<div className="flex flex-col gap-4">
|
||||
{hubEnabled ? (
|
||||
// Hub: show org selector
|
||||
<div className="flex flex-col gap-1.5">
|
||||
<span className="text-lightgray">{`Organization`}</span>
|
||||
<ScopeSelect />
|
||||
</div>
|
||||
) : (
|
||||
// Continue for teams: show org text
|
||||
<div>You are using Continue for Teams</div>
|
||||
)}
|
||||
<div className="flex flex-row items-center gap-2">
|
||||
<span className="text-lightgray">
|
||||
{session.account.label === ""
|
||||
? "Signed in"
|
||||
: `Signed in as ${session.account.label}`}
|
||||
</span>
|
||||
<span
|
||||
onClick={logout}
|
||||
className="text-lightgray cursor-pointer underline"
|
||||
>{`Sign out`}</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex flex-col">
|
||||
<div className="flex max-w-[400px] flex-col gap-4 py-6">
|
||||
|
|
@ -143,10 +267,14 @@ function ConfigPage() {
|
|||
value={null}
|
||||
className={`text-vsc-foreground hover:bg-list-active bg-vsc-input-background flex cursor-pointer flex-row items-center gap-2 px-3 py-2`}
|
||||
onClick={() => {
|
||||
ideMessenger.post("controlPlane/openUrl", {
|
||||
path: "new",
|
||||
orgSlug: selectedOrganization?.slug,
|
||||
});
|
||||
if (session) {
|
||||
ideMessenger.post("controlPlane/openUrl", {
|
||||
path: "new",
|
||||
orgSlug: selectedOrganization?.slug,
|
||||
});
|
||||
} else {
|
||||
login(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<PlusCircleIcon className="h-4 w-4" />
|
||||
|
|
@ -173,12 +301,301 @@ function ConfigPage() {
|
|||
) : (
|
||||
<div>Loading...</div>
|
||||
)}
|
||||
<div>
|
||||
<h2 className="m-0 mb-3 p-0 text-center text-sm">
|
||||
Active Models
|
||||
</h2>
|
||||
<div className="grid grid-cols-1 gap-x-3 gap-y-2 sm:grid-cols-[auto_1fr]">
|
||||
<ModelRoleSelector
|
||||
displayName="Chat"
|
||||
description="Used in the chat interface"
|
||||
models={config.modelsByRole.chat}
|
||||
selectedModel={{
|
||||
title: selectedChatModel,
|
||||
provider: "mock",
|
||||
model: "mock",
|
||||
}}
|
||||
onSelect={(model) => handleChatModelSelection(model)}
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Autocomplete"
|
||||
description="Used to generate code completion suggestions"
|
||||
models={config.modelsByRole.autocomplete}
|
||||
selectedModel={config.selectedModelByRole.autocomplete}
|
||||
onSelect={(model) => handleRoleUpdate("autocomplete", model)}
|
||||
/>
|
||||
{/* Jetbrains has a model selector inline */}
|
||||
{!jetbrains && (
|
||||
<ModelRoleSelector
|
||||
displayName="Edit"
|
||||
description="Used for inline edits"
|
||||
models={config.modelsByRole.edit}
|
||||
selectedModel={config.selectedModelByRole.edit}
|
||||
onSelect={(model) => handleRoleUpdate("edit", model)}
|
||||
/>
|
||||
)}
|
||||
<ModelRoleSelector
|
||||
displayName="Apply"
|
||||
description="Used to apply generated codeblocks to files"
|
||||
models={config.modelsByRole.apply}
|
||||
selectedModel={config.selectedModelByRole.apply}
|
||||
onSelect={(model) => handleRoleUpdate("apply", model)}
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Embed"
|
||||
description="Used to generate and query embeddings for the @codebase and @docs context providers"
|
||||
models={config.modelsByRole.embed}
|
||||
selectedModel={config.selectedModelByRole.embed}
|
||||
onSelect={(model) => handleRoleUpdate("embed", model)}
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Rerank"
|
||||
description="Used for reranking results from the @codebase and @docs context providers"
|
||||
models={config.modelsByRole.rerank}
|
||||
selectedModel={config.selectedModelByRole.rerank}
|
||||
onSelect={(model) => handleRoleUpdate("rerank", model)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{!controlServerBetaEnabled || hubEnabled ? (
|
||||
<div className="flex flex-col">
|
||||
<div className="flex max-w-[400px] flex-col">
|
||||
<UserSettingsUI />
|
||||
<div className="flex flex-col gap-4 py-6">
|
||||
<div>
|
||||
<h2 className="mb-2 mt-0">User settings</h2>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-4">
|
||||
<ToggleSwitch
|
||||
isToggled={codeWrap}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
codeWrap: !codeWrap,
|
||||
})
|
||||
}
|
||||
text="Wrap Codeblocks"
|
||||
/>
|
||||
<ToggleSwitch
|
||||
isToggled={displayRawMarkdown}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
displayRawMarkdown: !displayRawMarkdown,
|
||||
})
|
||||
}
|
||||
text="Display Raw Markdown"
|
||||
/>
|
||||
<ToggleSwitch
|
||||
isToggled={allowAnonymousTelemetry}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
allowAnonymousTelemetry: !allowAnonymousTelemetry,
|
||||
})
|
||||
}
|
||||
text="Allow Anonymous Telemetry"
|
||||
/>
|
||||
<ToggleSwitch
|
||||
isToggled={disableIndexing}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
disableIndexing: !disableIndexing,
|
||||
})
|
||||
}
|
||||
text="Disable Indexing"
|
||||
/>
|
||||
|
||||
<ToggleSwitch
|
||||
isToggled={disableSessionTitles}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
disableSessionTitles: !disableSessionTitles,
|
||||
})
|
||||
}
|
||||
text="Disable Session Titles"
|
||||
/>
|
||||
<ToggleSwitch
|
||||
isToggled={readResponseTTS}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
readResponseTTS: !readResponseTTS,
|
||||
})
|
||||
}
|
||||
text="Response Text to Speech"
|
||||
/>
|
||||
|
||||
<ToggleSwitch
|
||||
isToggled={showChatScrollbar}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
showChatScrollbar: !showChatScrollbar,
|
||||
})
|
||||
}
|
||||
text="Show Chat Scrollbar"
|
||||
/>
|
||||
|
||||
<ToggleSwitch
|
||||
isToggled={useAutocompleteCache}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
useAutocompleteCache: !useAutocompleteCache,
|
||||
})
|
||||
}
|
||||
text="Use Autocomplete Cache"
|
||||
/>
|
||||
|
||||
<ToggleSwitch
|
||||
isToggled={useChromiumForDocsCrawling}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
useChromiumForDocsCrawling: !useChromiumForDocsCrawling,
|
||||
})
|
||||
}
|
||||
text="Use Chromium for Docs Crawling"
|
||||
/>
|
||||
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="lines lines-1 text-left">
|
||||
Codeblock Actions Position
|
||||
</span>
|
||||
<Select
|
||||
value={codeBlockToolbarPosition}
|
||||
onChange={(e) =>
|
||||
handleUpdate({
|
||||
codeBlockToolbarPosition: e.target.value as
|
||||
| "top"
|
||||
| "bottom",
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="top">Top</option>
|
||||
<option value="bottom">Bottom</option>
|
||||
</Select>
|
||||
</label>
|
||||
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="lines lines-1 text-left">
|
||||
Multiline Autocompletions
|
||||
</span>
|
||||
<Select
|
||||
value={useAutocompleteMultilineCompletions}
|
||||
onChange={(e) =>
|
||||
handleUpdate({
|
||||
useAutocompleteMultilineCompletions: e.target
|
||||
.value as "auto" | "always" | "never",
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="auto">Auto</option>
|
||||
<option value="always">Always</option>
|
||||
<option value="never">Never</option>
|
||||
</Select>
|
||||
</label>
|
||||
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="text-left">Font Size</span>
|
||||
<NumberInput
|
||||
value={fontSize}
|
||||
onChange={(val) =>
|
||||
handleUpdate({
|
||||
fontSize: val,
|
||||
})
|
||||
}
|
||||
min={7}
|
||||
max={50}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<form
|
||||
className="flex flex-col gap-1"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
handleSubmitPromptPath();
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-1">
|
||||
<span>Workspace prompts path</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
value={formPromptPath}
|
||||
className="max-w-[100px]"
|
||||
onChange={(e) => {
|
||||
setFormPromptPath(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<div className="flex h-full flex-col">
|
||||
{formPromptPath !== promptPath ? (
|
||||
<>
|
||||
<div
|
||||
onClick={handleSubmitPromptPath}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
|
||||
</div>
|
||||
<div
|
||||
onClick={cancelChangePromptPath}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div>
|
||||
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form
|
||||
className="flex flex-col gap-1"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
handleDisableAutocompleteSubmit();
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between">
|
||||
<span>Disable autocomplete in files</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
value={formDisableAutocomplete}
|
||||
className="max-w-[100px]"
|
||||
onChange={(e) => {
|
||||
setFormDisableAutocomplete(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<div className="flex h-full flex-col">
|
||||
{formDisableAutocomplete !==
|
||||
disableAutocompleteInFiles ? (
|
||||
<>
|
||||
<div
|
||||
onClick={handleDisableAutocompleteSubmit}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
|
||||
</div>
|
||||
<div
|
||||
onClick={cancelChangeDisableAutocomplete}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div>
|
||||
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span className="text-vsc-foreground-muted text-lightgray self-end text-xs">
|
||||
Comma-separated list of path matchers
|
||||
</span>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,24 @@ const initialState: ConfigState = {
|
|||
models: [],
|
||||
tools: [],
|
||||
usePlatform: true,
|
||||
modelsByRole: {
|
||||
chat: [],
|
||||
apply: [],
|
||||
edit: [],
|
||||
summarize: [],
|
||||
autocomplete: [],
|
||||
rerank: [],
|
||||
embed: [],
|
||||
},
|
||||
selectedModelByRole: {
|
||||
chat: null,
|
||||
apply: null,
|
||||
edit: null,
|
||||
summarize: null,
|
||||
autocomplete: null,
|
||||
rerank: null,
|
||||
embed: null,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,6 @@ export const selectProfileThunk = createAsyncThunk<
|
|||
|
||||
let newId = id;
|
||||
|
||||
console.log(
|
||||
"Running Thunk: ",
|
||||
initialId,
|
||||
newId,
|
||||
state.session.availableProfiles,
|
||||
);
|
||||
// If no profiles, force clear
|
||||
if (state.session.availableProfiles.length === 0) {
|
||||
newId = null;
|
||||
|
|
@ -49,12 +43,6 @@ export const selectProfileThunk = createAsyncThunk<
|
|||
}
|
||||
|
||||
// Only update if there's a change
|
||||
console.log(
|
||||
"update selected profile?",
|
||||
newId,
|
||||
initialId,
|
||||
state.session.availableProfiles,
|
||||
);
|
||||
if ((newId ?? null) !== (initialId ?? null)) {
|
||||
dispatch(
|
||||
setSelectedProfile(
|
||||
|
|
@ -103,7 +91,6 @@ export const updateProfilesThunk = createAsyncThunk<
|
|||
dispatch(setAvailableProfiles(profiles));
|
||||
|
||||
// This will trigger reselection if needed
|
||||
console.log("selecting 3", selectedProfileId);
|
||||
dispatch(selectProfileThunk(selectedProfileId));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ const getSlashCommandForInput = (
|
|||
|
||||
if (lastText.startsWith("/")) {
|
||||
slashCommandName = lastText.split(" ")[0].substring(1);
|
||||
slashCommand = slashCommands.find(
|
||||
(command) => command.name === slashCommandName,
|
||||
slashCommand = slashCommands.find((command) =>
|
||||
lastText.startsWith(`/${command.name} `),
|
||||
);
|
||||
}
|
||||
if (!slashCommand || !slashCommandName) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {
|
|||
RangeInFile,
|
||||
SlashCommandDescription,
|
||||
} from "core";
|
||||
import { modelSupportsTools } from "core/llm/autodetect";
|
||||
import { selectDefaultModel } from "../slices/configSlice";
|
||||
import { abortStream, streamUpdate } from "../slices/sessionSlice";
|
||||
import { ThunkApiType } from "../store";
|
||||
|
|
@ -30,11 +31,18 @@ export const streamSlashCommand = createAsyncThunk<
|
|||
const defaultModel = selectDefaultModel(state);
|
||||
const isStreaming = state.session.isStreaming;
|
||||
const streamAborter = state.session.streamAborter;
|
||||
const toolSettings = state.ui.toolSettings;
|
||||
|
||||
if (!defaultModel) {
|
||||
throw new Error("Default model not defined");
|
||||
}
|
||||
|
||||
const useTools = state.ui.useTools;
|
||||
const includeTools =
|
||||
useTools &&
|
||||
modelSupportsTools(defaultModel) &&
|
||||
state.session.mode === "chat";
|
||||
|
||||
const modelTitle = defaultModel.title;
|
||||
|
||||
const checkActiveInterval = setInterval(() => {
|
||||
|
|
@ -55,6 +63,14 @@ export const streamSlashCommand = createAsyncThunk<
|
|||
params: slashCommand.params,
|
||||
historyIndex,
|
||||
selectedCode,
|
||||
completionOptions: includeTools
|
||||
? {
|
||||
// Temporarily commented out until slash commands are hooked up to the tool use feedback loop
|
||||
// tools: state.config.config.tools.filter(
|
||||
// (tool) => toolSettings[tool.function.name] !== "disabled",
|
||||
// ),
|
||||
}
|
||||
: {},
|
||||
},
|
||||
streamAborter.signal,
|
||||
)) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ type LocalStorageTypes = {
|
|||
showTutorialCard: boolean;
|
||||
shownProfilesIntroduction: boolean;
|
||||
disableIndexing: boolean;
|
||||
/** Indicates whether the user has seen any kind of onboarding card since hub.continue.dev */
|
||||
seenHubIntro: boolean;
|
||||
};
|
||||
|
||||
export function getLocalStorage<T extends keyof LocalStorageTypes>(
|
||||
|
|
|
|||
12
packages/config-yaml/package-lock.json
generated
12
packages/config-yaml/package-lock.json
generated
|
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.38",
|
||||
"version": "1.0.48",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.38",
|
||||
"version": "1.0.48",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"yaml": "^2.6.1",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
|
|
@ -3812,9 +3812,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/zod": {
|
||||
"version": "3.23.8",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
|
||||
"integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==",
|
||||
"version": "3.24.2",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz",
|
||||
"integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.38",
|
||||
"version": "1.0.50",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"yaml": "^2.6.1",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ export interface UserSecretLocation {
|
|||
|
||||
export interface ModelsAddOnSecretLocation {
|
||||
secretType: SecretType.ModelsAddOn;
|
||||
blockSlug: PackageSlug;
|
||||
secretName: string;
|
||||
}
|
||||
|
||||
export interface FreeTrialSecretLocation {
|
||||
secretType: SecretType.FreeTrial;
|
||||
blockSlug: PackageSlug;
|
||||
secretName: string;
|
||||
}
|
||||
|
||||
|
|
@ -66,9 +68,9 @@ export function encodeSecretLocation(secretLocation: SecretLocation): string {
|
|||
} else if (secretLocation.secretType === SecretType.NotFound) {
|
||||
return `${SecretType.NotFound}:${secretLocation.secretName}`;
|
||||
} else if (secretLocation.secretType === SecretType.ModelsAddOn) {
|
||||
return `${SecretType.ModelsAddOn}:${secretLocation.secretName}`;
|
||||
return `${SecretType.ModelsAddOn}:${encodePackageSlug(secretLocation.blockSlug)}/${secretLocation.secretName}`;
|
||||
} else if (secretLocation.secretType === SecretType.FreeTrial) {
|
||||
return `${SecretType.FreeTrial}:${secretLocation.secretName}`;
|
||||
return `${SecretType.FreeTrial}:${encodePackageSlug(secretLocation.blockSlug)}/${secretLocation.secretName}`;
|
||||
} else {
|
||||
throw new Error(`Invalid secret type: ${secretLocation}`);
|
||||
}
|
||||
|
|
@ -107,11 +109,19 @@ export function decodeSecretLocation(secretLocation: string): SecretLocation {
|
|||
return {
|
||||
secretType: SecretType.ModelsAddOn,
|
||||
secretName,
|
||||
blockSlug: {
|
||||
ownerSlug: parts[0],
|
||||
packageSlug: parts[1],
|
||||
},
|
||||
};
|
||||
case SecretType.FreeTrial:
|
||||
return {
|
||||
secretType: SecretType.FreeTrial,
|
||||
secretName,
|
||||
blockSlug: {
|
||||
ownerSlug: parts[0],
|
||||
packageSlug: parts[1],
|
||||
},
|
||||
};
|
||||
default:
|
||||
throw new Error(`Invalid secret type: ${secretType}`);
|
||||
|
|
|
|||
|
|
@ -34,14 +34,15 @@ export function getLocationsToLook(
|
|||
secretName: string,
|
||||
): SecretLocation[] {
|
||||
const locationsToLook: SecretLocation[] = [
|
||||
// Models Add-On
|
||||
{
|
||||
secretType: SecretType.ModelsAddOn as const,
|
||||
secretName,
|
||||
},
|
||||
// Block
|
||||
...(blockSlug
|
||||
? [
|
||||
// Models Add-On
|
||||
{
|
||||
secretType: SecretType.ModelsAddOn as const,
|
||||
secretName,
|
||||
blockSlug,
|
||||
},
|
||||
// Block
|
||||
{
|
||||
secretType: SecretType.Package as const,
|
||||
packageSlug: blockSlug,
|
||||
|
|
@ -67,11 +68,16 @@ export function getLocationsToLook(
|
|||
userSlug: currentUserSlug,
|
||||
secretName,
|
||||
},
|
||||
// Free Trial
|
||||
{
|
||||
secretType: SecretType.FreeTrial as const,
|
||||
secretName,
|
||||
},
|
||||
// Free Trial (must be using a eligible block)
|
||||
...(blockSlug
|
||||
? [
|
||||
{
|
||||
secretType: SecretType.FreeTrial as const,
|
||||
secretName,
|
||||
blockSlug,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
];
|
||||
return locationsToLook;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { z } from "zod";
|
||||
import { PlatformClient, SecretStore } from "../interfaces/index.js";
|
||||
import {
|
||||
decodeSecretLocation,
|
||||
|
|
@ -17,10 +18,12 @@ import {
|
|||
parseAssistantUnrolled,
|
||||
} from "./unroll.js";
|
||||
|
||||
export async function clientRender(
|
||||
export async function renderSecrets(
|
||||
packageSlug: PackageSlug,
|
||||
unrolledConfigContent: string,
|
||||
clientSecretStore: SecretStore,
|
||||
orgScopeId: string | null, // The "scope" that the user is logged in with
|
||||
onPremProxyUrl: string | null,
|
||||
platformClient?: PlatformClient,
|
||||
): Promise<AssistantUnrolled> {
|
||||
// 1. First we need to get a list of all the FQSNs that are required to render the config
|
||||
|
|
@ -67,7 +70,12 @@ export async function clientRender(
|
|||
const parsedYaml = parseAssistantUnrolled(renderedYaml);
|
||||
|
||||
// 7. We update any of the items with the proxy version if there are un-rendered secrets
|
||||
const finalConfig = useProxyForUnrenderedSecrets(parsedYaml, packageSlug);
|
||||
const finalConfig = useProxyForUnrenderedSecrets(
|
||||
parsedYaml,
|
||||
packageSlug,
|
||||
orgScopeId,
|
||||
onPremProxyUrl,
|
||||
);
|
||||
return finalConfig;
|
||||
}
|
||||
|
||||
|
|
@ -103,9 +111,11 @@ function getContinueProxyModelName(
|
|||
return `${packageSlug.ownerSlug}/${packageSlug.packageSlug}/${provider}/${model}`;
|
||||
}
|
||||
|
||||
function useProxyForUnrenderedSecrets(
|
||||
export function useProxyForUnrenderedSecrets(
|
||||
config: AssistantUnrolled,
|
||||
packageSlug: PackageSlug,
|
||||
orgScopeId: string | null,
|
||||
onPremProxyUrl: string | null,
|
||||
): AssistantUnrolled {
|
||||
if (config.models) {
|
||||
for (let i = 0; i < config.models.length; i++) {
|
||||
|
|
@ -122,6 +132,8 @@ function useProxyForUnrenderedSecrets(
|
|||
config.models[i].model,
|
||||
),
|
||||
apiKeyLocation: encodeSecretLocation(apiKeyLocation),
|
||||
orgScopeId,
|
||||
onPremProxyUrl,
|
||||
apiKey: undefined,
|
||||
};
|
||||
}
|
||||
|
|
@ -130,3 +142,12 @@ function useProxyForUnrenderedSecrets(
|
|||
|
||||
return config;
|
||||
}
|
||||
|
||||
/** The additional properties that are added to the otherwise OpenAI-compatible body when requesting a Continue proxy */
|
||||
export const continuePropertiesSchema = z.object({
|
||||
apiKeyLocation: z.string().optional(),
|
||||
apiBase: z.string().optional(),
|
||||
orgScopeId: z.string().nullable(),
|
||||
});
|
||||
|
||||
export type ContinueProperties = z.infer<typeof continuePropertiesSchema>;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import * as YAML from "yaml";
|
||||
import { Registry } from "../interfaces/index.js";
|
||||
import { PlatformClient, Registry } from "../interfaces/index.js";
|
||||
import { encodeSecretLocation } from "../interfaces/SecretResult.js";
|
||||
import {
|
||||
decodeFQSN,
|
||||
decodeFullSlug,
|
||||
encodeFQSN,
|
||||
encodePackageSlug,
|
||||
FQSN,
|
||||
FullSlug,
|
||||
PackageSlug,
|
||||
} from "../interfaces/slugs.js";
|
||||
|
|
@ -14,6 +18,7 @@ import {
|
|||
ConfigYaml,
|
||||
configYamlSchema,
|
||||
} from "../schemas/index.js";
|
||||
import { useProxyForUnrenderedSecrets } from "./clientRender.js";
|
||||
|
||||
export function parseConfigYaml(configYaml: string): ConfigYaml {
|
||||
try {
|
||||
|
|
@ -32,7 +37,9 @@ export function parseAssistantUnrolled(configYaml: string): AssistantUnrolled {
|
|||
const result = assistantUnrolledSchema.parse(parsed);
|
||||
return result;
|
||||
} catch (e: any) {
|
||||
throw new Error(`Failed to parse unrolled assistant: ${e.message}`);
|
||||
throw new Error(
|
||||
`Failed to parse unrolled assistant: ${e.message}\n\n${configYaml}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,54 +130,139 @@ function extractFQSNMap(
|
|||
return secretToFQSNMap(secrets, parentPackages);
|
||||
}
|
||||
|
||||
/**
|
||||
* All template vars are already FQSNs, here we just resolve them to either locations or values
|
||||
*/
|
||||
async function extractRenderedSecretsMap(
|
||||
rawContent: string,
|
||||
platformClient: PlatformClient,
|
||||
): Promise<Record<string, string>> {
|
||||
// Get all template variables
|
||||
const templateVars = getTemplateVariables(rawContent);
|
||||
const secrets = templateVars
|
||||
.filter((v) => v.startsWith("secrets."))
|
||||
.map((v) => v.replace("secrets.", ""));
|
||||
|
||||
const fqsns: FQSN[] = secrets.map(decodeFQSN);
|
||||
|
||||
// FQSN -> SecretResult
|
||||
const secretResults = await platformClient.resolveFQSNs(fqsns);
|
||||
|
||||
const map: Record<string, string> = {};
|
||||
for (const secretResult of secretResults) {
|
||||
if (!secretResult) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// User secrets are rendered
|
||||
if ("value" in secretResult) {
|
||||
map[encodeFQSN(secretResult.fqsn)] = secretResult.value;
|
||||
} else {
|
||||
// Other secrets are rendered as secret locations and then converted to proxy types later
|
||||
map[encodeFQSN(secretResult.fqsn)] =
|
||||
`\${{ secrets.${encodeSecretLocation(secretResult.secretLocation)} }}`;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
export interface DoNotRenderSecretsUnrollAssistantOptions {
|
||||
renderSecrets: false;
|
||||
}
|
||||
|
||||
export interface RenderSecretsUnrollAssistantOptions {
|
||||
renderSecrets: true;
|
||||
orgScopeId: string | null;
|
||||
currentUserSlug: string;
|
||||
platformClient: PlatformClient;
|
||||
onPremProxyUrl: string | null;
|
||||
}
|
||||
|
||||
export type UnrollAssistantOptions =
|
||||
| DoNotRenderSecretsUnrollAssistantOptions
|
||||
| RenderSecretsUnrollAssistantOptions;
|
||||
|
||||
export async function unrollAssistant(
|
||||
fullSlug: string,
|
||||
registry: Registry,
|
||||
options: UnrollAssistantOptions,
|
||||
): Promise<AssistantUnrolled> {
|
||||
const assistantSlug = decodeFullSlug(fullSlug);
|
||||
|
||||
// Request the content from the registry
|
||||
const rawContent = await registry.getContent(assistantSlug);
|
||||
return unrollAssistantFromContent(assistantSlug, rawContent, registry);
|
||||
return unrollAssistantFromContent(
|
||||
assistantSlug,
|
||||
rawContent,
|
||||
registry,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
function renderTemplateData(
|
||||
rawYaml: string,
|
||||
templateData: Partial<TemplateData>,
|
||||
): string {
|
||||
const fullTemplateData: TemplateData = {
|
||||
inputs: {},
|
||||
secrets: {},
|
||||
continue: {},
|
||||
...templateData,
|
||||
};
|
||||
const templatedYaml = fillTemplateVariables(
|
||||
rawYaml,
|
||||
flattenTemplateData(fullTemplateData),
|
||||
);
|
||||
return templatedYaml;
|
||||
}
|
||||
|
||||
export async function unrollAssistantFromContent(
|
||||
assistantSlug: FullSlug,
|
||||
rawYaml: string,
|
||||
registry: Registry,
|
||||
options: UnrollAssistantOptions,
|
||||
): Promise<AssistantUnrolled> {
|
||||
// Convert the raw YAML to unrolled config
|
||||
const templateData: TemplateData = {
|
||||
// no inputs to an assistant
|
||||
inputs: {},
|
||||
// at this stage, secrets are mapped to a (still templated) FQSN
|
||||
secrets: extractFQSNMap(rawYaml, [assistantSlug]),
|
||||
// Built-in variables
|
||||
continue: {},
|
||||
};
|
||||
|
||||
// Render the template
|
||||
const templatedYaml = fillTemplateVariables(
|
||||
rawYaml,
|
||||
flattenTemplateData(templateData),
|
||||
);
|
||||
|
||||
// Parse string to Zod-validated YAML
|
||||
let parsedYaml = parseConfigYaml(templatedYaml);
|
||||
let parsedYaml = parseConfigYaml(rawYaml);
|
||||
|
||||
// Unroll blocks
|
||||
const unrolledAssistant = await unrollBlocks(
|
||||
parsedYaml,
|
||||
assistantSlug,
|
||||
registry,
|
||||
// Unroll blocks and convert their secrets to FQSNs
|
||||
const unrolledAssistant = await unrollBlocks(parsedYaml, registry);
|
||||
|
||||
// Back to a string so we can fill in template variables
|
||||
const rawUnrolledYaml = YAML.stringify(unrolledAssistant);
|
||||
|
||||
// Convert all of the template variables to FQSNs
|
||||
// Secrets from the block will have the assistant slug prepended to the FQSN
|
||||
const templatedYaml = renderTemplateData(rawUnrolledYaml, {
|
||||
secrets: extractFQSNMap(rawUnrolledYaml, [assistantSlug]),
|
||||
});
|
||||
|
||||
if (!options.renderSecrets) {
|
||||
return parseAssistantUnrolled(templatedYaml);
|
||||
}
|
||||
|
||||
// Render secret values/locations for client
|
||||
const secrets = await extractRenderedSecretsMap(
|
||||
templatedYaml,
|
||||
options.platformClient,
|
||||
);
|
||||
const renderedYaml = renderTemplateData(templatedYaml, {
|
||||
secrets,
|
||||
});
|
||||
|
||||
return unrolledAssistant;
|
||||
// Parse again and replace models with proxy versions where secrets weren't rendered
|
||||
const finalConfig = useProxyForUnrenderedSecrets(
|
||||
parseAssistantUnrolled(renderedYaml),
|
||||
assistantSlug,
|
||||
options.orgScopeId,
|
||||
options.onPremProxyUrl,
|
||||
);
|
||||
return finalConfig;
|
||||
}
|
||||
|
||||
export async function unrollBlocks(
|
||||
assistant: ConfigYaml,
|
||||
assistantFullSlug: FullSlug,
|
||||
registry: Registry,
|
||||
): Promise<AssistantUnrolled> {
|
||||
const unrolledAssistant: AssistantUnrolled = {
|
||||
|
|
@ -178,7 +270,10 @@ export async function unrollBlocks(
|
|||
version: assistant.version,
|
||||
};
|
||||
|
||||
const sections: (keyof Omit<ConfigYaml, "name" | "version" | "rules">)[] = [
|
||||
const sections: (keyof Omit<
|
||||
ConfigYaml,
|
||||
"name" | "version" | "rules" | "schema"
|
||||
>)[] = [
|
||||
"models",
|
||||
"context",
|
||||
"data",
|
||||
|
|
@ -199,7 +294,6 @@ export async function unrollBlocks(
|
|||
const blockConfigYaml = await resolveBlock(
|
||||
decodeFullSlug(unrolledBlock.uses),
|
||||
unrolledBlock.with,
|
||||
assistantFullSlug,
|
||||
registry,
|
||||
);
|
||||
const block = blockConfigYaml[section]?.[0];
|
||||
|
|
@ -228,7 +322,6 @@ export async function unrollBlocks(
|
|||
const blockConfigYaml = await resolveBlock(
|
||||
decodeFullSlug(rule.uses),
|
||||
rule.with,
|
||||
assistantFullSlug,
|
||||
registry,
|
||||
);
|
||||
const block = blockConfigYaml.rules?.[0];
|
||||
|
|
@ -247,27 +340,37 @@ export async function unrollBlocks(
|
|||
export async function resolveBlock(
|
||||
fullSlug: FullSlug,
|
||||
inputs: Record<string, string> | undefined,
|
||||
parentFullSlug: FullSlug,
|
||||
registry: Registry,
|
||||
): Promise<AssistantUnrolled> {
|
||||
// Retrieve block raw yaml
|
||||
const rawYaml = await registry.getContent(fullSlug);
|
||||
|
||||
// Convert any input secrets to FQSNs (they get FQSNs as if they are in the block. This is so that we know when to use models add-on / free trial secrets)
|
||||
const renderedInputs = inputsToFQSNs(inputs || {}, fullSlug);
|
||||
|
||||
// Render template variables
|
||||
const templateData: TemplateData = {
|
||||
inputs,
|
||||
secrets: extractFQSNMap(rawYaml, [parentFullSlug, fullSlug]),
|
||||
continue: {},
|
||||
};
|
||||
const templatedYaml = fillTemplateVariables(
|
||||
rawYaml,
|
||||
flattenTemplateData(templateData),
|
||||
);
|
||||
const templatedYaml = renderTemplateData(rawYaml, {
|
||||
inputs: renderedInputs,
|
||||
secrets: extractFQSNMap(rawYaml, [fullSlug]),
|
||||
});
|
||||
|
||||
const parsedYaml = parseBlock(templatedYaml);
|
||||
return parsedYaml;
|
||||
}
|
||||
|
||||
function inputsToFQSNs(
|
||||
inputs: Record<string, string>,
|
||||
blockSlug: PackageSlug,
|
||||
): Record<string, string> {
|
||||
const renderedInputs: Record<string, string> = {};
|
||||
for (const [key, value] of Object.entries(inputs)) {
|
||||
renderedInputs[key] = renderTemplateData(value, {
|
||||
secrets: extractFQSNMap(value, [blockSlug]),
|
||||
});
|
||||
}
|
||||
return renderedInputs;
|
||||
}
|
||||
|
||||
export function mergeOverrides<T extends Record<string, any>>(
|
||||
block: T,
|
||||
overrides: Partial<T>,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import * as z from "zod";
|
||||
import { modelSchema, partialModelSchema } from "./models.js";
|
||||
import { dataSchema } from "./data/index.js";
|
||||
import { modelSchema, partialModelSchema } from "./models.js";
|
||||
|
||||
export const contextSchema = z.object({
|
||||
provider: z.string(),
|
||||
|
|
@ -45,9 +45,13 @@ export const blockItemWrapperSchema = <T extends z.AnyZodObject>(schema: T) =>
|
|||
export const blockOrSchema = <T extends z.AnyZodObject>(schema: T) =>
|
||||
z.union([schema, blockItemWrapperSchema(schema)]);
|
||||
|
||||
export const configYamlSchema = z.object({
|
||||
export const baseConfigYamlSchema = z.object({
|
||||
name: z.string(),
|
||||
version: z.string(),
|
||||
schema: z.string().optional(),
|
||||
});
|
||||
|
||||
export const configYamlSchema = baseConfigYamlSchema.extend({
|
||||
models: z
|
||||
.array(
|
||||
z.union([
|
||||
|
|
@ -81,9 +85,7 @@ export const configYamlSchema = z.object({
|
|||
|
||||
export type ConfigYaml = z.infer<typeof configYamlSchema>;
|
||||
|
||||
export const assistantUnrolledSchema = z.object({
|
||||
name: z.string(),
|
||||
version: z.string(),
|
||||
export const assistantUnrolledSchema = baseConfigYamlSchema.extend({
|
||||
models: z.array(modelSchema).optional(),
|
||||
context: z.array(contextSchema).optional(),
|
||||
data: z.array(dataSchema).optional(),
|
||||
|
|
@ -96,22 +98,17 @@ export const assistantUnrolledSchema = z.object({
|
|||
|
||||
export type AssistantUnrolled = z.infer<typeof assistantUnrolledSchema>;
|
||||
|
||||
export const blockSchema = z
|
||||
.object({
|
||||
name: z.string(),
|
||||
version: z.string(),
|
||||
})
|
||||
.and(
|
||||
z.union([
|
||||
z.object({ models: z.array(modelSchema).length(1) }),
|
||||
z.object({ context: z.array(contextSchema).length(1) }),
|
||||
z.object({ data: z.array(dataSchema).length(1) }),
|
||||
z.object({ tools: z.array(toolSchema).length(1) }),
|
||||
z.object({ mcpServers: z.array(mcpServerSchema).length(1) }),
|
||||
z.object({ rules: z.array(z.string()).length(1) }),
|
||||
z.object({ prompts: z.array(promptSchema).length(1) }),
|
||||
z.object({ docs: z.array(docSchema).length(1) }),
|
||||
]),
|
||||
);
|
||||
export const blockSchema = baseConfigYamlSchema.and(
|
||||
z.union([
|
||||
z.object({ models: z.array(modelSchema).length(1) }),
|
||||
z.object({ context: z.array(contextSchema).length(1) }),
|
||||
z.object({ data: z.array(dataSchema).length(1) }),
|
||||
z.object({ tools: z.array(toolSchema).length(1) }),
|
||||
z.object({ mcpServers: z.array(mcpServerSchema).length(1) }),
|
||||
z.object({ rules: z.array(z.string()).length(1) }),
|
||||
z.object({ prompts: z.array(promptSchema).length(1) }),
|
||||
z.object({ docs: z.array(docSchema).length(1) }),
|
||||
]),
|
||||
);
|
||||
|
||||
export type Block = z.infer<typeof blockSchema>;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ export const modelSchema = z.union([
|
|||
...baseModelFields,
|
||||
provider: z.literal("continue-proxy"),
|
||||
apiKeyLocation: z.string(),
|
||||
orgScopeId: z.string().nullable(),
|
||||
onPremProxyUrl: z.string().nullable(),
|
||||
}),
|
||||
z.object({
|
||||
...baseModelFields,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
import * as fs from "fs";
|
||||
import * as YAML from "yaml";
|
||||
import { decodeSecretLocation, resolveSecretLocationInProxy } from "../dist";
|
||||
import {
|
||||
decodeSecretLocation,
|
||||
encodeSecretLocation,
|
||||
resolveSecretLocationInProxy,
|
||||
} from "../dist";
|
||||
import {
|
||||
clientRender,
|
||||
FQSN,
|
||||
FullSlug,
|
||||
PlatformClient,
|
||||
|
|
@ -19,7 +13,6 @@ import {
|
|||
SecretType,
|
||||
unrollAssistant,
|
||||
} from "../src";
|
||||
import exp = require("constants");
|
||||
|
||||
// Test e2e flows from raw yaml -> unroll -> client render -> resolve secrets on proxy
|
||||
describe("E2E Scenarios", () => {
|
||||
|
|
@ -27,9 +20,8 @@ describe("E2E Scenarios", () => {
|
|||
OPENAI_API_KEY: "sk-123",
|
||||
};
|
||||
|
||||
const packageSecrets: Record<string, string> = {
|
||||
"test-org/assistant/ANTHROPIC_API_KEY": "sk-ant",
|
||||
"test-org/gemini/GEMINI_API_KEY": "gemini-api-key",
|
||||
const orgSecrets: Record<string, string> = {
|
||||
GEMINI_API_KEY: "gemini-api-key",
|
||||
};
|
||||
|
||||
const proxyEnvSecrets: Record<string, string> = {
|
||||
|
|
@ -71,14 +63,27 @@ describe("E2E Scenarios", () => {
|
|||
getSecretFromSecretLocation: async function (
|
||||
secretLocation: SecretLocation,
|
||||
): Promise<string | undefined> {
|
||||
if (secretLocation.secretType === SecretType.Package) {
|
||||
return packageSecrets[
|
||||
encodeSecretLocation(secretLocation).split(":")[1]
|
||||
];
|
||||
} else if (secretLocation.secretType === SecretType.User) {
|
||||
return userSecrets[secretLocation.secretName];
|
||||
} else {
|
||||
return undefined;
|
||||
switch (secretLocation.secretType) {
|
||||
case SecretType.Package:
|
||||
return undefined;
|
||||
case SecretType.User:
|
||||
return userSecrets[secretLocation.secretName];
|
||||
case SecretType.Organization:
|
||||
return orgSecrets[secretLocation.secretName];
|
||||
case SecretType.ModelsAddOn:
|
||||
case SecretType.FreeTrial:
|
||||
if (
|
||||
secretLocation.blockSlug.ownerSlug === "test-org" &&
|
||||
secretLocation.blockSlug.packageSlug === "claude35sonnet" &&
|
||||
secretLocation.secretName === "ANTHROPIC_API_KEY"
|
||||
) {
|
||||
return "sk-ant";
|
||||
}
|
||||
return undefined;
|
||||
case SecretType.NotFound:
|
||||
return undefined;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -97,18 +102,34 @@ describe("E2E Scenarios", () => {
|
|||
const unrolledConfig = await unrollAssistant(
|
||||
"test-org/assistant",
|
||||
registry,
|
||||
{
|
||||
renderSecrets: true,
|
||||
platformClient,
|
||||
orgScopeId: "test-org",
|
||||
currentUserSlug: "test-user",
|
||||
onPremProxyUrl: null,
|
||||
},
|
||||
);
|
||||
|
||||
// Test that packages were correctly unrolled and params replaced
|
||||
expect(unrolledConfig.models?.length).toBe(3);
|
||||
expect(unrolledConfig.models?.[0].apiKey).toBe(
|
||||
"${{ secrets.test-org/assistant/OPENAI_API_KEY }}",
|
||||
);
|
||||
expect(unrolledConfig.models?.[1].apiKey).toBe(
|
||||
"${{ secrets.test-org/assistant/test-org/gemini/GEMINI_API_KEY }}",
|
||||
);
|
||||
expect(unrolledConfig.models?.[2].apiKey).toBe(
|
||||
"${{ secrets.test-org/assistant/ANTHROPIC_API_KEY }}",
|
||||
|
||||
const openAiModel = unrolledConfig.models?.[0]!;
|
||||
expect(openAiModel.apiKey).toBe("sk-123");
|
||||
|
||||
const geminiModel = unrolledConfig.models?.[1]!;
|
||||
expect(geminiModel.provider).toBe("continue-proxy");
|
||||
expect(geminiModel.apiKey).toBeUndefined();
|
||||
const geminiSecretLocation = "organization:test-org/GEMINI_API_KEY";
|
||||
expect((geminiModel as any).apiKeyLocation).toBe(geminiSecretLocation);
|
||||
|
||||
const anthropicModel = unrolledConfig.models?.[2]!;
|
||||
expect(anthropicModel.provider).toBe("continue-proxy");
|
||||
expect(anthropicModel.apiKey).toBeUndefined();
|
||||
const anthropicSecretLocation =
|
||||
"models_add_on:test-org/claude35sonnet/ANTHROPIC_API_KEY";
|
||||
expect((anthropicModel as any).apiKeyLocation).toBe(
|
||||
anthropicSecretLocation,
|
||||
);
|
||||
|
||||
expect(unrolledConfig.rules?.length).toBe(2);
|
||||
|
|
@ -119,29 +140,6 @@ describe("E2E Scenarios", () => {
|
|||
"https://docs.python.org/release/3.13.1",
|
||||
);
|
||||
|
||||
const clientRendered = await clientRender(
|
||||
{ ownerSlug: "test-org", packageSlug: "assistant" },
|
||||
YAML.stringify(unrolledConfig),
|
||||
localUserSecretStore,
|
||||
platformClient,
|
||||
);
|
||||
|
||||
// Test that user secrets were injected and others were changed to use proxy
|
||||
const anthropicSecretLocation =
|
||||
"package:test-org/assistant/ANTHROPIC_API_KEY";
|
||||
const geminiSecretLocation = "package:test-org/gemini/GEMINI_API_KEY";
|
||||
expect(clientRendered.models?.[0].apiKey).toBe("sk-123");
|
||||
expect(clientRendered.models?.[1].provider).toBe("continue-proxy");
|
||||
expect((clientRendered.models?.[1] as any).apiKeyLocation).toBe(
|
||||
geminiSecretLocation,
|
||||
);
|
||||
expect(clientRendered.models?.[1].apiKey).toBeUndefined();
|
||||
expect(clientRendered.models?.[2].provider).toBe("continue-proxy");
|
||||
expect((clientRendered.models?.[2] as any).apiKeyLocation).toBe(
|
||||
anthropicSecretLocation,
|
||||
);
|
||||
expect(clientRendered.models?.[2].apiKey).toBeUndefined();
|
||||
|
||||
// Test that proxy can correctly resolve secrets
|
||||
const decodedAnthropicSecretLocation = decodeSecretLocation(
|
||||
anthropicSecretLocation,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/openai-adapters",
|
||||
"version": "1.0.14",
|
||||
"version": "1.0.15",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
"dependencies": {
|
||||
"@azure/openai": "^1.0.0-beta.12",
|
||||
"@continuedev/config-types": "^1.0.5",
|
||||
"@continuedev/config-yaml": "file:///users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist",
|
||||
"@continuedev/config-yaml": "^1.0.50",
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
"json-schema": "^0.4.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
|
|
|
|||
157
packages/openai-adapters/src/apis/Mock.ts
Normal file
157
packages/openai-adapters/src/apis/Mock.ts
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
import { OpenAI } from "openai/index";
|
||||
import {
|
||||
ChatCompletion,
|
||||
ChatCompletionChunk,
|
||||
ChatCompletionCreateParamsNonStreaming,
|
||||
ChatCompletionCreateParamsStreaming,
|
||||
Completion,
|
||||
CompletionCreateParamsNonStreaming,
|
||||
CompletionCreateParamsStreaming,
|
||||
Model,
|
||||
} from "openai/resources/index";
|
||||
import { chatChunk, chatCompletion } from "../util.js";
|
||||
import {
|
||||
BaseLlmApi,
|
||||
CreateRerankResponse,
|
||||
FimCreateParamsStreaming,
|
||||
RerankCreateParams,
|
||||
} from "./base.js";
|
||||
|
||||
const MOCK_RESPONSE =
|
||||
"This is a mock response from the OpenAI API. It can be returned all at once or streamed chunk by chunk.";
|
||||
|
||||
export class MockApi implements BaseLlmApi {
|
||||
async chatCompletionNonStream(
|
||||
body: ChatCompletionCreateParamsNonStreaming,
|
||||
signal: AbortSignal,
|
||||
): Promise<ChatCompletion> {
|
||||
await new Promise((resolve) => setTimeout(resolve, 800));
|
||||
const lastMessage = body.messages[body.messages.length - 1].content;
|
||||
const content = !lastMessage
|
||||
? MOCK_RESPONSE
|
||||
: typeof lastMessage === "string"
|
||||
? lastMessage
|
||||
: lastMessage[0].type === "text"
|
||||
? lastMessage[0].text
|
||||
: MOCK_RESPONSE;
|
||||
return chatCompletion({
|
||||
content,
|
||||
model: body.model,
|
||||
});
|
||||
}
|
||||
|
||||
async *chatCompletionStream(
|
||||
body: ChatCompletionCreateParamsStreaming,
|
||||
signal: AbortSignal,
|
||||
): AsyncGenerator<ChatCompletionChunk, any, unknown> {
|
||||
const lastMessage = body.messages[body.messages.length - 1].content;
|
||||
const content = !lastMessage
|
||||
? MOCK_RESPONSE
|
||||
: typeof lastMessage === "string"
|
||||
? lastMessage
|
||||
: lastMessage[0].type === "text"
|
||||
? lastMessage[0].text
|
||||
: MOCK_RESPONSE;
|
||||
const chunks = content.split(" ");
|
||||
for (const chunk of chunks) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
yield chatChunk({
|
||||
content: chunk + " ",
|
||||
model: body.model,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async completionNonStream(
|
||||
body: CompletionCreateParamsNonStreaming,
|
||||
signal: AbortSignal,
|
||||
): Promise<Completion> {
|
||||
await new Promise((resolve) => setTimeout(resolve, 800));
|
||||
return {
|
||||
id: "mock-completion",
|
||||
object: "text_completion",
|
||||
created: Date.now(),
|
||||
model: body.model,
|
||||
choices: [
|
||||
{
|
||||
text: body.prompt as string,
|
||||
index: 0,
|
||||
finish_reason: "stop",
|
||||
},
|
||||
],
|
||||
} as Completion;
|
||||
}
|
||||
|
||||
async *completionStream(
|
||||
body: CompletionCreateParamsStreaming,
|
||||
signal: AbortSignal,
|
||||
): AsyncGenerator<Completion, any, unknown> {
|
||||
const chunks = (body.prompt as string).split(" ");
|
||||
for (const chunk of chunks) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
yield {
|
||||
id: "mock-chunk",
|
||||
object: "text_completion",
|
||||
created: Date.now(),
|
||||
model: body.model,
|
||||
choices: [
|
||||
{
|
||||
text: chunk + " ",
|
||||
index: 0,
|
||||
finish_reason: "stop",
|
||||
},
|
||||
],
|
||||
} as Completion;
|
||||
}
|
||||
}
|
||||
|
||||
async *fimStream(
|
||||
body: FimCreateParamsStreaming,
|
||||
signal: AbortSignal,
|
||||
): AsyncGenerator<ChatCompletionChunk, any, unknown> {
|
||||
const chunks = (body.prompt as string).split(" ");
|
||||
for (const chunk of chunks) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
yield chatChunk({
|
||||
content: chunk + " ",
|
||||
model: body.model,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async embed(
|
||||
body: OpenAI.Embeddings.EmbeddingCreateParams,
|
||||
): Promise<OpenAI.Embeddings.CreateEmbeddingResponse> {
|
||||
await new Promise((resolve) => setTimeout(resolve, 400));
|
||||
return {
|
||||
data: [
|
||||
{
|
||||
embedding: new Array(1536).fill(0),
|
||||
index: 0,
|
||||
object: "embedding",
|
||||
},
|
||||
],
|
||||
model: body.model,
|
||||
object: "list",
|
||||
usage: {
|
||||
prompt_tokens: 0,
|
||||
total_tokens: 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async rerank(body: RerankCreateParams): Promise<CreateRerankResponse> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
async list(): Promise<Model[]> {
|
||||
return [
|
||||
{
|
||||
id: "mock-model",
|
||||
created: Date.now(),
|
||||
object: "model",
|
||||
owned_by: "mock",
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import { CohereApi } from "./apis/Cohere.js";
|
|||
import { DeepSeekApi } from "./apis/DeepSeek.js";
|
||||
import { GeminiApi } from "./apis/Gemini.js";
|
||||
import { JinaApi } from "./apis/Jina.js";
|
||||
import { MockApi } from "./apis/Mock.js";
|
||||
import { MoonshotApi } from "./apis/Moonshot.js";
|
||||
import { OpenAIApi } from "./apis/OpenAI.js";
|
||||
import { LLMConfig, OpenAIConfigSchema } from "./types.js";
|
||||
|
|
@ -84,6 +85,8 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined {
|
|||
return openAICompatible("http://localhost:8000/", config);
|
||||
case "lmstudio":
|
||||
return openAICompatible("http://localhost:1234/", config);
|
||||
case "mock":
|
||||
return new MockApi();
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,11 @@ export const DeepseekConfigSchema = OpenAIConfigSchema.extend({
|
|||
});
|
||||
export type DeepseekConfig = z.infer<typeof DeepseekConfigSchema>;
|
||||
|
||||
export const MockConfigSchema = BasePlusConfig.extend({
|
||||
provider: z.literal("mock"),
|
||||
});
|
||||
export type MockConfig = z.infer<typeof MockConfigSchema>;
|
||||
|
||||
// Other APIs
|
||||
export const CohereConfigSchema = OpenAIConfigSchema.extend({
|
||||
provider: z.literal("cohere"),
|
||||
|
|
@ -107,5 +112,6 @@ export const LLMConfigSchema = z.discriminatedUnion("provider", [
|
|||
GeminiConfigSchema,
|
||||
AnthropicConfigSchema,
|
||||
JinaConfigSchema,
|
||||
MockConfigSchema,
|
||||
]);
|
||||
export type LLMConfig = z.infer<typeof LLMConfigSchema>;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue