From c1157dbf02f6750d385b28006c90202e6b159d5a Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 1 Apr 2025 19:41:34 -0700 Subject: [PATCH 01/43] fix: handle deleted blocks --- packages/config-yaml/package-lock.json | 5 +- .../{test => src/__tests__}/index.test.ts | 25 ++++++++-- .../assistant-with-non-existing-block.yaml | 6 +++ .../packages/test-org/assistant.yaml | 0 .../packages/test-org/claude35sonnet.yaml | 0 .../__tests__}/packages/test-org/docs.yaml | 0 .../__tests__}/packages/test-org/gemini.yaml | 0 .../__tests__}/packages/test-org/rules.yaml | 0 packages/config-yaml/src/load/clientRender.ts | 7 +-- packages/config-yaml/src/load/unroll.ts | 50 ++++++++++++------- packages/config-yaml/src/schemas/index.ts | 14 +++--- 11 files changed, 73 insertions(+), 34 deletions(-) rename packages/config-yaml/{test => src/__tests__}/index.test.ts (89%) create mode 100644 packages/config-yaml/src/__tests__/packages/test-org/assistant-with-non-existing-block.yaml rename packages/config-yaml/{test => src/__tests__}/packages/test-org/assistant.yaml (100%) rename packages/config-yaml/{test => src/__tests__}/packages/test-org/claude35sonnet.yaml (100%) rename packages/config-yaml/{test => src/__tests__}/packages/test-org/docs.yaml (100%) rename packages/config-yaml/{test => src/__tests__}/packages/test-org/gemini.yaml (100%) rename packages/config-yaml/{test => src/__tests__}/packages/test-org/rules.yaml (100%) diff --git a/packages/config-yaml/package-lock.json b/packages/config-yaml/package-lock.json index 39d55afb1..76fef2ab2 100644 --- a/packages/config-yaml/package-lock.json +++ b/packages/config-yaml/package-lock.json @@ -1,12 +1,12 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.52", + "version": "1.0.67", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@continuedev/config-yaml", - "version": "1.0.52", + "version": "1.0.67", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", @@ -1045,6 +1045,7 @@ "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.14.tgz", "integrity": "sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==", "dev": true, + "license": "MIT", "dependencies": { "expect": "^29.0.0", "pretty-format": "^29.0.0" diff --git a/packages/config-yaml/test/index.test.ts b/packages/config-yaml/src/__tests__/index.test.ts similarity index 89% rename from packages/config-yaml/test/index.test.ts rename to packages/config-yaml/src/__tests__/index.test.ts index 71b073f42..e8c07fbe5 100644 --- a/packages/config-yaml/test/index.test.ts +++ b/packages/config-yaml/src/__tests__/index.test.ts @@ -1,18 +1,19 @@ import * as fs from "fs"; -import { decodeSecretLocation, resolveSecretLocationInProxy } from "../dist"; import { + decodeSecretLocation, FQSN, FullSlug, PlatformClient, PlatformSecretStore, Registry, resolveFQSN, + resolveSecretLocationInProxy, SecretLocation, SecretResult, SecretStore, SecretType, unrollAssistant, -} from "../src"; +} from "../index.js"; // Test e2e flows from raw yaml -> unroll -> client render -> resolve secrets on proxy describe("E2E Scenarios", () => { @@ -98,6 +99,22 @@ describe("E2E Scenarios", () => { }, }; + it.only("should unroll assistant with a single block that doesn't exist", async () => { + const unrolledConfig = await unrollAssistant( + "test-org/assistant-with-non-existing-block", + registry, + { + renderSecrets: true, + platformClient, + orgScopeId: "test-org", + currentUserSlug: "test-user", + onPremProxyUrl: null, + }, + ); + + expect(unrolledConfig.rules?.[0]).toBeNull(); + }); + it("should correctly unroll assistant", async () => { const unrolledConfig = await unrollAssistant( "test-org/assistant", @@ -133,10 +150,10 @@ describe("E2E Scenarios", () => { ); expect(unrolledConfig.rules?.length).toBe(2); - expect(unrolledConfig.docs?.[0].startUrl).toBe( + expect(unrolledConfig.docs?.[0]?.startUrl).toBe( "https://docs.python.org/release/3.13.1", ); - expect(unrolledConfig.docs?.[0].rootUrl).toBe( + expect(unrolledConfig.docs?.[0]?.rootUrl).toBe( "https://docs.python.org/release/3.13.1", ); diff --git a/packages/config-yaml/src/__tests__/packages/test-org/assistant-with-non-existing-block.yaml b/packages/config-yaml/src/__tests__/packages/test-org/assistant-with-non-existing-block.yaml new file mode 100644 index 000000000..4f01b32b8 --- /dev/null +++ b/packages/config-yaml/src/__tests__/packages/test-org/assistant-with-non-existing-block.yaml @@ -0,0 +1,6 @@ +name: Assistant with non-existing block +version: 0.0.1 +schema: v1 + +rules: + - uses: test-org/non-existing-package diff --git a/packages/config-yaml/test/packages/test-org/assistant.yaml b/packages/config-yaml/src/__tests__/packages/test-org/assistant.yaml similarity index 100% rename from packages/config-yaml/test/packages/test-org/assistant.yaml rename to packages/config-yaml/src/__tests__/packages/test-org/assistant.yaml diff --git a/packages/config-yaml/test/packages/test-org/claude35sonnet.yaml b/packages/config-yaml/src/__tests__/packages/test-org/claude35sonnet.yaml similarity index 100% rename from packages/config-yaml/test/packages/test-org/claude35sonnet.yaml rename to packages/config-yaml/src/__tests__/packages/test-org/claude35sonnet.yaml diff --git a/packages/config-yaml/test/packages/test-org/docs.yaml b/packages/config-yaml/src/__tests__/packages/test-org/docs.yaml similarity index 100% rename from packages/config-yaml/test/packages/test-org/docs.yaml rename to packages/config-yaml/src/__tests__/packages/test-org/docs.yaml diff --git a/packages/config-yaml/test/packages/test-org/gemini.yaml b/packages/config-yaml/src/__tests__/packages/test-org/gemini.yaml similarity index 100% rename from packages/config-yaml/test/packages/test-org/gemini.yaml rename to packages/config-yaml/src/__tests__/packages/test-org/gemini.yaml diff --git a/packages/config-yaml/test/packages/test-org/rules.yaml b/packages/config-yaml/src/__tests__/packages/test-org/rules.yaml similarity index 100% rename from packages/config-yaml/test/packages/test-org/rules.yaml rename to packages/config-yaml/src/__tests__/packages/test-org/rules.yaml diff --git a/packages/config-yaml/src/load/clientRender.ts b/packages/config-yaml/src/load/clientRender.ts index 585fc24ee..ffc62f0fc 100644 --- a/packages/config-yaml/src/load/clientRender.ts +++ b/packages/config-yaml/src/load/clientRender.ts @@ -120,16 +120,17 @@ export function useProxyForUnrenderedSecrets( if (config.models) { for (let i = 0; i < config.models.length; i++) { const apiKeyLocation = getUnrenderedSecretLocation( - config.models[i].apiKey, + config.models[i]?.apiKey, ); if (apiKeyLocation) { config.models[i] = { ...config.models[i], + name: config.models[i]?.name ?? "", provider: "continue-proxy", model: getContinueProxyModelName( packageSlug, - config.models[i].provider, - config.models[i].model, + config.models[i]?.provider ?? "", + config.models[i]?.model ?? "", ), apiKeyLocation: encodeSecretLocation(apiKeyLocation), orgScopeId, diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index f376fbc84..b3e7ff1ee 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -292,16 +292,23 @@ export async function unrollBlocks( for (const unrolledBlock of assistant[section]) { // "uses/with" block if ("uses" in unrolledBlock) { - const blockConfigYaml = await resolveBlock( - decodeFullSlug(unrolledBlock.uses), - unrolledBlock.with, - registry, - ); - const block = blockConfigYaml[section]?.[0]; - if (block) { - sectionBlocks.push( - mergeOverrides(block, unrolledBlock.override ?? {}), + try { + const blockConfigYaml = await resolveBlock( + decodeFullSlug(unrolledBlock.uses), + unrolledBlock.with, + registry, ); + const block = blockConfigYaml[section]?.[0]; + if (block) { + sectionBlocks.push( + mergeOverrides(block, unrolledBlock.override ?? {}), + ); + } + } catch (err) { + console.error( + `Failed to unroll block ${unrolledBlock.uses}: ${(err as Error).message}`, + ); + sectionBlocks.push(null); } } else { // Normal block @@ -315,19 +322,26 @@ export async function unrollBlocks( // Rules are a bit different because they're just strings, so handle separately if (assistant.rules) { - const rules: string[] = []; + const rules: Array = []; for (const rule of assistant.rules) { if (typeof rule === "string") { rules.push(rule); } else { - const blockConfigYaml = await resolveBlock( - decodeFullSlug(rule.uses), - rule.with, - registry, - ); - const block = blockConfigYaml.rules?.[0]; - if (block) { - rules.push(block); + try { + const blockConfigYaml = await resolveBlock( + decodeFullSlug(rule.uses), + rule.with, + registry, + ); + const block = blockConfigYaml.rules?.[0]; + if (block) { + rules.push(block); + } + } catch (err) { + console.error( + `Failed to unroll block ${rule.uses}: ${(err as Error).message}`, + ); + rules.push(null); } } } diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 1ca03b0b6..96f25b73b 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -78,13 +78,13 @@ export const configYamlSchema = baseConfigYamlSchema.extend({ export type ConfigYaml = z.infer; export const assistantUnrolledSchema = baseConfigYamlSchema.extend({ - models: z.array(modelSchema).optional(), - context: z.array(contextSchema).optional(), - data: z.array(dataSchema).optional(), - mcpServers: z.array(mcpServerSchema).optional(), - rules: z.array(z.string()).optional(), - prompts: z.array(promptSchema).optional(), - docs: z.array(docSchema).optional(), + models: z.array(modelSchema.nullable()).optional(), + context: z.array(contextSchema.nullable()).optional(), + data: z.array(dataSchema.nullable()).optional(), + mcpServers: z.array(mcpServerSchema.nullable()).optional(), + rules: z.array(z.string().nullable()).optional(), + prompts: z.array(promptSchema.nullable()).optional(), + docs: z.array(docSchema.nullable()).optional(), }); export type AssistantUnrolled = z.infer; From db3b891c4ccd4a2c5d9fc3c576b10a51dddc05ae Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 1 Apr 2025 19:48:16 -0700 Subject: [PATCH 02/43] Update index.test.ts --- packages/config-yaml/src/__tests__/index.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config-yaml/src/__tests__/index.test.ts b/packages/config-yaml/src/__tests__/index.test.ts index e8c07fbe5..d52f8f516 100644 --- a/packages/config-yaml/src/__tests__/index.test.ts +++ b/packages/config-yaml/src/__tests__/index.test.ts @@ -99,7 +99,7 @@ describe("E2E Scenarios", () => { }, }; - it.only("should unroll assistant with a single block that doesn't exist", async () => { + it("should unroll assistant with a single block that doesn't exist", async () => { const unrolledConfig = await unrollAssistant( "test-org/assistant-with-non-existing-block", registry, From 4e1cdb48ea46cd185d34faa897985953825b096a Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 1 Apr 2025 19:49:00 -0700 Subject: [PATCH 03/43] bump and fix tests --- packages/config-yaml/package.json | 2 +- packages/config-yaml/src/__tests__/index.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index d7d96c4f0..bf763c1e6 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.67", + "version": "1.0.69", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/config-yaml/src/__tests__/index.test.ts b/packages/config-yaml/src/__tests__/index.test.ts index e8c07fbe5..1dd44915b 100644 --- a/packages/config-yaml/src/__tests__/index.test.ts +++ b/packages/config-yaml/src/__tests__/index.test.ts @@ -93,7 +93,7 @@ describe("E2E Scenarios", () => { getContent: async function (fullSlug: FullSlug): Promise { return fs .readFileSync( - `./test/packages/${fullSlug.ownerSlug}/${fullSlug.packageSlug}.yaml`, + `./src/__tests__/packages/${fullSlug.ownerSlug}/${fullSlug.packageSlug}.yaml`, ) .toString(); }, From c9eb7821831bc14ede7c312341b744b43356e592 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 1 Apr 2025 19:55:48 -0700 Subject: [PATCH 04/43] bump --- packages/config-yaml/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index d7d96c4f0..bf763c1e6 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.67", + "version": "1.0.69", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", From 7b15fbfb53e28999bcfd55ffcfe72d83db485df9 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 1 Apr 2025 19:56:08 -0700 Subject: [PATCH 05/43] bump core, gui --- core/package-lock.json | 8 ++++---- core/package.json | 2 +- gui/package-lock.json | 10 +++++----- gui/package.json | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index 50df2a6f3..28d0efcb2 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.69", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -2974,9 +2974,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.67", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", - "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", + "version": "1.0.69", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.69.tgz", + "integrity": "sha512-y1aUgzz+4ajlMyP0J0PnHMjBoHWIfMtexrdrD7UDPh0LPBw7xTRb8jyn49KDMsWlcAAP2cvcCkWQdnOR0vfumA==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/core/package.json b/core/package.json index 205e3b778..eb2b94f3d 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.69", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/package-lock.json b/gui/package-lock.json index 78eb2e61d..1aad9c3a7 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -7,7 +7,7 @@ "name": "gui", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.69", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -111,7 +111,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.69", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -554,9 +554,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.67", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", - "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", + "version": "1.0.69", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.69.tgz", + "integrity": "sha512-y1aUgzz+4ajlMyP0J0PnHMjBoHWIfMtexrdrD7UDPh0LPBw7xTRb8jyn49KDMsWlcAAP2cvcCkWQdnOR0vfumA==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/gui/package.json b/gui/package.json index 3210a55f5..d123113d3 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.69", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", From 4ae3ac94348a22128da10043697e57802ac647b4 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 1 Apr 2025 20:25:51 -0700 Subject: [PATCH 06/43] injectBlock --- core/package-lock.json | 8 ++-- core/package.json | 2 +- gui/package-lock.json | 10 ++-- gui/package.json | 2 +- packages/config-yaml/package.json | 2 +- .../config-yaml/src/__tests__/index.test.ts | 35 ++++++++++++++ packages/config-yaml/src/load/unroll.ts | 46 +++++++++++++++++-- 7 files changed, 90 insertions(+), 15 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index 50df2a6f3..b6958f453 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.70", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -2974,9 +2974,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.67", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", - "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", + "version": "1.0.70", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.70.tgz", + "integrity": "sha512-0hwc2a2NyUDDNDAx23SOFfY4sV8EafuCow4JNpRzCz8swH3ZfO+vdOzKMIEzAzcYXcpjldsOAZsYE4iypu1L+Q==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/core/package.json b/core/package.json index 205e3b778..17bb74c6c 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.70", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/package-lock.json b/gui/package-lock.json index 78eb2e61d..c85af6cde 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -7,7 +7,7 @@ "name": "gui", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.70", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -111,7 +111,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.70", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -554,9 +554,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.67", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", - "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", + "version": "1.0.70", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.70.tgz", + "integrity": "sha512-0hwc2a2NyUDDNDAx23SOFfY4sV8EafuCow4JNpRzCz8swH3ZfO+vdOzKMIEzAzcYXcpjldsOAZsYE4iypu1L+Q==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/gui/package.json b/gui/package.json index 3210a55f5..4ae21ab1c 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.70", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index bf763c1e6..de200b566 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.69", + "version": "1.0.70", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/config-yaml/src/__tests__/index.test.ts b/packages/config-yaml/src/__tests__/index.test.ts index 1dd44915b..ce998541f 100644 --- a/packages/config-yaml/src/__tests__/index.test.ts +++ b/packages/config-yaml/src/__tests__/index.test.ts @@ -193,5 +193,40 @@ describe("E2E Scenarios", () => { expect(geminiSecretValue2).toBe("gemini-api-key"); }); + it("should correctly unroll assistant with injected blocks", async () => { + const unrolledConfig = await unrollAssistant( + "test-org/assistant", + registry, + { + renderSecrets: true, + platformClient, + orgScopeId: "test-org", + currentUserSlug: "test-user", + onPremProxyUrl: null, + // Add an injected block + injectBlocks: [ + { + ownerSlug: "test-org", + packageSlug: "docs", + versionSlug: "latest", + }, + ], + }, + ); + + // The original docs array should have one item + expect(unrolledConfig.docs?.length).toBe(2); // Now 2 with the injected block + + // Check the original doc is still there + expect(unrolledConfig.docs?.[0]?.startUrl).toBe( + "https://docs.python.org/release/3.13.1", + ); + + // Check the injected doc block was added + expect(unrolledConfig.docs?.[1]?.startUrl).toBe( + "https://docs.python.org/release/3.13.1", + ); + }); + it.skip("should prioritize org over user / package secrets", () => {}); }); diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index b3e7ff1ee..6390552d7 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -19,6 +19,7 @@ import { configYamlSchema, } from "../schemas/index.js"; import { useProxyForUnrenderedSecrets } from "./clientRender.js"; +import { getBlockType } from "./getBlockType.js"; export function parseConfigYaml(configYaml: string): ConfigYaml { try { @@ -176,11 +177,18 @@ async function extractRenderedSecretsMap( return map; } -export interface DoNotRenderSecretsUnrollAssistantOptions { +export interface BaseUnrollAssistantOptions { + renderSecrets: boolean; + injectBlocks?: FullSlug[]; +} + +export interface DoNotRenderSecretsUnrollAssistantOptions + extends BaseUnrollAssistantOptions { renderSecrets: false; } -export interface RenderSecretsUnrollAssistantOptions { +export interface RenderSecretsUnrollAssistantOptions + extends BaseUnrollAssistantOptions { renderSecrets: true; orgScopeId: string | null; currentUserSlug: string; @@ -236,7 +244,11 @@ export async function unrollAssistantFromContent( let parsedYaml = parseConfigYaml(rawYaml); // Unroll blocks and convert their secrets to FQSNs - const unrolledAssistant = await unrollBlocks(parsedYaml, registry); + const unrolledAssistant = await unrollBlocks( + parsedYaml, + registry, + options.injectBlocks, + ); // Back to a string so we can fill in template variables const rawUnrolledYaml = YAML.stringify(unrolledAssistant); @@ -273,6 +285,7 @@ export async function unrollAssistantFromContent( export async function unrollBlocks( assistant: ConfigYaml, registry: Registry, + injectBlocks: FullSlug[] | undefined, ): Promise { const unrolledAssistant: AssistantUnrolled = { name: assistant.name, @@ -349,6 +362,33 @@ export async function unrollBlocks( unrolledAssistant.rules = rules; } + // Add injected blocks + for (const injectBlock of injectBlocks ?? []) { + try { + const blockConfigYaml = await registry.getContent(injectBlock); + const parsedBlock = parseConfigYaml(blockConfigYaml); + const blockType = getBlockType(parsedBlock); + const resolvedBlock = await resolveBlock( + injectBlock, + undefined, + registry, + ); + + if (blockType) { + if (!unrolledAssistant[blockType]) { + unrolledAssistant[blockType] = []; + } + unrolledAssistant[blockType]?.push( + ...(resolvedBlock[blockType] as any), + ); + } + } catch (err) { + console.error( + `Failed to unroll block ${injectBlock}: ${(err as Error).message}`, + ); + } + } + return unrolledAssistant; } From 203704aa99524618102ea3de08291ee68903754e Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 2 Apr 2025 13:17:36 -0700 Subject: [PATCH 07/43] downgrade config-yaml --- core/package.json | 2 +- gui/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/package.json b/core/package.json index eb2b94f3d..205e3b778 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.69", + "@continuedev/config-yaml": "^1.0.67", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/package.json b/gui/package.json index d123113d3..3210a55f5 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "^1.0.69", + "@continuedev/config-yaml": "^1.0.67", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", From f5b6ffdb261bd43493493c3fe58a6cfe49fd1966 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 2 Apr 2025 13:20:24 -0700 Subject: [PATCH 08/43] update package-lock.json files --- core/package-lock.json | 2 +- gui/package-lock.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index 28d0efcb2..0514354d4 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.69", + "@continuedev/config-yaml": "^1.0.67", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/package-lock.json b/gui/package-lock.json index 1aad9c3a7..e2ca7e1b4 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -7,7 +7,7 @@ "name": "gui", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "^1.0.69", + "@continuedev/config-yaml": "^1.0.67", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -111,7 +111,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.69", + "@continuedev/config-yaml": "^1.0.67", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", From 49cf3d9f20884ab785290bc295d263f808995fb2 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 2 Apr 2025 13:35:33 -0700 Subject: [PATCH 09/43] explicit pin to 1.0.67 config-yaml --- core/package.json | 2 +- gui/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/package.json b/core/package.json index 205e3b778..43604af98 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "1.0.67", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/package.json b/gui/package.json index 3210a55f5..1a14125b7 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "1.0.67", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", From caf6cb02e4c09f0f861e48e940f3fbc25f266cbd Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 2 Apr 2025 13:43:56 -0700 Subject: [PATCH 10/43] bump package-lock files --- core/package-lock.json | 9 +++++---- gui/package-lock.json | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index 0514354d4..259750d62 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "1.0.67", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -2974,9 +2974,10 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.69", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.69.tgz", - "integrity": "sha512-y1aUgzz+4ajlMyP0J0PnHMjBoHWIfMtexrdrD7UDPh0LPBw7xTRb8jyn49KDMsWlcAAP2cvcCkWQdnOR0vfumA==", + "version": "1.0.67", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", + "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", + "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/gui/package-lock.json b/gui/package-lock.json index e2ca7e1b4..a1a71af32 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -7,7 +7,7 @@ "name": "gui", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "1.0.67", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -111,7 +111,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "1.0.67", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -554,9 +554,10 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.69", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.69.tgz", - "integrity": "sha512-y1aUgzz+4ajlMyP0J0PnHMjBoHWIfMtexrdrD7UDPh0LPBw7xTRb8jyn49KDMsWlcAAP2cvcCkWQdnOR0vfumA==", + "version": "1.0.67", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", + "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", + "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", From cfb7079494fea936ec6e39cb80b77fdc4b347555 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 4 Apr 2025 12:42:13 -0700 Subject: [PATCH 11/43] resolve type errors --- core/config/yaml/loadYaml.ts | 62 ++++++++++++++++------- core/package-lock.json | 9 ++-- core/package.json | 2 +- packages/config-yaml/package.json | 2 +- packages/config-yaml/src/schemas/index.ts | 25 +++++++++ 5 files changed, 74 insertions(+), 26 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index f2fefbb39..022ca8b53 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -5,6 +5,7 @@ import { ConfigResult, ConfigValidationError, FQSN, + isAssistantUnrolledNonNullable, ModelRole, PlatformClient, RegistryClient, @@ -92,7 +93,15 @@ async function loadConfigYaml( renderSecrets: true, }, )); - const errors = validateConfigYaml(config); + + const errors = isAssistantUnrolledNonNullable(config) + ? validateConfigYaml(config) + : [ + { + fatal: true, + message: "Assistant includes blocks that don't exist", + }, + ]; if (errors?.some((error) => error.fatal)) { return { @@ -122,29 +131,13 @@ async function configYamlToContinueConfig( allowFreeTrial: boolean = true, ): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> { const localErrors: ConfigValidationError[] = []; + const continueConfig: ContinueConfig = { slashCommands: [], models: [], tools: [...allTools], mcpServerStatuses: [], systemMessage: config.rules?.join("\n"), - experimental: { - modelContextProtocolServers: config.mcpServers?.map((mcpServer) => ({ - transport: { - type: "stdio", - command: mcpServer.command, - args: mcpServer.args ?? [], - env: mcpServer.env, - }, - })), - }, - docs: config.docs?.map((doc) => ({ - title: doc.name, - startUrl: doc.startUrl, - rootUrl: doc.rootUrl, - faviconUrl: doc.faviconUrl, - })), - rules: config.rules, contextProviders: [], modelsByRole: { chat: [], @@ -164,7 +157,38 @@ async function configYamlToContinueConfig( rerank: null, summarize: null, }, - data: config.data, + }; + + // Right now, if there are any missing packages in the config, then we will just throw an error + if (!isAssistantUnrolledNonNullable(config)) { + return { + config: continueConfig, + errors: [ + { + message: "Found missing blocks in config.yaml", + fatal: true, + }, + ], + }; + } + + continueConfig.data = config.data; + continueConfig.rules = config.rules; + continueConfig.docs = config.docs?.map((doc) => ({ + title: doc.name, + startUrl: doc.startUrl, + rootUrl: doc.rootUrl, + faviconUrl: doc.faviconUrl, + })); + continueConfig.experimental = { + modelContextProtocolServers: config.mcpServers?.map((mcpServer) => ({ + transport: { + type: "stdio", + command: mcpServer.command, + args: mcpServer.args ?? [], + env: mcpServer.env, + }, + })), }; // Prompt files - diff --git a/core/package-lock.json b/core/package-lock.json index 259750d62..043f6b2bd 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "1.0.67", + "@continuedev/config-yaml": "^1.0.75", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -2974,10 +2974,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.67", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", - "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", - "license": "Apache-2.0", + "version": "1.0.75", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.75.tgz", + "integrity": "sha512-N2YlSBiuWRlTn+6ERuueUoEAzMM3J1npQAYzJ32p5OAaggEYMUDNqAfqixvfr8MT/9M/JSYZ7buv1RSiM0qSig==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/core/package.json b/core/package.json index 43604af98..d8995be86 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "1.0.67", + "@continuedev/config-yaml": "^1.0.75", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index bf763c1e6..7069105af 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.69", + "version": "1.0.75", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 96f25b73b..ba6aa5e79 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -89,6 +89,31 @@ export const assistantUnrolledSchema = baseConfigYamlSchema.extend({ export type AssistantUnrolled = z.infer; +export const assistantUnrolledSchemaNonNullable = baseConfigYamlSchema.extend({ + models: z.array(modelSchema).optional(), + context: z.array(contextSchema).optional(), + data: z.array(dataSchema).optional(), + mcpServers: z.array(mcpServerSchema).optional(), + rules: z.array(z.string()).optional(), + prompts: z.array(promptSchema).optional(), + docs: z.array(docSchema).optional(), +}); + +export type AssistantUnrolledNonNullable = z.infer< + typeof assistantUnrolledSchemaNonNullable +>; + +export const isAssistantUnrolledNonNullable = ( + a: AssistantUnrolled, +): a is AssistantUnrolledNonNullable => + (!a.models || a.models.every((m) => m !== null)) && + (!a.context || a.context.every((c) => c !== null)) && + (!a.data || a.data.every((d) => d !== null)) && + (!a.mcpServers || a.mcpServers.every((s) => s !== null)) && + (!a.rules || a.rules.every((r) => r !== null)) && + (!a.prompts || a.prompts.every((p) => p !== null)) && + (!a.docs || a.docs.every((d) => d !== null)); + export const blockSchema = baseConfigYamlSchema.and( z.union([ z.object({ models: z.array(modelSchema).length(1) }), From 8a86def4235b26fb9accf1f2b1111931ff3dc1cd Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 4 Apr 2025 12:49:58 -0700 Subject: [PATCH 12/43] fix schema --- packages/config-yaml/src/schemas/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index fdfdcc170..e941ec025 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -92,7 +92,7 @@ export const assistantUnrolledSchema = baseConfigYamlSchema.extend({ context: z.array(contextSchema.nullable()).optional(), data: z.array(dataSchema.nullable()).optional(), mcpServers: z.array(mcpServerSchema.nullable()).optional(), - rules: z.array(z.string().nullable()).optional(), + rules: z.array(ruleSchema.nullable()).optional(), prompts: z.array(promptSchema.nullable()).optional(), docs: z.array(docSchema.nullable()).optional(), }); From 9f32eefb3957f49ce11572596b9144985623062e Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 4 Apr 2025 12:50:43 -0700 Subject: [PATCH 13/43] bump --- core/package-lock.json | 8 ++++---- core/package.json | 2 +- gui/package-lock.json | 5 ++--- gui/package.json | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index 7ee0b3de0..1f8d46f32 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.777.0", "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.75", + "@continuedev/config-yaml": "^1.0.76", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -2977,9 +2977,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.75", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.75.tgz", - "integrity": "sha512-N2YlSBiuWRlTn+6ERuueUoEAzMM3J1npQAYzJ32p5OAaggEYMUDNqAfqixvfr8MT/9M/JSYZ7buv1RSiM0qSig==", + "version": "1.0.76", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.76.tgz", + "integrity": "sha512-E/E78QRwV4jdJh7jjd7m0AMxs5xhKbBVhpm69D4JEQlWxpNXXChepdXqW8R4MUXpZi/ycuMlGKloA/ep/DfDPA==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/core/package.json b/core/package.json index 6ca032c69..fd5688f7a 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.777.0", "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.75", + "@continuedev/config-yaml": "^1.0.76", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/package-lock.json b/gui/package-lock.json index 2d9b4a2fa..4e626c58f 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -7,7 +7,7 @@ "name": "gui", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "1.0.67", + "@continuedev/config-yaml": "^1.0.67", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -111,7 +111,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.777.0", "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "1.0.67", + "@continuedev/config-yaml": "^1.0.76", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -558,7 +558,6 @@ "version": "1.0.67", "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", - "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/gui/package.json b/gui/package.json index 1a14125b7..3210a55f5 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "1.0.67", + "@continuedev/config-yaml": "^1.0.67", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", From 296d28c8c6f84b3122d02962709efa60df2fbc42 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 4 Apr 2025 12:51:41 -0700 Subject: [PATCH 14/43] bump gui --- gui/package-lock.json | 8 ++++---- gui/package.json | 2 +- .../components/mainInput/Lump/sections/RulesSection.tsx | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gui/package-lock.json b/gui/package-lock.json index 4e626c58f..b3854c564 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -7,7 +7,7 @@ "name": "gui", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.76", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -555,9 +555,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.67", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", - "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", + "version": "1.0.76", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.76.tgz", + "integrity": "sha512-E/E78QRwV4jdJh7jjd7m0AMxs5xhKbBVhpm69D4JEQlWxpNXXChepdXqW8R4MUXpZi/ycuMlGKloA/ep/DfDPA==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/gui/package.json b/gui/package.json index 3210a55f5..6c91ec591 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.76", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", diff --git a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx index 6bb3d1637..9fed37be7 100644 --- a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx @@ -1,4 +1,4 @@ -import { parseConfigYaml, Rule } from "@continuedev/config-yaml"; +import { parseConfigYaml, type Rule } from "@continuedev/config-yaml"; import { ArrowsPointingOutIcon, PencilIcon } from "@heroicons/react/24/outline"; import { useContext, useMemo } from "react"; import { useSelector } from "react-redux"; From ad826f85121c0a0ed1fde86192c5dc86956414b7 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 4 Apr 2025 12:54:57 -0700 Subject: [PATCH 15/43] bump core, gui --- core/package-lock.json | 8 ++++---- core/package.json | 2 +- gui/package-lock.json | 10 +++++----- gui/package.json | 2 +- packages/config-yaml/package.json | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index 1f8d46f32..daf8696a4 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.777.0", "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.76", + "@continuedev/config-yaml": "^1.0.77", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -2977,9 +2977,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.76", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.76.tgz", - "integrity": "sha512-E/E78QRwV4jdJh7jjd7m0AMxs5xhKbBVhpm69D4JEQlWxpNXXChepdXqW8R4MUXpZi/ycuMlGKloA/ep/DfDPA==", + "version": "1.0.77", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.77.tgz", + "integrity": "sha512-Vke6jp4bENjJc9fO1tavOnbYXRmmSIEzNhYeQ6DzZVl92+8rWwdO6zhbrK0r4FGjHnH0cJgyK/q0zX9/l+6asw==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/core/package.json b/core/package.json index fd5688f7a..a007fe637 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.777.0", "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.76", + "@continuedev/config-yaml": "^1.0.77", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/package-lock.json b/gui/package-lock.json index b3854c564..1c125df1f 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -7,7 +7,7 @@ "name": "gui", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "^1.0.76", + "@continuedev/config-yaml": "^1.0.77", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -111,7 +111,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.777.0", "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.76", + "@continuedev/config-yaml": "^1.0.77", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -555,9 +555,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.76", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.76.tgz", - "integrity": "sha512-E/E78QRwV4jdJh7jjd7m0AMxs5xhKbBVhpm69D4JEQlWxpNXXChepdXqW8R4MUXpZi/ycuMlGKloA/ep/DfDPA==", + "version": "1.0.77", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.77.tgz", + "integrity": "sha512-Vke6jp4bENjJc9fO1tavOnbYXRmmSIEzNhYeQ6DzZVl92+8rWwdO6zhbrK0r4FGjHnH0cJgyK/q0zX9/l+6asw==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/gui/package.json b/gui/package.json index 6c91ec591..2e694947e 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "^1.0.76", + "@continuedev/config-yaml": "^1.0.77", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index 1165210fb..652fcf1f8 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.76", + "version": "1.0.77", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", From 189d0c87c614687abe03130bd6869c635e54a58e Mon Sep 17 00:00:00 2001 From: chezsmithy Date: Mon, 7 Apr 2025 22:49:40 -0700 Subject: [PATCH 16/43] feat/bedrock-secure-prompt-caching --- core/llm/llms/Bedrock.ts | 7 +++ core/llm/utils/__tests__/getSecureID.test.ts | 49 ++++++++++++++++++++ core/llm/utils/getSecureID.ts | 8 ++++ 3 files changed, 64 insertions(+) create mode 100644 core/llm/utils/__tests__/getSecureID.test.ts create mode 100644 core/llm/utils/getSecureID.ts diff --git a/core/llm/llms/Bedrock.ts b/core/llm/llms/Bedrock.ts index 7fefbd329..b9517bb59 100644 --- a/core/llm/llms/Bedrock.ts +++ b/core/llm/llms/Bedrock.ts @@ -14,6 +14,7 @@ import { CompletionOptions, LLMOptions, } from "../../index.js"; +import { getSecureID } from "../utils/getSecureID.js"; import { renderChatMessage } from "../../util/messageContent.js"; import { BaseLLM } from "../index.js"; import { PROVIDER_TOOL_SUPPORT } from "../toolSupport.js"; @@ -427,6 +428,9 @@ class Bedrock extends BaseLLM { // Standard text message if (typeof message.content === "string") { + if (addCaching) { + message.content += getSecureID(); + } const content: any[] = [{ text: message.content }]; if (addCaching) { content.push({ cachePoint: { type: "default" } }); @@ -444,6 +448,9 @@ class Bedrock extends BaseLLM { // Process all parts first message.content.forEach((part) => { if (part.type === "text") { + if (addCaching) { + part.text += getSecureID(); + } content.push({ text: part.text }); } else if (part.type === "imageUrl" && part.imageUrl) { try { diff --git a/core/llm/utils/__tests__/getSecureID.test.ts b/core/llm/utils/__tests__/getSecureID.test.ts new file mode 100644 index 000000000..9c4ffd6e7 --- /dev/null +++ b/core/llm/utils/__tests__/getSecureID.test.ts @@ -0,0 +1,49 @@ +import { getSecureID } from '../getSecureID'; + +// Mock the crypto.randomUUID function +const mockRandomUUID = jest.fn(); +global.crypto = { + ...global.crypto, + randomUUID: mockRandomUUID +}; + +describe('getSecureID', () => { + beforeEach(() => { + // Reset the static property before each test + (getSecureID as any).uuid = undefined; + + // Reset the mock implementation + mockRandomUUID.mockReset(); + // Setup a mock implementation that returns a fixed value for testing + mockRandomUUID.mockReturnValue('test-uuid-1234'); + }); + + test('should generate a UUID on first call', () => { + const result = getSecureID(); + expect(mockRandomUUID).toHaveBeenCalledTimes(1); + expect(result).toBe(''); + }); + + test('should reuse the same UUID on subsequent calls', () => { + const firstResult = getSecureID(); + const secondResult = getSecureID(); + + // The UUID generation should only happen once + expect(mockRandomUUID).toHaveBeenCalledTimes(1); + + // Both results should be identical + expect(firstResult).toBe(secondResult); + expect(firstResult).toBe(''); + }); + + test('should maintain the same UUID across different test cases if not reset', () => { + // Don't reset the UUID here to test persistence + (getSecureID as any).uuid = 'persistent-uuid'; + + const result = getSecureID(); + + // No new UUID should be generated + expect(mockRandomUUID).not.toHaveBeenCalled(); + expect(result).toBe(''); + }); +}); \ No newline at end of file diff --git a/core/llm/utils/getSecureID.ts b/core/llm/utils/getSecureID.ts new file mode 100644 index 000000000..b05fefab6 --- /dev/null +++ b/core/llm/utils/getSecureID.ts @@ -0,0 +1,8 @@ +// Utility function to get or generate UUID for LLM prompts +export function getSecureID(): string { + // Adding a type declaration for the static property + if (!(getSecureID as any).uuid) { + (getSecureID as any).uuid = crypto.randomUUID(); + } + return ``; +} From 305dc937eaddddd14c8c1de254ae3e2095ba37ee Mon Sep 17 00:00:00 2001 From: chezsmithy Date: Mon, 7 Apr 2025 23:09:14 -0700 Subject: [PATCH 17/43] fix/web-search-typo --- core/tools/definitions/searchWeb.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tools/definitions/searchWeb.ts b/core/tools/definitions/searchWeb.ts index 0f98f382c..d2ce78efc 100644 --- a/core/tools/definitions/searchWeb.ts +++ b/core/tools/definitions/searchWeb.ts @@ -7,7 +7,7 @@ export const searchWebTool: Tool = { displayTitle: "Search Web", wouldLikeTo: 'search the web for "{{{ query }}}"', isCurrently: 'searching the web for "{{{ query }}}"', - hasAlready: 'searched the web fore "{{{ query }}}"', + hasAlready: 'searched the web for "{{{ query }}}"', readonly: true, group: BUILT_IN_GROUP_NAME, function: { From 8638f7fc529ea36f83b8aebd46015ed9790f671b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 15:02:09 +0000 Subject: [PATCH 18/43] build(deps): bump peter-evans/create-pull-request from 5 to 7 Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 5 to 7. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v5...v7) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/jetbrains-release.yaml | 2 +- .github/workflows/preview.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jetbrains-release.yaml b/.github/workflows/jetbrains-release.yaml index 058d6191b..252aa76ff 100644 --- a/.github/workflows/jetbrains-release.yaml +++ b/.github/workflows/jetbrains-release.yaml @@ -70,7 +70,7 @@ jobs: echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.CI_GITHUB_TOKEN }} commit-message: "chore: bump jetbrains extension version to ${{ env.NEW_VERSION }}" diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 80eaa4931..23ea26bf6 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -263,7 +263,7 @@ jobs: echo "NEW_VERSION=$VERSION" >> $GITHUB_ENV - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.CI_GITHUB_TOKEN }} commit-message: "chore: bump vscode extension version to ${{ env.NEW_VERSION }}" From 98f2eacb09e176bcf3a6acc51b242681f9565db4 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Tue, 8 Apr 2025 14:58:16 -0700 Subject: [PATCH 19/43] improv: stricter linting --- core/.eslintrc.json | 2 +- core/core.ts | 489 +++++++++++++++++++++++--------------------- 2 files changed, 258 insertions(+), 233 deletions(-) diff --git a/core/.eslintrc.json b/core/.eslintrc.json index 633895fb7..4790b5c45 100644 --- a/core/.eslintrc.json +++ b/core/.eslintrc.json @@ -13,7 +13,7 @@ "@typescript-eslint/semi": "off", "eqeqeq": "error", "complexity": ["error", { "max": 38 }], - "max-lines-per-function": ["error", { "max": 996 }], + "max-lines-per-function": ["error", { "max": 485 }], "max-statements": ["error", { "max": 114 }], "max-depth": ["error", { "max": 6 }], "max-nested-callbacks": ["error", { "max": 4 }], diff --git a/core/core.ts b/core/core.ts index 159946849..e929a863b 100644 --- a/core/core.ts +++ b/core/core.ts @@ -5,11 +5,6 @@ import { v4 as uuidv4 } from "uuid"; import { CompletionProvider } from "./autocomplete/CompletionProvider"; import { ConfigHandler } from "./config/ConfigHandler"; import { SYSTEM_PROMPT_DOT_FILE } from "./config/getSystemPromptDotFile"; -import { - setupBestConfig, - setupLocalConfig, - setupQuickstartConfig, -} from "./config/onboarding"; import { addModel, deleteModel } from "./config/util"; import CodebaseContextProvider from "./context/providers/CodebaseContextProvider"; import CurrentFileContextProvider from "./context/providers/CurrentFileContextProvider"; @@ -19,7 +14,6 @@ import { getAuthUrlForTokenPage } from "./control-plane/auth/index"; import { getControlPlaneEnv } from "./control-plane/env"; import { DevDataSqliteDb } from "./data/devdataSqlite"; import { DataLogger } from "./data/log"; -import { streamDiffLines } from "./edit/streamDiffLines"; import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer"; import DocsService from "./indexing/docs/DocsService"; import { countTokens } from "./llm/countTokens"; @@ -37,6 +31,8 @@ import { TTS } from "./util/tts"; import { DiffLine, + IdeSettings, + RangeInFile, type ContextItemId, type IDE, type IndexingProgressUpdate, @@ -44,7 +40,13 @@ import { import { ConfigYaml } from "@continuedev/config-yaml"; import { isLocalAssistantFile } from "./config/loadLocalAssistants"; +import { + setupBestConfig, + setupLocalConfig, + setupQuickstartConfig, +} from "./config/onboarding"; import { MCPManagerSingleton } from "./context/mcp"; +import { streamDiffLines } from "./edit/streamDiffLines"; import { shouldIgnore } from "./indexing/shouldIgnore"; import { walkDirCache } from "./indexing/walkDir"; import { LLMLogger } from "./llm/logger"; @@ -52,6 +54,31 @@ import { llmStreamChat } from "./llm/streamChat"; import type { FromCoreProtocol, ToCoreProtocol } from "./protocol"; import type { IMessenger, Message } from "./protocol/messenger"; +async function* streamDiffLinesGenerator( + configHandler: ConfigHandler, + abortedMessageIds: Set, + msg: Message, +): AsyncGenerator { + const data = msg.data; + const llm = await configHandler.llmFromTitle(msg.data.modelTitle); + for await (const diffLine of streamDiffLines( + data.prefix, + data.highlighted, + data.suffix, + llm, + data.input, + data.language, + false, + undefined, + )) { + if (abortedMessageIds.has(msg.messageId)) { + abortedMessageIds.delete(msg.messageId); + break; + } + yield diffLine; + } +} + export class Core { configHandler: ConfigHandler; codebaseIndexerPromise: Promise; @@ -118,8 +145,7 @@ export class Core { this.messenger, ); - const mcpManager = MCPManagerSingleton.getInstance(); - mcpManager.onConnectionsRefreshed = async () => { + MCPManagerSingleton.getInstance().onConnectionsRefreshed = async () => { await this.configHandler.reloadConfig(); }; @@ -210,6 +236,10 @@ export class Core { (..._) => Promise.resolve([]), ); + this.registerMessageHandlers(ideSettingsPromise); + } + + private registerMessageHandlers(ideSettingsPromise: Promise) { const on = this.messenger.on.bind(this.messenger); // Note, VsCode's in-process messenger doesn't do anything with this @@ -329,7 +359,7 @@ export class Core { }); on("mcp/reloadServer", async (msg) => { - mcpManager.refreshConnection(msg.data.id); + MCPManagerSingleton.getInstance().refreshConnection(msg.data.id); }); // Context providers on("context/addDocs", async (msg) => { @@ -361,94 +391,7 @@ export class Core { return items || []; }); - on("context/getContextItems", async (msg) => { - const { config } = await this.configHandler.loadConfig(); - if (!config) { - return []; - } - - const { name, query, fullInput, selectedCode, selectedModelTitle } = - msg.data; - - const llm = await this.configHandler.llmFromTitle(selectedModelTitle); - const provider = - config.contextProviders?.find( - (provider) => provider.description.title === name, - ) ?? - [ - // user doesn't need these in their config.json for the shortcuts to work - // option+enter - new CurrentFileContextProvider({}), - // cmd+enter - new CodebaseContextProvider({}), - ].find((provider) => provider.description.title === name); - if (!provider) { - return []; - } - - try { - const id: ContextItemId = { - providerTitle: provider.description.title, - itemId: uuidv4(), - }; - - const items = await provider.getContextItems(query, { - config, - llm, - embeddingsProvider: config.selectedModelByRole.embed, - fullInput, - ide, - selectedCode, - reranker: config.selectedModelByRole.rerank, - fetch: (url, init) => - fetchwithRequestOptions(url, init, config.requestOptions), - }); - - void Telemetry.capture( - "useContextProvider", - { - name: provider.description.title, - }, - true, - ); - - return items.map((item) => ({ - ...item, - id, - })); - } catch (e) { - let knownError = false; - - if (e instanceof Error) { - // After removing transformers JS embeddings provider from jetbrains - // Should no longer see this error - // if (e.message.toLowerCase().includes("embeddings provider")) { - // knownError = true; - // const toastOption = "See Docs"; - // void this.ide - // .showToast( - // "error", - // `Set up an embeddings model to use @${name}`, - // toastOption, - // ) - // .then((userSelection) => { - // if (userSelection === toastOption) { - // void this.ide.openUrl( - // "https://docs.continue.dev/customize/model-roles/embeddings", - // ); - // } - // }); - // } - } - if (!knownError) { - void this.ide.showToast( - "error", - `Error getting context items from ${name}: ${e}`, - ); - } - return []; - } - }); + on("context/getContextItems", this.getContextItems.bind(this)); on("context/getSymbolsForFiles", async (msg) => { const { uris } = msg.data; @@ -481,7 +424,7 @@ export class Core { this.configHandler, this.abortedMessageIds, msg, - ide, + this.ide, this.messenger, ), ); @@ -495,31 +438,7 @@ export class Core { ); return completion; }); - on("llm/listModels", async (msg) => { - const { config } = await this.configHandler.loadConfig(); - if (!config) { - return []; - } - - const model = - config.models.find((model) => model.title === msg.data.title) ?? - config.models.find((model) => model.title?.startsWith(msg.data.title)); - try { - if (model) { - return await model.listModels(); - } else { - if (msg.data.title === "Ollama") { - const models = await new Ollama({ model: "" }).listModels(); - return models; - } else { - return undefined; - } - } - } catch (e) { - console.debug(`Error listing Ollama models: ${e}`); - return undefined; - } - }); + on("llm/listModels", this.handleListModels); // Provide messenger to utils so they can interact with GUI + state TTS.messenger = this.messenger; @@ -552,66 +471,11 @@ export class Core { this.completionProvider.cancel(); }); - async function* streamDiffLinesGenerator( - configHandler: ConfigHandler, - abortedMessageIds: Set, - msg: Message, - ): AsyncGenerator { - const data = msg.data; - const llm = await configHandler.llmFromTitle(msg.data.modelTitle); - for await (const diffLine of streamDiffLines( - data.prefix, - data.highlighted, - data.suffix, - llm, - data.input, - data.language, - false, - undefined, - )) { - if (abortedMessageIds.has(msg.messageId)) { - abortedMessageIds.delete(msg.messageId); - break; - } - yield diffLine; - } - } - on("streamDiffLines", (msg) => streamDiffLinesGenerator(this.configHandler, this.abortedMessageIds, msg), ); - on("completeOnboarding", (msg) => { - const mode = msg.data.mode; - - if (mode === "Custom") { - return; - } - - let editConfigYamlCallback: (config: ConfigYaml) => ConfigYaml; - - switch (mode) { - case "Local": - editConfigYamlCallback = setupLocalConfig; - break; - - case "Quickstart": - editConfigYamlCallback = setupQuickstartConfig; - break; - - case "Best": - editConfigYamlCallback = setupBestConfig; - break; - - default: - console.error(`Invalid mode: ${mode}`); - editConfigYamlCallback = (config) => config; - } - - editConfigFile((c) => c, editConfigYamlCallback); - - void this.configHandler.reloadConfig(); - }); + on("completeOnboarding", this.handleCompleteOnboarding); on("addAutocompleteModel", (msg) => { const model = msg.data.model; @@ -681,63 +545,12 @@ export class Core { // File changes // TODO - remove remaining logic for these from IDEs where possible - on("files/changed", async ({ data }) => { - if (data?.uris?.length) { - walkDirCache.invalidate(); // safe approach for now - TODO - only invalidate on relevant changes - for (const uri of data.uris) { - const currentProfileUri = - this.configHandler.currentProfile?.profileDescription.uri ?? ""; - - if (URI.equal(uri, currentProfileUri)) { - // Trigger a toast notification to provide UI feedback that config has been updated - const showToast = - this.globalContext.get("showConfigUpdateToast") ?? true; - if (showToast) { - const selection = await this.ide.showToast( - "info", - "Config updated", - "Don't show again", - ); - if (selection === "Don't show again") { - this.globalContext.update("showConfigUpdateToast", false); - } - } - await this.configHandler.reloadConfig(); - continue; - } - - if ( - uri.endsWith(".continuerc.json") || - uri.endsWith(".prompt") || - uri.endsWith(SYSTEM_PROMPT_DOT_FILE) - ) { - await this.configHandler.reloadConfig(); - } else if ( - uri.endsWith(".continueignore") || - uri.endsWith(".gitignore") - ) { - // Reindex the workspaces - this.invoke("index/forceReIndex", { - shouldClearIndexes: true, - }); - } else { - const { config } = await this.configHandler.loadConfig(); - if (config && !config.disableIndexing) { - // Reindex the file - const ignore = await shouldIgnore(uri, this.ide); - if (!ignore) { - await this.refreshCodebaseIndexFiles([uri]); - } - } - } - } - } - }); + on("files/changed", this.handleFilesChanged); const refreshIfNotIgnored = async (uris: string[]) => { const toRefresh: string[] = []; for (const uri of uris) { - const ignore = await shouldIgnore(uri, ide); + const ignore = await shouldIgnore(uri, this.ide); if (!ignore) { toRefresh.push(uri); } @@ -912,6 +725,218 @@ export class Core { }); } + private async handleFilesChanged({ + data, + }: Message<{ + uris?: string[]; + }>) { + if (data?.uris?.length) { + walkDirCache.invalidate(); // safe approach for now - TODO - only invalidate on relevant changes + for (const uri of data.uris) { + const currentProfileUri = + this.configHandler.currentProfile?.profileDescription.uri ?? ""; + + if (URI.equal(uri, currentProfileUri)) { + // Trigger a toast notification to provide UI feedback that config has been updated + const showToast = + this.globalContext.get("showConfigUpdateToast") ?? true; + if (showToast) { + const selection = await this.ide.showToast( + "info", + "Config updated", + "Don't show again", + ); + if (selection === "Don't show again") { + this.globalContext.update("showConfigUpdateToast", false); + } + } + await this.configHandler.reloadConfig(); + continue; + } + + if ( + uri.endsWith(".continuerc.json") || + uri.endsWith(".prompt") || + uri.endsWith(SYSTEM_PROMPT_DOT_FILE) + ) { + await this.configHandler.reloadConfig(); + } else if ( + uri.endsWith(".continueignore") || + uri.endsWith(".gitignore") + ) { + // Reindex the workspaces + this.invoke("index/forceReIndex", { + shouldClearIndexes: true, + }); + } else { + const { config } = await this.configHandler.loadConfig(); + if (config && !config.disableIndexing) { + // Reindex the file + const ignore = await shouldIgnore(uri, this.ide); + if (!ignore) { + await this.refreshCodebaseIndexFiles([uri]); + } + } + } + } + } + } + + private async handleListModels(msg: Message<{ title: string }>) { + const { config } = await this.configHandler.loadConfig(); + if (!config) { + return []; + } + + const model = + config.models.find((model) => model.title === msg.data.title) ?? + config.models.find((model) => model.title?.startsWith(msg.data.title)); + try { + if (model) { + return await model.listModels(); + } else { + if (msg.data.title === "Ollama") { + const models = await new Ollama({ model: "" }).listModels(); + return models; + } else { + return undefined; + } + } + } catch (e) { + console.debug(`Error listing Ollama models: ${e}`); + return undefined; + } + } + + private async handleCompleteOnboarding(msg: Message<{ mode: string }>) { + const mode = msg.data.mode; + + if (mode === "Custom") { + return; + } + + let editConfigYamlCallback: (config: ConfigYaml) => ConfigYaml; + + switch (mode) { + case "Local": + editConfigYamlCallback = setupLocalConfig; + break; + + case "Quickstart": + editConfigYamlCallback = setupQuickstartConfig; + break; + + case "Best": + editConfigYamlCallback = setupBestConfig; + break; + + default: + console.error(`Invalid mode: ${mode}`); + editConfigYamlCallback = (config) => config; + } + + editConfigFile((c) => c, editConfigYamlCallback); + + void this.configHandler.reloadConfig(); + } + + private getContextItems = async ( + msg: Message<{ + name: string; + query: string; + fullInput: string; + selectedCode: RangeInFile[]; + selectedModelTitle: string; + }>, + ) => { + const { config } = await this.configHandler.loadConfig(); + if (!config) { + return []; + } + + const { name, query, fullInput, selectedCode, selectedModelTitle } = + msg.data; + + const llm = await this.configHandler.llmFromTitle(selectedModelTitle); + const provider = + config.contextProviders?.find( + (provider) => provider.description.title === name, + ) ?? + [ + // user doesn't need these in their config.json for the shortcuts to work + // option+enter + new CurrentFileContextProvider({}), + // cmd+enter + new CodebaseContextProvider({}), + ].find((provider) => provider.description.title === name); + if (!provider) { + return []; + } + + try { + const id: ContextItemId = { + providerTitle: provider.description.title, + itemId: uuidv4(), + }; + + const items = await provider.getContextItems(query, { + config, + llm, + embeddingsProvider: config.selectedModelByRole.embed, + fullInput, + ide: this.ide, + selectedCode, + reranker: config.selectedModelByRole.rerank, + fetch: (url, init) => + fetchwithRequestOptions(url, init, config.requestOptions), + }); + + void Telemetry.capture( + "useContextProvider", + { + name: provider.description.title, + }, + true, + ); + + return items.map((item) => ({ + ...item, + id, + })); + } catch (e) { + let knownError = false; + + if (e instanceof Error) { + // After removing transformers JS embeddings provider from jetbrains + // Should no longer see this error + // if (e.message.toLowerCase().includes("embeddings provider")) { + // knownError = true; + // const toastOption = "See Docs"; + // void this.ide + // .showToast( + // "error", + // `Set up an embeddings model to use @${name}`, + // toastOption, + // ) + // .then((userSelection) => { + // if (userSelection === toastOption) { + // void this.ide.openUrl( + // "https://docs.continue.dev/customize/model-roles/embeddings", + // ); + // } + // }); + // } + } + if (!knownError) { + void this.ide.showToast( + "error", + `Error getting context items from ${name}: ${e}`, + ); + } + return []; + } + }; + private indexingCancellationController: AbortController | undefined; private async sendIndexingErrorTelemetry(update: IndexingProgressUpdate) { console.debug( From b601c22d01478d74a66bf162f3e12c4c4e1a93d7 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 17:02:29 -0700 Subject: [PATCH 20/43] feat: fallback to chat model in IDE --- core/config/selectedModels.ts | 6 +++- core/config/yaml/loadYaml.ts | 26 ---------------- core/protocol/ideWebview.ts | 1 - .../continue/IdeProtocolClient.kt | 30 ++++++++++++------- .../protocol/ideWebview.kt | 1 - extensions/vscode/package-lock.json | 4 +-- .../vscode/src/extension/VsCodeMessenger.ts | 18 +++++------ .../StepContainerPreActionButtons.tsx | 11 ++----- .../StepContainerPreToolbar.tsx | 1 - gui/src/pages/config/ModelRoleSelector.tsx | 6 ++++ gui/src/redux/thunks/callTool.ts | 3 -- 11 files changed, 42 insertions(+), 65 deletions(-) diff --git a/core/config/selectedModels.ts b/core/config/selectedModels.ts index c2ef111c0..99d89e1a0 100644 --- a/core/config/selectedModels.ts +++ b/core/config/selectedModels.ts @@ -52,7 +52,11 @@ export function rectifySelectedModelsFromGlobalContext( fellBack = true; } - if (newModel?.getConfigurationStatus() !== LLMConfigurationStatuses.VALID) { + // Currently only check for configuration status for apply + if ( + role === "apply" && + newModel?.getConfigurationStatus() !== LLMConfigurationStatuses.VALID + ) { break; } diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 867917ac0..1edb48604 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -43,7 +43,6 @@ import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader"; import { modifyAnyConfigWithSharedConfig } from "../sharedConfig"; import { getControlPlaneEnvSync } from "../../control-plane/env"; -import { LLMConfigurationStatuses } from "../../llm/constants"; import { llmsFromModelConfig } from "./models"; export class LocalPlatformClient implements PlatformClient { @@ -237,31 +236,6 @@ async function configYamlToContinueConfig( if (model.roles?.includes("apply")) { continueConfig.modelsByRole.apply.push(...llms); - - if ( - llms.every( - (llm) => - llm.getConfigurationStatus() !== LLMConfigurationStatuses.VALID, - ) - ) { - const chatModelForApplyFallback = config.models?.find((model) => - model.roles?.includes("chat"), - ); - if (chatModelForApplyFallback) { - const [chatLlmForApplyFallback] = await llmsFromModelConfig({ - model: chatModelForApplyFallback, - ide, - uniqueId, - ideSettings, - llmLogger, - platformConfigMetadata, - config: continueConfig, - }); - - continueConfig.modelsByRole.apply.unshift(chatLlmForApplyFallback); - continueConfig.selectedModelByRole.apply = chatLlmForApplyFallback; - } - } } if (model.roles?.includes("edit")) { diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 6aae337f0..47c28680c 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -17,7 +17,6 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { { text: string; streamId: string; - curSelectedModelTitle: string; filepath?: string; toolCallId?: string; }, 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 41c2c4892..5f4316f8e 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 @@ -497,21 +497,29 @@ class IdeProtocolClient( val config = result["config"] as Map<*, *> val selectedModels = config["selectedModelByRole"] as? Map<*, *> - val applyCodeBlockModel = selectedModels?.get("apply") as? Map<*, *> + var applyCodeBlockModel = selectedModels?.get("apply") as? Map<*, *> + + // If "apply" role model is not found, try "chat" role + if (applyCodeBlockModel == null) { + applyCodeBlockModel = selectedModels?.get("chat") as? Map<*, *> + } + + // If neither "apply" nor "chat" models are available in selectedModelByRole, + // fallback to modelsByRole.chat[0] + if (applyCodeBlockModel == null) { + val modelsByRole = config["modelsByRole"] as? Map<*, *> + val chatModels = modelsByRole?.get("chat") as? List<*> + if (chatModels != null && chatModels.isNotEmpty()) { + applyCodeBlockModel = chatModels[0] as? Map<*, *> + } + } + if (applyCodeBlockModel != null) { continuation.resume(applyCodeBlockModel) } else { - val models = - config["models"] as List> - val curSelectedModel = - models.find { it["title"] == params.curSelectedModelTitle } - - if (curSelectedModel == null) { - continuation.resumeWithException(IllegalStateException("Model '${params.curSelectedModelTitle}' not found in config.")) - } else { - continuation.resume(curSelectedModel) - } + // If neither "apply" nor "chat" models are available, return with exception + continuation.resumeWithException(IllegalStateException("No 'apply' or 'chat' model found in configuration.")) } } catch (e: Exception) { continuation.resumeWithException(e) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt index 5c587c54d..718755a99 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt @@ -11,7 +11,6 @@ data class SetGitHubAuthTokenParams( data class ApplyToFileParams( val text: String, val streamId: String, - val curSelectedModelTitle: String, val filepath: String?, val toolCallId: String? ) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 108520e49..efc342f19 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.21", + "version": "1.1.22", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.21", + "version": "1.1.22", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 9563eb8a9..910b33c1f 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -18,7 +18,6 @@ import { stripImages } from "core/util/messageContent"; import { getUriPathBasename } from "core/util/uri"; import * as vscode from "vscode"; -import { ILLM } from "core"; import { VerticalDiffManager } from "../diff/vertical/manager"; import EditDecorationManager from "../quickEdit/EditDecorationManager"; import { @@ -180,19 +179,16 @@ export class VsCodeMessenger { return; } - let llm: ILLM | null | undefined = config.selectedModelByRole.apply; + let llm = + config.selectedModelByRole.apply ?? + config.selectedModelByRole.chat ?? + config.modelsByRole.chat[0]; if (!llm) { - llm = config.models.find( - (model) => model.title === data.curSelectedModelTitle, + vscode.window.showErrorMessage( + `No model with roles "apply" or "chat" found in config.`, ); - - if (!llm) { - vscode.window.showErrorMessage( - `Model ${data.curSelectedModelTitle} not found in config.`, - ); - return; - } + return; } const fastLlm = getModelByRole(config, "repoMapFileSelection") ?? llm; diff --git a/gui/src/components/markdown/StepContainerPreActionButtons.tsx b/gui/src/components/markdown/StepContainerPreActionButtons.tsx index 85ece0990..7e42dfb1c 100644 --- a/gui/src/components/markdown/StepContainerPreActionButtons.tsx +++ b/gui/src/components/markdown/StepContainerPreActionButtons.tsx @@ -13,10 +13,7 @@ import { import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useWebviewListener } from "../../hooks/useWebviewListener"; import { useAppSelector } from "../../redux/hooks"; -import { - selectDefaultModel, - selectUIConfig, -} from "../../redux/slices/configSlice"; +import { selectUIConfig } from "../../redux/slices/configSlice"; import { isJetBrains } from "../../util"; import { CopyIconButton } from "../gui/CopyIconButton"; import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; @@ -56,16 +53,14 @@ export default function StepContainerPreActionButtons({ streamIdRef.current = uuidv4(); } - const defaultModel = useAppSelector(selectDefaultModel); - function onClickApply() { - if (!defaultModel || !streamIdRef.current) { + if (!streamIdRef.current) { return; } + ideMessenger.post("applyToFile", { streamId: streamIdRef.current, text: codeBlockContent, - curSelectedModelTitle: defaultModel.title, }); } diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index f09ed1a9f..a415f6f84 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -97,7 +97,6 @@ export default function StepContainerPreToolbar( streamId: props.codeBlockStreamId, filepath: fileUri, text: codeBlockContent, - curSelectedModelTitle: defaultModel.title, }); } diff --git a/gui/src/pages/config/ModelRoleSelector.tsx b/gui/src/pages/config/ModelRoleSelector.tsx index 5af026f61..c6d2e5a98 100644 --- a/gui/src/pages/config/ModelRoleSelector.tsx +++ b/gui/src/pages/config/ModelRoleSelector.tsx @@ -38,6 +38,10 @@ const ModelRoleSelector = ({ const ideMessenger = useContext(IdeMessengerContext); const [hoveredIdx, setHoveredIdx] = useState(null); + const noConfiguredModels = models.every( + (model) => model.configurationStatus !== LLMConfigurationStatuses.VALID, + ); + function handleSelect(title: string | null) { onSelect(models.find((m) => m.title === title) ?? null); } @@ -81,6 +85,8 @@ const ModelRoleSelector = ({ > {models.length === 0 ? ( {`No ${displayName} models${["Chat", "Apply", "Edit"].includes(displayName) ? ". Using chat model" : ""}`} + ) : noConfiguredModels ? ( + {`No valid ${displayName} models${["Chat", "Apply", "Edit"].includes(displayName) ? ". Using chat model" : ""}`} ) : ( {selectedModel?.title ?? `Select ${displayName} model`} diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index bf15e7ae8..76b37b6fd 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -54,7 +54,6 @@ export const callTool = createAsyncThunk( args, extra.ideMessenger, state.session.activeToolStreamId[0], - defaultModel.title, toolCallState.toolCallId, ); } catch (e) { @@ -125,7 +124,6 @@ async function customGuiEditImpl( args: EditToolArgs, ideMessenger: IIdeMessenger, streamId: string, - modelTitle: string, toolCallId: string, ) { const firstUriMatch = await resolveRelativePathInDir( @@ -138,7 +136,6 @@ async function customGuiEditImpl( const apply = await ideMessenger.request("applyToFile", { streamId, text: args.new_contents, - curSelectedModelTitle: modelTitle, toolCallId, filepath: firstUriMatch, }); From a02012da321f0bc80a3686934ee146b3ec451485 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 17:19:24 -0700 Subject: [PATCH 21/43] Update ContinuePluginToolWindowFactory.kt --- .../toolWindow/ContinuePluginToolWindowFactory.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt index 5d8335220..d0d44655c 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt @@ -11,7 +11,7 @@ import com.intellij.openapi.wm.ToolWindowFactory import com.intellij.ui.content.ContentFactory import javax.swing.* -const val JS_QUERY_POOL_SIZE = 200 +const val JS_QUERY_POOL_SIZE = "200" class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware { override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) { @@ -43,6 +43,11 @@ class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware { class ContinuePluginWindow(project: Project) { private val defaultGUIUrl = "http://continue/index.html" + init { + System.setProperty("ide.browser.jcef.jsQueryPoolSize", JS_QUERY_POOL_SIZE) + System.setProperty("ide.browser.jcef.contextMenu.devTools.enabled", "true") + } + val browser: ContinueBrowser by lazy { val url = System.getenv("GUI_URL")?.toString() ?: defaultGUIUrl From 1bf359a55fdb833569878167a1440e66c65d7249 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 17:55:11 -0700 Subject: [PATCH 22/43] feat: remove defaultTitle --- core/config/selectedModels.ts | 5 +- gui/src/components/Footer.tsx | 4 +- .../components/BestExperienceConfigForm.tsx | 6 +- .../tabs/OnboardingLocalTab.tsx | 6 +- .../StepContainer/ThinkingIndicator.tsx | 4 +- .../mainInput/AtMentionDropdown/index.tsx | 9 ++- gui/src/components/mainInput/InputToolbar.tsx | 4 +- .../mainInput/Lump/sections/ModelsSection.tsx | 27 +-------- .../mainInput/TipTapEditor/TipTapEditor.tsx | 4 +- .../TipTapEditor/utils/editorConfig.ts | 4 +- .../StepContainerPreToolbar.tsx | 4 +- .../components/modelSelection/ModeSelect.tsx | 4 +- .../components/modelSelection/ModelSelect.tsx | 10 ++-- .../platform/AssistantSelect.tsx | 37 ++++++------ gui/src/forms/AddModelForm.tsx | 8 +-- gui/src/hooks/useSetup.ts | 4 +- gui/src/pages/gui/Chat.tsx | 4 +- gui/src/pages/gui/StreamError.tsx | 4 +- gui/src/redux/slices/configSlice.ts | 59 ++++++------------- gui/src/redux/thunks/callTool.ts | 4 +- gui/src/redux/thunks/gatherContext.ts | 4 +- gui/src/redux/thunks/session.ts | 4 +- gui/src/redux/thunks/streamNormalInput.ts | 6 +- gui/src/redux/thunks/streamResponse.ts | 4 +- .../thunks/streamResponseAfterToolCall.ts | 4 +- 25 files changed, 94 insertions(+), 139 deletions(-) diff --git a/core/config/selectedModels.ts b/core/config/selectedModels.ts index 99d89e1a0..20dfb5063 100644 --- a/core/config/selectedModels.ts +++ b/core/config/selectedModels.ts @@ -20,15 +20,14 @@ export function rectifySelectedModelsFromGlobalContext( let fellBack = false; - // chat and summarize not implemented yet - // default chat model is stored in GUI still - + // summarize not implemented yet const roles: ModelRole[] = [ "autocomplete", "apply", "edit", "embed", "rerank", + "chat", ]; for (const role of roles) { diff --git a/gui/src/components/Footer.tsx b/gui/src/components/Footer.tsx index b2efd221c..d6e79651c 100644 --- a/gui/src/components/Footer.tsx +++ b/gui/src/components/Footer.tsx @@ -1,11 +1,11 @@ import { useAppSelector } from "../redux/hooks"; -import { selectDefaultModel } from "../redux/slices/configSlice"; +import { selectSelectedChatModel } from "../redux/slices/configSlice"; import { FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial"; import { getLocalStorage } from "../util/localStorage"; import FreeTrialProgressBar from "./loaders/FreeTrialProgressBar"; function Footer() { - const defaultModel = useAppSelector(selectDefaultModel); + const defaultModel = useAppSelector(selectSelectedChatModel); if (defaultModel?.provider === "free-trial") { return ( diff --git a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx index 389ed72dd..d05481dfb 100644 --- a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx +++ b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx @@ -5,7 +5,7 @@ import { Button, Input, InputSubtext, lightGray } from "../.."; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { models } from "../../../pages/AddNewModel/configs/models"; import { providers } from "../../../pages/AddNewModel/configs/providers"; -import { setDefaultModel } from "../../../redux/slices/configSlice"; +import { setSelectedChatModel } from "../../../redux/slices/configSlice"; import AddModelButtonSubtext from "../../AddModelButtonSubtext"; const { anthropic, mistral } = providers; @@ -61,7 +61,9 @@ function BestExperienceConfigForm({ model: repoMapConfig, role: "repoMapFileSelection", }); - dispatch(setDefaultModel({ title: chatModelConfig.title, force: true })); + dispatch( + setSelectedChatModel({ title: chatModelConfig.title, force: true }), + ); if (!!autocompleteApiKey) { await ideMessenger.request("addAutocompleteModel", { diff --git a/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx b/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx index 81b0a7a6b..54f036118 100644 --- a/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx +++ b/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx @@ -9,12 +9,12 @@ import { useContext, useEffect, useState } from "react"; import { useDispatch } from "react-redux"; import { Button } from "../.."; import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { setSelectedChatModel } from "../../../redux/slices/configSlice"; +import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; import AddModelButtonSubtext from "../../AddModelButtonSubtext"; import OllamaModelDownload from "../components/OllamaModelDownload"; import { OllamaStatus } from "../components/OllamaStatus"; import { useSubmitOnboarding } from "../hooks"; -import { setDefaultModel } from "../../../redux/slices/configSlice"; -import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; const OLLAMA_CHECK_INTERVAL_MS = 3000; @@ -137,7 +137,7 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) { // Set the selected model to the local chat model dispatch( - setDefaultModel({ + setSelectedChatModel({ title: LOCAL_ONBOARDING_CHAT_TITLE, force: true, // Because it doesn't exist in the webview's config object yet }), diff --git a/gui/src/components/StepContainer/ThinkingIndicator.tsx b/gui/src/components/StepContainer/ThinkingIndicator.tsx index 862351872..3dcbf9491 100644 --- a/gui/src/components/StepContainer/ThinkingIndicator.tsx +++ b/gui/src/components/StepContainer/ThinkingIndicator.tsx @@ -1,7 +1,7 @@ import { ChatHistoryItem } from "core"; import { useEffect, useState } from "react"; import { useAppSelector } from "../../redux/hooks"; -import { selectDefaultModel } from "../../redux/slices/configSlice"; +import { selectSelectedChatModel } from "../../redux/slices/configSlice"; interface ThinkingIndicatorProps { historyItem: ChatHistoryItem; @@ -22,7 +22,7 @@ const ThinkingIndicator = ({ historyItem }: ThinkingIndicatorProps) => { }; }, []); - const selectedModel = useAppSelector(selectDefaultModel); + const selectedModel = useAppSelector(selectSelectedChatModel); const isStreaming = useAppSelector((state) => state.session.isStreaming); const hasContent = Array.isArray(historyItem.message.content) diff --git a/gui/src/components/mainInput/AtMentionDropdown/index.tsx b/gui/src/components/mainInput/AtMentionDropdown/index.tsx index c028b7a87..9d5a10bec 100644 --- a/gui/src/components/mainInput/AtMentionDropdown/index.tsx +++ b/gui/src/components/mainInput/AtMentionDropdown/index.tsx @@ -26,6 +26,7 @@ import { } from "../.."; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { useAppSelector } from "../../../redux/hooks"; +import { selectSelectedChatModel } from "../../../redux/slices/configSlice"; import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; import { fontSize } from "../../../util"; import FileIcon from "../../FileIcon"; @@ -161,9 +162,7 @@ const AtMentionDropdown = forwardRef((props: AtMentionDropdownProps, ref) => { const ideMessenger = useContext(IdeMessengerContext); - const selectedModelTitle = useAppSelector( - (store) => store.config.defaultModelTitle, - ); + const selectedModelTitle = useAppSelector(selectSelectedChatModel); const [selectedIndex, setSelectedIndex] = useState(0); @@ -192,7 +191,7 @@ const AtMentionDropdown = forwardRef((props: AtMentionDropdownProps, ref) => { query, fullInput: "", selectedCode, - selectedModelTitle: selectedModelTitle ?? "", + selectedModelTitle: selectedModelTitle?.title ?? "", }, ); @@ -205,7 +204,7 @@ const AtMentionDropdown = forwardRef((props: AtMentionDropdownProps, ref) => { // Check if the context item exceeds the context length of the selected model const result = await ideMessenger.request("isItemTooBig", { item, - selectedModelTitle: selectedModelTitle, + selectedModelTitle: selectedModelTitle?.title, }); if (result.status === "error") { diff --git a/gui/src/components/mainInput/InputToolbar.tsx b/gui/src/components/mainInput/InputToolbar.tsx index 20e40d9a9..252126425 100644 --- a/gui/src/components/mainInput/InputToolbar.tsx +++ b/gui/src/components/mainInput/InputToolbar.tsx @@ -14,7 +14,7 @@ import { import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { selectUseActiveFile } from "../../redux/selectors"; import { selectCurrentToolCall } from "../../redux/selectors/selectCurrentToolCall"; -import { selectDefaultModel } from "../../redux/slices/configSlice"; +import { selectSelectedChatModel } from "../../redux/slices/configSlice"; import { selectHasCodeToEdit, selectIsInEditMode, @@ -92,7 +92,7 @@ interface InputToolbarProps { function InputToolbar(props: InputToolbarProps) { const dispatch = useAppDispatch(); const fileInputRef = useRef(null); - const defaultModel = useAppSelector(selectDefaultModel); + const defaultModel = useAppSelector(selectSelectedChatModel); const useActiveFile = useAppSelector(selectUseActiveFile); const isInEditMode = useAppSelector(selectIsInEditMode); const hasCodeToEdit = useAppSelector(selectHasCodeToEdit); diff --git a/gui/src/components/mainInput/Lump/sections/ModelsSection.tsx b/gui/src/components/mainInput/Lump/sections/ModelsSection.tsx index 05e9352f0..f6edc7400 100644 --- a/gui/src/components/mainInput/Lump/sections/ModelsSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/ModelsSection.tsx @@ -5,11 +5,7 @@ import { useAuth } from "../../../../context/Auth"; import { IdeMessengerContext } from "../../../../context/IdeMessenger"; import ModelRoleSelector from "../../../../pages/config/ModelRoleSelector"; import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; -import { - selectDefaultModel, - setDefaultModel, - updateConfig, -} from "../../../../redux/slices/configSlice"; +import { updateConfig } from "../../../../redux/slices/configSlice"; import { isJetBrains } from "../../../../util"; import { ExploreBlocksButton } from "./ExploreBlocksButton"; @@ -20,7 +16,6 @@ export function ModelsSection() { const config = useAppSelector((state) => state.config.config); const jetbrains = isJetBrains(); - const selectedChatModel = useAppSelector(selectDefaultModel); function handleRoleUpdate(role: ModelRole, model: ModelDescription | null) { if (!selectedProfile) { @@ -43,14 +38,6 @@ export function ModelsSection() { }); } - // TODO use handleRoleUpdate for chat - function handleChatModelSelection(model: ModelDescription | null) { - if (!model) { - return; - } - dispatch(setDefaultModel({ title: model.title })); - } - return (
@@ -58,16 +45,8 @@ export function ModelsSection() { displayName="Chat" description="Used in the chat interface" models={config.modelsByRole.chat} - selectedModel={ - selectedChatModel - ? { - title: selectedChatModel.title, - provider: selectedChatModel.provider, - model: selectedChatModel.model, - } - : null - } - onSelect={(model) => handleChatModelSelection(model)} + selectedModel={config.selectedModelByRole.chat} + onSelect={(model) => handleRoleUpdate("chat", model)} /> state.session.isStreaming); const isInEditMode = useAppSelector(selectIsInEditMode); const historyLength = useAppSelector((store) => store.session.history.length); diff --git a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts index e50769ac8..9c56819e3 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts @@ -21,7 +21,7 @@ import { useInputHistory } from "../../../../hooks/useInputHistory"; import useUpdatingRef from "../../../../hooks/useUpdatingRef"; import { useAppSelector } from "../../../../redux/hooks"; import { selectUseActiveFile } from "../../../../redux/selectors"; -import { selectDefaultModel } from "../../../../redux/slices/configSlice"; +import { selectSelectedChatModel } from "../../../../redux/slices/configSlice"; import { addCodeToEdit, selectHasCodeToEdit, @@ -83,7 +83,7 @@ export function createEditorConfig(options: { const posthog = usePostHog(); const { getSubmenuContextItems } = useSubmenuContextProviders(); - const defaultModel = useAppSelector(selectDefaultModel); + const defaultModel = useAppSelector(selectSelectedChatModel); const isStreaming = useAppSelector((state) => state.session.isStreaming); const useActiveFile = useAppSelector(selectUseActiveFile); const historyLength = useAppSelector((store) => store.session.history.length); diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index a415f6f84..ed4a7ea47 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -11,7 +11,7 @@ import { import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { useWebviewListener } from "../../../hooks/useWebviewListener"; import { useAppSelector } from "../../../redux/hooks"; -import { selectDefaultModel } from "../../../redux/slices/configSlice"; +import { selectSelectedChatModel } from "../../../redux/slices/configSlice"; import { selectApplyStateByStreamId, selectIsInEditMode, @@ -81,7 +81,7 @@ export default function StepContainerPreToolbar( const isNextCodeBlock = nextCodeBlockIndex === props.codeBlockIndex; const hasFileExtension = /\.[0-9a-z]+$/i.test(props.relativeFilepath); - const defaultModel = useAppSelector(selectDefaultModel); + const defaultModel = useAppSelector(selectSelectedChatModel); async function onClickApply() { if (!defaultModel) { diff --git a/gui/src/components/modelSelection/ModeSelect.tsx b/gui/src/components/modelSelection/ModeSelect.tsx index 0e14adfad..92395f545 100644 --- a/gui/src/components/modelSelection/ModeSelect.tsx +++ b/gui/src/components/modelSelection/ModeSelect.tsx @@ -12,7 +12,7 @@ import { useEffect, useMemo } from "react"; import styled from "styled-components"; import { lightGray } from ".."; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; -import { selectDefaultModel } from "../../redux/slices/configSlice"; +import { selectSelectedChatModel } from "../../redux/slices/configSlice"; import { cycleMode, selectCurrentMode, @@ -40,7 +40,7 @@ const ShortcutText = styled.span` function ModeSelect() { const dispatch = useAppDispatch(); const mode = useAppSelector(selectCurrentMode); - const selectedModel = useAppSelector(selectDefaultModel); + const selectedModel = useAppSelector(selectSelectedChatModel); const agentModeSupported = selectedModel && modelSupportsTools(selectedModel); const jetbrains = useMemo(() => { diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index 4c2e31387..a6e7756ac 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -14,8 +14,8 @@ import { IdeMessengerContext } from "../../context/IdeMessenger"; import AddModelForm from "../../forms/AddModelForm"; import { useAppSelector } from "../../redux/hooks"; import { - selectDefaultModel, - setDefaultModel, + selectSelectedChatModel, + setSelectedChatModel, } from "../../redux/slices/configSlice"; import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util"; @@ -123,7 +123,7 @@ function ModelOption({ function ModelSelect() { const dispatch = useDispatch(); - const defaultModel = useAppSelector(selectDefaultModel); + const defaultModel = useAppSelector(selectSelectedChatModel); const allModels = useAppSelector((state) => state.config.config.models); const buttonRef = useRef(null); const [options, setOptions] = useState([]); @@ -164,7 +164,7 @@ function ModelSelect() { let nextIndex = (currentIndex + 1 * direction) % options.length; if (nextIndex < 0) nextIndex = options.length - 1; const newModelTitle = options[nextIndex].value; - dispatch(setDefaultModel({ title: newModelTitle })); + dispatch(setSelectedChatModel({ title: newModelTitle })); } }; @@ -199,7 +199,7 @@ function ModelSelect() { { if (val === defaultModel?.title) return; - dispatch(setDefaultModel({ title: val })); + dispatch(setSelectedChatModel({ title: val })); }} >
diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index e0d88dc12..649cb2684 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -1,5 +1,5 @@ import { - ArrowPathRoundedSquareIcon, + ArrowPathIcon, ArrowTopRightOnSquareIcon, BuildingOfficeIcon, ChevronDownIcon, @@ -291,6 +291,20 @@ export default function AssistantSelect() { +
+ Assistants +
{ + e.stopPropagation(); + refreshProfiles(); + buttonRef.current?.click(); + }} + > + +
+
+
@@ -314,8 +328,9 @@ export default function AssistantSelect() { }} /> -
+
login(false)} @@ -330,24 +345,6 @@ export default function AssistantSelect() { New Assistant
-
{ - e.stopPropagation(); - refreshProfiles(); - buttonRef.current?.click(); - }} - > - - - Refresh - -
void; @@ -115,7 +115,7 @@ function AddModelForm({ profileId: "local", }); - dispatch(setDefaultModel({ title: model.title, force: true })); + dispatch(setSelectedChatModel({ title: model.title, force: true })); onDone(); } diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index 5b3e665ad..f840c49b4 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -11,7 +11,7 @@ import { } from "../redux"; import { useAppDispatch, useAppSelector } from "../redux/hooks"; import { - selectDefaultModel, + selectSelectedChatModel, setConfigResult, } from "../redux/slices/configSlice"; import { updateIndexingStatus } from "../redux/slices/indexingSlice"; @@ -35,7 +35,7 @@ function useSetup() { const dispatch = useAppDispatch(); const ideMessenger = useContext(IdeMessengerContext); const history = useAppSelector((store) => store.session.history); - const defaultModel = useAppSelector(selectDefaultModel); + const defaultModel = useAppSelector(selectSelectedChatModel); const selectedProfileId = useAppSelector( (store) => store.profiles.selectedProfileId, ); diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 682671cbb..ec195d9c9 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -31,7 +31,7 @@ import { useWebviewListener } from "../../hooks/useWebviewListener"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { selectUseHub } from "../../redux/selectors"; import { selectCurrentToolCall } from "../../redux/selectors/selectCurrentToolCall"; -import { selectDefaultModel } from "../../redux/slices/configSlice"; +import { selectSelectedChatModel } from "../../redux/slices/configSlice"; import { submitEdit } from "../../redux/slices/editModeState"; import { newSession, @@ -105,7 +105,7 @@ export function Chat() { const showSessionTabs = useAppSelector( (store) => store.config.config.ui?.showSessionTabs, ); - const defaultModel = useAppSelector(selectDefaultModel); + const defaultModel = useAppSelector(selectSelectedChatModel); const isStreaming = useAppSelector((state) => state.session.isStreaming); const [stepsOpen, setStepsOpen] = useState<(boolean | undefined)[]>([]); const mainTextInputRef = useRef(null); diff --git a/gui/src/pages/gui/StreamError.tsx b/gui/src/pages/gui/StreamError.tsx index 389528cd0..35fe3dc91 100644 --- a/gui/src/pages/gui/StreamError.tsx +++ b/gui/src/pages/gui/StreamError.tsx @@ -9,7 +9,7 @@ import { IdeMessengerContext } from "../../context/IdeMessenger"; import { selectSelectedProfile } from "../../redux/"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { selectUseHub } from "../../redux/selectors"; -import { selectDefaultModel } from "../../redux/slices/configSlice"; +import { selectSelectedChatModel } from "../../redux/slices/configSlice"; import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; import { isLocalProfile } from "../../util"; import { providers } from "../AddNewModel/configs/providers"; @@ -20,7 +20,7 @@ interface StreamErrorProps { const StreamErrorDialog = ({ error }: StreamErrorProps) => { const dispatch = useAppDispatch(); const ideMessenger = useContext(IdeMessengerContext); - const selectedModel = useAppSelector(selectDefaultModel); + const selectedModel = useAppSelector(selectSelectedChatModel); const hubEnabled = useAppSelector(selectUseHub); const selectedProfile = useAppSelector(selectSelectedProfile); const { session, refreshProfiles } = useAuth(); diff --git a/gui/src/redux/slices/configSlice.ts b/gui/src/redux/slices/configSlice.ts index 3092f01c5..c1528daa9 100644 --- a/gui/src/redux/slices/configSlice.ts +++ b/gui/src/redux/slices/configSlice.ts @@ -6,7 +6,6 @@ import { DEFAULT_MAX_TOKENS } from "core/llm/constants"; export type ConfigState = { configError: ConfigValidationError[] | undefined; config: BrowserSerializedContinueConfig; - defaultModelTitle?: string; }; const EMPTY_CONFIG: BrowserSerializedContinueConfig = { @@ -47,7 +46,6 @@ const EMPTY_CONFIG: BrowserSerializedContinueConfig = { const initialState: ConfigState = { configError: undefined, - defaultModelTitle: undefined, config: EMPTY_CONFIG, }; @@ -70,12 +68,8 @@ export const configSlice = createSlice({ // Don't invalidate the loaded config if (!config) { state.config = EMPTY_CONFIG; - state.defaultModelTitle = undefined; } else { state.config = config; - state.defaultModelTitle = - config.models.find((model) => model.title === state.defaultModelTitle) - ?.title || config.models[0]?.title; } }, updateConfig: ( @@ -84,63 +78,48 @@ export const configSlice = createSlice({ ) => { state.config = config; }, - setDefaultModel: ( + setSelectedChatModel: ( state, { payload }: PayloadAction<{ title: string; force?: boolean }>, ) => { - const model = state.config.models.find( + const model = state.config.modelsByRole["chat"].find( (model) => model.title === payload.title, ); + if (!model && !payload.force) return; - return { - ...state, - defaultModelTitle: payload.title, - }; - }, - cycleDefaultModel: (state, { payload }: PayloadAction<"next" | "prev">) => { - const currentIndex = state.config.models.findIndex( - (model) => model.title === state.defaultModelTitle, - ); - const nextIndex = - (currentIndex + - (payload === "next" ? 1 : -1) + - state.config.models.length) % - state.config.models.length; - return { - ...state, - defaultModelTitle: state.config.models[nextIndex].title, + + state.config = { + ...state.config, + selectedModelByRole: { + ...state.config.selectedModelByRole, + chat: model ?? null, + }, }; }, }, selectors: { - selectDefaultModel: (state) => { - return state.config.models.find( - (model) => model.title === state.defaultModelTitle, - ); - }, - selectDefaultModelContextLength: (state): number => { + selectSelectedChatModelContextLength: (state): number => { return ( - configSlice.getSelectors().selectDefaultModel(state)?.contextLength || + state.config.selectedModelByRole.chat?.contextLength || DEFAULT_MAX_TOKENS ); }, + selectSelectedChatModel: (state) => { + return state.config.selectedModelByRole.chat; + }, selectUIConfig: (state) => { return state.config?.ui ?? null; }, }, }); -export const { - setDefaultModel, - cycleDefaultModel, - updateConfig, - setConfigResult, -} = configSlice.actions; +export const { updateConfig, setConfigResult, setSelectedChatModel } = + configSlice.actions; export const { - selectDefaultModel, - selectDefaultModelContextLength, + selectSelectedChatModelContextLength, selectUIConfig, + selectSelectedChatModel, } = configSlice.selectors; export default configSlice.reducer; diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 76b37b6fd..04d49007f 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -5,7 +5,7 @@ import { EditToolArgs } from "core/tools/definitions/editFile"; import { resolveRelativePathInDir } from "core/util/ideUtils"; import { IIdeMessenger } from "../../context/IdeMessenger"; import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall"; -import { selectDefaultModel } from "../slices/configSlice"; +import { selectSelectedChatModel } from "../slices/configSlice"; import { acceptToolCall, cancelToolCall, @@ -30,7 +30,7 @@ export const callTool = createAsyncThunk( return; } - const defaultModel = selectDefaultModel(state); + const defaultModel = selectSelectedChatModel(state); if (!defaultModel) { throw new Error("No model selected"); } diff --git a/gui/src/redux/thunks/gatherContext.ts b/gui/src/redux/thunks/gatherContext.ts index 450471164..e810e1025 100644 --- a/gui/src/redux/thunks/gatherContext.ts +++ b/gui/src/redux/thunks/gatherContext.ts @@ -9,7 +9,7 @@ import { } from "core"; import * as URI from "uri-js"; import { resolveEditorContent } from "../../components/mainInput/TipTapEditor/utils"; -import { selectDefaultModel } from "../slices/configSlice"; +import { selectSelectedChatModel } from "../slices/configSlice"; import { ThunkApiType } from "../store"; export const gatherContext = createAsyncThunk< @@ -37,7 +37,7 @@ export const gatherContext = createAsyncThunk< { dispatch, extra, getState }, ) => { const state = getState(); - const defaultModel = selectDefaultModel(state); + const defaultModel = selectSelectedChatModel(state); const defaultContextProviders = state.config.config.experimental?.defaultContext ?? []; diff --git a/gui/src/redux/thunks/session.ts b/gui/src/redux/thunks/session.ts index b5ef0ac9a..413c3c678 100644 --- a/gui/src/redux/thunks/session.ts +++ b/gui/src/redux/thunks/session.ts @@ -3,7 +3,7 @@ import { ChatMessage, Session, SessionMetadata } from "core"; import { NEW_SESSION_TITLE } from "core/util/constants"; import { renderChatMessage } from "core/util/messageContent"; import { IIdeMessenger } from "../../context/IdeMessenger"; -import { selectDefaultModel } from "../slices/configSlice"; +import { selectSelectedChatModel } from "../slices/configSlice"; import { deleteSessionMetadata, newSession, @@ -167,7 +167,7 @@ export const saveCurrentSession = createAsyncThunk< // Now save previous session and update chat title if relevant let title = state.session.title; if (title === NEW_SESSION_TITLE) { - const defaultModel = selectDefaultModel(state); + const defaultModel = selectSelectedChatModel(state); if (!state.config.config?.disableSessionTitles && defaultModel) { let assistantResponse = state.session.history ?.filter((h) => h.message.role === "assistant")[0] diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index afc80fbe4..47cccff2d 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -3,13 +3,13 @@ import { ChatMessage } from "core"; import { modelSupportsTools } from "core/llm/autodetect"; import { ToCoreProtocol } from "core/protocol"; import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall"; -import { selectDefaultModel } from "../slices/configSlice"; +import { selectSelectedChatModel } from "../slices/configSlice"; import { abortStream, addPromptCompletionPair, selectUseTools, setToolGenerated, - streamUpdate + streamUpdate, } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; import { callTool } from "./callTool"; @@ -29,7 +29,7 @@ export const streamNormalInput = createAsyncThunk< ) => { // Gather state const state = getState(); - const defaultModel = selectDefaultModel(state); + const defaultModel = selectSelectedChatModel(state); const toolSettings = state.ui.toolSettings; const toolGroupSettings = state.ui.toolGroupSettings; const streamAborter = state.session.streamAborter; diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts index 9b802ffbb..e7c013fca 100644 --- a/gui/src/redux/thunks/streamResponse.ts +++ b/gui/src/redux/thunks/streamResponse.ts @@ -4,7 +4,7 @@ import { InputModifiers } from "core"; import { constructMessages } from "core/llm/constructMessages"; import posthog from "posthog-js"; import { v4 as uuidv4 } from "uuid"; -import { selectDefaultModel } from "../slices/configSlice"; +import { selectSelectedChatModel } from "../slices/configSlice"; import { submitEditorAndInitAtIndex, updateHistoryItemAtIndex, @@ -34,7 +34,7 @@ export const streamResponseThunk = createAsyncThunk< await dispatch( streamThunkWrapper(async () => { const state = getState(); - const defaultModel = selectDefaultModel(state); + const defaultModel = selectSelectedChatModel(state); const slashCommands = state.config.config.slashCommands || []; const inputIndex = index ?? state.session.history.length; // Either given index or concat to end diff --git a/gui/src/redux/thunks/streamResponseAfterToolCall.ts b/gui/src/redux/thunks/streamResponseAfterToolCall.ts index 99554a628..8605d190d 100644 --- a/gui/src/redux/thunks/streamResponseAfterToolCall.ts +++ b/gui/src/redux/thunks/streamResponseAfterToolCall.ts @@ -2,7 +2,7 @@ import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit"; import { ChatMessage, ContextItem } from "core"; import { constructMessages } from "core/llm/constructMessages"; import { renderContextItems } from "core/util/messageContent"; -import { selectDefaultModel } from "../slices/configSlice"; +import { selectSelectedChatModel } from "../slices/configSlice"; import { addContextItemsAtIndex, setActive, @@ -27,7 +27,7 @@ export const streamResponseAfterToolCall = createAsyncThunk< streamThunkWrapper(async () => { const state = getState(); const initialHistory = state.session.history; - const defaultModel = selectDefaultModel(state); + const defaultModel = selectSelectedChatModel(state); if (!defaultModel) { throw new Error("No model selected"); From e179bb73deacdd688c5711236558800dfb003f83 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 17:56:56 -0700 Subject: [PATCH 23/43] Update AssistantSelect.tsx --- gui/src/components/modelSelection/platform/AssistantSelect.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 649cb2684..71a10547e 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -99,7 +99,7 @@ const AssistantSelectOption = ({ fontSize: tinyFont, }} > -
+
From ea753e98d42ff6ed785d992e0bc4f380840edbaf Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 17:58:43 -0700 Subject: [PATCH 24/43] remove stale code --- .../continue/IdeProtocolClient.kt | 11 ----------- extensions/vscode/src/extension/VsCodeMessenger.ts | 4 +--- 2 files changed, 1 insertion(+), 14 deletions(-) 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 5f4316f8e..5bdb31cd4 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 @@ -504,17 +504,6 @@ class IdeProtocolClient( applyCodeBlockModel = selectedModels?.get("chat") as? Map<*, *> } - // If neither "apply" nor "chat" models are available in selectedModelByRole, - // fallback to modelsByRole.chat[0] - if (applyCodeBlockModel == null) { - val modelsByRole = config["modelsByRole"] as? Map<*, *> - val chatModels = modelsByRole?.get("chat") as? List<*> - if (chatModels != null && chatModels.isNotEmpty()) { - applyCodeBlockModel = chatModels[0] as? Map<*, *> - } - } - - if (applyCodeBlockModel != null) { continuation.resume(applyCodeBlockModel) } else { diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 910b33c1f..898e6eac2 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -180,9 +180,7 @@ export class VsCodeMessenger { } let llm = - config.selectedModelByRole.apply ?? - config.selectedModelByRole.chat ?? - config.modelsByRole.chat[0]; + config.selectedModelByRole.apply ?? config.selectedModelByRole.chat; if (!llm) { vscode.window.showErrorMessage( From 5886841d886494b535d958e208e11d7474b5f005 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 8 Apr 2025 18:20:57 -0700 Subject: [PATCH 25/43] embed/rerank fixes --- core/config/load.ts | 3 ++ core/config/yaml/loadYaml.ts | 55 ++++++------------------------------ 2 files changed, 12 insertions(+), 46 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index 1a3acd6c6..38bba2e7d 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -423,6 +423,7 @@ async function intermediateToFinalConfig( if (!embedConfig) { return null; } + // config.ts-injected ILLM if ("providerName" in embedConfig) { return embedConfig; } @@ -464,6 +465,7 @@ async function intermediateToFinalConfig( if (!rerankingConfig) { return null; } + // config.ts-injected ILLM if ("providerName" in rerankingConfig) { return rerankingConfig; } @@ -488,6 +490,7 @@ async function intermediateToFinalConfig( }; return new rerankerClass(llmOptions, (url: string | URL, init: any) => fetchwithRequestOptions(url, init, { + ...config.requestOptions, ...params?.requestOptions, }), ); diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index f157bf21d..e5683e369 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -12,7 +12,6 @@ import { unrollAssistantFromContent, validateConfigYaml, } from "@continuedev/config-yaml"; -import { fetchwithRequestOptions } from "@continuedev/fetch"; import { ContinueConfig, @@ -22,14 +21,12 @@ import { IdeSettings, } from "../.."; import { slashFromCustomCommand } from "../../commands"; -import { AllRerankers } from "../../context/allRerankers"; import { MCPManagerSingleton } from "../../context/mcp"; import CodebaseContextProvider from "../../context/providers/CodebaseContextProvider"; import DocsContextProvider from "../../context/providers/DocsContextProvider"; import FileContextProvider from "../../context/providers/FileContextProvider"; import { contextProviderClassFromName } from "../../context/providers/index"; import { ControlPlaneClient } from "../../control-plane/client"; -import { allEmbeddingsProviders } from "../../indexing/allEmbeddingsProviders"; import FreeTrial from "../../llm/llms/FreeTrial"; import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider"; import { slashCommandFromPromptFileV1 } from "../../promptFiles/v1/slashCommandFromPromptFile"; @@ -247,58 +244,24 @@ async function configYamlToContinueConfig( if (model.roles?.includes("embed")) { const { provider, ...options } = model; - const embeddingsProviderClass = allEmbeddingsProviders[provider]; - if (embeddingsProviderClass) { - if ( - embeddingsProviderClass.name === "_TransformersJsEmbeddingsProvider" - ) { + if (provider === "transformers.js") { + if (ideInfo.ideType === "vscode") { continueConfig.modelsByRole.embed.push( - new embeddingsProviderClass(), + new TransformersJsEmbeddingsProvider(), ); } else { - continueConfig.modelsByRole.embed.push( - new embeddingsProviderClass( - { - ...options, - title: options.name, - }, - (url: string | URL, init: any) => - fetchwithRequestOptions(url, init, { - ...options.requestOptions, - }), - ), - ); + localErrors.push({ + fatal: false, + message: `Transformers.js embeddings provider not supported in this IDE.`, + }); } } else { - localErrors.push({ - fatal: false, - message: `Unsupported embeddings model provider found: ${provider}`, - }); + continueConfig.modelsByRole.embed.push(...llms); } } if (model.roles?.includes("rerank")) { - const { provider, ...options } = model; - const rerankerClass = AllRerankers[provider]; - if (rerankerClass) { - continueConfig.modelsByRole.rerank.push( - new rerankerClass( - { - ...options, - title: options.name, - }, - (url: string | URL, init: any) => - fetchwithRequestOptions(url, init, { - ...options.requestOptions, - }), - ), - ); - } else { - localErrors.push({ - fatal: false, - message: `Unsupported reranking model provider found: ${provider}`, - }); - } + continueConfig.modelsByRole.rerank.push(...llms); } } catch (e) { localErrors.push({ From eae1dd20bb296099db94175c43bf7af445e97200 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 18:47:29 -0700 Subject: [PATCH 26/43] feat: use thunj --- core/config/yaml/loadYaml.ts | 2 +- .../components/BestExperienceConfigForm.tsx | 15 +++-- .../tabs/OnboardingLocalTab.tsx | 16 ++--- .../mainInput/Lump/sections/ModelsSection.tsx | 24 +++----- .../components/modelSelection/ModelSelect.tsx | 45 +++++++++----- gui/src/forms/AddModelForm.tsx | 16 +++-- gui/src/redux/slices/configSlice.ts | 21 +------ gui/src/redux/thunks/index.ts | 1 + .../redux/thunks/updateSelectedModelByRole.ts | 58 +++++++++++++++++++ 9 files changed, 129 insertions(+), 69 deletions(-) create mode 100644 gui/src/redux/thunks/updateSelectedModelByRole.ts diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 1edb48604..1ad9fd2c6 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -157,7 +157,7 @@ async function configYamlToContinueConfig( summarize: [], }, selectedModelByRole: { - chat: null, // not currently used - defaultModel on GUI is used + chat: null, edit: null, // not currently used apply: null, embed: null, diff --git a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx index d05481dfb..d739a8434 100644 --- a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx +++ b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx @@ -1,11 +1,12 @@ import { CubeIcon } from "@heroicons/react/24/outline"; import { FormEventHandler, useContext, useState } from "react"; -import { useDispatch } from "react-redux"; import { Button, Input, InputSubtext, lightGray } from "../.."; +import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { models } from "../../../pages/AddNewModel/configs/models"; import { providers } from "../../../pages/AddNewModel/configs/providers"; -import { setSelectedChatModel } from "../../../redux/slices/configSlice"; +import { useAppDispatch } from "../../../redux/hooks"; +import { updateSelectedModelByRole } from "../../../redux/thunks"; import AddModelButtonSubtext from "../../AddModelButtonSubtext"; const { anthropic, mistral } = providers; @@ -25,7 +26,8 @@ interface BestExperienceConfigFormProps { function BestExperienceConfigForm({ onComplete, }: BestExperienceConfigFormProps) { - const dispatch = useDispatch(); + const dispatch = useAppDispatch(); + const { selectedProfile } = useAuth(); const ideMessenger = useContext(IdeMessengerContext); @@ -61,8 +63,13 @@ function BestExperienceConfigForm({ model: repoMapConfig, role: "repoMapFileSelection", }); + dispatch( - setSelectedChatModel({ title: chatModelConfig.title, force: true }), + updateSelectedModelByRole({ + selectedProfile, + role: "chat", + modelTitle: chatModelConfig.title, + }), ); if (!!autocompleteApiKey) { diff --git a/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx b/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx index 54f036118..0f1e05da0 100644 --- a/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx +++ b/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx @@ -6,11 +6,12 @@ import { LOCAL_ONBOARDING_PROVIDER_TITLE, } from "core/config/onboarding"; import { useContext, useEffect, useState } from "react"; -import { useDispatch } from "react-redux"; import { Button } from "../.."; +import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { setSelectedChatModel } from "../../../redux/slices/configSlice"; +import { useAppDispatch } from "../../../redux/hooks"; import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; +import { updateSelectedModelByRole } from "../../../redux/thunks"; import AddModelButtonSubtext from "../../AddModelButtonSubtext"; import OllamaModelDownload from "../components/OllamaModelDownload"; import { OllamaStatus } from "../components/OllamaStatus"; @@ -23,13 +24,14 @@ interface OnboardingLocalTabProps { } function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) { - const dispatch = useDispatch(); + const dispatch = useAppDispatch(); const ideMessenger = useContext(IdeMessengerContext); const { submitOnboarding } = useSubmitOnboarding("Local", isDialog); const [hasLoadedChatModel, setHasLoadedChatModel] = useState(false); const [downloadedOllamaModels, setDownloadedOllamaModels] = useState< string[] >([]); + const { selectedProfile } = useAuth(); const [isOllamaConnected, setIsOllamaConnected] = useState(false); @@ -135,11 +137,11 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) { dispatch(setShowDialog(false)); } - // Set the selected model to the local chat model dispatch( - setSelectedChatModel({ - title: LOCAL_ONBOARDING_CHAT_TITLE, - force: true, // Because it doesn't exist in the webview's config object yet + updateSelectedModelByRole({ + selectedProfile, + role: "chat", + modelTitle: LOCAL_ONBOARDING_CHAT_TITLE, }), ); }} diff --git a/gui/src/components/mainInput/Lump/sections/ModelsSection.tsx b/gui/src/components/mainInput/Lump/sections/ModelsSection.tsx index f6edc7400..b128db0a2 100644 --- a/gui/src/components/mainInput/Lump/sections/ModelsSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/ModelsSection.tsx @@ -1,41 +1,31 @@ import { ModelRole } from "@continuedev/config-yaml"; import { ModelDescription } from "core"; -import { useContext } from "react"; import { useAuth } from "../../../../context/Auth"; -import { IdeMessengerContext } from "../../../../context/IdeMessenger"; import ModelRoleSelector from "../../../../pages/config/ModelRoleSelector"; import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; -import { updateConfig } from "../../../../redux/slices/configSlice"; +import { updateSelectedModelByRole } from "../../../../redux/thunks"; import { isJetBrains } from "../../../../util"; import { ExploreBlocksButton } from "./ExploreBlocksButton"; export function ModelsSection() { const { selectedProfile } = useAuth(); const dispatch = useAppDispatch(); - const ideMessenger = useContext(IdeMessengerContext); const config = useAppSelector((state) => state.config.config); const jetbrains = isJetBrains(); function handleRoleUpdate(role: ModelRole, model: ModelDescription | null) { - if (!selectedProfile) { + if (!model) { return; } - // Optimistic update + dispatch( - updateConfig({ - ...config, - selectedModelByRole: { - ...config.selectedModelByRole, - [role]: model, - }, + updateSelectedModelByRole({ + role, + selectedProfile, + modelTitle: model.title, }), ); - ideMessenger.post("config/updateSelectedModel", { - profileId: selectedProfile.id, - role, - title: model?.title ?? null, - }); } return ( diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index a6e7756ac..a25fd210d 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -6,18 +6,15 @@ import { PlusIcon, } from "@heroicons/react/24/outline"; import { useContext, useEffect, useRef, useState } from "react"; -import { useDispatch } from "react-redux"; import styled from "styled-components"; import { defaultBorderRadius, lightGray } from ".."; import { useAuth } from "../../context/Auth"; import { IdeMessengerContext } from "../../context/IdeMessenger"; import AddModelForm from "../../forms/AddModelForm"; -import { useAppSelector } from "../../redux/hooks"; -import { - selectSelectedChatModel, - setSelectedChatModel, -} from "../../redux/slices/configSlice"; +import { useAppDispatch, useAppSelector } from "../../redux/hooks"; +import { selectSelectedChatModel } from "../../redux/slices/configSlice"; import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; +import { updateSelectedModelByRole } from "../../redux/thunks"; import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util"; import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from "../ui"; @@ -122,8 +119,8 @@ function ModelOption({ } function ModelSelect() { - const dispatch = useDispatch(); - const defaultModel = useAppSelector(selectSelectedChatModel); + const dispatch = useAppDispatch(); + const selectedChatModel = useAppSelector(selectSelectedChatModel); const allModels = useAppSelector((state) => state.config.config.models); const buttonRef = useRef(null); const [options, setOptions] = useState([]); @@ -157,14 +154,25 @@ function ModelSelect() { useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if (event.key === "'" && isMetaEquivalentKeyPressed(event as any)) { + if (!selectedProfile) { + return; + } + const direction = event.shiftKey ? -1 : 1; const currentIndex = options.findIndex( - (option) => option.value === defaultModel?.title, + (option) => option.value === selectedChatModel?.title, ); let nextIndex = (currentIndex + 1 * direction) % options.length; if (nextIndex < 0) nextIndex = options.length - 1; const newModelTitle = options[nextIndex].value; - dispatch(setSelectedChatModel({ title: newModelTitle })); + + dispatch( + updateSelectedModelByRole({ + selectedProfile, + role: "chat", + modelTitle: newModelTitle, + }), + ); } }; @@ -172,7 +180,7 @@ function ModelSelect() { return () => { window.removeEventListener("keydown", handleKeyDown); }; - }, [options, defaultModel]); + }, [options, selectedChatModel]); function onClickAddModel(e: MouseEvent) { e.stopPropagation(); @@ -195,11 +203,16 @@ function ModelSelect() { } return ( - // Hiad sfasdfasdf asdfasdf { - if (val === defaultModel?.title) return; - dispatch(setSelectedChatModel({ title: val })); + if (val === selectedChatModel?.title) return; + dispatch( + updateSelectedModelByRole({ + selectedProfile, + role: "chat", + modelTitle: val, + }), + ); }} >
@@ -209,7 +222,7 @@ function ModelSelect() { className="h-[18px] gap-1 border-none text-gray-400" > - {modelSelectTitle(defaultModel) || "Select model"} + {modelSelectTitle(selectedChatModel) || "Select model"} ))}
diff --git a/gui/src/forms/AddModelForm.tsx b/gui/src/forms/AddModelForm.tsx index 259d7c1d3..94a26adbc 100644 --- a/gui/src/forms/AddModelForm.tsx +++ b/gui/src/forms/AddModelForm.tsx @@ -1,11 +1,11 @@ import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline"; import { useContext, useEffect, useState } from "react"; import { FormProvider, useForm } from "react-hook-form"; -import { useDispatch } from "react-redux"; import { Button, Input, InputSubtext, StyledActionButton } from "../components"; import AddModelButtonSubtext from "../components/AddModelButtonSubtext"; import Alert from "../components/gui/Alert"; import ModelSelectionListbox from "../components/modelSelection/ModelSelectionListbox"; +import { useAuth } from "../context/Auth"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { completionParamsInputs } from "../pages/AddNewModel/configs/completionParamsInputs"; import { DisplayInfo } from "../pages/AddNewModel/configs/models"; @@ -13,7 +13,8 @@ import { ProviderInfo, providers, } from "../pages/AddNewModel/configs/providers"; -import { setSelectedChatModel } from "../redux/slices/configSlice"; +import { useAppDispatch } from "../redux/hooks"; +import { updateSelectedModelByRole } from "../redux/thunks"; import { FREE_TRIAL_LIMIT_REQUESTS, hasPassedFTL } from "../util/freeTrial"; interface QuickModelSetupProps { @@ -33,13 +34,14 @@ function AddModelForm({ const [selectedProvider, setSelectedProvider] = useState( providers["openai"]!, ); + const dispatch = useAppDispatch(); + const { selectedProfile } = useAuth(); const [selectedModel, setSelectedModel] = useState( selectedProvider.packages[0], ); const formMethods = useForm(); - const dispatch = useDispatch(); const ideMessenger = useContext(IdeMessengerContext); const popularProviderTitles = [ @@ -115,7 +117,13 @@ function AddModelForm({ profileId: "local", }); - dispatch(setSelectedChatModel({ title: model.title, force: true })); + dispatch( + updateSelectedModelByRole({ + selectedProfile, + role: "chat", + modelTitle: model.title, + }), + ); onDone(); } diff --git a/gui/src/redux/slices/configSlice.ts b/gui/src/redux/slices/configSlice.ts index c1528daa9..ca1856421 100644 --- a/gui/src/redux/slices/configSlice.ts +++ b/gui/src/redux/slices/configSlice.ts @@ -78,24 +78,6 @@ export const configSlice = createSlice({ ) => { state.config = config; }, - setSelectedChatModel: ( - state, - { payload }: PayloadAction<{ title: string; force?: boolean }>, - ) => { - const model = state.config.modelsByRole["chat"].find( - (model) => model.title === payload.title, - ); - - if (!model && !payload.force) return; - - state.config = { - ...state.config, - selectedModelByRole: { - ...state.config.selectedModelByRole, - chat: model ?? null, - }, - }; - }, }, selectors: { selectSelectedChatModelContextLength: (state): number => { @@ -113,8 +95,7 @@ export const configSlice = createSlice({ }, }); -export const { updateConfig, setConfigResult, setSelectedChatModel } = - configSlice.actions; +export const { updateConfig, setConfigResult } = configSlice.actions; export const { selectSelectedChatModelContextLength, diff --git a/gui/src/redux/thunks/index.ts b/gui/src/redux/thunks/index.ts index 59b556f8d..ad987fafa 100644 --- a/gui/src/redux/thunks/index.ts +++ b/gui/src/redux/thunks/index.ts @@ -5,3 +5,4 @@ export { streamNormalInput } from "./streamNormalInput"; export { streamResponseThunk } from "./streamResponse"; export { streamResponseAfterToolCall } from "./streamResponseAfterToolCall"; export { streamThunkWrapper } from "./streamThunkWrapper"; +export { updateSelectedModelByRole } from "./updateSelectedModelByRole"; diff --git a/gui/src/redux/thunks/updateSelectedModelByRole.ts b/gui/src/redux/thunks/updateSelectedModelByRole.ts new file mode 100644 index 000000000..8ad4f3df5 --- /dev/null +++ b/gui/src/redux/thunks/updateSelectedModelByRole.ts @@ -0,0 +1,58 @@ +import { ModelRole } from "@continuedev/config-yaml"; +import { createAsyncThunk } from "@reduxjs/toolkit"; +import { ProfileDescription } from "core/config/ProfileLifecycleManager"; +import { updateConfig } from "../slices/configSlice"; +import { ThunkApiType } from "../store"; + +export const updateSelectedModelByRole = createAsyncThunk< + void, + { + role: ModelRole; + modelTitle: string; + selectedProfile: ProfileDescription | null; + }, + ThunkApiType +>( + "config/updateSelectedModel", + async ( + { role, modelTitle, selectedProfile }, + { dispatch, extra, getState }, + ) => { + if (!selectedProfile) { + return; + } + + const state = getState(); + + const { + config: { config }, + } = state; + + const model = state.config.config.modelsByRole[role]?.find( + (m) => m.title === modelTitle, + ); + + if (!model) { + console.error( + `Model with title "${modelTitle}" not found for role "${role}"`, + ); + return; + } + + dispatch( + updateConfig({ + ...config, + selectedModelByRole: { + ...config.selectedModelByRole, + [role]: model, + }, + }), + ); + + extra.ideMessenger.post("config/updateSelectedModel", { + role, + profileId: selectedProfile.id, + title: modelTitle, + }); + }, +); From dcaf723d9561a1c8fd9f8151cf989e51d37c60f3 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 8 Apr 2025 19:12:00 -0700 Subject: [PATCH 27/43] updated rerank and embed logic --- core/config/load.ts | 88 +++++++++++-------------- core/config/yaml/loadYaml.ts | 2 +- core/context/allRerankers.ts | 21 ------ core/indexing/allEmbeddingsProviders.ts | 53 --------------- 4 files changed, 41 insertions(+), 123 deletions(-) delete mode 100644 core/context/allRerankers.ts delete mode 100644 core/indexing/allEmbeddingsProviders.ts diff --git a/core/config/load.ts b/core/config/load.ts index 38bba2e7d..58c12a5a9 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -8,7 +8,6 @@ import { ConfigValidationError, ModelRole, } from "@continuedev/config-yaml"; -import { fetchwithRequestOptions } from "@continuedev/fetch"; import * as JSONC from "comment-json"; import * as tar from "tar"; @@ -37,7 +36,6 @@ import { slashCommandFromDescription, slashFromCustomCommand, } from "../commands/index"; -import { AllRerankers } from "../context/allRerankers"; import { MCPManagerSingleton } from "../context/mcp"; import CodebaseContextProvider from "../context/providers/CodebaseContextProvider"; import ContinueProxyContextProvider from "../context/providers/ContinueProxyContextProvider"; @@ -45,9 +43,8 @@ import CustomContextProviderClass from "../context/providers/CustomContextProvid import FileContextProvider from "../context/providers/FileContextProvider"; import { contextProviderClassFromName } from "../context/providers/index"; import { useHub } from "../control-plane/env"; -import { allEmbeddingsProviders } from "../indexing/allEmbeddingsProviders"; import { BaseLLM } from "../llm"; -import { llmFromDescription } from "../llm/llms"; +import { LLMClasses, llmFromDescription } from "../llm/llms"; import CustomLLMClass from "../llm/llms/CustomLLM"; import FreeTrial from "../llm/llms/FreeTrial"; import { LLMReranker } from "../llm/llms/llm"; @@ -420,39 +417,32 @@ async function intermediateToFinalConfig( function getEmbeddingsILLM( embedConfig: EmbeddingsProviderDescription | ILLM | undefined, ): ILLM | null { - if (!embedConfig) { - return null; - } - // config.ts-injected ILLM - if ("providerName" in embedConfig) { - return embedConfig; - } - const { provider, ...options } = embedConfig; - const embeddingsProviderClass = allEmbeddingsProviders[provider]; - if (embeddingsProviderClass) { - if ( - embeddingsProviderClass.name === "_TransformersJsEmbeddingsProvider" - ) { - return new embeddingsProviderClass(); - } else { - const llmOptions: LLMOptions = { - model: options.model ?? "UNSPECIFIED", - ...options, - }; - return new embeddingsProviderClass( - llmOptions, - (url: string | URL, init: any) => - fetchwithRequestOptions(url, init, { - ...config.requestOptions, - ...options.requestOptions, - }), - ); + if (embedConfig) { + // config.ts-injected ILLM + if ("providerName" in embedConfig) { + return embedConfig; } - } else { - errors.push({ - fatal: false, - message: `Embeddings provider ${provider} not found. Using default`, - }); + const { provider, ...options } = embedConfig; + if (provider === "transformers.js") { + return new TransformersJsEmbeddingsProvider(); + } else { + const cls = LLMClasses.find((c) => c.providerName === provider); + if (cls) { + const llmOptions: LLMOptions = { + model: options.model ?? "UNSPECIFIED", + ...options, + }; + return new cls(llmOptions); + } else { + errors.push({ + fatal: false, + message: `Embeddings provider ${provider} not found`, + }); + } + } + } + if (ideInfo.ideType === "vscode") { + return new TransformersJsEmbeddingsProvider(); } return null; } @@ -470,7 +460,6 @@ async function intermediateToFinalConfig( 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); @@ -483,17 +472,20 @@ async function intermediateToFinalConfig( } else { return new LLMReranker(llm); } - } else if (rerankerClass) { - const llmOptions: LLMOptions = { - model: "rerank-2", - ...params, - }; - return new rerankerClass(llmOptions, (url: string | URL, init: any) => - fetchwithRequestOptions(url, init, { - ...config.requestOptions, - ...params?.requestOptions, - }), - ); + } else { + const cls = LLMClasses.find((c) => c.providerName === name); + if (cls) { + const llmOptions: LLMOptions = { + model: params?.model, + ...params, + }; + return new cls(llmOptions); + } else { + errors.push({ + fatal: false, + message: `Unknown reranking provider ${name}`, + }); + } } return null; } diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index e5683e369..23795e3ea 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -243,7 +243,7 @@ async function configYamlToContinueConfig( } if (model.roles?.includes("embed")) { - const { provider, ...options } = model; + const { provider } = model; if (provider === "transformers.js") { if (ideInfo.ideType === "vscode") { continueConfig.modelsByRole.embed.push( diff --git a/core/context/allRerankers.ts b/core/context/allRerankers.ts deleted file mode 100644 index e87cd06e3..000000000 --- a/core/context/allRerankers.ts +++ /dev/null @@ -1,21 +0,0 @@ -import Bedrock from "../llm/llms/Bedrock"; -import Cohere from "../llm/llms/Cohere"; -import FreeTrial from "../llm/llms/FreeTrial"; -import HuggingFaceTEI from "../llm/llms/HuggingFaceTEI"; -import { LLMReranker } from "../llm/llms/llm"; -import SiliconFlow from "../llm/llms/SiliconFlow"; -import ContinueProxy from "../llm/llms/stubs/ContinueProxy"; -import Voyage from "../llm/llms/Voyage"; -import WatsonX from "../llm/llms/WatsonX"; - -export const AllRerankers: { [key: string]: any } = { - cohere: Cohere, - bedrock: Bedrock, - llm: LLMReranker, - voyage: Voyage, - watsonx: WatsonX, - "free-trial": FreeTrial, - "huggingface-tei": HuggingFaceTEI, - "continue-proxy": ContinueProxy, - siliconflow: SiliconFlow, -}; diff --git a/core/indexing/allEmbeddingsProviders.ts b/core/indexing/allEmbeddingsProviders.ts deleted file mode 100644 index 3986fa2c0..000000000 --- a/core/indexing/allEmbeddingsProviders.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { ILLM } from "../index.js"; -import Bedrock from "../llm/llms/Bedrock.js"; -import Cohere from "../llm/llms/Cohere.js"; -import DeepInfra from "../llm/llms/DeepInfra.js"; -import FreeTrial from "../llm/llms/FreeTrial.js"; -import FunctionNetwork from "../llm/llms/FunctionNetwork.js"; -import Gemini from "../llm/llms/Gemini.js"; -import HuggingFaceTEIEmbeddingsProvider from "../llm/llms/HuggingFaceTEI.js"; -import LMStudio from "../llm/llms/LMStudio.js"; -import Mistral from "../llm/llms/Mistral.js"; -import NCompass from "../llm/llms/NCompass.js"; -import Nebius from "../llm/llms/Nebius.js"; -import Nvidia from "../llm/llms/Nvidia.js"; -import Ollama from "../llm/llms/Ollama.js"; -import OpenAI from "../llm/llms/OpenAI.js"; -import SageMaker from "../llm/llms/SageMaker.js"; -import Scaleway from "../llm/llms/Scaleway.js"; -import SiliconFlow from "../llm/llms/SiliconFlow.js"; -import ContinueProxy from "../llm/llms/stubs/ContinueProxy.js"; -import TransformersJsEmbeddingsProvider from "../llm/llms/TransformersJsEmbeddingsProvider.js"; -import VertexAI from "../llm/llms/VertexAI.js"; -import Voyage from "../llm/llms/Voyage.js"; -import WatsonX from "../llm/llms/WatsonX.js"; - -type EmbeddingsProviderConstructor = new (...args: any[]) => ILLM; - -export const allEmbeddingsProviders: Record< - string, - EmbeddingsProviderConstructor -> = { - sagemaker: SageMaker, - bedrock: Bedrock, - ollama: Ollama, - "transformers.js": TransformersJsEmbeddingsProvider, - openai: OpenAI, - cohere: Cohere, - "free-trial": FreeTrial, - "function-network": FunctionNetwork, - "huggingface-tei": HuggingFaceTEIEmbeddingsProvider, - gemini: Gemini, - "continue-proxy": ContinueProxy, - deepinfra: DeepInfra, - ncompass: NCompass, - nvidia: Nvidia, - voyage: Voyage, - mistral: Mistral, - nebius: Nebius, - vertexai: VertexAI, - watsonx: WatsonX, - lmstudio: LMStudio, - siliconflow: SiliconFlow, - scaleway: Scaleway, -}; From 7f8882eee136b90db9400175f9ee00fa1aa3ad93 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 19:28:48 -0700 Subject: [PATCH 28/43] feat: remove `models` property --- binary/test/binary.test.ts | 10 +-- core/config/ConfigHandler.test.ts | 4 +- core/config/ConfigHandler.ts | 27 -------- core/config/load.ts | 6 +- core/config/profile/doLoadConfig.ts | 2 +- core/config/selectedModels.ts | 2 +- core/config/util.ts | 2 +- core/config/yaml/loadYaml.ts | 16 ++--- .../providers/_context-providers.test.ts | 2 +- core/core.ts | 61 +++++++++++++++---- core/index.d.ts | 2 - core/llm/streamChat.ts | 13 ++-- .../OnboardingCard/OnboardingCard.tsx | 2 +- .../platform/PlatformOnboardingCard.tsx | 2 +- .../components/modelSelection/ModelSelect.tsx | 4 +- gui/src/hooks/useSetup.ts | 1 + gui/src/redux/slices/configSlice.ts | 1 - 17 files changed, 84 insertions(+), 73 deletions(-) diff --git a/binary/test/binary.test.ts b/binary/test/binary.test.ts index bd8504986..fb1be39bb 100644 --- a/binary/test/binary.test.ts +++ b/binary/test/binary.test.ts @@ -234,15 +234,17 @@ describe("Test Suite", () => { result: { config }, } = await messenger.request("config/getSerializedProfileInfo", undefined); - expect(config!.models.some((m) => m.title === model.title)).toBe(true); + expect(config!.modelsByRole.chat.some((m) => m.title === model.title)).toBe( + true, + ); await messenger.request("config/deleteModel", { title: model.title }); const { result: { config: configAfterDelete }, } = await messenger.request("config/getSerializedProfileInfo", undefined); - expect(configAfterDelete!.models.some((m) => m.title === model.title)).toBe( - false, - ); + expect( + configAfterDelete!.modelsByRole.chat.some((m) => m.title === model.title), + ).toBe(false); }); it("should make an LLM completion", async () => { diff --git a/core/config/ConfigHandler.test.ts b/core/config/ConfigHandler.test.ts index bf71952e9..4b4be0762 100644 --- a/core/config/ConfigHandler.test.ts +++ b/core/config/ConfigHandler.test.ts @@ -19,7 +19,9 @@ describe.skip("Test the ConfigHandler and E2E config loading", () => { test("should load the default config successfully", async () => { const result = await testConfigHandler.loadConfig(); - expect(result.config!.models.length).toBe(defaultConfig.models?.length); + expect(result.config!.modelsByRole.chat.length).toBe( + defaultConfig.models?.length, + ); }); test.skip("should add a system message from config.ts", async () => { diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 2d4a471d5..6fa6e4204 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -11,17 +11,11 @@ import { IContextProvider, IDE, IdeSettings, - ILLM, ILLMLogger, } from "../index.js"; -import Ollama from "../llm/llms/Ollama.js"; import { GlobalContext } from "../util/GlobalContext.js"; import { getAllAssistantFiles } from "./loadLocalAssistants.js"; -import { - LOCAL_ONBOARDING_CHAT_MODEL, - LOCAL_ONBOARDING_PROVIDER_TITLE, -} from "./onboarding.js"; import ControlPlaneProfileLoader from "./profile/ControlPlaneProfileLoader.js"; import LocalProfileLoader from "./profile/LocalProfileLoader.js"; import PlatformProfileLoader from "./profile/PlatformProfileLoader.js"; @@ -473,27 +467,6 @@ export class ConfigHandler { } } - // Only used till we move to using selectedModelByRole.chat - async llmFromTitle(title?: string): Promise { - const { config } = await this.loadConfig(); - const model = config?.models.find((m) => m.title === title); - if (!model) { - if (title === LOCAL_ONBOARDING_PROVIDER_TITLE) { - // Special case, make calls to Ollama before we have it in the config - const ollama = new Ollama({ - model: LOCAL_ONBOARDING_CHAT_MODEL, - }); - return ollama; - } else if (config?.models?.length) { - return config?.models[0]; - } - - throw new Error("No model found"); - } - - return model; - } - // Ancient method of adding custom providers through vs code private additionalContextProviders: IContextProvider[] = []; registerCustomContextProvider(contextProvider: IContextProvider) { diff --git a/core/config/load.ts b/core/config/load.ts index ed7164681..8575206ad 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -504,7 +504,6 @@ async function intermediateToFinalConfig( const continueConfig: ContinueConfig = { ...config, contextProviders, - models, tools: [...allTools], mcpServerStatuses: [], slashCommands: config.slashCommands ?? [], @@ -544,7 +543,7 @@ 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( + const match = continueConfig.modelsByRole.chat.find( (m) => m.title === inlineEditModel, ); if (match) { @@ -563,7 +562,7 @@ async function intermediateToFinalConfig( "applyCodeBlock", )?.title; if (applyBlockModel) { - const match = continueConfig.models.find( + const match = continueConfig.modelsByRole.chat.find( (m) => m.title === applyBlockModel, ); if (match) { @@ -617,7 +616,6 @@ async function finalToBrowserConfig( ): Promise { return { allowAnonymousTelemetry: final.allowAnonymousTelemetry, - models: final.models.map(llmToSerializedModelDescription), systemMessage: final.systemMessage, completionOptions: final.completionOptions, slashCommands: final.slashCommands?.map( diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index 626546b74..2957ca9d6 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -258,7 +258,7 @@ async function injectControlPlaneProxyInfo( } }); - config.models.forEach((model) => { + config.modelsByRole.chat.forEach((model) => { if (model.providerName === "continue-proxy") { (model as ContinueProxy).controlPlaneProxyInfo = info; } diff --git a/core/config/selectedModels.ts b/core/config/selectedModels.ts index 20dfb5063..42b966cf7 100644 --- a/core/config/selectedModels.ts +++ b/core/config/selectedModels.ts @@ -56,7 +56,7 @@ export function rectifySelectedModelsFromGlobalContext( role === "apply" && newModel?.getConfigurationStatus() !== LLMConfigurationStatuses.VALID ) { - break; + continue; } configCopy.selectedModelByRole[role] = newModel; diff --git a/core/config/util.ts b/core/config/util.ts index ee827c2f9..957e6c6ff 100644 --- a/core/config/util.ts +++ b/core/config/util.ts @@ -94,7 +94,7 @@ export function getModelByRole( return undefined; } - const matchingModel = config.models.find( + const matchingModel = config.modelsByRole.chat.find( (model) => model.title === roleTitle, ); diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 1ad9fd2c6..ff6fb8212 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -125,7 +125,6 @@ async function configYamlToContinueConfig( const localErrors: ConfigValidationError[] = []; const continueConfig: ContinueConfig = { slashCommands: [], - models: [], tools: [...allTools], mcpServerStatuses: [], systemMessage: undefined, @@ -222,10 +221,6 @@ async function configYamlToContinueConfig( config: continueConfig, }); - if (modelsArrayRoles.some((role) => model.roles?.includes(role))) { - continueConfig.models.push(...llms); - } - if (model.roles?.includes("chat")) { continueConfig.modelsByRole.chat.push(...llms); } @@ -323,7 +318,7 @@ async function configYamlToContinueConfig( if (allowFreeTrial) { // Obtain auth token (iff free trial being used) - const freeTrialModels = continueConfig.models.filter( + const freeTrialModels = continueConfig.modelsByRole.chat.filter( (model) => model.providerName === "free-trial", ); if (freeTrialModels.length > 0) { @@ -338,14 +333,15 @@ async function configYamlToContinueConfig( message: `Failed to obtain GitHub auth token for free trial:\n${e instanceof Error ? e.message : e}`, }); // Remove free trial models - continueConfig.models = continueConfig.models.filter( - (model) => model.providerName !== "free-trial", - ); + continueConfig.modelsByRole.chat = + continueConfig.modelsByRole.chat.filter( + (model) => model.providerName !== "free-trial", + ); } } } else { // Remove free trial models - continueConfig.models = continueConfig.models.filter( + continueConfig.modelsByRole.chat = continueConfig.modelsByRole.chat.filter( (model) => model.providerName !== "free-trial", ); } diff --git a/core/context/providers/_context-providers.test.ts b/core/context/providers/_context-providers.test.ts index d8eb90ef9..468aac6ec 100644 --- a/core/context/providers/_context-providers.test.ts +++ b/core/context/providers/_context-providers.test.ts @@ -45,7 +45,7 @@ async function getContextProviderExtras( config, embeddingsProvider: config.selectedModelByRole.embed, fetch: fetch, - llm: config.models[0], + llm: config.modelsByRole.chat[0], reranker: config.selectedModelByRole.rerank, selectedCode: [], }; diff --git a/core/core.ts b/core/core.ts index e929a863b..9bdf00750 100644 --- a/core/core.ts +++ b/core/core.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-lines-per-function */ import { fetchwithRequestOptions } from "@continuedev/fetch"; import * as URI from "uri-js"; import { v4 as uuidv4 } from "uuid"; @@ -60,7 +61,13 @@ async function* streamDiffLinesGenerator( msg: Message, ): AsyncGenerator { const data = msg.data; - const llm = await configHandler.llmFromTitle(msg.data.modelTitle); + const llm = (await configHandler.loadConfig()).config?.selectedModelByRole + .chat; + + if (!llm) { + throw new Error("No chat model selected"); + } + for await (const diffLine of streamDiffLines( data.prefix, data.highlighted, @@ -430,7 +437,13 @@ export class Core { ); on("llm/complete", async (msg) => { - const model = await this.configHandler.llmFromTitle(msg.data.title); + const model = (await this.configHandler.loadConfig()).config + ?.selectedModelByRole.chat; + + if (!model) { + throw new Error("No chat model selected"); + } + const completion = await model.complete( msg.data.prompt, new AbortController().signal, @@ -449,9 +462,13 @@ export class Core { }); on("chatDescriber/describe", async (msg) => { - const currentModel = await this.configHandler.llmFromTitle( - msg.data.selectedModelTitle, - ); + const currentModel = (await this.configHandler.loadConfig()).config + ?.selectedModelByRole.chat; + + if (!currentModel) { + throw new Error("No chat model selected"); + } + return await ChatDescriber.describe(currentModel, {}, msg.data.text); }); @@ -681,7 +698,12 @@ export class Core { throw new Error(`Tool ${toolCall.function.name} not found`); } - const llm = await this.configHandler.llmFromTitle(selectedModelTitle); + const llm = (await this.configHandler.loadConfig()).config + ?.selectedModelByRole.chat; + + if (!llm) { + throw new Error("No chat model selected"); + } const contextItems = await callTool( tool, @@ -711,7 +733,12 @@ export class Core { return false; } - const llm = await this.configHandler.llmFromTitle(selectedModelTitle); + const llm = (await this.configHandler.loadConfig()).config + ?.selectedModelByRole.chat; + + if (!llm) { + throw new Error("No chat model selected"); + } // Count the size of the file tokenwise const tokens = countTokens(item.content); @@ -789,8 +816,13 @@ export class Core { } const model = - config.models.find((model) => model.title === msg.data.title) ?? - config.models.find((model) => model.title?.startsWith(msg.data.title)); + config.modelsByRole.chat.find( + (model) => model.title === msg.data.title, + ) ?? + config.modelsByRole.chat.find((model) => + model.title?.startsWith(msg.data.title), + ); + try { if (model) { return await model.listModels(); @@ -854,10 +886,15 @@ export class Core { return []; } - const { name, query, fullInput, selectedCode, selectedModelTitle } = - msg.data; + const { name, query, fullInput, selectedCode } = msg.data; + + const llm = (await this.configHandler.loadConfig()).config + ?.selectedModelByRole.chat; + + if (!llm) { + throw new Error("No chat model selected"); + } - const llm = await this.configHandler.llmFromTitle(selectedModelTitle); const provider = config.contextProviders?.find( (provider) => provider.description.title === name, diff --git a/core/index.d.ts b/core/index.d.ts index d951da60d..f81f14262 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1393,7 +1393,6 @@ export interface Config { // in the actual Continue source code export interface ContinueConfig { allowAnonymousTelemetry?: boolean; - models: ILLM[]; systemMessage?: string; completionOptions?: BaseCompletionOptions; requestOptions?: RequestOptions; @@ -1417,7 +1416,6 @@ export interface ContinueConfig { export interface BrowserSerializedContinueConfig { allowAnonymousTelemetry?: boolean; - models: ModelDescription[]; systemMessage?: string; completionOptions?: BaseCompletionOptions; requestOptions?: RequestOptions; diff --git a/core/llm/streamChat.ts b/core/llm/streamChat.ts index 9b1ea87b3..223b5b20e 100644 --- a/core/llm/streamChat.ts +++ b/core/llm/streamChat.ts @@ -23,19 +23,22 @@ export async function* llmStreamChat( void TTS.kill(); } - const { title, legacySlashCommandData, completionOptions, messages } = - msg.data; + const { legacySlashCommandData, completionOptions, messages } = msg.data; - const model = await configHandler.llmFromTitle(title); + const model = config.selectedModelByRole.chat; + + if (!model) { + throw new Error("No chat model selected"); + } // Log to return in case of error const errorPromptLog = { - modelTitle: model.title ?? model.model, + modelTitle: model?.title ?? model?.model, completion: "", prompt: "", completionOptions: { ...msg.data.completionOptions, - model: model.model, + model: model?.model, }, }; diff --git a/gui/src/components/OnboardingCard/OnboardingCard.tsx b/gui/src/components/OnboardingCard/OnboardingCard.tsx index a4baa9a1e..aa8be2a29 100644 --- a/gui/src/components/OnboardingCard/OnboardingCard.tsx +++ b/gui/src/components/OnboardingCard/OnboardingCard.tsx @@ -37,7 +37,7 @@ export function OnboardingCard({ isDialog }: OnboardingCardProps) { return ( onboardingCard.close()} testId="onboarding-card" > diff --git a/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx b/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx index 4c0deda74..daa064ea2 100644 --- a/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx +++ b/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx @@ -28,7 +28,7 @@ export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) { return ( onboardingCard.close()} >
diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index a25fd210d..df0b5dc58 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -121,7 +121,9 @@ function ModelOption({ function ModelSelect() { const dispatch = useAppDispatch(); const selectedChatModel = useAppSelector(selectSelectedChatModel); - const allModels = useAppSelector((state) => state.config.config.models); + const allModels = useAppSelector( + (state) => state.config.config.modelsByRole.chat, + ); const buttonRef = useRef(null); const [options, setOptions] = useState([]); const [sortedOptions, setSortedOptions] = useState([]); diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index f840c49b4..67880839e 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -50,6 +50,7 @@ function useSetup() { organizations, selectedOrgId, } = result; + debugger; if (isInitial && hasDoneInitialConfigLoad.current) { return; } diff --git a/gui/src/redux/slices/configSlice.ts b/gui/src/redux/slices/configSlice.ts index ca1856421..9c33ec3ff 100644 --- a/gui/src/redux/slices/configSlice.ts +++ b/gui/src/redux/slices/configSlice.ts @@ -20,7 +20,6 @@ const EMPTY_CONFIG: BrowserSerializedContinueConfig = { }, ], contextProviders: [], - models: [], tools: [], mcpServerStatuses: [], usePlatform: true, From 045c6bdfec45ffadb25b3db2306b78f34780e84b Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 19:31:44 -0700 Subject: [PATCH 29/43] feat: model name update --- extensions/vscode/package-lock.json | 2 +- gui/src/components/modelSelection/ModelSelect.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index efc342f19..19b4e5384 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -106,7 +106,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.777.0", "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.71", + "@continuedev/config-yaml": "^1.0.77", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index df0b5dc58..aa84f9f33 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -121,7 +121,7 @@ function ModelOption({ function ModelSelect() { const dispatch = useAppDispatch(); const selectedChatModel = useAppSelector(selectSelectedChatModel); - const allModels = useAppSelector( + const allChatModels = useAppSelector( (state) => state.config.config.modelsByRole.chat, ); const buttonRef = useRef(null); @@ -141,7 +141,7 @@ function ModelSelect() { useEffect(() => { setOptions( - allModels + allChatModels .filter((m) => !m.roles || m.roles.includes("chat")) .map((model) => { return { @@ -151,7 +151,7 @@ function ModelSelect() { }; }), ); - }, [allModels]); + }, [allChatModels]); useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { From e76fda09759e3fdde4d53ebe72a6efae296e55b6 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 8 Apr 2025 20:00:49 -0700 Subject: [PATCH 30/43] add metadata to config-yaml --- packages/config-yaml/src/schemas/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index e941ec025..2b2ba0461 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -48,10 +48,20 @@ export const blockItemWrapperSchema = (schema: T) => export const blockOrSchema = (schema: T) => z.union([schema, blockItemWrapperSchema(schema)]); +export const commonMetadataSchema = z.object({ + tags: z.string().optional(), + sourceCodeUrl: z.string().optional(), + description: z.string().optional(), + author: z.string().optional(), + license: z.string().optional(), + iconUrl: z.string().optional(), +}); + export const baseConfigYamlSchema = z.object({ name: z.string(), version: z.string(), schema: z.string().optional(), + metadata: z.record(z.string()).and(commonMetadataSchema.partial()).optional(), }); export const configYamlSchema = baseConfigYamlSchema.extend({ From 96863db15ca71965f6c4784e8603155755a01921 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 21:35:45 -0700 Subject: [PATCH 31/43] remove default model title --- core/protocol/ideWebview.ts | 1 - core/protocol/passThrough.ts | 1 - .../constants/MessageTypes.kt | 1 - .../continue/CoreMessenger.kt | 15 ---- extensions/vscode/package-lock.json | 2 +- extensions/vscode/src/commands.ts | 21 +++-- .../vscode/src/diff/vertical/manager.ts | 15 ++-- .../vscode/src/extension/VsCodeMessenger.ts | 14 +++- .../src/quickEdit/ModelSelectionQuickPick.ts | 32 -------- .../src/quickEdit/QuickEditQuickPick.ts | 77 ++++--------------- .../vscode/src/test/test-suites/main.test.ts | 28 ------- .../StepContainerPreToolbar.tsx | 1 + gui/src/hooks/useSetup.ts | 14 ---- gui/src/pages/config/ModelRoleSelector.tsx | 12 ++- gui/src/pages/gui/Chat.tsx | 1 - manual-testing-sandbox/test.js | 1 - manual-testing-sandbox/test.kt | 1 + 17 files changed, 55 insertions(+), 182 deletions(-) delete mode 100644 extensions/vscode/src/quickEdit/ModelSelectionQuickPick.ts delete mode 100644 extensions/vscode/src/test/test-suites/main.test.ts diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 47c28680c..b477fcce9 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -51,7 +51,6 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { { prompt: MessageContent; range: RangeInFileWithContents; - selectedModelTitle: string; }, void, ]; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 9564f557d..1d854f948 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -68,7 +68,6 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] = [ "configUpdate", - "getDefaultModelTitle", "indexProgress", // Codebase "indexing/statusUpdate", // Docs, etc. "addContextItem", 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 5d17fbe6c..100ee2aad 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 @@ -60,7 +60,6 @@ class MessageTypes { // core/protocol/passThrough.ts val PASS_THROUGH_TO_WEBVIEW = listOf( "configUpdate", - "getDefaultModelTitle", "indexProgress", // Codebase "indexing/statusUpdate", // Docs, etc. "addContextItem", diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt index 4378d273d..cbcee8e98 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt @@ -65,21 +65,6 @@ class CoreMessenger( // Forward to webview if (MessageTypes.PASS_THROUGH_TO_WEBVIEW.contains(messageType)) { - // TODO: Currently we aren't set up to receive a response back from the webview - // Can circumvent for getDefaultsModelTitle here for now - if (messageType == "getDefaultModelTitle") { - val continueSettingsService = service() - val defaultModelTitle = continueSettingsService.continueState.lastSelectedInlineEditModel - val message = - gson.toJson( - mapOf( - "messageId" to messageId, - "messageType" to messageType, - "data" to defaultModelTitle - ) - ) - write(message) - } val continuePluginService = project.service() continuePluginService.sendToWebview(messageType, responseMap["data"], messageType) } diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 19b4e5384..efc342f19 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -106,7 +106,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.777.0", "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.77", + "@continuedev/config-yaml": "^1.0.71", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 9009d2b58..719c1a5d1 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -12,7 +12,10 @@ import { ConfigHandler } from "core/config/ConfigHandler"; import { ContinueServerClient } from "core/continueServer/stubs/client"; import { EXTENSION_NAME } from "core/control-plane/env"; import { Core } from "core/core"; +import { LOCAL_DEV_DATA_VERSION } from "core/data/log"; import { walkDirAsync } from "core/indexing/walkDir"; +import { isModelInstaller } from "core/llm"; +import { startLocalOllama } from "core/util/ollamaHelper"; import { getDevDataFilePath } from "core/util/paths"; import { Telemetry } from "core/util/posthog"; import readLastLines from "read-last-lines"; @@ -29,7 +32,6 @@ import { } from "./autocomplete/statusBar"; import { ContinueConsoleWebviewViewProvider } from "./ContinueConsoleWebviewViewProvider"; import { ContinueGUIWebviewViewProvider } from "./ContinueGUIWebviewViewProvider"; - import { VerticalDiffManager } from "./diff/vertical/manager"; import EditDecorationManager from "./quickEdit/EditDecorationManager"; import { QuickEdit, QuickEditShowParams } from "./quickEdit/QuickEditQuickPick"; @@ -37,9 +39,6 @@ import { Battery } from "./util/battery"; import { getMetaKeyLabel } from "./util/util"; import { VsCodeIde } from "./VsCodeIde"; -import { LOCAL_DEV_DATA_VERSION } from "core/data/log"; -import { isModelInstaller } from "core/llm"; -import { startLocalOllama } from "core/util/ollamaHelper"; import type { VsCodeWebviewProtocol } from "./webviewProtocol"; let fullScreenPanel: vscode.WebviewPanel | undefined; @@ -364,18 +363,18 @@ const getCommandsMap: ( throw new Error("Config not loaded"); } - const modelTitle = - config.selectedModelByRole.edit?.title ?? - (await sidebar.webviewProtocol.request( - "getDefaultModelTitle", - undefined, - )); + const llm = + config.selectedModelByRole.edit ?? config.selectedModelByRole.chat; + + if (!llm) { + throw new Error("No edit or chat model selected"); + } void sidebar.webviewProtocol.request("incrementFtc", undefined); await verticalDiffManager.streamEdit( config.experimental?.contextMenuPrompts?.[promptName] ?? fallbackPrompt, - modelTitle, + llm, undefined, onlyOneInsertion, undefined, diff --git a/extensions/vscode/src/diff/vertical/manager.ts b/extensions/vscode/src/diff/vertical/manager.ts index 4d4256a1f..48741a142 100644 --- a/extensions/vscode/src/diff/vertical/manager.ts +++ b/extensions/vscode/src/diff/vertical/manager.ts @@ -1,4 +1,4 @@ -import { ChatMessage, DiffLine } from "core"; +import { ChatMessage, DiffLine, ILLM } from "core"; import { ConfigHandler } from "core/config/ConfigHandler"; import { streamDiffLines } from "core/edit/streamDiffLines"; import { pruneLinesFromBottom, pruneLinesFromTop } from "core/llm/countTokens"; @@ -7,9 +7,9 @@ import * as URI from "uri-js"; import * as vscode from "vscode"; import EditDecorationManager from "../../quickEdit/EditDecorationManager"; +import { handleLLMError } from "../../util/errorHandling"; import { VsCodeWebviewProtocol } from "../../webviewProtocol"; -import { handleLLMError } from "../../util/errorHandling"; import { VerticalDiffHandler, VerticalDiffHandlerOptions } from "./handler"; export interface VerticalDiffCodeLens { @@ -272,7 +272,7 @@ export class VerticalDiffManager { async streamEdit( input: string, - modelTitle: string | undefined, + llm: ILLM, streamId?: string, onlyOneInsertion?: boolean, quickEdit?: string, @@ -308,13 +308,13 @@ export class VerticalDiffManager { // Previous diff was a quickEdit // Check if user has highlighted a range let rangeBool = - startLine != endLine || - editor.selection.start.character != editor.selection.end.character; + startLine !== endLine || + editor.selection.start.character !== editor.selection.end.character; // Check if the range is different from the previous range let newRangeBool = - startLine != existingHandler.range.start.line || - endLine != existingHandler.range.end.line; + startLine !== existingHandler.range.start.line || + endLine !== existingHandler.range.end.line; if (!rangeBool || !newRangeBool) { // User did not highlight a new range -> use start/end from the previous quickEdit @@ -374,7 +374,6 @@ export class VerticalDiffManager { ); } - const llm = await this.configHandler.llmFromTitle(modelTitle); const rangeContent = editor.document.getText(selectedRange); const prefix = pruneLinesFromTop( editor.document.getText( diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 898e6eac2..591c82454 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -223,7 +223,7 @@ export class VsCodeMessenger { await verticalDiffManager.streamEdit( prompt, - llm.title, + llm, data.streamId, undefined, undefined, @@ -286,9 +286,19 @@ export class VsCodeMessenger { const { start, end } = msg.data.range.range; const verticalDiffManager = await verticalDiffManagerPromise; + const configHandler = await configHandlerPromise; + const { config } = await configHandler.loadConfig(); + + const model = + config?.selectedModelByRole.edit ?? config?.selectedModelByRole.chat; + + if (!model) { + throw new Error("No Edit or Chat model selected"); + } + const fileAfterEdit = await verticalDiffManager.streamEdit( stripImages(prompt), - msg.data.selectedModelTitle, + model, "edit", undefined, undefined, diff --git a/extensions/vscode/src/quickEdit/ModelSelectionQuickPick.ts b/extensions/vscode/src/quickEdit/ModelSelectionQuickPick.ts deleted file mode 100644 index d46ed6d43..000000000 --- a/extensions/vscode/src/quickEdit/ModelSelectionQuickPick.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { ContinueConfig } from "core"; -import { QuickPickItem, window } from "vscode"; - -export async function getModelQuickPickVal( - curModelTitle: string, - config: ContinueConfig, -) { - const modelItems: QuickPickItem[] = config.models.map((model) => { - const isCurModel = curModelTitle === model.title; - - return { - label: model.title - ? `${isCurModel ? "$(check)" : " "} ${model.title}` - : "Model title not set", - }; - }); - - const selectedItem = await window.showQuickPick(modelItems, { - title: "Models", - placeHolder: "Select a model", - }); - - if (!selectedItem) { - return undefined; - } - - const selectedModelTitle = config.models.find( - (model) => model.title && selectedItem.label.includes(model.title), - )?.title; - - return selectedModelTitle; -} diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts index ec84eb81b..e0c826fb1 100644 --- a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { IDE } from "core"; +import { IDE, ILLM } from "core"; import { ConfigHandler } from "core/config/ConfigHandler"; +import { DataLogger } from "core/data/log"; import { Telemetry } from "core/util/posthog"; import * as vscode from "vscode"; @@ -8,10 +9,8 @@ import { VerticalDiffManager } from "../diff/vertical/manager"; import { FileSearch } from "../util/FileSearch"; import { VsCodeWebviewProtocol } from "../webviewProtocol"; -import { DataLogger } from "core/data/log"; import { getContextProviderQuickPickVal } from "./ContextProvidersQuickPick"; import { appendToHistory, getHistoryQuickPickVal } from "./HistoryQuickPick"; -import { getModelQuickPickVal } from "./ModelSelectionQuickPick"; // @ts-ignore - error finding typings // @ts-ignore @@ -23,7 +22,6 @@ import { getModelQuickPickVal } from "./ModelSelectionQuickPick"; enum QuickEditInitialItemLabels { History = "History", ContextProviders = "Context providers", - Model = "Model", Submit = "Submit", } @@ -100,11 +98,6 @@ export class QuickEdit { */ private contextProviderStr?: string; - /** - * Stores the current model title for potential changes - */ - private _curModelTitle?: string; - constructor( private readonly verticalDiffManager: VerticalDiffManager, private readonly configHandler: ConfigHandler, @@ -224,7 +217,7 @@ export class QuickEdit { default: break; } - let model = await this.getCurModelTitle(); + let model = await this.getCurModel(); void DataLogger.getInstance().logDevData({ name: "quickEdit", @@ -233,7 +226,7 @@ export class QuickEdit { path, label, diffs: this.verticalDiffManager.logDiffs, - model, + model: model?.title, }, }); @@ -245,12 +238,12 @@ export class QuickEdit { prompt: string, path: string | undefined, ) => { - const modelTitle = await this.getCurModelTitle(); - if (!modelTitle) { + const model = await this.getCurModel(); + if (!model) { throw new Error("No model selected"); } - await this._streamEditWithInputAndContext(prompt, modelTitle); + await this._streamEditWithInputAndContext(prompt, model); this.openAcceptRejectMenu(prompt, path); }; @@ -266,25 +259,13 @@ export class QuickEdit { /** * Gets the model title the user has chosen, or their default model */ - private async getCurModelTitle(): Promise { - if (this._curModelTitle) { - return this._curModelTitle; - } - + private async getCurModel(): Promise { const { config } = await this.configHandler.loadConfig(); if (!config) { - return undefined; + return null; } - return ( - config.selectedModelByRole.edit?.title ?? - (await this.webviewProtocol.request( - "getDefaultModelTitle", - undefined, - false, - )) ?? - config.models[0]?.title - ); + return config.selectedModelByRole.edit ?? config.selectedModelByRole.chat; } /** @@ -314,10 +295,7 @@ export class QuickEdit { }`; }; - private async _streamEditWithInputAndContext( - prompt: string, - modelTitle: string, - ) { + private async _streamEditWithInputAndContext(prompt: string, model: ILLM) { // Extracts all file references from the prompt string, // which are denoted by an '@' symbol followed by // one or more non-whitespace characters. @@ -343,7 +321,7 @@ export class QuickEdit { await this.verticalDiffManager.streamEdit( prompt, - modelTitle, + model, undefined, undefined, this.previousInput, @@ -351,7 +329,7 @@ export class QuickEdit { ); } - private getInitialItems(modelTitle: string): vscode.QuickPickItem[] { + private getInitialItems(): vscode.QuickPickItem[] { return [ { label: QuickEditInitialItemLabels.History, @@ -361,10 +339,6 @@ export class QuickEdit { label: QuickEditInitialItemLabels.ContextProviders, detail: "$(add) Add context to your prompt", }, - { - label: QuickEditInitialItemLabels.Model, - detail: `$(chevron-down) ${modelTitle}`, - }, ]; } @@ -372,7 +346,7 @@ export class QuickEdit { label: QuickEditInitialItemLabels | undefined; value: string | undefined; }> { - const modelTitle = await this.getCurModelTitle(); + const modelTitle = await this.getCurModel(); if (!modelTitle) { this.ide.showToast("error", "Please configure a model to use Quick Edit"); @@ -381,7 +355,7 @@ export class QuickEdit { const quickPick = vscode.window.createQuickPick(); - const initialItems = this.getInitialItems(modelTitle); + const initialItems = this.getInitialItems(); quickPick.items = initialItems; quickPick.placeholder = "Enter a prompt to edit your code (@ to search files, ⏎ to submit)"; @@ -552,27 +526,6 @@ export class QuickEdit { break; - case QuickEditInitialItemLabels.Model: - const curModelTitle = await this.getCurModelTitle(); - - if (!curModelTitle) { - break; - } - - const selectedModelTitle = await getModelQuickPickVal( - curModelTitle, - config, - ); - - if (selectedModelTitle) { - this._curModelTitle = selectedModelTitle; - } - - // Recurse back to let the user write their prompt - this.initiateNewQuickPick(editor, params); - - break; - case QuickEditInitialItemLabels.Submit: if (selectedValue) { prompt = selectedValue; diff --git a/extensions/vscode/src/test/test-suites/main.test.ts b/extensions/vscode/src/test/test-suites/main.test.ts deleted file mode 100644 index 2cd1945fa..000000000 --- a/extensions/vscode/src/test/test-suites/main.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import assert from "node:assert"; - -import { describe, test } from "mocha"; -import * as vscode from "vscode"; - -import { VsCodeExtension } from "../../extension/VsCodeExtension"; - -describe("Extension Test Suite", () => { - vscode.window.showInformationMessage("Start all tests."); - - // test("Make sure that nothing breaks after 10 seconds", async () => { - // await new Promise((resolve) => setTimeout(resolve, 10_000)); - // }); - - test("Get the default model from webview", async () => { - const continueExtensionApi = - vscode.extensions.getExtension("continue.continue"); - const extension: VsCodeExtension = continueExtensionApi?.exports.extension; - await new Promise((resolve) => setTimeout(resolve, 400)); - await vscode.commands.executeCommand("continue.focusContinueInput"); - await new Promise((resolve) => setTimeout(resolve, 400)); - const title = await ( - await extension.webviewProtocolPromise - ).request("getDefaultModelTitle", undefined); - assert.strictEqual(typeof title, "string"); - assert.strictEqual(title, "Test Model"); - }); -}); diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index ed4a7ea47..0571913b6 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -31,6 +31,7 @@ const TopDiv = styled.div` outline-offset: -0.5px; border-radius: ${defaultBorderRadius}; margin-bottom: 8px !important; + margin-top: 8px !important; background-color: ${vscEditorBackground}; min-width: 0; `; diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index 67880839e..3f65ecfa3 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -254,26 +254,12 @@ function useSetup() { dispatch(updateIndexingStatus(data)); }); - useWebviewListener( - "getDefaultModelTitle", - async () => { - return defaultModel?.title; - }, - [defaultModel], - ); - const activeToolStreamId = useAppSelector( (store) => store.session.activeToolStreamId, ); useWebviewListener( "updateApplyState", async (state) => { - // dispatch( - // updateCurCheckpoint({ - // filepath: state.filepath, - // content: state.fileContent, - // }), - // ); dispatch(updateApplyState(state)); if ( activeToolStreamId && diff --git a/gui/src/pages/config/ModelRoleSelector.tsx b/gui/src/pages/config/ModelRoleSelector.tsx index c6d2e5a98..e3464a6f2 100644 --- a/gui/src/pages/config/ModelRoleSelector.tsx +++ b/gui/src/pages/config/ModelRoleSelector.tsx @@ -83,10 +83,14 @@ const ModelRoleSelector = ({ disabled={models.length === 0} className={`bg-vsc-editor-background hover:bg-list-active hover:text-list-active-foreground w-full justify-between`} > - {models.length === 0 ? ( - {`No ${displayName} models${["Chat", "Apply", "Edit"].includes(displayName) ? ". Using chat model" : ""}`} - ) : noConfiguredModels ? ( - {`No valid ${displayName} models${["Chat", "Apply", "Edit"].includes(displayName) ? ". Using chat model" : ""}`} + {models.length === 0 || noConfiguredModels ? ( + + {`No ${models.length === 0 ? "" : "valid "}${displayName} models${ + ["Chat", "Apply", "Edit"].includes(displayName) + ? ". Using Chat model" + : "" + }`} + ) : ( {selectedModel?.title ?? `Select ${displayName} model`} diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index ec195d9c9..b6fa33ee8 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -259,7 +259,6 @@ export function Chat() { ideMessenger.post("edit/sendPrompt", { prompt, range: codeToEdit[0] as RangeInFileWithContents, - selectedModelTitle: defaultModel.title, }); dispatch(submitEdit(prompt)); diff --git a/manual-testing-sandbox/test.js b/manual-testing-sandbox/test.js index 44c55402e..eee0aa7c5 100644 --- a/manual-testing-sandbox/test.js +++ b/manual-testing-sandbox/test.js @@ -9,7 +9,6 @@ class Calculator { } subtract(number) { - this.result -= number; return this; } diff --git a/manual-testing-sandbox/test.kt b/manual-testing-sandbox/test.kt index 683993e81..bb13ae9ee 100644 --- a/manual-testing-sandbox/test.kt +++ b/manual-testing-sandbox/test.kt @@ -30,3 +30,4 @@ class Test { return this } } + From ab0e6b22ef73a9147d9c45572f3936b7cd527480 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 21:42:02 -0700 Subject: [PATCH 32/43] Update ContextProvidersQuickPick.ts --- extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts b/extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts index 074ec4d86..684508a7f 100644 --- a/extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts +++ b/extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts @@ -43,7 +43,7 @@ export async function getContextProvidersString( ide, embeddingsProvider: config.selectedModelByRole.embed, reranker: config.selectedModelByRole.rerank, - llm: config.models[0], + llm: config.selectedModelByRole.chat, fullInput: "", selectedCode: [], fetch: (url, init) => From ae72f3a29358d8e6a4dbd90a99bfd7ab3b2efe5d Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 21:54:34 -0700 Subject: [PATCH 33/43] remove eslint disable for max line error --- core/core.ts | 70 +++++++++---------- gui/src/redux/thunks/callTool.ts | 3 +- gui/src/redux/thunks/gatherContext.ts | 3 +- gui/src/redux/thunks/session.ts | 3 +- gui/src/redux/thunks/streamNormalInput.ts | 3 +- gui/src/redux/thunks/streamResponse.ts | 3 +- .../thunks/streamResponseAfterToolCall.ts | 2 +- 7 files changed, 45 insertions(+), 42 deletions(-) diff --git a/core/core.ts b/core/core.ts index 9bdf00750..68aa605ac 100644 --- a/core/core.ts +++ b/core/core.ts @@ -1,4 +1,3 @@ -/* eslint-disable max-lines-per-function */ import { fetchwithRequestOptions } from "@continuedev/fetch"; import * as URI from "uri-js"; import { v4 as uuidv4 } from "uuid"; @@ -33,6 +32,7 @@ import { TTS } from "./util/tts"; import { DiffLine, IdeSettings, + ModelDescription, RangeInFile, type ContextItemId, type IDE, @@ -494,32 +494,7 @@ export class Core { on("completeOnboarding", this.handleCompleteOnboarding); - on("addAutocompleteModel", (msg) => { - const model = msg.data.model; - editConfigFile( - (config) => { - return { - ...config, - tabAutocompleteModel: model, - }; - }, - (config) => ({ - ...config, - models: [ - ...(config.models ?? []), - { - name: model.title, - provider: model.provider, - model: model.model, - apiKey: model.apiKey, - roles: ["autocomplete"], - apiBase: model.apiBase, - }, - ], - }), - ); - void this.configHandler.reloadConfig(); - }); + on("addAutocompleteModel", this.handleAddAutocompleteModel); on("stats/getTokensPerDay", async (msg) => { const rows = await DevDataSqliteDb.getTokensPerDay(); @@ -530,7 +505,6 @@ export class Core { return rows; }); - // Codebase indexing on("index/forceReIndex", async ({ data }) => { const { config } = await this.configHandler.loadConfig(); if (!config || config.disableIndexing) { @@ -616,11 +590,7 @@ export class Core { } }); - on("files/opened", async ({ data }) => { - if (data?.uris?.length) { - // Do something on files opened - } - }); + on("files/opened", async () => {}); // Docs, etc. indexing on("indexing/reindex", async (msg) => { @@ -635,7 +605,6 @@ export class Core { }); on("indexing/setPaused", async (msg) => { if (msg.data.type === "docs") { - // this.docsService.setPaused(msg.data.id, msg.data.paused); // not supported yet } }); on("docs/initStatuses", async (msg) => { @@ -740,10 +709,8 @@ export class Core { throw new Error("No chat model selected"); } - // Count the size of the file tokenwise const tokens = countTokens(item.content); - // File exceeds context length of the model if (tokens > llm.contextLength - llm.completionOptions!.maxTokens!) { return true; } @@ -752,6 +719,37 @@ export class Core { }); } + private handleAddAutocompleteModel( + msg: Message<{ + model: ModelDescription; + }>, + ) { + const model = msg.data.model; + editConfigFile( + (config) => { + return { + ...config, + tabAutocompleteModel: model, + }; + }, + (config) => ({ + ...config, + models: [ + ...(config.models ?? []), + { + name: model.title, + provider: model.provider, + model: model.model, + apiKey: model.apiKey, + roles: ["autocomplete"], + apiBase: model.apiBase, + }, + ], + }), + ); + void this.configHandler.reloadConfig(); + } + private async handleFilesChanged({ data, }: Message<{ diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 04d49007f..31e67b6d3 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -30,7 +30,8 @@ export const callTool = createAsyncThunk( return; } - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); + if (!defaultModel) { throw new Error("No model selected"); } diff --git a/gui/src/redux/thunks/gatherContext.ts b/gui/src/redux/thunks/gatherContext.ts index e810e1025..abc547c41 100644 --- a/gui/src/redux/thunks/gatherContext.ts +++ b/gui/src/redux/thunks/gatherContext.ts @@ -37,7 +37,8 @@ export const gatherContext = createAsyncThunk< { dispatch, extra, getState }, ) => { const state = getState(); - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); + const defaultContextProviders = state.config.config.experimental?.defaultContext ?? []; diff --git a/gui/src/redux/thunks/session.ts b/gui/src/redux/thunks/session.ts index 413c3c678..f5d40c4d4 100644 --- a/gui/src/redux/thunks/session.ts +++ b/gui/src/redux/thunks/session.ts @@ -167,7 +167,8 @@ export const saveCurrentSession = createAsyncThunk< // Now save previous session and update chat title if relevant let title = state.session.title; if (title === NEW_SESSION_TITLE) { - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); + if (!state.config.config?.disableSessionTitles && defaultModel) { let assistantResponse = state.session.history ?.filter((h) => h.message.role === "assistant")[0] diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 47cccff2d..507382d3f 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -29,7 +29,8 @@ export const streamNormalInput = createAsyncThunk< ) => { // Gather state const state = getState(); - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); + const toolSettings = state.ui.toolSettings; const toolGroupSettings = state.ui.toolGroupSettings; const streamAborter = state.session.streamAborter; diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts index e7c013fca..b6c806a2e 100644 --- a/gui/src/redux/thunks/streamResponse.ts +++ b/gui/src/redux/thunks/streamResponse.ts @@ -34,7 +34,8 @@ export const streamResponseThunk = createAsyncThunk< await dispatch( streamThunkWrapper(async () => { const state = getState(); - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); + const slashCommands = state.config.config.slashCommands || []; const inputIndex = index ?? state.session.history.length; // Either given index or concat to end diff --git a/gui/src/redux/thunks/streamResponseAfterToolCall.ts b/gui/src/redux/thunks/streamResponseAfterToolCall.ts index 8605d190d..cb0de2756 100644 --- a/gui/src/redux/thunks/streamResponseAfterToolCall.ts +++ b/gui/src/redux/thunks/streamResponseAfterToolCall.ts @@ -27,7 +27,7 @@ export const streamResponseAfterToolCall = createAsyncThunk< streamThunkWrapper(async () => { const state = getState(); const initialHistory = state.session.history; - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); if (!defaultModel) { throw new Error("No model selected"); From fe97190e40b04c7b08bcd8775957e2dc880c20ef Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 22:00:54 -0700 Subject: [PATCH 34/43] fix linting errors --- .../StepContainerPreToolbar.tsx | 4 ++-- gui/src/pages/gui/Chat.tsx | 10 +++++----- gui/src/redux/thunks/callTool.ts | 4 ++-- gui/src/redux/thunks/gatherContext.ts | 2 +- gui/src/redux/thunks/streamNormalInput.ts | 4 ++-- gui/src/redux/thunks/streamResponse.ts | 4 +--- gui/src/redux/thunks/streamResponseAfterToolCall.ts | 2 +- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index 0571913b6..c00290e4c 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -82,10 +82,10 @@ export default function StepContainerPreToolbar( const isNextCodeBlock = nextCodeBlockIndex === props.codeBlockIndex; const hasFileExtension = /\.[0-9a-z]+$/i.test(props.relativeFilepath); - const defaultModel = useAppSelector(selectSelectedChatModel); + const selectedChatModel = useAppSelector(selectSelectedChatModel); async function onClickApply() { - if (!defaultModel) { + if (!selectedChatModel) { return; } diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index b6fa33ee8..0ffd577c1 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -105,7 +105,7 @@ export function Chat() { const showSessionTabs = useAppSelector( (store) => store.config.config.ui?.showSessionTabs, ); - const defaultModel = useAppSelector(selectSelectedChatModel); + const selectedChatModel = useAppSelector(selectSelectedChatModel); const isStreaming = useAppSelector((state) => state.session.isStreaming); const [stepsOpen, setStepsOpen] = useState<(boolean | undefined)[]>([]); const mainTextInputRef = useRef(null); @@ -165,7 +165,7 @@ export function Chat() { "Cannot submit message while awaiting tool confirmation", ); } - if (defaultModel?.provider === "free-trial") { + if (selectedChatModel?.provider === "free-trial") { const newCount = incrementFreeTrialCount(); if (newCount === FREE_TRIAL_LIMIT_REQUESTS) { @@ -224,7 +224,7 @@ export function Chat() { }, [ history, - defaultModel, + selectedChatModel, streamResponse, isSingleRangeEditOrInsertion, codeToEdit, @@ -233,7 +233,7 @@ export function Chat() { ); async function handleSingleRangeEditOrInsertion(editorState: JSONContent) { - if (!defaultModel) { + if (!selectedChatModel) { console.error("No selected chat model"); return; } @@ -248,7 +248,7 @@ export function Chat() { defaultContextProviders: [], availableSlashCommands: [], dispatch, - selectedModelTitle: defaultModel.title, + selectedModelTitle: selectedChatModel.title, }); const prompt = [ diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 31e67b6d3..cb875f805 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -32,7 +32,7 @@ export const callTool = createAsyncThunk( const selectedChatModel = selectSelectedChatModel(state); - if (!defaultModel) { + if (!selectedChatModel) { throw new Error("No model selected"); } @@ -77,7 +77,7 @@ export const callTool = createAsyncThunk( } else { const result = await extra.ideMessenger.request("tools/call", { toolCall: toolCallState.toolCall, - selectedModelTitle: defaultModel.title, + selectedModelTitle: selectedChatModel.title, }); if (result.status === "error") { errorMessage = result.error; diff --git a/gui/src/redux/thunks/gatherContext.ts b/gui/src/redux/thunks/gatherContext.ts index abc547c41..927866ed8 100644 --- a/gui/src/redux/thunks/gatherContext.ts +++ b/gui/src/redux/thunks/gatherContext.ts @@ -42,7 +42,7 @@ export const gatherContext = createAsyncThunk< const defaultContextProviders = state.config.config.experimental?.defaultContext ?? []; - if (!defaultModel) { + if (!selectedChatModel) { console.error( "gatherContext thunk: Cannot gather context, no model selected", ); diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 507382d3f..447ac3d3d 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -35,10 +35,10 @@ export const streamNormalInput = createAsyncThunk< const toolGroupSettings = state.ui.toolGroupSettings; const streamAborter = state.session.streamAborter; const useTools = selectUseTools(state); - if (!defaultModel) { + if (!selectedChatModel) { throw new Error("Default model not defined"); } - const includeTools = useTools && modelSupportsTools(defaultModel); + const includeTools = useTools && modelSupportsTools(selectedChatModel); // Send request const gen = extra.ideMessenger.llmStreamChat( diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts index b6c806a2e..e79bcdf85 100644 --- a/gui/src/redux/thunks/streamResponse.ts +++ b/gui/src/redux/thunks/streamResponse.ts @@ -35,11 +35,9 @@ export const streamResponseThunk = createAsyncThunk< streamThunkWrapper(async () => { const state = getState(); const selectedChatModel = selectSelectedChatModel(state); - - const slashCommands = state.config.config.slashCommands || []; const inputIndex = index ?? state.session.history.length; // Either given index or concat to end - if (!defaultModel) { + if (!selectedChatModel) { throw new Error("No chat model selected"); } diff --git a/gui/src/redux/thunks/streamResponseAfterToolCall.ts b/gui/src/redux/thunks/streamResponseAfterToolCall.ts index cb0de2756..3fa335d8b 100644 --- a/gui/src/redux/thunks/streamResponseAfterToolCall.ts +++ b/gui/src/redux/thunks/streamResponseAfterToolCall.ts @@ -29,7 +29,7 @@ export const streamResponseAfterToolCall = createAsyncThunk< const initialHistory = state.session.history; const selectedChatModel = selectSelectedChatModel(state); - if (!defaultModel) { + if (!selectedChatModel) { throw new Error("No model selected"); } From 70c6a0a42382aa0e9c794ba698e1baa439da5153 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 22:06:34 -0700 Subject: [PATCH 35/43] linting --- gui/src/redux/thunks/gatherContext.ts | 6 +++--- gui/src/redux/thunks/session.ts | 4 ++-- gui/src/redux/thunks/streamNormalInput.ts | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gui/src/redux/thunks/gatherContext.ts b/gui/src/redux/thunks/gatherContext.ts index 927866ed8..2ba244d3f 100644 --- a/gui/src/redux/thunks/gatherContext.ts +++ b/gui/src/redux/thunks/gatherContext.ts @@ -58,12 +58,12 @@ export const gatherContext = createAsyncThunk< defaultContextProviders, availableSlashCommands: state.config.config.slashCommands, dispatch, - selectedModelTitle: defaultModel.title, + selectedModelTitle: selectedChatModel.title, }); // Automatically use currently open file if (!modifiers.noContext) { - const usingFreeTrial = defaultModel.provider === "free-trial"; + const usingFreeTrial = selectedChatModel.provider === "free-trial"; const currentFileResponse = await extra.ideMessenger.request( "context/getContextItems", @@ -72,7 +72,7 @@ export const gatherContext = createAsyncThunk< query: "non-mention-usage", fullInput: "", selectedCode: [], - selectedModelTitle: defaultModel.title, + selectedModelTitle: selectedChatModel.title, }, ); if (currentFileResponse.status === "success") { diff --git a/gui/src/redux/thunks/session.ts b/gui/src/redux/thunks/session.ts index f5d40c4d4..7572b1fe4 100644 --- a/gui/src/redux/thunks/session.ts +++ b/gui/src/redux/thunks/session.ts @@ -169,7 +169,7 @@ export const saveCurrentSession = createAsyncThunk< if (title === NEW_SESSION_TITLE) { const selectedChatModel = selectSelectedChatModel(state); - if (!state.config.config?.disableSessionTitles && defaultModel) { + if (!state.config.config?.disableSessionTitles && selectedChatModel) { let assistantResponse = state.session.history ?.filter((h) => h.message.role === "assistant")[0] ?.message?.content?.toString(); @@ -180,7 +180,7 @@ export const saveCurrentSession = createAsyncThunk< "chatDescriber/describe", { text: assistantResponse, - selectedModelTitle: defaultModel.title, + selectedModelTitle: selectedChatModel.title, }, ); if (result.status === "success" && result.content) { diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 447ac3d3d..c8b10dc37 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -52,7 +52,7 @@ export const streamNormalInput = createAsyncThunk< ), } : {}, - title: defaultModel.title, + title: selectedChatModel.title, messages, legacySlashCommandData, }, @@ -82,8 +82,8 @@ export const streamNormalInput = createAsyncThunk< data: { prompt: next.value.prompt, completion: next.value.completion, - modelProvider: defaultModel.provider, - modelTitle: defaultModel.title, + modelProvider: selectedChatModel.provider, + modelTitle: selectedChatModel.title, sessionId: state.session.id, }, }); @@ -94,8 +94,8 @@ export const streamNormalInput = createAsyncThunk< // data: { // prompt: next.value.prompt, // completion: next.value.completion, - // modelProvider: defaultModel.provider, - // modelTitle: defaultModel.title, + // modelProvider: selectedChatModel.provider, + // modelTitle: selectedChatModel.title, // }, // }); // } From 71ec4518995bdce0b516891efe64e32fa369aedd Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Apr 2025 22:11:30 -0700 Subject: [PATCH 36/43] Update ContextProvidersQuickPick.ts --- extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts b/extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts index 684508a7f..f982c5c55 100644 --- a/extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts +++ b/extensions/vscode/src/quickEdit/ContextProvidersQuickPick.ts @@ -34,7 +34,7 @@ export async function getContextProvidersString( provider.description.displayTitle === selectedProvider.label, ); - if (!provider) { + if (!provider || !config.selectedModelByRole.chat) { return []; } From 654c15aa0105e9ddc1467c6ef9bca02c2d8b7546 Mon Sep 17 00:00:00 2001 From: "Brett C." <32656963+breca@users.noreply.github.com> Date: Wed, 9 Apr 2025 21:44:58 +1000 Subject: [PATCH 37/43] docs: adds missing key in yaml migration example This merge adds a missing key to the YAML migration example doc. --- docs/docs/yaml-migration.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs/yaml-migration.md b/docs/docs/yaml-migration.md index 82df8edd2..c07f99c18 100644 --- a/docs/docs/yaml-migration.md +++ b/docs/docs/yaml-migration.md @@ -114,6 +114,7 @@ models: - name: My Voyage Reranker provider: voyage apiKey: + roles: - rerank - name: My Starcoder From 12de49cd33dee8f7a7a33a64b88fb00903a1a537 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Wed, 9 Apr 2025 17:44:56 +0530 Subject: [PATCH 38/43] use concurrently in npm script --- package-lock.json | 234 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 7 +- 2 files changed, 229 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index cdfb21273..06f811afa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,6 +6,7 @@ "": { "devDependencies": { "@typescript-eslint/parser": "^7.8.0", + "concurrently": "^9.1.2", "eslint-plugin-import": "^2.29.1", "prettier": "^3.3.3", "prettier-plugin-tailwindcss": "^0.6.8", @@ -360,7 +361,6 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, - "peer": true, "engines": { "node": ">=8" } @@ -370,7 +370,6 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -587,7 +586,6 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -599,12 +597,26 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -616,8 +628,7 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "peer": true + "dev": true }, "node_modules/concat-map": { "version": "0.0.1", @@ -625,6 +636,48 @@ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, + "node_modules/concurrently": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.1.2.tgz", + "integrity": "sha512-H9MWcoPsYddwbOGM6difjVwVZHl63nwMEwDJG/L7VGtuaJhb12h2caPG2tVPWs7emuYix252iGfqOyrz1GczTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.2", + "lodash": "^4.17.21", + "rxjs": "^7.8.1", + "shell-quote": "^1.8.1", + "supports-color": "^8.1.1", + "tree-kill": "^1.2.2", + "yargs": "^17.7.2" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -775,6 +828,13 @@ "node": ">=6.0.0" } }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, "node_modules/es-abstract": { "version": "1.23.3", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz", @@ -908,6 +968,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -1399,6 +1469,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, "node_modules/get-intrinsic": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", @@ -1579,7 +1659,6 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, - "peer": true, "engines": { "node": ">=8" } @@ -1826,6 +1905,16 @@ "node": ">=0.10.0" } }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -2071,6 +2160,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -2515,6 +2611,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/resolve": { "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", @@ -2592,6 +2698,16 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/rxjs": { + "version": "7.8.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, "node_modules/safe-array-concat": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.2.tgz", @@ -2694,6 +2810,19 @@ "node": ">=8" } }, + "node_modules/shell-quote": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.2.tgz", + "integrity": "sha512-AzqKpGKjrj7EM6rKVQEPpB288oCfnrEIuyoT9cyF4nmGa7V8Zk6f7RRqYisX8X9m+Q7bd632aZW4ky7EhbQztA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/side-channel": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", @@ -2721,6 +2850,21 @@ "node": ">=8" } }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/string.prototype.trim": { "version": "1.2.9", "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.9.tgz", @@ -2775,7 +2919,6 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, - "peer": true, "dependencies": { "ansi-regex": "^5.0.1" }, @@ -2810,7 +2953,6 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -2849,6 +2991,16 @@ "node": ">=8.0" } }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "license": "MIT", + "bin": { + "tree-kill": "cli.js" + } + }, "node_modules/ts-api-utils": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", @@ -2873,6 +3025,13 @@ "strip-bom": "^3.0.0" } }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD" + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -3071,6 +3230,24 @@ "node": ">=0.10.0" } }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -3078,6 +3255,45 @@ "dev": true, "peer": true }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index dd376f1ec..01270032f 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,17 @@ { "scripts": { - "tsc:watch": "npx concurrently -n gui,vscode,core,binary -c cyan,magenta,yellow,green \"npm run tsc:watch:gui\" \"npm run tsc:watch:vscode\" \"npm run tsc:watch:core\" \"npm run tsc:watch:binary\"", + "tsc:watch": "concurrently -n gui,vscode,core,binary -c cyan,magenta,yellow,green \"npm run tsc:watch:gui\" \"npm run tsc:watch:vscode\" \"npm run tsc:watch:core\" \"npm run tsc:watch:binary\"", "tsc:watch:gui": "tsc --project gui/tsconfig.json --watch --noEmit --pretty", "tsc:watch:vscode": "tsc --project extensions/vscode/tsconfig.json --watch --noEmit --pretty", "tsc:watch:core": "tsc --project core/tsconfig.json --watch --noEmit --pretty", "tsc:watch:binary": "tsc --project binary/tsconfig.json --watch --noEmit --pretty" }, "devDependencies": { - "typescript": "^5.6.3", "@typescript-eslint/parser": "^7.8.0", + "concurrently": "^9.1.2", "eslint-plugin-import": "^2.29.1", "prettier": "^3.3.3", - "prettier-plugin-tailwindcss": "^0.6.8" + "prettier-plugin-tailwindcss": "^0.6.8", + "typescript": "^5.6.3" } } From e9ef2f9c1573aa1fadec66cbbb17ec2c439a03ba Mon Sep 17 00:00:00 2001 From: Fred Bricon Date: Wed, 9 Apr 2025 14:40:28 +0200 Subject: [PATCH 39/43] Enable tools support for Cogito on Ollama Signed-off-by: Fred Bricon --- core/llm/toolSupport.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index 7f4975170..3d0d72cc8 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -82,7 +82,7 @@ export const PROVIDER_TOOL_SUPPORT: Record< } else { modelName = model; } - + if ( ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some( (part) => modelName.toLowerCase().includes(part), @@ -92,6 +92,7 @@ export const PROVIDER_TOOL_SUPPORT: Record< } if ( [ + "cogito", "llama3.3", "qwq", "llama3.2", From 4599d066c14201ba7e0681c7eafd9a1f56728a50 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 9 Apr 2025 08:14:12 -0700 Subject: [PATCH 40/43] bump --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 3948b3c8e..9fb36d937 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.1.22", + "version": "1.1.23", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From f6ecad7ccef81d170a2294fe8f1eb8a8c7fd84ea Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Tue, 8 Apr 2025 15:57:51 -0700 Subject: [PATCH 41/43] improv: stricter linting --- core/.eslintrc.json | 2 +- core/config/ConfigHandler.ts | 26 ++-- core/config/load.ts | 38 ++++-- .../profile/ControlPlaneProfileLoader.ts | 24 ++-- core/config/profile/LocalProfileLoader.ts | 24 ++-- core/config/profile/PlatformProfileLoader.ts | 128 ++++++++++++------ core/config/profile/doLoadConfig.ts | 40 ++++-- core/config/yaml/loadYaml.ts | 76 +++++++---- 8 files changed, 223 insertions(+), 135 deletions(-) diff --git a/core/.eslintrc.json b/core/.eslintrc.json index 4790b5c45..64c478d09 100644 --- a/core/.eslintrc.json +++ b/core/.eslintrc.json @@ -17,6 +17,6 @@ "max-statements": ["error", { "max": 114 }], "max-depth": ["error", { "max": 6 }], "max-nested-callbacks": ["error", { "max": 4 }], - "max-params": ["error", { "max": 11 }] + "max-params": ["error", { "max": 8 }] } } diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 2d4a471d5..aa213d270 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -172,22 +172,22 @@ export class ConfigHandler { return await Promise.all( assistants.map(async (assistant) => { - const profileLoader = await PlatformProfileLoader.create( - { + const profileLoader = await PlatformProfileLoader.create({ + configResult: { ...assistant.configResult, config: assistant.configResult.config, }, - assistant.ownerSlug, - assistant.packageSlug, - assistant.iconUrl, - assistant.configResult.config?.version ?? "latest", - this.controlPlaneClient, - this.ide, - this.ideSettingsPromise, - this.llmLogger, - assistant.rawYaml, - orgScopeId, - ); + ownerSlug: assistant.ownerSlug, + packageSlug: assistant.packageSlug, + iconUrl: assistant.iconUrl, + versionSlug: assistant.configResult.config?.version ?? "latest", + controlPlaneClient: this.controlPlaneClient, + ide: this.ide, + ideSettingsPromise: this.ideSettingsPromise, + llmLogger: this.llmLogger, + rawYaml: assistant.rawYaml, + orgScopeId: orgScopeId, + }); return new ProfileLifecycleManager(profileLoader, this.ide); }), diff --git a/core/config/load.ts b/core/config/load.ts index b85359641..6ca5ce17a 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -217,17 +217,27 @@ export function isContextProviderWithParams( } /** Only difference between intermediate and final configs is the `models` array */ -async function intermediateToFinalConfig( - config: Config, - ide: IDE, - ideSettings: IdeSettings, - ideInfo: IdeInfo, - uniqueId: string, - llmLogger: ILLMLogger, - workOsAccessToken: string | undefined, - loadPromptFiles: boolean = true, - allowFreeTrial: boolean = true, -): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> { +async function intermediateToFinalConfig({ + config, + ide, + ideSettings, + ideInfo, + uniqueId, + llmLogger, + workOsAccessToken, + loadPromptFiles = true, + allowFreeTrial = true, +}: { + config: Config; + ide: IDE; + ideSettings: IdeSettings; + ideInfo: IdeInfo; + uniqueId: string; + llmLogger: ILLMLogger; + workOsAccessToken: string | undefined; + loadPromptFiles?: boolean; + allowFreeTrial?: boolean; +}): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> { const errors: ConfigValidationError[] = []; // Auto-detect models @@ -930,15 +940,15 @@ async function loadContinueConfigFromJson( // Convert to final config format const { config: finalConfig, errors: finalErrors } = - await intermediateToFinalConfig( - intermediate, + await intermediateToFinalConfig({ + config: intermediate, ide, ideSettings, ideInfo, uniqueId, llmLogger, workOsAccessToken, - ); + }); return { config: finalConfig, errors: [...(errors ?? []), ...finalErrors], diff --git a/core/config/profile/ControlPlaneProfileLoader.ts b/core/config/profile/ControlPlaneProfileLoader.ts index 21ea27e14..bf705fd95 100644 --- a/core/config/profile/ControlPlaneProfileLoader.ts +++ b/core/config/profile/ControlPlaneProfileLoader.ts @@ -62,18 +62,18 @@ export default class ControlPlaneProfileLoader implements IProfileLoader { )) as any); const serializedConfig: SerializedContinueConfig = settings; - return await doLoadConfig( - this.ide, - this.ideSettingsPromise, - this.controlPlaneClient, - this.llmLogger, - serializedConfig, - undefined, - undefined, - this.workspaceId, - undefined, - null, - ); + return await doLoadConfig({ + ide: this.ide, + ideSettingsPromise: this.ideSettingsPromise, + controlPlaneClient: this.controlPlaneClient, + llmLogger: this.llmLogger, + overrideConfigJson: serializedConfig, + overrideConfigYaml: undefined, + platformConfigMetadata: undefined, + profileId: this.workspaceId, + overrideConfigYamlByPath: undefined, + orgScopeId: null, + }); } setIsActive(isActive: boolean): void {} diff --git a/core/config/profile/LocalProfileLoader.ts b/core/config/profile/LocalProfileLoader.ts index f49c8bb7a..5b73a13e6 100644 --- a/core/config/profile/LocalProfileLoader.ts +++ b/core/config/profile/LocalProfileLoader.ts @@ -55,18 +55,18 @@ export default class LocalProfileLoader implements IProfileLoader { description: ProfileDescription; async doLoadConfig(): Promise> { - const result = await doLoadConfig( - this.ide, - this.ideSettingsPromise, - this.controlPlaneClient, - this.llmLogger, - undefined, - undefined, - undefined, - this.description.id, - this.overrideAssistantFile?.path, - null, - ); + const result = await doLoadConfig({ + ide: this.ide, + ideSettingsPromise: this.ideSettingsPromise, + controlPlaneClient: this.controlPlaneClient, + llmLogger: this.llmLogger, + overrideConfigJson: undefined, + overrideConfigYaml: undefined, + platformConfigMetadata: undefined, + profileId: this.description.id, + overrideConfigYamlByPath: this.overrideAssistantFile?.path, + orgScopeId: null, + }); this.description.errors = result.errors; diff --git a/core/config/profile/PlatformProfileLoader.ts b/core/config/profile/PlatformProfileLoader.ts index cf9efb399..66bea1ef2 100644 --- a/core/config/profile/PlatformProfileLoader.ts +++ b/core/config/profile/PlatformProfileLoader.ts @@ -21,33 +21,81 @@ export interface PlatformConfigMetadata { export default class PlatformProfileLoader implements IProfileLoader { static RELOAD_INTERVAL = 1000 * 5; // 5 seconds - private constructor( - private configResult: ConfigResult, - private readonly ownerSlug: string, - private readonly packageSlug: string, - private readonly iconUrl: string, - private readonly versionSlug: string, - private readonly controlPlaneClient: ControlPlaneClient, - private readonly ide: IDE, - private ideSettingsPromise: Promise, - private llmLogger: ILLMLogger, - readonly description: ProfileDescription, - private readonly orgScopeId: string | null, - ) {} + private configResult: ConfigResult; + private readonly ownerSlug: string; + private readonly packageSlug: string; + private readonly iconUrl: string; + private readonly versionSlug: string; + private readonly controlPlaneClient: ControlPlaneClient; + private readonly ide: IDE; + private ideSettingsPromise: Promise; + private llmLogger: ILLMLogger; + readonly description: ProfileDescription; + private readonly orgScopeId: string | null; - static async create( - configResult: ConfigResult, - ownerSlug: string, - packageSlug: string, - iconUrl: string, - versionSlug: string, - controlPlaneClient: ControlPlaneClient, - ide: IDE, - ideSettingsPromise: Promise, - llmLogger: ILLMLogger, - rawYaml: string, - orgScopeId: string | null, - ): Promise { + private constructor({ + configResult, + ownerSlug, + packageSlug, + iconUrl, + versionSlug, + controlPlaneClient, + ide, + ideSettingsPromise, + llmLogger, + description, + orgScopeId, + }: { + configResult: ConfigResult; + ownerSlug: string; + packageSlug: string; + iconUrl: string; + versionSlug: string; + controlPlaneClient: ControlPlaneClient; + ide: IDE; + ideSettingsPromise: Promise; + llmLogger: ILLMLogger; + description: ProfileDescription; + orgScopeId: string | null; + }) { + this.configResult = configResult; + this.ownerSlug = ownerSlug; + this.packageSlug = packageSlug; + this.iconUrl = iconUrl; + this.versionSlug = versionSlug; + this.controlPlaneClient = controlPlaneClient; + this.ide = ide; + this.ideSettingsPromise = ideSettingsPromise; + this.llmLogger = llmLogger; + this.description = description; + this.orgScopeId = orgScopeId; + } + + static async create({ + configResult, + ownerSlug, + packageSlug, + iconUrl, + versionSlug, + controlPlaneClient, + ide, + ideSettingsPromise, + llmLogger, + rawYaml, + orgScopeId, + }: { + configResult: ConfigResult; + ownerSlug: string; + packageSlug: string; + iconUrl: string; + versionSlug: string; + controlPlaneClient: ControlPlaneClient; + ide: IDE; + ideSettingsPromise: Promise; + llmLogger: ILLMLogger; + rawYaml: string; + orgScopeId: string | null; + }): Promise { const controlPlaneEnv = await getControlPlaneEnv(ideSettingsPromise); const description: ProfileDescription = { @@ -65,7 +113,7 @@ export default class PlatformProfileLoader implements IProfileLoader { rawYaml, }; - return new PlatformProfileLoader( + return new PlatformProfileLoader({ configResult, ownerSlug, packageSlug, @@ -77,7 +125,7 @@ export default class PlatformProfileLoader implements IProfileLoader { llmLogger, description, orgScopeId, - ); + }); } async doLoadConfig(): Promise> { @@ -89,21 +137,21 @@ export default class PlatformProfileLoader implements IProfileLoader { }; } - const results = await doLoadConfig( - this.ide, - this.ideSettingsPromise, - this.controlPlaneClient, - this.llmLogger, - undefined, - this.configResult.config, - { + const results = await doLoadConfig({ + ide: this.ide, + ideSettingsPromise: this.ideSettingsPromise, + controlPlaneClient: this.controlPlaneClient, + llmLogger: this.llmLogger, + overrideConfigJson: undefined, + overrideConfigYaml: this.configResult.config, + platformConfigMetadata: { ownerSlug: this.ownerSlug, packageSlug: this.packageSlug, }, - this.description.id, - undefined, - this.orgScopeId, - ); + profileId: this.description.id, + overrideConfigYamlByPath: undefined, + orgScopeId: this.orgScopeId, + }); return { config: results.config, diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index 626546b74..d3f720017 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -36,18 +36,29 @@ import { loadContinueConfigFromYaml } from "../yaml/loadYaml"; import { PlatformConfigMetadata } from "./PlatformProfileLoader"; -export default async function doLoadConfig( - ide: IDE, - ideSettingsPromise: Promise, - controlPlaneClient: ControlPlaneClient, - llmLogger: ILLMLogger, - overrideConfigJson: SerializedContinueConfig | undefined, - overrideConfigYaml: AssistantUnrolled | undefined, - platformConfigMetadata: PlatformConfigMetadata | undefined, - profileId: string, - overrideConfigYamlByPath: string | undefined, - orgScopeId: string | null, -): Promise> { +export default async function doLoadConfig({ + ide, + ideSettingsPromise, + controlPlaneClient, + llmLogger, + overrideConfigJson, + overrideConfigYaml, + platformConfigMetadata, + profileId, + overrideConfigYamlByPath, + orgScopeId, +}: { + ide: IDE; + ideSettingsPromise: Promise; + controlPlaneClient: ControlPlaneClient; + llmLogger: ILLMLogger; + overrideConfigJson: SerializedContinueConfig | undefined; + overrideConfigYaml: AssistantUnrolled | undefined; + platformConfigMetadata: PlatformConfigMetadata | undefined; + profileId: string; + overrideConfigYamlByPath: string | undefined; + orgScopeId: string | null; +}): Promise> { const workspaceConfigs = await getWorkspaceConfigs(ide); const ideInfo = await ide.getIdeInfo(); const uniqueId = await ide.getUniqueId(); @@ -70,19 +81,18 @@ export default async function doLoadConfig( let configLoadInterrupted = false; if (overrideConfigYaml || fs.existsSync(configYamlPath)) { - const result = await loadContinueConfigFromYaml( + const result = await loadContinueConfigFromYaml({ ide, ideSettings, ideInfo, uniqueId, llmLogger, - workOsAccessToken, overrideConfigYaml, platformConfigMetadata, controlPlaneClient, configYamlPath, orgScopeId, - ); + }); newConfig = result.config; errors = result.errors; configLoadInterrupted = result.configLoadInterrupted; diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 1edb48604..fd1c8ac02 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -111,17 +111,25 @@ async function loadConfigYaml( }; } -async function configYamlToContinueConfig( - config: AssistantUnrolled, - ide: IDE, - ideSettings: IdeSettings, - ideInfo: IdeInfo, - uniqueId: string, - llmLogger: ILLMLogger, - workOsAccessToken: string | undefined, - platformConfigMetadata: PlatformConfigMetadata | undefined, - allowFreeTrial: boolean = true, -): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> { +async function configYamlToContinueConfig({ + config, + ide, + ideSettings, + ideInfo, + uniqueId, + llmLogger, + platformConfigMetadata, + allowFreeTrial = true, +}: { + config: AssistantUnrolled; + ide: IDE; + ideSettings: IdeSettings; + ideInfo: IdeInfo; + uniqueId: string; + llmLogger: ILLMLogger; + platformConfigMetadata: PlatformConfigMetadata | undefined; + allowFreeTrial: boolean; +}): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> { const localErrors: ConfigValidationError[] = []; const continueConfig: ContinueConfig = { slashCommands: [], @@ -408,19 +416,31 @@ async function configYamlToContinueConfig( return { config: continueConfig, errors: localErrors }; } -export async function loadContinueConfigFromYaml( - ide: IDE, - ideSettings: IdeSettings, - ideInfo: IdeInfo, - uniqueId: string, - llmLogger: ILLMLogger, - workOsAccessToken: string | undefined, - overrideConfigYaml: AssistantUnrolled | undefined, - platformConfigMetadata: PlatformConfigMetadata | undefined, - controlPlaneClient: ControlPlaneClient, - configYamlPath: string | undefined, - orgScopeId: string | null, -): Promise> { +export async function loadContinueConfigFromYaml({ + ide, + ideSettings, + ideInfo, + uniqueId, + llmLogger, + // workOsAccessToken, + overrideConfigYaml, + platformConfigMetadata, + controlPlaneClient, + configYamlPath, + orgScopeId, +}: { + ide: IDE; + ideSettings: IdeSettings; + ideInfo: IdeInfo; + uniqueId: string; + llmLogger: ILLMLogger; + // workOsAccessToken: string | undefined; + overrideConfigYaml: AssistantUnrolled | undefined; + platformConfigMetadata: PlatformConfigMetadata | undefined; + controlPlaneClient: ControlPlaneClient; + configYamlPath: string | undefined; + orgScopeId: string | null; +}): Promise> { const rawYaml = overrideConfigYaml === undefined ? fs.readFileSync( @@ -446,16 +466,16 @@ export async function loadContinueConfigFromYaml( } const { config: continueConfig, errors: localErrors } = - await configYamlToContinueConfig( - configYamlResult.config, + await configYamlToContinueConfig({ + config: configYamlResult.config, ide, ideSettings, ideInfo, uniqueId, llmLogger, - workOsAccessToken, platformConfigMetadata, - ); + allowFreeTrial: true, + }); try { const systemPromptDotFile = await getSystemPromptDotFile(ide); From 1864ce1641d965e26482038bfd5f397c1d934046 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 9 Apr 2025 09:08:45 -0700 Subject: [PATCH 42/43] improv: stricter linting --- core/.eslintrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/.eslintrc.json b/core/.eslintrc.json index 64c478d09..3a5427dd2 100644 --- a/core/.eslintrc.json +++ b/core/.eslintrc.json @@ -12,7 +12,7 @@ "curly": "off", "@typescript-eslint/semi": "off", "eqeqeq": "error", - "complexity": ["error", { "max": 38 }], + "complexity": ["error", { "max": 36 }], "max-lines-per-function": ["error", { "max": 485 }], "max-statements": ["error", { "max": 114 }], "max-depth": ["error", { "max": 6 }], From 0fda76868b0e98c969e672a022eff9b8ad3f5545 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 9 Apr 2025 09:36:37 -0700 Subject: [PATCH 43/43] improv: stricter linting --- core/.eslintrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/.eslintrc.json b/core/.eslintrc.json index 3a5427dd2..ac673b38f 100644 --- a/core/.eslintrc.json +++ b/core/.eslintrc.json @@ -13,7 +13,7 @@ "@typescript-eslint/semi": "off", "eqeqeq": "error", "complexity": ["error", { "max": 36 }], - "max-lines-per-function": ["error", { "max": 485 }], + "max-lines-per-function": ["error", { "max": 472 }], "max-statements": ["error", { "max": 114 }], "max-depth": ["error", { "max": 6 }], "max-nested-callbacks": ["error", { "max": 4 }],