diff --git a/core/config/load.ts b/core/config/load.ts index 5400bc81b..c8499dc8b 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -326,6 +326,7 @@ async function intermediateToFinalConfig( ...model.requestOptions, ...config.requestOptions, }; + model.roles = model.roles ?? ["chat"]; // Default to chat role if not specified } if (allowFreeTrial) { @@ -559,6 +560,7 @@ async function finalToBrowserConfig( requestOptions: m.requestOptions, promptTemplates: m.promptTemplates as any, capabilities: m.capabilities, + roles: m.roles, })), systemMessage: final.systemMessage, completionOptions: final.completionOptions, diff --git a/core/config/profile/PlatformProfileLoader.ts b/core/config/profile/PlatformProfileLoader.ts index 7650cb0e3..04f1d3acf 100644 --- a/core/config/profile/PlatformProfileLoader.ts +++ b/core/config/profile/PlatformProfileLoader.ts @@ -1,5 +1,4 @@ -import { ConfigResult } from "@continuedev/config-yaml"; -import { AssistantUnrolled } from "@continuedev/config-yaml/dist/schemas/index.js"; +import { ConfigResult, AssistantUnrolled } from "@continuedev/config-yaml"; import { ControlPlaneClient } from "../../control-plane/client.js"; import { ContinueConfig, IDE, IdeSettings } from "../../index.js"; diff --git a/core/config/types.ts b/core/config/types.ts index 384da0c8f..2a68c4c35 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -956,7 +956,7 @@ declare global { fixGrammar?: string; } - interface ModelRoles { + interface ExperimentalModelRoles { inlineEdit?: string; applyCodeBlock?: string; repoMapFileSelection?: string; @@ -1024,7 +1024,7 @@ declare global { interface ExperimentalConfig { contextMenuPrompts?: ContextMenuConfig; - modelRoles?: ModelRoles; + modelRoles?: ExperimentalModelRoles; defaultContext?: DefaultContextProvider[]; promptPath?: string; diff --git a/core/config/util.ts b/core/config/util.ts index 6d28dcbcb..06acdf2b1 100644 --- a/core/config/util.ts +++ b/core/config/util.ts @@ -7,7 +7,7 @@ import { IDE, ILLM, ModelDescription, - ModelRoles, + ExperimentalModelRoles, } from "../"; import { GlobalContext } from "../util/GlobalContext"; import { editConfigJson } from "../util/paths"; @@ -34,7 +34,10 @@ export function addContextProvider(provider: ContextProviderWithParams) { }); } -export function addModel(model: ModelDescription, role?: keyof ModelRoles) { +export function addModel( + model: ModelDescription, + role?: keyof ExperimentalModelRoles, +) { editConfigJson((config) => { if (config.models?.some((m: any) => stringify(m) === stringify(model))) { return config; @@ -85,7 +88,7 @@ export function deleteModel(title: string) { }); } -export function getModelByRole( +export function getModelByRole( config: ContinueConfig, role: T, ): ILLM | undefined { diff --git a/core/config/yaml/convertFromJson.ts b/core/config/yaml/convertFromJson.ts index 576e196c8..a989d2631 100644 --- a/core/config/yaml/convertFromJson.ts +++ b/core/config/yaml/convertFromJson.ts @@ -1,5 +1,4 @@ -import { ModelConfig } from "@continuedev/config-yaml"; -import { AssistantUnrolled } from "@continuedev/config-yaml/dist/schemas"; +import { ModelConfig, AssistantUnrolled } from "@continuedev/config-yaml"; import { SerializedContinueConfig } from "../.."; diff --git a/core/config/yaml/default.ts b/core/config/yaml/default.ts index 0bc872f88..c9ca4dc8e 100644 --- a/core/config/yaml/default.ts +++ b/core/config/yaml/default.ts @@ -1,4 +1,4 @@ -import { AssistantUnrolled } from "@continuedev/config-yaml/dist/schemas"; +import { AssistantUnrolled } from "@continuedev/config-yaml"; // TODO export const defaultConfigYaml: AssistantUnrolled = { diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 7bf59c343..57660ce53 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -7,10 +7,10 @@ import { parseAssistantUnrolled, validateConfigYaml, } from "@continuedev/config-yaml"; +import { ModelRole } from "@continuedev/config-yaml"; import { fetchwithRequestOptions } from "@continuedev/fetch"; import { - BrowserSerializedContinueConfig, ContinueConfig, IContextProvider, IDE, @@ -18,9 +18,11 @@ import { IdeType, SlashCommand, } 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 PromptFilesContextProvider from "../../context/providers/PromptFilesContextProvider"; @@ -30,15 +32,13 @@ import FreeTrial from "../../llm/llms/FreeTrial"; import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider"; import { slashCommandFromPromptFileV1 } from "../../promptFiles/v1/slashCommandFromPromptFile"; import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles"; +import { allTools } from "../../tools"; +import { GlobalContext } from "../../util/GlobalContext"; import { getConfigYamlPath } from "../../util/paths"; import { getSystemPromptDotFile } from "../getSystemPromptDotFile"; import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader"; - -import { slashFromCustomCommand } from "../../commands"; -import DocsContextProvider from "../../context/providers/DocsContextProvider"; -import { allTools } from "../../tools"; -import { GlobalContext } from "../../util/GlobalContext"; import { modifyContinueConfigWithSharedConfig } from "../sharedConfig"; + import { clientRenderHelper } from "./clientRender"; import { llmsFromModelConfig } from "./models"; @@ -134,12 +134,10 @@ async function configYamlToContinueConfig( }; // Models + const modelsArrayRoles: ModelRole[] = ["chat", "summarize", "apply", "edit"]; for (const model of config.models ?? []) { - if ( - ["chat", "summarize", "apply", "edit"].some((role: any) => - model.roles?.includes(role), - ) - ) { + model.roles = model.roles ?? ["chat"]; // Default to chat role if not specified + if (modelsArrayRoles.some((role) => model.roles?.includes(role))) { // Main model array const llms = await llmsFromModelConfig( model, @@ -245,6 +243,7 @@ async function configYamlToContinueConfig( } // Embeddings Provider + // IMPORTANT this currently will grab the first model found with an embed role const embedConfig = config.models?.find((model) => model.roles?.includes("embed"), ); @@ -269,6 +268,7 @@ async function configYamlToContinueConfig( } // Reranker + // IMPORTANT this currently will grab the first model found with a rerank role const rerankConfig = config.models?.find((model) => model.roles?.includes("rerank"), ); @@ -402,5 +402,3 @@ export async function loadContinueConfigFromYaml( configLoadInterrupted: false, }; } - -export { type BrowserSerializedContinueConfig }; diff --git a/core/index.d.ts b/core/index.d.ts index b1d15847a..ca55db8a0 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1,6 +1,6 @@ import Parser from "web-tree-sitter"; import { GetGhTokenArgs } from "./protocol/ide"; - +import { ModelRole } from "@continuedev/config-yaml"; declare global { interface Window { ide?: "vscode"; @@ -94,6 +94,8 @@ export interface ILLM extends LLMOptions { apiKey?: string; apiBase?: string; cacheBehavior?: CacheBehavior; + capabilities?: ModelCapability; + roles?: ModelRole[]; deployment?: string; apiVersion?: string; @@ -480,6 +482,8 @@ export interface LLMOptions { aiGatewaySlug?: string; apiBase?: string; cacheBehavior?: CacheBehavior; + capabilities?: ModelCapability; + roles?: ModelRole[]; useLegacyCompletionsEndpoint?: boolean; @@ -503,9 +507,6 @@ export interface LLMOptions { // AWS and GCP Options region?: string; - // GCP Options - capabilities?: ModelCapability; - // GCP and Watsonx Options projectId?: string; @@ -923,8 +924,9 @@ export interface ModelDescription { systemMessage?: string; requestOptions?: RequestOptions; promptTemplates?: { [key: string]: string }; - capabilities?: ModelCapability; cacheBehavior?: CacheBehavior; + capabilities?: ModelCapability; + roles?: ModelRole[]; } export interface EmbedOptions { @@ -1015,7 +1017,7 @@ export interface ContextMenuConfig { fixGrammar?: string; } -export interface ModelRoles { +export interface ExperimentalModelRoles { inlineEdit?: string; applyCodeBlock?: string; repoMapFileSelection?: string; @@ -1083,7 +1085,7 @@ export type DefaultContextProvider = ContextProviderWithParams & { export interface ExperimentalConfig { contextMenuPrompts?: ContextMenuConfig; - modelRoles?: ModelRoles; + modelRoles?: ExperimentalModelRoles; defaultContext?: DefaultContextProvider[]; promptPath?: string; diff --git a/core/llm/index.ts b/core/llm/index.ts index 4989f14fa..7e3c37fc2 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -56,6 +56,7 @@ import { toCompleteBody, toFimBody, } from "./openaiTypeConverters.js"; +import { ModelRole } from "@continuedev/config-yaml"; export abstract class BaseLLM implements ILLM { static providerName: string; @@ -121,6 +122,7 @@ export abstract class BaseLLM implements ILLM { apiBase?: string; cacheBehavior?: CacheBehavior; capabilities?: ModelCapability; + roles?: ModelRole[]; deployment?: string; apiVersion?: string; @@ -209,6 +211,7 @@ export abstract class BaseLLM implements ILLM { } this.accountId = options.accountId; this.capabilities = options.capabilities; + this.roles = options.roles; this.deployment = options.deployment; this.apiVersion = options.apiVersion; diff --git a/core/package-lock.json b/core/package-lock.json index 134bf9838..c96746622 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.28", + "@continuedev/config-yaml": "^1.0.29", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", @@ -3038,9 +3038,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.28", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.28.tgz", - "integrity": "sha512-XTTRHeIYgLlwzPkub2jAPx4TqRf47g/TR2K9AIdZYQRNxYuHAeFRRqaIaAZPdykZATg30vdGQGGdssVr6IyCCg==", + "version": "1.0.29", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.29.tgz", + "integrity": "sha512-5zKebdoNp52eSFCrs/EODF36I0basrDdE9gQ6Vxoxd9axzVTyWlbpm6gLXXeaHpJMSCaTcQMh/uzAiq8trwrYA==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/core/package.json b/core/package.json index 516e8a071..aaf16af5c 100644 --- a/core/package.json +++ b/core/package.json @@ -46,7 +46,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.28", + "@continuedev/config-yaml": "^1.0.29", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/core/protocol/core.ts b/core/protocol/core.ts index d02b0812e..82ce4eea7 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -18,7 +18,7 @@ import type { IdeSettings, LLMFullCompletionOptions, ModelDescription, - ModelRoles, + ExperimentalModelRoles, PromptLog, RangeInFile, SerializedContinueConfig, @@ -52,7 +52,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { "config/addModel": [ { model: SerializedContinueConfig["models"][number]; - role?: keyof ModelRoles; + role?: keyof ExperimentalModelRoles; }, void, ]; diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index d9dab076b..44cb6dfc3 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1683,33 +1683,6 @@ } ] }, - "ModelRoles": { - "title": "ModelRoles", - "type": "object", - "properties": { - "default": { - "title": "Default", - "description": "The default model. If other model roles are not set, they will fall back to default.", - "type": "string" - }, - "chat": { - "title": "Chat", - "description": "The model to use for chat. If not set, will fall back to default.", - "type": "string" - }, - "edit": { - "title": "Edit", - "description": "The model to use for editing. If not set, will fall back to default.", - "type": "string" - }, - "summarize": { - "title": "Summarize", - "description": "The model to use for summarization. If not set, will fall back to default.", - "type": "string" - } - }, - "required": ["default"] - }, "SlashCommand": { "title": "SlashCommand", "type": "object", diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 12bad6086..8d530b1de 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -106,7 +106,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.28", + "@continuedev/config-yaml": "^1.0.29", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/gui/package-lock.json b/gui/package-lock.json index fd717a89e..f9642efc6 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.28", + "@continuedev/config-yaml": "^1.0.29", "@headlessui/react": "^1.7.17", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -108,7 +108,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.28", + "@continuedev/config-yaml": "^1.0.29", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", @@ -556,9 +556,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.28", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.28.tgz", - "integrity": "sha512-XTTRHeIYgLlwzPkub2jAPx4TqRf47g/TR2K9AIdZYQRNxYuHAeFRRqaIaAZPdykZATg30vdGQGGdssVr6IyCCg==", + "version": "1.0.29", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.29.tgz", + "integrity": "sha512-5zKebdoNp52eSFCrs/EODF36I0basrDdE9gQ6Vxoxd9axzVTyWlbpm6gLXXeaHpJMSCaTcQMh/uzAiq8trwrYA==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", @@ -13755,9 +13755,9 @@ } }, "node_modules/zod": { - "version": "3.24.1", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.1.tgz", - "integrity": "sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==", + "version": "3.24.2", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz", + "integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==", "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/gui/package.json b/gui/package.json index b19106429..a3ab8240e 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "^1.0.28", + "@continuedev/config-yaml": "^1.0.29", "@headlessui/react": "^1.7.17", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index 68f5ea996..efa717a0b 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -235,13 +235,15 @@ function ModelSelect() { useEffect(() => { setOptions( - allModels.map((model) => { - return { - value: model.title, - title: modelSelectTitle(model), - apiKey: model.apiKey, - }; - }), + allModels + .filter((m) => !m.roles || m.roles.includes("chat")) + .map((model) => { + return { + value: model.title, + title: modelSelectTitle(model), + apiKey: model.apiKey, + }; + }), ); }, [allModels]); diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index 005112b06..a4b386bbe 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.28", + "version": "1.0.29", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/config-yaml/src/converter.ts b/packages/config-yaml/src/converter.ts index 56d5326d2..13f54cb8c 100644 --- a/packages/config-yaml/src/converter.ts +++ b/packages/config-yaml/src/converter.ts @@ -1,6 +1,6 @@ import { ConfigJson } from "@continuedev/config-types"; import { ConfigYaml } from "./schemas/index.js"; -import { ModelRoles } from "./schemas/models.js"; +import { ModelRole } from "./schemas/models.js"; type ModelYaml = NonNullable[number]; type ContextYaml = NonNullable[number]; @@ -8,7 +8,7 @@ type PromptYaml = NonNullable[number]; function convertModel( m: ConfigJson["models"][number], - roles: ModelRoles[], + roles: ModelRole[], ): ModelYaml { return { name: m.title, diff --git a/packages/config-yaml/src/index.ts b/packages/config-yaml/src/index.ts index 0fcd5ae10..51f9287c0 100644 --- a/packages/config-yaml/src/index.ts +++ b/packages/config-yaml/src/index.ts @@ -8,5 +8,5 @@ export * from "./load/merge.js"; export * from "./load/proxySecretResolution.js"; export * from "./load/unroll.js"; export * from "./schemas/index.js"; -export type { ModelConfig } from "./schemas/models.js"; +export type { ModelConfig, ModelRole } from "./schemas/models.js"; export * from "./validation.js"; diff --git a/packages/config-yaml/src/schemas/models.ts b/packages/config-yaml/src/schemas/models.ts index b5e40fcc1..05df2c1ad 100644 --- a/packages/config-yaml/src/schemas/models.ts +++ b/packages/config-yaml/src/schemas/models.ts @@ -29,7 +29,7 @@ export const modelRolesSchema = z.enum([ "apply", "summarize", ]); -export type ModelRoles = z.infer; +export type ModelRole = z.infer; export const completionOptionsSchema = z.object({ contextLength: z.number().optional(),