From adcede0ac8f7d41dc6fb22479f623f46a71df0c7 Mon Sep 17 00:00:00 2001 From: tim-jagenberg-piscada <77322574+tim-jagenberg-piscada@users.noreply.github.com> Date: Fri, 24 Jan 2025 10:24:32 +0100 Subject: [PATCH 01/66] remove duplicate `/` in VertexAI _embed Removed duplicate `/` and aligned `new URL(...` usage with the rest of the file. --- core/llm/llms/VertexAI.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/llm/llms/VertexAI.ts b/core/llm/llms/VertexAI.ts index 8d20c3212..4d52e5c43 100644 --- a/core/llm/llms/VertexAI.ts +++ b/core/llm/llms/VertexAI.ts @@ -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({ From f28031902f41c4ae9f7cab01398216272950b7d0 Mon Sep 17 00:00:00 2001 From: liuk Date: Sat, 25 Jan 2025 17:46:16 +0800 Subject: [PATCH 02/66] fix: Handle empty addedLines in revertDiff --- .../continueintellijextension/editor/VerticalDiffBlock.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt index 6f311c29b..627b89d4a 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt @@ -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()) { From 9910fc17225526973f65097f75f50456b35ddef0 Mon Sep 17 00:00:00 2001 From: Lukas Kreussel Date: Wed, 12 Feb 2025 12:05:46 +0100 Subject: [PATCH 03/66] Allow articels without `h2` tags --- core/indexing/docs/article.ts | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/core/indexing/docs/article.ts b/core/indexing/docs/article.ts index 428bae967..aba1da6b0 100644 --- a/core/indexing/docs/article.ts +++ b/core/indexing/docs/article.ts @@ -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 { From f358d0a27321e69e6d49c03ac2a922cff3cd249b Mon Sep 17 00:00:00 2001 From: Fred Bricon Date: Wed, 12 Feb 2025 14:43:28 +0100 Subject: [PATCH 04/66] Fix cross-platform prepackaging failing to copy start_ollama.sh Signed-off-by: Fred Bricon --- extensions/vscode/scripts/utils.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/extensions/vscode/scripts/utils.js b/extensions/vscode/scripts/utils.js index 4f9ce187c..9cbe62455 100644 --- a/extensions/vscode/scripts/utils.js +++ b/extensions/vscode/scripts/utils.js @@ -508,21 +508,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 = { From de842ea51cd149e25c3782fb1f9512b0c6ee5a30 Mon Sep 17 00:00:00 2001 From: Roger Meier Date: Fri, 14 Feb 2025 09:10:00 +0100 Subject: [PATCH 05/66] docs: add Django to the pre indexed docs --- core/indexing/docs/preIndexedDocs.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/indexing/docs/preIndexedDocs.ts b/core/indexing/docs/preIndexedDocs.ts index 4b0c12fee..5342396fd 100644 --- a/core/indexing/docs/preIndexedDocs.ts +++ b/core/indexing/docs/preIndexedDocs.ts @@ -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; From 71186117ef4e437d6940ab12068baf89edba6500 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 8 Feb 2025 14:24:55 -0500 Subject: [PATCH 06/66] Autocomplete: make Granite 3 detection broader The Granite 3 models on Hugging Face use names like: https://huggingface.co/ibm-granite/granite-3.1-8b-instruct Compared to: https://ollama.com/library/granite3.1-dense Use the hole-filler template for names with or without the dash. --- core/autocomplete/templating/AutocompleteTemplate.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/autocomplete/templating/AutocompleteTemplate.ts b/core/autocomplete/templating/AutocompleteTemplate.ts index 7f5366df0..2c8b12a31 100644 --- a/core/autocomplete/templating/AutocompleteTemplate.ts +++ b/core/autocomplete/templating/AutocompleteTemplate.ts @@ -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; } From b076be7b791d38737bf0484558b6ffa65c142645 Mon Sep 17 00:00:00 2001 From: ferenci84 Date: Sat, 15 Feb 2025 14:43:13 +0100 Subject: [PATCH 07/66] Add package to tasks.json --- .vscode/tasks.json | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index e3250d80a..110f01fae 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -73,7 +73,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", From ac282093fa4cc67a5cee432c21781a0915f9e3e5 Mon Sep 17 00:00:00 2001 From: ferenci84 Date: Sat, 15 Feb 2025 17:55:13 +0100 Subject: [PATCH 08/66] update extension packaging instructions in CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b69b1fd44..4f7e1634f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 From c2c4a5f940ec86958f79da8397e95c22f4fd7c4c Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 16 Feb 2025 15:49:49 -0800 Subject: [PATCH 09/66] add a mock llm to openai-adapters --- packages/openai-adapters/package.json | 2 +- packages/openai-adapters/src/apis/Mock.ts | 157 ++++++++++++++++++++++ packages/openai-adapters/src/index.ts | 3 + packages/openai-adapters/src/types.ts | 6 + 4 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 packages/openai-adapters/src/apis/Mock.ts diff --git a/packages/openai-adapters/package.json b/packages/openai-adapters/package.json index afc7a3211..918fc9b70 100644 --- a/packages/openai-adapters/package.json +++ b/packages/openai-adapters/package.json @@ -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", diff --git a/packages/openai-adapters/src/apis/Mock.ts b/packages/openai-adapters/src/apis/Mock.ts new file mode 100644 index 000000000..01553b815 --- /dev/null +++ b/packages/openai-adapters/src/apis/Mock.ts @@ -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 { + 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 { + 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 { + 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 { + 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 { + 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 { + 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 { + throw new Error("Method not implemented."); + } + + async list(): Promise { + return [ + { + id: "mock-model", + created: Date.now(), + object: "model", + owned_by: "mock", + }, + ]; + } +} diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index 094920e63..dede527c4 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -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; } diff --git a/packages/openai-adapters/src/types.ts b/packages/openai-adapters/src/types.ts index c86d63abf..a174174b1 100644 --- a/packages/openai-adapters/src/types.ts +++ b/packages/openai-adapters/src/types.ts @@ -69,6 +69,11 @@ export const DeepseekConfigSchema = OpenAIConfigSchema.extend({ }); export type DeepseekConfig = z.infer; +export const MockConfigSchema = BasePlusConfig.extend({ + provider: z.literal("mock"), +}); +export type MockConfig = z.infer; + // 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; From d57c315effefd88d8872d21b39c03c88ca97d6d2 Mon Sep 17 00:00:00 2001 From: AkatQuas <295140755@qq.com> Date: Mon, 17 Feb 2025 19:17:16 +0800 Subject: [PATCH 10/66] chore: small typo --- .continue/prompts/core-unit-test.prompt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.continue/prompts/core-unit-test.prompt b/.continue/prompts/core-unit-test.prompt index 42ecef7bb..1a08945b4 100644 --- a/.continue/prompts/core-unit-test.prompt +++ b/.continue/prompts/core-unit-test.prompt @@ -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 From 58ae1f79956b704dd2964d290d359711a95c2441 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 18 Feb 2025 11:15:18 -0800 Subject: [PATCH 11/66] BROKEN - config progress --- core/config/load.ts | 74 ++-- core/config/migrateSharedConfig.ts | 40 +++ core/config/sharedConfig.ts | 69 ++-- core/config/types.ts | 2 - core/config/yaml/loadYaml.ts | 24 +- core/context/retrieval/repoMapRequest.ts | 2 +- core/index.d.ts | 52 +-- docs/docs/reference.md | 4 +- docs/docs/yaml-migration.md | 2 +- .../current/reference.md | 2 - extensions/vscode/config_schema.json | 8 - extensions/vscode/package-lock.json | 4 +- gui/src/pages/config/UserSettings.tsx | 322 ----------------- gui/src/pages/config/index.tsx | 328 +++++++++++++++++- 14 files changed, 514 insertions(+), 419 deletions(-) delete mode 100644 gui/src/pages/config/UserSettings.tsx diff --git a/core/config/load.ts b/core/config/load.ts index c8499dc8b..41507b200 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -62,7 +62,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 +76,7 @@ import { defaultSlashCommandsVscode, } from "./default"; import { getSystemPromptDotFile } from "./getSystemPromptDotFile"; -import { modifyContinueConfigWithSharedConfig } from "./sharedConfig"; +import { modifyAnyConfigWithSharedConfig } from "./sharedConfig"; import { validateConfig } from "./validation.js"; export function resolveSerializedConfig( @@ -178,7 +182,7 @@ async function serializedToIntermediateConfig( initial: SerializedContinueConfig, ide: IDE, ): Promise { - // DEPRECATED - load custom slash commands + // DEPRECATED - load cuastom slash commands const slashCommands: SlashCommand[] = []; for (const command of initial.slashCommands || []) { const newCommand = slashCommandFromDescription(command); @@ -497,6 +501,24 @@ async function intermediateToFinalConfig( tabAutocompleteModels, reranker: config.reranker as any, tools: allTools, + modelsByRole: { + chat: [], + edit: [], + apply: [], + embed: [], + autocomplete: [], + rerank: [], + summarize: [], + }, + selectedModelByRole: { + chat: null, + edit: null, + apply: null, + embed: null, + autocomplete: null, + rerank: null, + summarize: null, + }, }; // Apply MCP if specified @@ -541,27 +563,31 @@ async function intermediateToFinalConfig( 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 { 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) => ({ @@ -580,6 +606,13 @@ async function finalToBrowserConfig( tools: final.tools, tabAutocompleteOptions: final.tabAutocompleteOptions, usePlatform: await useHub(ide.getIdeSettings()), + modelsByRole: Object.fromEntries( + Object.entries(final.modelsByRole).map(([k, v]) => [ + k, + v.map(llmToSerializedModelDescription), + ]), + ) as unknown as Record, // TODO better types here + selectedModelByRole: final.selectedModelByRole, }; } @@ -798,10 +831,7 @@ 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); diff --git a/core/config/migrateSharedConfig.ts b/core/config/migrateSharedConfig.ts index 189bb21ed..6586c604b 100644 --- a/core/config/migrateSharedConfig.ts +++ b/core/config/migrateSharedConfig.ts @@ -124,6 +124,46 @@ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void { effected = true; } + const { modelRoles, ...withoutModelRoles } = migratedExperimental; + if (modelRoles !== undefined) { + let migratedModelRoles = { ...modelRoles }; + + const { applyCodeBlock, ...rest90 } = migratedModelRoles; + if (applyCodeBlock !== undefined) { + shareConfigUpdates.selectedModels = { + ...currentSharedConfig.selectedModels, + local: { + ...currentSharedConfig.selectedModels?.["local"], + apply: applyCodeBlock, + }, + }; + migratedModelRoles = rest90; + effected = true; + } + + const { inlineEdit, ...rest91 } = migratedModelRoles; + if (inlineEdit !== undefined) { + shareConfigUpdates.selectedModels = { + ...currentSharedConfig.selectedModels, + local: { + ...currentSharedConfig.selectedModels?.["local"], + edit: inlineEdit, + }, + }; + migratedModelRoles = rest91; + effected = true; + } + + if (Object.keys(migratedModelRoles).length > 0) { + migratedExperimental = { + ...migratedExperimental, + modelRoles: migratedModelRoles, + }; + } else { + migratedExperimental = withoutModelRoles; + } + } + if (Object.keys(migratedExperimental).length > 0) { config = { ...withoutExperimental, diff --git a/core/config/sharedConfig.ts b/core/config/sharedConfig.ts index 9f2335243..9ac797841 100644 --- a/core/config/sharedConfig.ts +++ b/core/config/sharedConfig.ts @@ -5,9 +5,19 @@ import { Config, SerializedContinueConfig, } from ".."; +import { + ModelRole, + modelRolesSchema, +} from "@continuedev/config-yaml/dist/schemas/models"; export const sharedConfigSchema = z .object({ + selectedModels: z.record( + z.string(), + z.record(modelRolesSchema, z.string()), + ), + + // boolean fields in config.json allowAnonymousTelemetry: z.boolean(), disableIndexing: z.boolean(), disableSessionTitles: z.boolean(), @@ -65,7 +75,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 +// - modifyAnyConfigWithSharedConfig - includes boolean flags like allowAnonymousTelemetry which +// must be added BEFORE config.ts and remote server config apply for JSON +// for security reasons +// - modifyFinalConfigWithSharedConfig - 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 +114,7 @@ export function modifyContinueConfigWithSharedConfig< configCopy.ui = { ...configCopy.ui, }; + if (sharedConfig.codeBlockToolbarPosition !== undefined) { configCopy.ui.codeBlockToolbarPosition = sharedConfig.codeBlockToolbarPosition; @@ -136,27 +159,23 @@ 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, -// }; +export function modifyFinalConfigWithSharedConfig< + T extends ContinueConfig | BrowserSerializedContinueConfig, +>( + continueConfig: T, + sharedConfig: SharedConfigSchema, + selectedProfileId: string | null, +): T { + const configCopy = { ...continueConfig }; + const selectedModelsForProfile: Record = { + apply: null, + autocomplete: null, + chat: null, + edit: null, + embed: null, + rerank: null, + summarize: null, + }; + configCopy.selectedModelByRole = selectedModelsForProfile; + return configCopy; +} diff --git a/core/config/types.ts b/core/config/types.ts index 2a68c4c35..5b2f124c0 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -957,8 +957,6 @@ declare global { } interface ExperimentalModelRoles { - inlineEdit?: string; - applyCodeBlock?: string; repoMapFileSelection?: string; } diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 37abaf83e..1da57ba81 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -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"; @@ -132,12 +132,30 @@ 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, + }, }; // 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 roles if not specified if (modelsArrayRoles.some((role) => model.roles?.includes(role))) { // Main model array const llms = await llmsFromModelConfig( @@ -392,7 +410,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, ); diff --git a/core/context/retrieval/repoMapRequest.ts b/core/context/retrieval/repoMapRequest.ts index 39223321b..7115b2d18 100644 --- a/core/context/retrieval/repoMapRequest.ts +++ b/core/context/retrieval/repoMapRequest.ts @@ -16,7 +16,7 @@ function isSupportedModel( config: ContinueConfig, modelTitle?: string, ): boolean { - if (config.experimental?.modelRoles?.applyCodeBlock) { + if (config.experimental?.modelRoles?.repoMapFileSelection) { return true; } diff --git a/core/index.d.ts b/core/index.d.ts index 7d882cb27..6c2b3ed23 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -43,13 +43,13 @@ export interface IndexingProgressUpdate { desc: string; shouldClearIndexes?: boolean; status: - | "loading" - | "indexing" - | "done" - | "failed" - | "paused" - | "disabled" - | "cancelled"; + | "loading" + | "indexing" + | "done" + | "failed" + | "paused" + | "disabled" + | "cancelled"; debugInfo?: string; } @@ -667,10 +667,10 @@ export interface IDE { getCurrentFile(): Promise< | undefined | { - isUntitled: boolean; - path: string; - contents: string; - } + isUntitled: boolean; + path: string; + contents: string; + } >; getLastFileSaveTimestamp?(): number; @@ -853,11 +853,11 @@ export interface CustomCommand { export interface Prediction { type: "content"; content: - | string - | { - type: "text"; - text: string; - }[]; + | string + | { + type: "text"; + text: string; + }[]; } export interface ToolExtras { @@ -1028,9 +1028,9 @@ export interface ContextMenuConfig { } export interface ExperimentalModelRoles { - inlineEdit?: string; - applyCodeBlock?: string; repoMapFileSelection?: string; + inlineEdit?: string; // DEPRECATED - this is removed from config.json if detected + applyCodeBlock?: string; // DEPRECATED - this removed from config.json if detected } export type EditStatus = @@ -1186,9 +1186,9 @@ export interface Config { embeddingsProvider?: EmbeddingsProviderDescription | ILLM; /** The model that Continue will use for tab autocompletions. */ tabAutocompleteModel?: - | CustomLLM - | ModelDescription - | (CustomLLM | ModelDescription)[]; + | CustomLLM + | ModelDescription + | (CustomLLM | ModelDescription)[]; /** Options for tab autocomplete */ tabAutocompleteOptions?: Partial; /** UI styles customization */ @@ -1222,6 +1222,8 @@ export interface ContinueConfig { analytics?: AnalyticsConfig; docs?: SiteIndexingConfig[]; tools: Tool[]; + modelsByRole: Record; + selectedModelByRole: Record; } export interface BrowserSerializedContinueConfig { @@ -1244,6 +1246,8 @@ export interface BrowserSerializedContinueConfig { tools: Tool[]; usePlatform: boolean; tabAutocompleteOptions?: Partial; + modelsByRole: Record; + selectedModelByRole: Record; } // DOCS SUGGESTIONS AND PACKAGE INFO @@ -1279,9 +1283,9 @@ export type PackageDetailsSuccess = PackageDetails & { export type PackageDocsResult = { packageInfo: ParsedPackageInfo; } & ( - | { error: string; details?: never } - | { details: PackageDetailsSuccess; error?: never } - ); + | { error: string; details?: never } + | { details: PackageDetailsSuccess; error?: never } +); export interface TerminalOptions { reuseTerminal?: boolean; diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 4d09d4ac6..9e28b79e1 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -354,8 +354,6 @@ Several experimental config parameters are available, as described below: - `defaultContext`: Defines the default context for the LLM. Uses the same format as `contextProviders` but includes an additional `query` property to specify custom query parameters.= - `modelRoles`: - - `inlineEdit`: Model title for inline edits. - - `applyCodeBlock`: Model title for applying code blocks. - `repoMapFileSelection`: Model title for repo map selections. - `quickActions`: Array of custom quick actions - `title` (**required**): Display title for the quick action. @@ -374,7 +372,7 @@ Example { "experimental": { "modelRoles": { - "inlineEdit": "Edit Model" + "repoMapFileSelection": "My Favorite Repo Map Selection Model" }, "quickActions": [ { diff --git a/docs/docs/yaml-migration.md b/docs/docs/yaml-migration.md index 04f1b4e15..38583f868 100644 --- a/docs/docs/yaml-migration.md +++ b/docs/docs/yaml-migration.md @@ -145,7 +145,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 diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md index 98addf212..56acacca6 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md @@ -399,8 +399,6 @@ Several experimental config parameters are available, as described below: - `defaultContext`: Defines the default context for the LLM. Uses the same format as `contextProviders` but includes an additional `query` property to specify custom query parameters.= - `modelRoles`: - - `inlineEdit`: Model title for inline edits. - - `applyCodeBlock`: Model title for applying code blocks. - `repoMapFileSelection`: Model title for repo map selections. - `readResponseTTS`: If `true`, reads LLM responses aloud with TTS. Default is `true`. - `promptPath`: Change the path to custom prompt files from the default ".prompts" diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 259d3e7c8..cb0ce8c20 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -3211,14 +3211,6 @@ "modelRoles": { "type": "object", "properties": { - "inlineEdit": { - "description": "The 'title' property of the model you wish to use for inline edits", - "type": "string" - }, - "applyCodeBlock": { - "description": "The 'title' property of the model you wish to use for applying code blocks", - "type": "string" - }, "repoMapFileSelection": { "description": "The 'title' property of the model you wish to use for repo map file selections", "type": "string" diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 5372a9c97..57f283f76 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.266", + "version": "0.9.268", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.266", + "version": "0.9.268", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/pages/config/UserSettings.tsx b/gui/src/pages/config/UserSettings.tsx deleted file mode 100644 index 6912cd031..000000000 --- a/gui/src/pages/config/UserSettings.tsx +++ /dev/null @@ -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) { - 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 ( -
-
-

User settings

-
- -
- - handleUpdate({ - codeWrap: !codeWrap, - }) - } - text="Wrap Codeblocks" - /> - - handleUpdate({ - displayRawMarkdown: !displayRawMarkdown, - }) - } - text="Display Raw Markdown" - /> - - handleUpdate({ - allowAnonymousTelemetry: !allowAnonymousTelemetry, - }) - } - text="Allow Anonymous Telemetry" - /> - - handleUpdate({ - disableIndexing: !disableIndexing, - }) - } - text="Disable Indexing" - /> - - - handleUpdate({ - disableSessionTitles: !disableSessionTitles, - }) - } - text="Disable Session Titles" - /> - - handleUpdate({ - readResponseTTS: !readResponseTTS, - }) - } - text="Response Text to Speech" - /> - - - handleUpdate({ - showChatScrollbar: !showChatScrollbar, - }) - } - text="Show Chat Scrollbar" - /> - - - handleUpdate({ - useAutocompleteCache: !useAutocompleteCache, - }) - } - text="Use Autocomplete Cache" - /> - - - handleUpdate({ - useChromiumForDocsCrawling: !useChromiumForDocsCrawling, - }) - } - text="Use Chromium for Docs Crawling" - /> - - - - - - - -
{ - e.preventDefault(); - handleSubmitPromptPath(); - }} - > -
- Workspace prompts path -
- { - setFormPromptPath(e.target.value); - }} - /> -
- {formPromptPath !== promptPath ? ( - <> -
- -
-
- -
- - ) : ( -
- -
- )} -
-
-
-
-
{ - e.preventDefault(); - handleDisableAutocompleteSubmit(); - }} - > -
- Disable autocomplete in files -
- { - setFormDisableAutocomplete(e.target.value); - }} - /> -
- {formDisableAutocomplete !== disableAutocompleteInFiles ? ( - <> -
- -
-
- -
- - ) : ( -
- -
- )} -
-
-
- - Comma-separated list of path matchers - -
-
-
- ); -} - -export default UserSettingsUI; diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index 6a00aa8cc..a482ad8cb 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -3,14 +3,28 @@ import { useNavigate } from "react-router-dom"; import PageHeader from "../../components/PageHeader"; import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useNavigationListener } from "../../hooks/useNavigationListener"; -import { useAppDispatch } from "../../redux/hooks"; +import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { SecondaryButton } from "../../components"; import { useAuth } from "../../context/Auth"; import { ScopeSelect } from "./ScopeSelect"; -import UserSettingsUI from "./UserSettings"; import { Listbox, Transition } from "@headlessui/react"; -import { ChevronUpDownIcon, PlusCircleIcon } from "@heroicons/react/24/outline"; +import { + CheckIcon, + XMarkIcon, + ChevronUpDownIcon, + PlusCircleIcon, +} from "@heroicons/react/24/outline"; import { selectProfileThunk } from "../../redux/thunks/profileAndOrg"; +import { + SharedConfigSchema, + modifyAnyConfigWithSharedConfig, +} 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 ConfigPage() { useNavigationListener(); @@ -51,6 +65,77 @@ 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); + + function handleUpdate(sharedConfig: SharedConfigSchema) { + // Optimistic update + dispatch( + updateConfig(modifyAnyConfigWithSharedConfig(config, sharedConfig)), + ); + // Actual update to core which propogates back with config update event + 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 (
navigate("/")} title="Chat" /> @@ -166,12 +251,247 @@ function ConfigPage() { : "Open Workspace"} )} +

Model Roles

+
{!controlServerBetaEnabled || hubEnabled ? (
- +
+
+

User settings

+
+ +
+ + handleUpdate({ + codeWrap: !codeWrap, + }) + } + text="Wrap Codeblocks" + /> + + handleUpdate({ + displayRawMarkdown: !displayRawMarkdown, + }) + } + text="Display Raw Markdown" + /> + + handleUpdate({ + allowAnonymousTelemetry: !allowAnonymousTelemetry, + }) + } + text="Allow Anonymous Telemetry" + /> + + handleUpdate({ + disableIndexing: !disableIndexing, + }) + } + text="Disable Indexing" + /> + + + handleUpdate({ + disableSessionTitles: !disableSessionTitles, + }) + } + text="Disable Session Titles" + /> + + handleUpdate({ + readResponseTTS: !readResponseTTS, + }) + } + text="Response Text to Speech" + /> + + + handleUpdate({ + showChatScrollbar: !showChatScrollbar, + }) + } + text="Show Chat Scrollbar" + /> + + + handleUpdate({ + useAutocompleteCache: !useAutocompleteCache, + }) + } + text="Use Autocomplete Cache" + /> + + + handleUpdate({ + useChromiumForDocsCrawling: !useChromiumForDocsCrawling, + }) + } + text="Use Chromium for Docs Crawling" + /> + + + + + + + +
{ + e.preventDefault(); + handleSubmitPromptPath(); + }} + > +
+ Workspace prompts path +
+ { + setFormPromptPath(e.target.value); + }} + /> +
+ {formPromptPath !== promptPath ? ( + <> +
+ +
+
+ +
+ + ) : ( +
+ +
+ )} +
+
+
+
+
{ + e.preventDefault(); + handleDisableAutocompleteSubmit(); + }} + > +
+ Disable autocomplete in files +
+ { + setFormDisableAutocomplete(e.target.value); + }} + /> +
+ {formDisableAutocomplete !== + disableAutocompleteInFiles ? ( + <> +
+ +
+
+ +
+ + ) : ( +
+ +
+ )} +
+
+
+ + Comma-separated list of path matchers + +
+
+
) : null} From 3258c303a524b0b29c74e0a7d5608ec7d685d9ea Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 18 Feb 2025 12:22:41 -0800 Subject: [PATCH 12/66] revert removals of experimental config --- core/config/load.ts | 2 +- core/config/migrateSharedConfig.ts | 40 ------------------- core/config/types.ts | 2 + core/index.d.ts | 4 +- docs/docs/reference.md | 4 +- .../current/reference.md | 2 + extensions/vscode/config_schema.json | 8 ++++ extensions/vscode/package-lock.json | 4 +- 8 files changed, 20 insertions(+), 46 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index 41507b200..6e8a11c9b 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -182,7 +182,7 @@ async function serializedToIntermediateConfig( initial: SerializedContinueConfig, ide: IDE, ): Promise { - // DEPRECATED - load cuastom slash commands + // DEPRECATED - load custom slash commands const slashCommands: SlashCommand[] = []; for (const command of initial.slashCommands || []) { const newCommand = slashCommandFromDescription(command); diff --git a/core/config/migrateSharedConfig.ts b/core/config/migrateSharedConfig.ts index 6586c604b..189bb21ed 100644 --- a/core/config/migrateSharedConfig.ts +++ b/core/config/migrateSharedConfig.ts @@ -124,46 +124,6 @@ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void { effected = true; } - const { modelRoles, ...withoutModelRoles } = migratedExperimental; - if (modelRoles !== undefined) { - let migratedModelRoles = { ...modelRoles }; - - const { applyCodeBlock, ...rest90 } = migratedModelRoles; - if (applyCodeBlock !== undefined) { - shareConfigUpdates.selectedModels = { - ...currentSharedConfig.selectedModels, - local: { - ...currentSharedConfig.selectedModels?.["local"], - apply: applyCodeBlock, - }, - }; - migratedModelRoles = rest90; - effected = true; - } - - const { inlineEdit, ...rest91 } = migratedModelRoles; - if (inlineEdit !== undefined) { - shareConfigUpdates.selectedModels = { - ...currentSharedConfig.selectedModels, - local: { - ...currentSharedConfig.selectedModels?.["local"], - edit: inlineEdit, - }, - }; - migratedModelRoles = rest91; - effected = true; - } - - if (Object.keys(migratedModelRoles).length > 0) { - migratedExperimental = { - ...migratedExperimental, - modelRoles: migratedModelRoles, - }; - } else { - migratedExperimental = withoutModelRoles; - } - } - if (Object.keys(migratedExperimental).length > 0) { config = { ...withoutExperimental, diff --git a/core/config/types.ts b/core/config/types.ts index 5b2f124c0..2a68c4c35 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -957,6 +957,8 @@ declare global { } interface ExperimentalModelRoles { + inlineEdit?: string; + applyCodeBlock?: string; repoMapFileSelection?: string; } diff --git a/core/index.d.ts b/core/index.d.ts index 6c2b3ed23..c174e158a 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1029,8 +1029,8 @@ export interface ContextMenuConfig { export interface ExperimentalModelRoles { repoMapFileSelection?: string; - inlineEdit?: string; // DEPRECATED - this is removed from config.json if detected - applyCodeBlock?: string; // DEPRECATED - this removed from config.json if detected + inlineEdit?: string; + applyCodeBlock?: string; } export type EditStatus = diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 9e28b79e1..4d09d4ac6 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -354,6 +354,8 @@ Several experimental config parameters are available, as described below: - `defaultContext`: Defines the default context for the LLM. Uses the same format as `contextProviders` but includes an additional `query` property to specify custom query parameters.= - `modelRoles`: + - `inlineEdit`: Model title for inline edits. + - `applyCodeBlock`: Model title for applying code blocks. - `repoMapFileSelection`: Model title for repo map selections. - `quickActions`: Array of custom quick actions - `title` (**required**): Display title for the quick action. @@ -372,7 +374,7 @@ Example { "experimental": { "modelRoles": { - "repoMapFileSelection": "My Favorite Repo Map Selection Model" + "inlineEdit": "Edit Model" }, "quickActions": [ { diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md index 56acacca6..98addf212 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md @@ -399,6 +399,8 @@ Several experimental config parameters are available, as described below: - `defaultContext`: Defines the default context for the LLM. Uses the same format as `contextProviders` but includes an additional `query` property to specify custom query parameters.= - `modelRoles`: + - `inlineEdit`: Model title for inline edits. + - `applyCodeBlock`: Model title for applying code blocks. - `repoMapFileSelection`: Model title for repo map selections. - `readResponseTTS`: If `true`, reads LLM responses aloud with TTS. Default is `true`. - `promptPath`: Change the path to custom prompt files from the default ".prompts" diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index cb0ce8c20..259d3e7c8 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -3211,6 +3211,14 @@ "modelRoles": { "type": "object", "properties": { + "inlineEdit": { + "description": "The 'title' property of the model you wish to use for inline edits", + "type": "string" + }, + "applyCodeBlock": { + "description": "The 'title' property of the model you wish to use for applying code blocks", + "type": "string" + }, "repoMapFileSelection": { "description": "The 'title' property of the model you wish to use for repo map file selections", "type": "string" diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 57f283f76..5372a9c97 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.268", + "version": "0.9.266", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.268", + "version": "0.9.266", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", From 6ccf535ef450fe41742b1e61311687064cbc7e47 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 18 Feb 2025 16:11:24 -0800 Subject: [PATCH 13/66] json config roles --- core/config/load.ts | 130 +++++++++++++----- core/index.d.ts | 4 +- .../llms/TransformersJsEmbeddingsProvider.ts | 1 + .../continue/IdeProtocolClient.kt | 21 +-- extensions/vscode/src/commands.ts | 2 +- .../vscode/src/extension/VsCodeMessenger.ts | 3 +- .../src/quickEdit/QuickEditQuickPick.ts | 2 +- 7 files changed, 107 insertions(+), 56 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index 6e8a11c9b..0793ff825 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -78,6 +78,7 @@ import { import { getSystemPromptDotFile } from "./getSystemPromptDotFile"; import { modifyAnyConfigWithSharedConfig } from "./sharedConfig"; import { validateConfig } from "./validation.js"; +import { getModelByRole } from "./util"; export function resolveSerializedConfig( filepath: string, @@ -330,7 +331,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) { @@ -440,23 +441,28 @@ async function intermediateToFinalConfig( } // Embeddings Provider - const embeddingsProviderDescription = config.embeddingsProvider as - | EmbeddingsProviderDescription - | undefined; - if (embeddingsProviderDescription?.provider) { - const { provider, ...options } = embeddingsProviderDescription; + function getEmbeddingsILLM( + configEmbedder: EmbeddingsProviderDescription | ILLM | undefined, + ): ILLM { + if (!configEmbedder) { + return new TransformersJsEmbeddingsProvider(); + } + if ("providerName" in configEmbedder) { + return configEmbedder; + } + const { provider, ...options } = configEmbedder; 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, { @@ -465,59 +471,76 @@ async function intermediateToFinalConfig( }), ); } + } else { + errors.push({ + fatal: false, + message: `Embeddings provider ${provider} not found. Using default`, + }); } + return new TransformersJsEmbeddingsProvider(); } - - 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 | undefined { + if (!rerankingConfig) { + return undefined; + } + 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 undefined; } 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 undefined; } + const newReranker = getRerankingILLM(config.reranker); - let continueConfig: ContinueConfig = { + const continueConfig: ContinueConfig = { ...config, contextProviders, models, - embeddingsProvider: config.embeddingsProvider as any, + embeddingsProvider: newEmbedder, tabAutocompleteModels, - reranker: config.reranker as any, + reranker: newReranker, tools: allTools, modelsByRole: { - chat: [], - edit: [], - apply: [], - embed: [], - autocomplete: [], - rerank: [], - summarize: [], + chat: models, + edit: models, + apply: models, + summarize: models, + embed: [newEmbedder], + autocomplete: [...tabAutocompleteModels], + rerank: newReranker ? [newReranker] : [], }, selectedModelByRole: { - chat: null, + chat: null, // Not implemented (uses GUI defaultModel) edit: null, apply: null, - embed: null, + embed: newEmbedder ?? null, autocomplete: null, - rerank: null, - summarize: null, + rerank: newReranker ?? null, + summarize: null, // Not implemented }, }; @@ -560,6 +583,42 @@ 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`, + }); + } + } + return { config: continueConfig, errors }; } @@ -593,7 +652,7 @@ async function finalToBrowserConfig( 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, @@ -611,8 +670,13 @@ async function finalToBrowserConfig( k, v.map(llmToSerializedModelDescription), ]), - ) as unknown as Record, // TODO better types here - selectedModelByRole: final.selectedModelByRole, + ) as Record, // TODO better types here + selectedModelByRole: Object.fromEntries( + Object.entries(final.selectedModelByRole).map(([k, v]) => [ + k, + v ? llmToSerializedModelDescription(v) : null, + ]), + ) as Record, // TODO better types here }; } diff --git a/core/index.d.ts b/core/index.d.ts index c174e158a..04aa580f0 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1223,7 +1223,7 @@ export interface ContinueConfig { docs?: SiteIndexingConfig[]; tools: Tool[]; modelsByRole: Record; - selectedModelByRole: Record; + selectedModelByRole: Record; } export interface BrowserSerializedContinueConfig { @@ -1247,7 +1247,7 @@ export interface BrowserSerializedContinueConfig { usePlatform: boolean; tabAutocompleteOptions?: Partial; modelsByRole: Record; - selectedModelByRole: Record; + selectedModelByRole: Record; } // DOCS SUGGESTIONS AND PACKAGE INFO diff --git a/core/llm/llms/TransformersJsEmbeddingsProvider.ts b/core/llm/llms/TransformersJsEmbeddingsProvider.ts index 206d534d3..6a2c78bd9 100644 --- a/core/llm/llms/TransformersJsEmbeddingsProvider.ts +++ b/core/llm/llms/TransformersJsEmbeddingsProvider.ts @@ -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"; static defaultOptions: Partial | undefined = { model: TransformersJsEmbeddingsProvider.model, diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index 9b8f558c2..a96d4eda1 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -447,7 +447,8 @@ class IdeProtocolClient( val result = responseContent["result"] as Map<*, *> val config = result["config"] as Map - val applyCodeBlockModel = getModelByRole(config, "applyCodeBlock") + val selectedModels = config["selectedModelByRole"] as Map + val applyCodeBlockModel = selectedModels["applyCodeBlock"] as Map if (applyCodeBlockModel != null) { continuation.resume(applyCodeBlockModel) @@ -587,20 +588,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 - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index d99bbd5ae..1bfc5e621 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -348,7 +348,7 @@ const getCommandsMap: ( ); const modelTitle = - getModelByRole(config, "inlineEdit")?.title ?? defaultModelTitle; + config.selectedModelByRole.edit?.title ?? defaultModelTitle; void sidebar.webviewProtocol.request("incrementFtc", undefined); diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index aac537d93..79380f60e 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -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( diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts index 09cf8e2cd..6cdb749c4 100644 --- a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -273,7 +273,7 @@ export class QuickEdit { } return ( - getModelByRole(config, "inlineEdit")?.title ?? + config.selectedModelByRole.edit?.title ?? (await this.webviewProtocol.request( "getDefaultModelTitle", undefined, From eb06857124f5dd88552407a69ea0b4cfaf37264b Mon Sep 17 00:00:00 2001 From: VisualPlugin Date: Wed, 19 Feb 2025 01:01:43 +0000 Subject: [PATCH 14/66] Update AutocompleteLanguageInfo.ts --- .../autocomplete/constants/AutocompleteLanguageInfo.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/autocomplete/constants/AutocompleteLanguageInfo.ts b/core/autocomplete/constants/AutocompleteLanguageInfo.ts index d51fe1f1f..82b169677 100644 --- a/core/autocomplete/constants/AutocompleteLanguageInfo.ts +++ b/core/autocomplete/constants/AutocompleteLanguageInfo.ts @@ -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 { From 166e2b728de21536f3065ee7c12feb6fab31d121 Mon Sep 17 00:00:00 2001 From: VisualPlugin Date: Wed, 19 Feb 2025 01:06:02 +0000 Subject: [PATCH 15/66] Update treeSitter.ts --- core/util/treeSitter.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/util/treeSitter.ts b/core/util/treeSitter.ts index 067445994..df1296e0c 100644 --- a/core/util/treeSitter.ts +++ b/core/util/treeSitter.ts @@ -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, From 103c685c7598ad538fbffa65d6da2a629bac26fe Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 18 Feb 2025 23:52:04 -0800 Subject: [PATCH 16/66] select tab autocomplete model --- core/config/profile/doLoadConfig.ts | 3 + core/config/sharedConfig.ts | 22 ++-- core/config/yaml/loadYaml.ts | 70 +++++------ core/context/retrieval/repoMapRequest.ts | 1 - core/core.ts | 27 ++-- core/protocol/core.ts | 13 +- core/protocol/passThrough.ts | 1 + core/util/GlobalContext.test.ts | 10 -- core/util/GlobalContext.ts | 18 ++- .../constants/MessageTypes.kt | 1 + extensions/vscode/package-lock.json | 4 +- .../src/autocomplete/completionProvider.ts | 14 ++- extensions/vscode/src/commands.ts | 24 ++-- .../vscode/src/extension/VsCodeExtension.ts | 9 +- .../src/quickEdit/QuickEditQuickPick.ts | 1 - .../vscode/src/util/loadAutocompleteModel.ts | 65 ---------- gui/src/components/Layout.tsx | 4 +- gui/src/components/gui/Switch.tsx | 4 +- .../platform/AssistantSelectOptions.tsx | 14 ++- gui/src/pages/config/ModelRoleSelector.tsx | 88 +++++++++++++ gui/src/pages/config/index.tsx | 119 +++++++++++++++--- gui/src/redux/slices/configSlice.ts | 18 +++ 22 files changed, 335 insertions(+), 195 deletions(-) delete mode 100644 extensions/vscode/src/util/loadAutocompleteModel.ts create mode 100644 gui/src/pages/config/ModelRoleSelector.tsx diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index af8c59c97..d88cc019f 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -86,6 +86,9 @@ export default async function doLoadConfig( configLoadInterrupted = result.configLoadInterrupted; } + // Rectify model selections for each role + // These start out + if (configLoadInterrupted || !newConfig) { return { errors, config: newConfig, configLoadInterrupted: true }; } diff --git a/core/config/sharedConfig.ts b/core/config/sharedConfig.ts index 9ac797841..8fc18e24b 100644 --- a/core/config/sharedConfig.ts +++ b/core/config/sharedConfig.ts @@ -1,21 +1,19 @@ +import { + ModelRole, + modelRolesSchema, +} from "@continuedev/config-yaml/dist/schemas/models"; import z from "zod"; + import { BrowserSerializedContinueConfig, ContinueConfig, Config, SerializedContinueConfig, } from ".."; -import { - ModelRole, - modelRolesSchema, -} from "@continuedev/config-yaml/dist/schemas/models"; export const sharedConfigSchema = z .object({ - selectedModels: z.record( - z.string(), - z.record(modelRolesSchema, z.string()), - ), + selectedModels: z.record(modelRolesSchema, z.string().nullable()), // boolean fields in config.json allowAnonymousTelemetry: z.boolean(), @@ -161,11 +159,7 @@ export function modifyAnyConfigWithSharedConfig< export function modifyFinalConfigWithSharedConfig< T extends ContinueConfig | BrowserSerializedContinueConfig, ->( - continueConfig: T, - sharedConfig: SharedConfigSchema, - selectedProfileId: string | null, -): T { +>(continueConfig: T, sharedConfig: SharedConfigSchema): T { const configCopy = { ...continueConfig }; const selectedModelsForProfile: Record = { apply: null, @@ -176,6 +170,6 @@ export function modifyFinalConfigWithSharedConfig< rerank: null, summarize: null, }; - configCopy.selectedModelByRole = selectedModelsForProfile; + // configCopy.selectedModelByRole = selectedModelsForProfile; return configCopy; } diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 1da57ba81..dbd7248c3 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -155,51 +155,49 @@ async function configYamlToContinueConfig( // Models const modelsArrayRoles: ModelRole[] = ["chat", "summarize", "apply", "edit"]; for (const model of config.models ?? []) { - model.roles = model.roles ?? modelsArrayRoles; // Default to all 4 roles 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")) { + continueConfig.modelsByRole.embed.push(...llms); } - 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")) { + continueConfig.modelsByRole.rerank.push(...llms); } } @@ -221,8 +219,6 @@ async function configYamlToContinueConfig( ); } - // TODO: Split into model roles. - // Context providers const codebaseContextParams: IContextProvider[] = (config.context || []).find((cp) => cp.provider === "codebase")?.params || diff --git a/core/context/retrieval/repoMapRequest.ts b/core/context/retrieval/repoMapRequest.ts index 7115b2d18..5637019ad 100644 --- a/core/context/retrieval/repoMapRequest.ts +++ b/core/context/retrieval/repoMapRequest.ts @@ -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", diff --git a/core/core.ts b/core/core.ts index 6bbc34006..983fc8066 100644 --- a/core/core.ts +++ b/core/core.ts @@ -187,12 +187,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, @@ -226,11 +224,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); @@ -305,8 +298,18 @@ 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 newSharedConfig = this.globalContext.updateSelectedModel( + msg.data.role, + msg.data.title, + ); + await this.configHandler.reloadConfig(); + return newSharedConfig; }); on("controlPlane/openUrl", async (msg) => { diff --git a/core/protocol/core.ts b/core/protocol/core.ts index c3084f6b8..188c7869a 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -1,4 +1,4 @@ -import { ConfigResult } from "@continuedev/config-yaml"; +import { ConfigResult, ModelRole } from "@continuedev/config-yaml"; import { AutocompleteInput } from "../autocomplete/util/types"; import { ProfileDescription } from "../config/ConfigHandler"; @@ -36,8 +36,6 @@ export interface ListHistoryOptions { } export type ToCoreFromIdeOrWebviewProtocol = { - "update/selectTabAutocompleteModel": [string, void]; - // Special ping: [string, string]; abort: [undefined, void]; @@ -70,7 +68,14 @@ export type ToCoreFromIdeOrWebviewProtocol = { "config/reload": [undefined, ConfigResult]; "config/listProfiles": [undefined, ProfileDescription[]]; "config/openProfile": [{ profileId: string | undefined }, void]; - "config/updateSharedConfig": [SharedConfigSchema, void]; + "config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema]; + "config/updateSelectedModel": [ + { + role: ModelRole; + title: string | null; + }, + SharedConfigSchema, + ]; "context/getContextItems": [ { name: string; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index f0c66f465..d3a7259f2 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -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", diff --git a/core/util/GlobalContext.test.ts b/core/util/GlobalContext.test.ts index 0d6b9d799..b13f3b87b 100644 --- a/core/util/GlobalContext.test.ts +++ b/core/util/GlobalContext.test.ts @@ -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, ); diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 34c3d8ddf..2eee95028 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -8,10 +8,10 @@ import { import { getGlobalContextFilePath } from "./paths"; import { SiteIndexingConfig } from ".."; +import { ModelRole } from "@continuedev/config-yaml"; export type GlobalContextType = { indexingPaused: boolean; - selectedTabAutocompleteModel: string; lastSelectedProfileForWorkspace: { [workspaceIdentifier: string]: string | null; }; @@ -113,4 +113,20 @@ export class GlobalContext { this.update("sharedConfig", updatedSharedConfig); return updatedSharedConfig; } + + updateSelectedModel( + role: ModelRole, + title: string | null, + ): SharedConfigSchema { + const currentSharedConfig = this.getSharedConfig(); + const updatedSharedConfig = { + ...currentSharedConfig, + selectedModels: { + ...currentSharedConfig.selectedModels, + [role]: title, + }, + }; + this.update("sharedConfig", updatedSharedConfig); + return updatedSharedConfig; + } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index c6e5684e3..bfbe614cc 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -91,6 +91,7 @@ class MessageTypes { "config/listProfiles", "config/openProfile", "config/updateSharedConfig", + "config/updateSelectedModel", "context/getContextItems", "context/getSymbolsForFiles", "context/loadSubmenuItems", diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 5372a9c97..57f283f76 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.266", + "version": "0.9.268", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.266", + "version": "0.9.268", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts index fb174b53c..497de3875 100644 --- a/extensions/vscode/src/autocomplete/completionProvider.ts +++ b/extensions/vscode/src/autocomplete/completionProvider.ts @@ -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, ); diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 1bfc5e621..a6482998c 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -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"; @@ -872,16 +871,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 = @@ -956,11 +951,10 @@ const getCommandsMap: ( } else if ( autocompleteModels.some((model) => model.title === selectedOption) ) { - new GlobalContext().update( - "selectedTabAutocompleteModel", - selectedOption, - ); - configHandler.reloadConfig(); + core.invoke("config/updateSelectedModel", { + role: "autocomplete", + title: selectedOption, + }); } else if (selectedOption === "$(feedback) Give feedback") { vscode.commands.executeCommand("continue.giveAutocompleteFeedback"); } else if (selectedOption === "$(comment) Open chat (Cmd+L)") { diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index f8b8ca130..33deb7324 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -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(); onDidChange = this.onDidChangeEmitter.event; diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts index 6cdb749c4..84e0503d3 100644 --- a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -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 { logDevData } from "core/util/devdata"; import { Telemetry } from "core/util/posthog"; import * as vscode from "vscode"; diff --git a/extensions/vscode/src/util/loadAutocompleteModel.ts b/extensions/vscode/src/util/loadAutocompleteModel.ts deleted file mode 100644 index fda69f023..000000000 --- a/extensions/vscode/src/util/loadAutocompleteModel.ts +++ /dev/null @@ -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; - } -} diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index b54db7549..f5d8cf178 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -278,9 +278,7 @@ const Layout = () => { onClick={() => navigate(ROUTES.CONFIG_ERROR)} > Error!{" "} - - Could not load config.json - + Could not load config
Learn More
)} diff --git a/gui/src/components/gui/Switch.tsx b/gui/src/components/gui/Switch.tsx index 7d6105e6d..8957038ac 100644 --- a/gui/src/components/gui/Switch.tsx +++ b/gui/src/components/gui/Switch.tsx @@ -13,10 +13,10 @@ const ToggleSwitch: React.FC = ({ }) => { return (
- {text} + {text}
diff --git a/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx b/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx index 755e0570b..4a8ea59ca 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx @@ -1,4 +1,8 @@ -import { BuildingOfficeIcon, PlusIcon } from "@heroicons/react/24/outline"; +import { + BuildingOfficeIcon, + PlusIcon, + UserCircleIcon, +} from "@heroicons/react/24/outline"; import { useContext } from "react"; import { useNavigate } from "react-router-dom"; import { lightGray } from "../.."; @@ -21,7 +25,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(); @@ -83,7 +88,10 @@ export function AssistantSelectOptions({
- + login(true)} + >
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 ( + <> +
+ {displayName} + + + {description} + +
+ + {({ open }) => ( +
+ + + {selectedModel?.title ?? "No"} + +
+
+
+ + + + {models.map((option, idx) => ( + + + {option.title} + + + ))} + + +
+ )} +
+ + ); +}; + +export default ModelRoleSelector; diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index a482ad8cb..942b2cabf 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -18,13 +18,17 @@ import { selectProfileThunk } from "../../redux/thunks/profileAndOrg"; import { SharedConfigSchema, modifyAnyConfigWithSharedConfig, + modifyFinalConfigWithSharedConfig, } 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 { setDefaultModel, updateConfig } from "../../redux/slices/configSlice"; import { getFontSize } from "../../util"; +import ModelRoleSelector from "./ModelRoleSelector"; +import { ModelDescription } from "core"; +import { ModelRole } from "@continuedev/config-yaml"; function ConfigPage() { useNavigationListener(); @@ -67,16 +71,48 @@ function ConfigPage() { /////// User settings section ////// const config = useAppSelector((state) => state.config.config); + const profileId = useAppSelector((state) => state.session.selectedProfileId); + const selectedChatModel = useAppSelector( + (store) => store.config.defaultModelTitle, + ); function handleUpdate(sharedConfig: SharedConfigSchema) { // Optimistic update - dispatch( - updateConfig(modifyAnyConfigWithSharedConfig(config, sharedConfig)), + const firstPass = modifyAnyConfigWithSharedConfig(config, sharedConfig); + const secondPass = modifyFinalConfigWithSharedConfig( + firstPass, + sharedConfig, ); + dispatch(updateConfig(secondPass)); // Actual update to core which propogates back with config update event ideMessenger.post("config/updateSharedConfig", sharedConfig); } + function handleRoleUpdate(role: ModelRole, model: ModelDescription | null) { + // Optimistic update + dispatch( + updateConfig({ + ...config, + selectedModelByRole: { + ...config.selectedModelByRole, + [role]: model?.title, + }, + }), + ); + ideMessenger.post("config/updateSelectedModel", { + 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; @@ -225,10 +261,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); + } }} > @@ -251,8 +291,59 @@ function ConfigPage() { : "Open Workspace"} )} -

Model Roles

- +
+

+ Active Models +

+
+ handleChatModelSelection(model)} + /> + handleRoleUpdate("autocomplete", model)} + /> + handleRoleUpdate("edit", model)} + /> + handleRoleUpdate("apply", model)} + /> + handleRoleUpdate("embed", model)} + /> + handleRoleUpdate("rerank", model)} + /> +
+
{!controlServerBetaEnabled || hubEnabled ? ( @@ -351,7 +442,7 @@ function ConfigPage() { />