select tab autocomplete model
This commit is contained in:
parent
6ccf535ef4
commit
103c685c75
22 changed files with 335 additions and 195 deletions
|
|
@ -86,6 +86,9 @@ export default async function doLoadConfig(
|
|||
configLoadInterrupted = result.configLoadInterrupted;
|
||||
}
|
||||
|
||||
// Rectify model selections for each role
|
||||
// These start out
|
||||
|
||||
if (configLoadInterrupted || !newConfig) {
|
||||
return { errors, config: newConfig, configLoadInterrupted: true };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,19 @@
|
|||
import {
|
||||
ModelRole,
|
||||
modelRolesSchema,
|
||||
} from "@continuedev/config-yaml/dist/schemas/models";
|
||||
import z from "zod";
|
||||
|
||||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
ContinueConfig,
|
||||
Config,
|
||||
SerializedContinueConfig,
|
||||
} from "..";
|
||||
import {
|
||||
ModelRole,
|
||||
modelRolesSchema,
|
||||
} from "@continuedev/config-yaml/dist/schemas/models";
|
||||
|
||||
export const sharedConfigSchema = z
|
||||
.object({
|
||||
selectedModels: z.record(
|
||||
z.string(),
|
||||
z.record(modelRolesSchema, z.string()),
|
||||
),
|
||||
selectedModels: z.record(modelRolesSchema, z.string().nullable()),
|
||||
|
||||
// boolean fields in config.json
|
||||
allowAnonymousTelemetry: z.boolean(),
|
||||
|
|
@ -161,11 +159,7 @@ export function modifyAnyConfigWithSharedConfig<
|
|||
|
||||
export function modifyFinalConfigWithSharedConfig<
|
||||
T extends ContinueConfig | BrowserSerializedContinueConfig,
|
||||
>(
|
||||
continueConfig: T,
|
||||
sharedConfig: SharedConfigSchema,
|
||||
selectedProfileId: string | null,
|
||||
): T {
|
||||
>(continueConfig: T, sharedConfig: SharedConfigSchema): T {
|
||||
const configCopy = { ...continueConfig };
|
||||
const selectedModelsForProfile: Record<ModelRole, string | null> = {
|
||||
apply: null,
|
||||
|
|
@ -176,6 +170,6 @@ export function modifyFinalConfigWithSharedConfig<
|
|||
rerank: null,
|
||||
summarize: null,
|
||||
};
|
||||
configCopy.selectedModelByRole = selectedModelsForProfile;
|
||||
// configCopy.selectedModelByRole = selectedModelsForProfile;
|
||||
return configCopy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,51 +155,49 @@ async function configYamlToContinueConfig(
|
|||
// Models
|
||||
const modelsArrayRoles: ModelRole[] = ["chat", "summarize", "apply", "edit"];
|
||||
for (const model of config.models ?? []) {
|
||||
model.roles = model.roles ?? modelsArrayRoles; // Default to all 4 roles if not specified
|
||||
model.roles = model.roles ?? modelsArrayRoles; // Default to all 4 chat-esque roles if not specified
|
||||
const llms = await llmsFromModelConfig(
|
||||
model,
|
||||
ide,
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
continueConfig.systemMessage,
|
||||
);
|
||||
|
||||
//
|
||||
if (modelsArrayRoles.some((role) => model.roles?.includes(role))) {
|
||||
// Main model array
|
||||
const llms = await llmsFromModelConfig(
|
||||
model,
|
||||
ide,
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
continueConfig.systemMessage,
|
||||
);
|
||||
continueConfig.models.push(...llms);
|
||||
}
|
||||
|
||||
if (model.roles?.includes("chat")) {
|
||||
continueConfig.modelsByRole.chat.push(...llms);
|
||||
}
|
||||
|
||||
if (model.roles?.includes("summarize")) {
|
||||
continueConfig.modelsByRole.summarize.push(...llms);
|
||||
}
|
||||
|
||||
if (model.roles?.includes("apply")) {
|
||||
continueConfig.modelsByRole.apply.push(...llms);
|
||||
}
|
||||
|
||||
if (model.roles?.includes("edit")) {
|
||||
continueConfig.modelsByRole.edit.push(...llms);
|
||||
}
|
||||
|
||||
if (model.roles?.includes("autocomplete")) {
|
||||
// Autocomplete models array
|
||||
const llms = await llmsFromModelConfig(
|
||||
model,
|
||||
ide,
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
continueConfig.systemMessage,
|
||||
);
|
||||
continueConfig.tabAutocompleteModels?.push(...llms);
|
||||
continueConfig.modelsByRole.autocomplete.push(...llms);
|
||||
}
|
||||
|
||||
if (
|
||||
model.roles?.includes("apply") &&
|
||||
!continueConfig.experimental?.modelRoles?.applyCodeBlock
|
||||
) {
|
||||
continueConfig.experimental ??= {};
|
||||
continueConfig.experimental!.modelRoles ??= {};
|
||||
continueConfig.experimental!.modelRoles!.applyCodeBlock = model.name;
|
||||
if (model.roles?.includes("embed")) {
|
||||
continueConfig.modelsByRole.embed.push(...llms);
|
||||
}
|
||||
|
||||
if (
|
||||
model.roles?.includes("edit") &&
|
||||
!continueConfig.experimental?.modelRoles?.inlineEdit
|
||||
) {
|
||||
continueConfig.experimental ??= {};
|
||||
continueConfig.experimental!.modelRoles ??= {};
|
||||
continueConfig.experimental!.modelRoles!.inlineEdit = model.name;
|
||||
if (model.roles?.includes("rerank")) {
|
||||
continueConfig.modelsByRole.rerank.push(...llms);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -221,8 +219,6 @@ async function configYamlToContinueConfig(
|
|||
);
|
||||
}
|
||||
|
||||
// TODO: Split into model roles.
|
||||
|
||||
// Context providers
|
||||
const codebaseContextParams: IContextProvider[] =
|
||||
(config.context || []).find((cp) => cp.provider === "codebase")?.params ||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { Chunk, ContinueConfig, IDE, ILLM } from "../..";
|
|||
import { getModelByRole } from "../../config/util";
|
||||
import generateRepoMap from "../../util/generateRepoMap";
|
||||
import { renderChatMessage } from "../../util/messageContent";
|
||||
import { getUriPathBasename } from "../../util/uri";
|
||||
|
||||
const SUPPORTED_MODEL_TITLE_FAMILIES = [
|
||||
"claude-3",
|
||||
|
|
|
|||
27
core/core.ts
27
core/core.ts
|
|
@ -187,12 +187,10 @@ export class Core {
|
|||
|
||||
const getLlm = async () => {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
const selected = this.globalContext.get("selectedTabAutocompleteModel");
|
||||
return (
|
||||
config?.tabAutocompleteModels?.find(
|
||||
(model) => model.title === selected,
|
||||
) ?? config?.tabAutocompleteModels?.[0]
|
||||
);
|
||||
if (!config) {
|
||||
return undefined;
|
||||
}
|
||||
return config.selectedModelByRole.autocomplete ?? undefined;
|
||||
};
|
||||
this.completionProvider = new CompletionProvider(
|
||||
this.configHandler,
|
||||
|
|
@ -226,11 +224,6 @@ export class Core {
|
|||
}
|
||||
});
|
||||
|
||||
on("update/selectTabAutocompleteModel", async (msg) => {
|
||||
this.globalContext.update("selectedTabAutocompleteModel", msg.data);
|
||||
void this.configHandler.reloadConfig();
|
||||
});
|
||||
|
||||
// Special
|
||||
on("abort", (msg) => {
|
||||
this.abortedMessageIds.add(msg.messageId);
|
||||
|
|
@ -305,8 +298,18 @@ export class Core {
|
|||
});
|
||||
|
||||
on("config/updateSharedConfig", async (msg) => {
|
||||
this.globalContext.updateSharedConfig(msg.data);
|
||||
const newSharedConfig = this.globalContext.updateSharedConfig(msg.data);
|
||||
await this.configHandler.reloadConfig();
|
||||
return newSharedConfig;
|
||||
});
|
||||
|
||||
on("config/updateSelectedModel", async (msg) => {
|
||||
const newSharedConfig = this.globalContext.updateSelectedModel(
|
||||
msg.data.role,
|
||||
msg.data.title,
|
||||
);
|
||||
await this.configHandler.reloadConfig();
|
||||
return newSharedConfig;
|
||||
});
|
||||
|
||||
on("controlPlane/openUrl", async (msg) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ConfigResult, ModelRole } from "@continuedev/config-yaml";
|
||||
|
||||
import { AutocompleteInput } from "../autocomplete/util/types";
|
||||
import { ProfileDescription } from "../config/ConfigHandler";
|
||||
|
|
@ -36,8 +36,6 @@ export interface ListHistoryOptions {
|
|||
}
|
||||
|
||||
export type ToCoreFromIdeOrWebviewProtocol = {
|
||||
"update/selectTabAutocompleteModel": [string, void];
|
||||
|
||||
// Special
|
||||
ping: [string, string];
|
||||
abort: [undefined, void];
|
||||
|
|
@ -70,7 +68,14 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
"config/reload": [undefined, ConfigResult<BrowserSerializedContinueConfig>];
|
||||
"config/listProfiles": [undefined, ProfileDescription[]];
|
||||
"config/openProfile": [{ profileId: string | undefined }, void];
|
||||
"config/updateSharedConfig": [SharedConfigSchema, void];
|
||||
"config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema];
|
||||
"config/updateSelectedModel": [
|
||||
{
|
||||
role: ModelRole;
|
||||
title: string | null;
|
||||
},
|
||||
SharedConfigSchema,
|
||||
];
|
||||
"context/getContextItems": [
|
||||
{
|
||||
name: string;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"config/listProfiles",
|
||||
"config/openProfile",
|
||||
"config/updateSharedConfig",
|
||||
"config/updateSelectedModel",
|
||||
"context/getContextItems",
|
||||
"context/getSymbolsForFiles",
|
||||
"context/loadSubmenuItems",
|
||||
|
|
|
|||
|
|
@ -29,12 +29,6 @@ describe("GlobalContext", () => {
|
|||
expect(value).toBe(true);
|
||||
});
|
||||
|
||||
it("should update and get a string value correctly", () => {
|
||||
globalContext.update("selectedTabAutocompleteModel", "test-model");
|
||||
const value = globalContext.get("selectedTabAutocompleteModel");
|
||||
expect(value).toBe("test-model");
|
||||
});
|
||||
|
||||
it("should update and get an object value correctly", () => {
|
||||
const workspaceIdentifier = "workspace-1";
|
||||
globalContext.update("lastSelectedProfileForWorkspace", {
|
||||
|
|
@ -108,13 +102,9 @@ describe("GlobalContext", () => {
|
|||
|
||||
it("should update and retrieve multiple values correctly", () => {
|
||||
globalContext.update("indexingPaused", true);
|
||||
globalContext.update("selectedTabAutocompleteModel", "test-model");
|
||||
globalContext.update("hasDismissedConfigTsNoticeJetBrains", false);
|
||||
|
||||
expect(globalContext.get("indexingPaused")).toBe(true);
|
||||
expect(globalContext.get("selectedTabAutocompleteModel")).toBe(
|
||||
"test-model",
|
||||
);
|
||||
expect(globalContext.get("hasDismissedConfigTsNoticeJetBrains")).toBe(
|
||||
false,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ import {
|
|||
|
||||
import { getGlobalContextFilePath } from "./paths";
|
||||
import { SiteIndexingConfig } from "..";
|
||||
import { ModelRole } from "@continuedev/config-yaml";
|
||||
|
||||
export type GlobalContextType = {
|
||||
indexingPaused: boolean;
|
||||
selectedTabAutocompleteModel: string;
|
||||
lastSelectedProfileForWorkspace: {
|
||||
[workspaceIdentifier: string]: string | null;
|
||||
};
|
||||
|
|
@ -113,4 +113,20 @@ export class GlobalContext {
|
|||
this.update("sharedConfig", updatedSharedConfig);
|
||||
return updatedSharedConfig;
|
||||
}
|
||||
|
||||
updateSelectedModel(
|
||||
role: ModelRole,
|
||||
title: string | null,
|
||||
): SharedConfigSchema {
|
||||
const currentSharedConfig = this.getSharedConfig();
|
||||
const updatedSharedConfig = {
|
||||
...currentSharedConfig,
|
||||
selectedModels: {
|
||||
...currentSharedConfig.selectedModels,
|
||||
[role]: title,
|
||||
},
|
||||
};
|
||||
this.update("sharedConfig", updatedSharedConfig);
|
||||
return updatedSharedConfig;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ class MessageTypes {
|
|||
"config/listProfiles",
|
||||
"config/openProfile",
|
||||
"config/updateSharedConfig",
|
||||
"config/updateSelectedModel",
|
||||
"context/getContextItems",
|
||||
"context/getSymbolsForFiles",
|
||||
"context/loadSubmenuItems",
|
||||
|
|
|
|||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.266",
|
||||
"version": "0.9.268",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.266",
|
||||
"version": "0.9.268",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import {
|
|||
stopStatusBarLoading,
|
||||
} from "./statusBar";
|
||||
|
||||
import type { TabAutocompleteModel } from "../util/loadAutocompleteModel";
|
||||
import { startLocalOllama } from "core/util/ollamaHelper";
|
||||
import type { IDE } from "core";
|
||||
|
||||
|
|
@ -41,7 +40,8 @@ interface VsCodeCompletionInput {
|
|||
}
|
||||
|
||||
export class ContinueCompletionProvider
|
||||
implements vscode.InlineCompletionItemProvider {
|
||||
implements vscode.InlineCompletionItemProvider
|
||||
{
|
||||
private onError(e: any) {
|
||||
let options = ["Documentation"];
|
||||
if (e.message.includes("Ollama may not be installed")) {
|
||||
|
|
@ -82,13 +82,19 @@ export class ContinueCompletionProvider
|
|||
constructor(
|
||||
private readonly configHandler: ConfigHandler,
|
||||
private readonly ide: IDE,
|
||||
private readonly tabAutocompleteModel: TabAutocompleteModel,
|
||||
private readonly webviewProtocol: VsCodeWebviewProtocol,
|
||||
) {
|
||||
async function getAutocompleteModel() {
|
||||
const { config } = await configHandler.loadConfig();
|
||||
if (!config) {
|
||||
return;
|
||||
}
|
||||
return config.selectedModelByRole.autocomplete ?? undefined;
|
||||
}
|
||||
this.completionProvider = new CompletionProvider(
|
||||
this.configHandler,
|
||||
this.ide,
|
||||
this.tabAutocompleteModel.get.bind(this.tabAutocompleteModel),
|
||||
getAutocompleteModel,
|
||||
this.onError.bind(this),
|
||||
getDefinitionsFromLsp,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import * as os from "node:os";
|
|||
import { ContextMenuConfig, RangeInFileWithContents } from "core";
|
||||
import { CompletionProvider } from "core/autocomplete/CompletionProvider";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { getModelByRole } from "core/config/util";
|
||||
import { ContinueServerClient } from "core/continueServer/stubs/client";
|
||||
import { EXTENSION_NAME } from "core/control-plane/env";
|
||||
import { Core } from "core/core";
|
||||
|
|
@ -872,16 +871,12 @@ const getCommandsMap: (
|
|||
|
||||
const config = vscode.workspace.getConfiguration(EXTENSION_NAME);
|
||||
const quickPick = vscode.window.createQuickPick();
|
||||
const autocompleteModels =
|
||||
(await configHandler.loadConfig()).config?.tabAutocompleteModels ?? [];
|
||||
|
||||
let selected = new GlobalContext().get("selectedTabAutocompleteModel");
|
||||
if (
|
||||
!selected ||
|
||||
!autocompleteModels.some((model) => model.title === selected)
|
||||
) {
|
||||
selected = autocompleteModels[0]?.title;
|
||||
}
|
||||
const { config: continueConfig } = await configHandler.loadConfig();
|
||||
const autocompleteModels =
|
||||
continueConfig?.modelsByRole.autocomplete ?? [];
|
||||
const selected =
|
||||
continueConfig?.selectedModelByRole?.autocomplete?.title ?? undefined;
|
||||
|
||||
// Toggle between Disabled, Paused, and Enabled
|
||||
const pauseOnBattery =
|
||||
|
|
@ -956,11 +951,10 @@ const getCommandsMap: (
|
|||
} else if (
|
||||
autocompleteModels.some((model) => model.title === selectedOption)
|
||||
) {
|
||||
new GlobalContext().update(
|
||||
"selectedTabAutocompleteModel",
|
||||
selectedOption,
|
||||
);
|
||||
configHandler.reloadConfig();
|
||||
core.invoke("config/updateSelectedModel", {
|
||||
role: "autocomplete",
|
||||
title: selectedOption,
|
||||
});
|
||||
} else if (selectedOption === "$(feedback) Give feedback") {
|
||||
vscode.commands.executeCommand("continue.giveAutocompleteFeedback");
|
||||
} else if (selectedOption === "$(comment) Open chat (Cmd+L)") {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import {
|
|||
} from "../stubs/WorkOsAuthProvider";
|
||||
import { Battery } from "../util/battery";
|
||||
import { FileSearch } from "../util/FileSearch";
|
||||
import { TabAutocompleteModel } from "../util/loadAutocompleteModel";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
|
||||
import { VsCodeMessenger } from "./VsCodeMessenger";
|
||||
|
|
@ -47,7 +46,6 @@ export class VsCodeExtension {
|
|||
private configHandler: ConfigHandler;
|
||||
private extensionContext: vscode.ExtensionContext;
|
||||
private ide: VsCodeIde;
|
||||
private tabAutocompleteModel: TabAutocompleteModel;
|
||||
private sidebar: ContinueGUIWebviewViewProvider;
|
||||
private windowId: string;
|
||||
private editDecorationManager: EditDecorationManager;
|
||||
|
|
@ -143,7 +141,6 @@ export class VsCodeExtension {
|
|||
this.editDecorationManager,
|
||||
);
|
||||
resolveVerticalDiffManager?.(this.verticalDiffManager);
|
||||
this.tabAutocompleteModel = new TabAutocompleteModel(this.configHandler);
|
||||
|
||||
setupRemoteConfigSync(
|
||||
this.configHandler.reloadConfig.bind(this.configHandler),
|
||||
|
|
@ -168,8 +165,6 @@ export class VsCodeExtension {
|
|||
} else if (newConfig) {
|
||||
setupStatusBar(undefined, undefined, false);
|
||||
|
||||
this.tabAutocompleteModel.clearLlm();
|
||||
|
||||
registerAllCodeLensProviders(
|
||||
context,
|
||||
this.verticalDiffManager.fileUriToCodeLens,
|
||||
|
|
@ -193,7 +188,6 @@ export class VsCodeExtension {
|
|||
new ContinueCompletionProvider(
|
||||
this.configHandler,
|
||||
this.ide,
|
||||
this.tabAutocompleteModel,
|
||||
this.sidebar.webviewProtocol,
|
||||
),
|
||||
),
|
||||
|
|
@ -347,7 +341,8 @@ export class VsCodeExtension {
|
|||
|
||||
// Register a content provider for the readonly virtual documents
|
||||
const documentContentProvider = new (class
|
||||
implements vscode.TextDocumentContentProvider {
|
||||
implements vscode.TextDocumentContentProvider
|
||||
{
|
||||
// emitter and its event
|
||||
onDidChangeEmitter = new vscode.EventEmitter<vscode.Uri>();
|
||||
onDidChange = this.onDidChangeEmitter.event;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { IDE } from "core";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { getModelByRole } from "core/config/util";
|
||||
import { logDevData } from "core/util/devdata";
|
||||
import { Telemetry } from "core/util/posthog";
|
||||
import * as vscode from "vscode";
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import Ollama from "core/llm/llms/Ollama";
|
||||
import { GlobalContext } from "core/util/GlobalContext";
|
||||
|
||||
import type { ILLM } from "core";
|
||||
|
||||
export class TabAutocompleteModel {
|
||||
private _llm: ILLM | undefined;
|
||||
private defaultTag = "qwen2.5-coder:1.5b";
|
||||
private globalContext: GlobalContext = new GlobalContext();
|
||||
|
||||
constructor(private configHandler: ConfigHandler) {}
|
||||
|
||||
clearLlm() {
|
||||
this._llm = undefined;
|
||||
}
|
||||
|
||||
async getDefaultTabAutocompleteModel() {
|
||||
const llm = new Ollama({
|
||||
model: this.defaultTag,
|
||||
});
|
||||
|
||||
try {
|
||||
const models = await llm.listModels();
|
||||
if (!models.includes(this.defaultTag)) {
|
||||
return undefined;
|
||||
}
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return llm;
|
||||
}
|
||||
|
||||
async get() {
|
||||
if (!this._llm) {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
if (!config) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (config.tabAutocompleteModels?.length) {
|
||||
const selected = this.globalContext.get("selectedTabAutocompleteModel");
|
||||
if (selected) {
|
||||
this._llm =
|
||||
config.tabAutocompleteModels?.find(
|
||||
(model) => model.title === selected,
|
||||
) ?? config.tabAutocompleteModels?.[0];
|
||||
} else {
|
||||
if (config.tabAutocompleteModels[0].title) {
|
||||
this.globalContext.update(
|
||||
"selectedTabAutocompleteModel",
|
||||
config.tabAutocompleteModels[0].title,
|
||||
);
|
||||
}
|
||||
this._llm = config.tabAutocompleteModels[0];
|
||||
}
|
||||
} else {
|
||||
this._llm = await this.getDefaultTabAutocompleteModel();
|
||||
}
|
||||
}
|
||||
|
||||
return this._llm;
|
||||
}
|
||||
}
|
||||
|
|
@ -278,9 +278,7 @@ const Layout = () => {
|
|||
onClick={() => navigate(ROUTES.CONFIG_ERROR)}
|
||||
>
|
||||
<strong className="font-bold">Error!</strong>{" "}
|
||||
<span className="block sm:inline">
|
||||
Could not load config.json
|
||||
</span>
|
||||
<span className="block sm:inline">Could not load config</span>
|
||||
<div className="mt-2 underline">Learn More</div>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
|
|||
}) => {
|
||||
return (
|
||||
<div className="flex cursor-pointer select-none items-center justify-between gap-3">
|
||||
<span className="truncate-right text-right">{text}</span>
|
||||
<span className="truncate-right">{text}</span>
|
||||
<div>
|
||||
<div
|
||||
className={`border-vsc-input-border bg-vsc-input-background flex h-5 w-10 items-center rounded-full border border-solid p-0.5`}
|
||||
className={`border-vsc-input-border bg-vsc-input-background flex h-4 w-8 items-center rounded-full border border-solid p-0.5`}
|
||||
onClick={onToggle}
|
||||
>
|
||||
<div className="relative h-full w-full">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
import { BuildingOfficeIcon, PlusIcon } from "@heroicons/react/24/outline";
|
||||
import {
|
||||
BuildingOfficeIcon,
|
||||
PlusIcon,
|
||||
UserCircleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useContext } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { lightGray } from "../..";
|
||||
|
|
@ -21,7 +25,8 @@ export function AssistantSelectOptions({
|
|||
onClose,
|
||||
}: AssistantSelectOptionsProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { profiles, selectedProfile, selectedOrganization } = useAuth();
|
||||
const { profiles, selectedProfile, selectedOrganization, session, login } =
|
||||
useAuth();
|
||||
const dispatch = useAppDispatch();
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
|
@ -83,7 +88,10 @@ export function AssistantSelectOptions({
|
|||
</div>
|
||||
|
||||
<div className="mt-auto w-full">
|
||||
<OptionDiv key={profiles.length} onClick={onNewAssistant}>
|
||||
<OptionDiv
|
||||
key={"new-assistant"}
|
||||
onClick={session ? onNewAssistant : () => login(true)}
|
||||
>
|
||||
<div
|
||||
className="flex items-center py-0.5"
|
||||
style={{ fontSize: getFontSize() - 2 }}
|
||||
|
|
|
|||
88
gui/src/pages/config/ModelRoleSelector.tsx
Normal file
88
gui/src/pages/config/ModelRoleSelector.tsx
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
import { Fragment, useContext, useEffect, useState } from "react";
|
||||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import {
|
||||
CheckIcon,
|
||||
XMarkIcon,
|
||||
ChevronUpDownIcon,
|
||||
PlusCircleIcon,
|
||||
InformationCircleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { type ModelDescription } from "core";
|
||||
import HoverItem from "../../components/mainInput/InputToolbar/HoverItem";
|
||||
import { ToolTip } from "../../components/gui/Tooltip";
|
||||
|
||||
interface ModelRoleSelectorProps {
|
||||
models: ModelDescription[];
|
||||
selectedModel: ModelDescription | null;
|
||||
onSelect: (model: ModelDescription | null) => void;
|
||||
displayName: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
const ModelRoleSelector = ({
|
||||
models,
|
||||
selectedModel,
|
||||
onSelect,
|
||||
displayName,
|
||||
description,
|
||||
}: ModelRoleSelectorProps) => {
|
||||
function handleSelect(title: string | null) {
|
||||
onSelect(models.find((m) => m.title === title) ?? null);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mt-2 flex flex-row items-center gap-1 sm:mt-0">
|
||||
<span className="text-sm">{displayName}</span>
|
||||
<InformationCircleIcon
|
||||
className="h-3 w-3"
|
||||
data-tooltip-id={`${displayName}-description`}
|
||||
/>
|
||||
<ToolTip id={`${displayName}-description`} place={"bottom"}>
|
||||
{description}
|
||||
</ToolTip>
|
||||
</div>
|
||||
<Listbox value={selectedModel?.title ?? null} onChange={handleSelect}>
|
||||
{({ open }) => (
|
||||
<div className="relative">
|
||||
<Listbox.Button className="border-vsc-input-border bg-vsc-background hover:bg-vsc-input-background text-vsc-foreground relative m-0 flex w-full cursor-pointer items-center justify-between rounded-md border border-solid px-2 py-1 text-left">
|
||||
<span className="lines lines-1">
|
||||
{selectedModel?.title ?? "No"}
|
||||
</span>
|
||||
<div className="pointer-events-none flex items-center">
|
||||
<ChevronUpDownIcon className="h-3.5 w-3.5" aria-hidden="true" />
|
||||
</div>
|
||||
</Listbox.Button>
|
||||
|
||||
<Transition
|
||||
as={Fragment}
|
||||
show={open}
|
||||
enter="transition ease-out duration-100"
|
||||
enterFrom="transform opacity-0 scale-95"
|
||||
enterTo="transform opacity-100 scale-100"
|
||||
leave="transition ease-in duration-75"
|
||||
leaveFrom="transform opacity-100 scale-100"
|
||||
leaveTo="transform opacity-0 scale-95"
|
||||
>
|
||||
<Listbox.Options className="bg-vsc-background max-h-80vh absolute z-[800] mt-0.5 w-full overflow-y-scroll rounded-sm p-0">
|
||||
{models.map((option, idx) => (
|
||||
<Listbox.Option
|
||||
key={idx}
|
||||
value={option.title}
|
||||
className={`text-vsc-foreground hover:text-list-active-foreground flex cursor-pointer flex-row items-center gap-3 px-2 py-1 ${option?.title === selectedModel?.title ? "bg-list-active" : "bg-vsc-input-background"}`}
|
||||
>
|
||||
<span className="lines lines-1 relative flex h-5 items-center justify-between gap-3 pr-2 text-xs">
|
||||
{option.title}
|
||||
</span>
|
||||
</Listbox.Option>
|
||||
))}
|
||||
</Listbox.Options>
|
||||
</Transition>
|
||||
</div>
|
||||
)}
|
||||
</Listbox>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelRoleSelector;
|
||||
|
|
@ -18,13 +18,17 @@ import { selectProfileThunk } from "../../redux/thunks/profileAndOrg";
|
|||
import {
|
||||
SharedConfigSchema,
|
||||
modifyAnyConfigWithSharedConfig,
|
||||
modifyFinalConfigWithSharedConfig,
|
||||
} from "core/config/sharedConfig";
|
||||
import { Input } from "../../components";
|
||||
import NumberInput from "../../components/gui/NumberInput";
|
||||
import { Select } from "../../components/gui/Select";
|
||||
import ToggleSwitch from "../../components/gui/Switch";
|
||||
import { updateConfig } from "../../redux/slices/configSlice";
|
||||
import { setDefaultModel, updateConfig } from "../../redux/slices/configSlice";
|
||||
import { getFontSize } from "../../util";
|
||||
import ModelRoleSelector from "./ModelRoleSelector";
|
||||
import { ModelDescription } from "core";
|
||||
import { ModelRole } from "@continuedev/config-yaml";
|
||||
|
||||
function ConfigPage() {
|
||||
useNavigationListener();
|
||||
|
|
@ -67,16 +71,48 @@ function ConfigPage() {
|
|||
|
||||
/////// User settings section //////
|
||||
const config = useAppSelector((state) => state.config.config);
|
||||
const profileId = useAppSelector((state) => state.session.selectedProfileId);
|
||||
const selectedChatModel = useAppSelector(
|
||||
(store) => store.config.defaultModelTitle,
|
||||
);
|
||||
|
||||
function handleUpdate(sharedConfig: SharedConfigSchema) {
|
||||
// Optimistic update
|
||||
dispatch(
|
||||
updateConfig(modifyAnyConfigWithSharedConfig(config, sharedConfig)),
|
||||
const firstPass = modifyAnyConfigWithSharedConfig(config, sharedConfig);
|
||||
const secondPass = modifyFinalConfigWithSharedConfig(
|
||||
firstPass,
|
||||
sharedConfig,
|
||||
);
|
||||
dispatch(updateConfig(secondPass));
|
||||
// Actual update to core which propogates back with config update event
|
||||
ideMessenger.post("config/updateSharedConfig", sharedConfig);
|
||||
}
|
||||
|
||||
function handleRoleUpdate(role: ModelRole, model: ModelDescription | null) {
|
||||
// Optimistic update
|
||||
dispatch(
|
||||
updateConfig({
|
||||
...config,
|
||||
selectedModelByRole: {
|
||||
...config.selectedModelByRole,
|
||||
[role]: model?.title,
|
||||
},
|
||||
}),
|
||||
);
|
||||
ideMessenger.post("config/updateSelectedModel", {
|
||||
role,
|
||||
title: model?.title ?? null,
|
||||
});
|
||||
}
|
||||
|
||||
// TODO use handleRoleUpdate for chat
|
||||
function handleChatModelSelection(model: ModelDescription | null) {
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
dispatch(setDefaultModel({ title: model.title }));
|
||||
}
|
||||
|
||||
// TODO defaults are in multiple places, should be consolidated and probably not explicit here
|
||||
const codeWrap = config.ui?.codeWrap ?? false;
|
||||
const showChatScrollbar = config.ui?.showChatScrollbar ?? false;
|
||||
|
|
@ -225,10 +261,14 @@ function ConfigPage() {
|
|||
value={null}
|
||||
className={`text-vsc-foreground hover:bg-list-active bg-vsc-input-background flex cursor-pointer flex-row items-center gap-2 px-3 py-2`}
|
||||
onClick={() => {
|
||||
ideMessenger.post("controlPlane/openUrl", {
|
||||
path: "new",
|
||||
orgSlug: selectedOrganization?.slug,
|
||||
});
|
||||
if (session) {
|
||||
ideMessenger.post("controlPlane/openUrl", {
|
||||
path: "new",
|
||||
orgSlug: selectedOrganization?.slug,
|
||||
});
|
||||
} else {
|
||||
login(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<PlusCircleIcon className="h-4 w-4" />
|
||||
|
|
@ -251,8 +291,59 @@ function ConfigPage() {
|
|||
: "Open Workspace"}
|
||||
</SecondaryButton>
|
||||
)}
|
||||
<h2 className="text-sm">Model Roles</h2>
|
||||
|
||||
<div>
|
||||
<h2 className="m-0 mb-3 p-0 text-center text-sm">
|
||||
Active Models
|
||||
</h2>
|
||||
<div className="grid grid-cols-1 gap-x-3 gap-y-2 sm:grid-cols-[auto_1fr]">
|
||||
<ModelRoleSelector
|
||||
displayName="Chat"
|
||||
description="Used in the chat interface"
|
||||
models={config.modelsByRole.chat}
|
||||
selectedModel={{
|
||||
title: selectedChatModel,
|
||||
provider: "mock",
|
||||
model: "mock",
|
||||
}}
|
||||
onSelect={(model) => handleChatModelSelection(model)}
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Autocomplete"
|
||||
description="Used to generate code completion suggestions"
|
||||
models={config.modelsByRole.autocomplete}
|
||||
selectedModel={config.selectedModelByRole.autocomplete}
|
||||
onSelect={(model) => handleRoleUpdate("autocomplete", model)}
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Edit"
|
||||
description="Used for inline and multi-file Edit mode requests"
|
||||
models={config.modelsByRole.edit}
|
||||
selectedModel={config.selectedModelByRole.edit}
|
||||
onSelect={(model) => handleRoleUpdate("edit", model)}
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Apply"
|
||||
description="Used to determine how to apply generated code to files"
|
||||
models={config.modelsByRole.apply}
|
||||
selectedModel={config.selectedModelByRole.apply}
|
||||
onSelect={(model) => handleRoleUpdate("apply", model)}
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Embed"
|
||||
description="Used to generate and query embeddings for the @codebase and @docs context providers"
|
||||
models={config.modelsByRole.embed}
|
||||
selectedModel={config.selectedModelByRole.embed}
|
||||
onSelect={(model) => handleRoleUpdate("embed", model)}
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Rerank"
|
||||
description="Used for reranking results from the @codebase and @docs context providers"
|
||||
models={config.modelsByRole.rerank}
|
||||
selectedModel={config.selectedModelByRole.rerank}
|
||||
onSelect={(model) => handleRoleUpdate("rerank", model)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{!controlServerBetaEnabled || hubEnabled ? (
|
||||
|
|
@ -351,7 +442,7 @@ function ConfigPage() {
|
|||
/>
|
||||
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="text-right">
|
||||
<span className="lines lines-1 text-left">
|
||||
Codeblock Actions Position
|
||||
</span>
|
||||
<Select
|
||||
|
|
@ -370,7 +461,7 @@ function ConfigPage() {
|
|||
</label>
|
||||
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="text-right">
|
||||
<span className="lines lines-1 text-left">
|
||||
Multiline Autocompletions
|
||||
</span>
|
||||
<Select
|
||||
|
|
@ -389,7 +480,7 @@ function ConfigPage() {
|
|||
</label>
|
||||
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="text-right">Font Size</span>
|
||||
<span className="text-left">Font Size</span>
|
||||
<NumberInput
|
||||
value={fontSize}
|
||||
onChange={(val) =>
|
||||
|
|
@ -409,7 +500,7 @@ function ConfigPage() {
|
|||
handleSubmitPromptPath();
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center justify-between gap-1">
|
||||
<span>Workspace prompts path</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
|
|
@ -486,7 +577,7 @@ function ConfigPage() {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span className="text-vsc-foreground-muted self-end text-xs">
|
||||
<span className="text-vsc-foreground-muted text-lightgray self-end text-xs">
|
||||
Comma-separated list of path matchers
|
||||
</span>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,24 @@ const initialState: ConfigState = {
|
|||
models: [],
|
||||
tools: [],
|
||||
usePlatform: false,
|
||||
modelsByRole: {
|
||||
chat: [],
|
||||
apply: [],
|
||||
edit: [],
|
||||
summarize: [],
|
||||
autocomplete: [],
|
||||
rerank: [],
|
||||
embed: [],
|
||||
},
|
||||
selectedModelByRole: {
|
||||
chat: null,
|
||||
apply: null,
|
||||
edit: null,
|
||||
summarize: null,
|
||||
autocomplete: null,
|
||||
rerank: null,
|
||||
embed: null,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue