Merge pull request #4103 from continuedev/dallin/model-roles
Model Role Updates
This commit is contained in:
commit
1c2bbf33d1
21 changed files with 67 additions and 86 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<T extends keyof ModelRoles>(
|
||||
export function getModelByRole<T extends keyof ExperimentalModelRoles>(
|
||||
config: ContinueConfig,
|
||||
role: T,
|
||||
): ILLM | undefined {
|
||||
|
|
|
|||
|
|
@ -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 "../..";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { AssistantUnrolled } from "@continuedev/config-yaml/dist/schemas";
|
||||
import { AssistantUnrolled } from "@continuedev/config-yaml";
|
||||
|
||||
// TODO
|
||||
export const defaultConfigYaml: AssistantUnrolled = {
|
||||
|
|
|
|||
|
|
@ -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 };
|
||||
|
|
|
|||
16
core/index.d.ts
vendored
16
core/index.d.ts
vendored
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
8
core/package-lock.json
generated
8
core/package-lock.json
generated
|
|
@ -13,7 +13,7 @@
|
|||
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
|
||||
"@aws-sdk/credential-providers": "^3.620.1",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "^1.0.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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
2
extensions/vscode/package-lock.json
generated
2
extensions/vscode/package-lock.json
generated
|
|
@ -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",
|
||||
|
|
|
|||
16
gui/package-lock.json
generated
16
gui/package-lock.json
generated
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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<ConfigYaml["models"]>[number];
|
||||
type ContextYaml = NonNullable<ConfigYaml["context"]>[number];
|
||||
|
|
@ -8,7 +8,7 @@ type PromptYaml = NonNullable<ConfigYaml["prompts"]>[number];
|
|||
|
||||
function convertModel(
|
||||
m: ConfigJson["models"][number],
|
||||
roles: ModelRoles[],
|
||||
roles: ModelRole[],
|
||||
): ModelYaml {
|
||||
return {
|
||||
name: m.title,
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export const modelRolesSchema = z.enum([
|
|||
"apply",
|
||||
"summarize",
|
||||
]);
|
||||
export type ModelRoles = z.infer<typeof modelRolesSchema>;
|
||||
export type ModelRole = z.infer<typeof modelRolesSchema>;
|
||||
|
||||
export const completionOptionsSchema = z.object({
|
||||
contextLength: z.number().optional(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue