Merge branch 'main' into pe/baseSystemPrompt
This commit is contained in:
commit
75942dbbd4
91 changed files with 1496 additions and 1174 deletions
2
.github/workflows/jetbrains-release.yaml
vendored
2
.github/workflows/jetbrains-release.yaml
vendored
|
|
@ -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 }}"
|
||||
|
|
|
|||
2
.github/workflows/preview.yaml
vendored
2
.github/workflows/preview.yaml
vendored
|
|
@ -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 }}"
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@
|
|||
"curly": "off",
|
||||
"@typescript-eslint/semi": "off",
|
||||
"eqeqeq": "error",
|
||||
"complexity": ["error", { "max": 38 }],
|
||||
"max-lines-per-function": ["error", { "max": 996 }],
|
||||
"complexity": ["error", { "max": 36 }],
|
||||
"max-lines-per-function": ["error", { "max": 472 }],
|
||||
"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 }]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
@ -172,22 +166,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);
|
||||
}),
|
||||
|
|
@ -473,27 +467,6 @@ export class ConfigHandler {
|
|||
}
|
||||
}
|
||||
|
||||
// Only used till we move to using selectedModelByRole.chat
|
||||
async llmFromTitle(title?: string): Promise<ILLM> {
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
@ -38,7 +37,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";
|
||||
|
|
@ -46,9 +44,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";
|
||||
|
|
@ -221,17 +218,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
|
||||
|
|
@ -429,38 +436,32 @@ async function intermediateToFinalConfig(
|
|||
function getEmbeddingsILLM(
|
||||
embedConfig: EmbeddingsProviderDescription | ILLM | undefined,
|
||||
): ILLM | null {
|
||||
if (!embedConfig) {
|
||||
return null;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
@ -473,11 +474,11 @@ async function intermediateToFinalConfig(
|
|||
if (!rerankingConfig) {
|
||||
return null;
|
||||
}
|
||||
// config.ts-injected ILLM
|
||||
if ("providerName" in rerankingConfig) {
|
||||
return rerankingConfig;
|
||||
}
|
||||
const { name, params } = config.reranker as RerankerDescription;
|
||||
const rerankerClass = AllRerankers[name];
|
||||
|
||||
if (name === "llm") {
|
||||
const llm = models.find((model) => model.title === params?.modelTitle);
|
||||
|
|
@ -490,16 +491,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, {
|
||||
...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;
|
||||
}
|
||||
|
|
@ -508,7 +513,6 @@ async function intermediateToFinalConfig(
|
|||
const continueConfig: ContinueConfig = {
|
||||
...config,
|
||||
contextProviders,
|
||||
models,
|
||||
tools: [...allTools],
|
||||
mcpServerStatuses: [],
|
||||
slashCommands: config.slashCommands ?? [],
|
||||
|
|
@ -548,7 +552,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) {
|
||||
|
|
@ -567,7 +571,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) {
|
||||
|
|
@ -621,7 +625,6 @@ async function finalToBrowserConfig(
|
|||
): Promise<BrowserSerializedContinueConfig> {
|
||||
return {
|
||||
allowAnonymousTelemetry: final.allowAnonymousTelemetry,
|
||||
models: final.models.map(llmToSerializedModelDescription),
|
||||
systemMessage: final.systemMessage,
|
||||
completionOptions: final.completionOptions,
|
||||
slashCommands: final.slashCommands?.map(
|
||||
|
|
@ -935,15 +938,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],
|
||||
|
|
|
|||
|
|
@ -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 {}
|
||||
|
|
|
|||
|
|
@ -55,18 +55,18 @@ export default class LocalProfileLoader implements IProfileLoader {
|
|||
description: ProfileDescription;
|
||||
|
||||
async doLoadConfig(): Promise<ConfigResult<ContinueConfig>> {
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<AssistantUnrolled>,
|
||||
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<IdeSettings>,
|
||||
private llmLogger: ILLMLogger,
|
||||
readonly description: ProfileDescription,
|
||||
private readonly orgScopeId: string | null,
|
||||
) {}
|
||||
private configResult: ConfigResult<AssistantUnrolled>;
|
||||
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<IdeSettings>;
|
||||
private llmLogger: ILLMLogger;
|
||||
readonly description: ProfileDescription;
|
||||
private readonly orgScopeId: string | null;
|
||||
|
||||
static async create(
|
||||
configResult: ConfigResult<AssistantUnrolled>,
|
||||
ownerSlug: string,
|
||||
packageSlug: string,
|
||||
iconUrl: string,
|
||||
versionSlug: string,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
ide: IDE,
|
||||
ideSettingsPromise: Promise<IdeSettings>,
|
||||
llmLogger: ILLMLogger,
|
||||
rawYaml: string,
|
||||
orgScopeId: string | null,
|
||||
): Promise<PlatformProfileLoader> {
|
||||
private constructor({
|
||||
configResult,
|
||||
ownerSlug,
|
||||
packageSlug,
|
||||
iconUrl,
|
||||
versionSlug,
|
||||
controlPlaneClient,
|
||||
ide,
|
||||
ideSettingsPromise,
|
||||
llmLogger,
|
||||
description,
|
||||
orgScopeId,
|
||||
}: {
|
||||
configResult: ConfigResult<AssistantUnrolled>;
|
||||
ownerSlug: string;
|
||||
packageSlug: string;
|
||||
iconUrl: string;
|
||||
versionSlug: string;
|
||||
controlPlaneClient: ControlPlaneClient;
|
||||
ide: IDE;
|
||||
ideSettingsPromise: Promise<IdeSettings>;
|
||||
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<AssistantUnrolled>;
|
||||
ownerSlug: string;
|
||||
packageSlug: string;
|
||||
iconUrl: string;
|
||||
versionSlug: string;
|
||||
controlPlaneClient: ControlPlaneClient;
|
||||
ide: IDE;
|
||||
ideSettingsPromise: Promise<IdeSettings>;
|
||||
llmLogger: ILLMLogger;
|
||||
rawYaml: string;
|
||||
orgScopeId: string | null;
|
||||
}): Promise<PlatformProfileLoader> {
|
||||
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<ConfigResult<ContinueConfig>> {
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -36,18 +36,29 @@ import { loadContinueConfigFromYaml } from "../yaml/loadYaml";
|
|||
|
||||
import { PlatformConfigMetadata } from "./PlatformProfileLoader";
|
||||
|
||||
export default async function doLoadConfig(
|
||||
ide: IDE,
|
||||
ideSettingsPromise: Promise<IdeSettings>,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
llmLogger: ILLMLogger,
|
||||
overrideConfigJson: SerializedContinueConfig | undefined,
|
||||
overrideConfigYaml: AssistantUnrolled | undefined,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
profileId: string,
|
||||
overrideConfigYamlByPath: string | undefined,
|
||||
orgScopeId: string | null,
|
||||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
export default async function doLoadConfig({
|
||||
ide,
|
||||
ideSettingsPromise,
|
||||
controlPlaneClient,
|
||||
llmLogger,
|
||||
overrideConfigJson,
|
||||
overrideConfigYaml,
|
||||
platformConfigMetadata,
|
||||
profileId,
|
||||
overrideConfigYamlByPath,
|
||||
orgScopeId,
|
||||
}: {
|
||||
ide: IDE;
|
||||
ideSettingsPromise: Promise<IdeSettings>;
|
||||
controlPlaneClient: ControlPlaneClient;
|
||||
llmLogger: ILLMLogger;
|
||||
overrideConfigJson: SerializedContinueConfig | undefined;
|
||||
overrideConfigYaml: AssistantUnrolled | undefined;
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined;
|
||||
profileId: string;
|
||||
overrideConfigYamlByPath: string | undefined;
|
||||
orgScopeId: string | null;
|
||||
}): Promise<ConfigResult<ContinueConfig>> {
|
||||
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;
|
||||
|
|
@ -258,7 +268,7 @@ async function injectControlPlaneProxyInfo(
|
|||
}
|
||||
});
|
||||
|
||||
config.models.forEach((model) => {
|
||||
config.modelsByRole.chat.forEach((model) => {
|
||||
if (model.providerName === "continue-proxy") {
|
||||
(model as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
@ -52,8 +51,12 @@ export function rectifySelectedModelsFromGlobalContext(
|
|||
fellBack = true;
|
||||
}
|
||||
|
||||
if (newModel?.getConfigurationStatus() !== LLMConfigurationStatuses.VALID) {
|
||||
break;
|
||||
// Currently only check for configuration status for apply
|
||||
if (
|
||||
role === "apply" &&
|
||||
newModel?.getConfigurationStatus() !== LLMConfigurationStatuses.VALID
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
configCopy.selectedModelByRole[role] = newModel;
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ export function getModelByRole<T extends keyof ExperimentalModelRoles>(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const matchingModel = config.models.find(
|
||||
const matchingModel = config.modelsByRole.chat.find(
|
||||
(model) => model.title === roleTitle,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {
|
|||
ConfigResult,
|
||||
ConfigValidationError,
|
||||
FQSN,
|
||||
isAssistantUnrolledNonNullable,
|
||||
ModelRole,
|
||||
PlatformClient,
|
||||
RegistryClient,
|
||||
|
|
@ -12,7 +13,6 @@ import {
|
|||
unrollAssistantFromContent,
|
||||
validateConfigYaml,
|
||||
} from "@continuedev/config-yaml";
|
||||
import { fetchwithRequestOptions } from "@continuedev/fetch";
|
||||
|
||||
import {
|
||||
ContinueConfig,
|
||||
|
|
@ -23,14 +23,12 @@ import {
|
|||
ILLMLogger,
|
||||
} 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";
|
||||
|
|
@ -43,7 +41,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 {
|
||||
|
|
@ -94,7 +91,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 {
|
||||
|
|
@ -112,41 +117,32 @@ 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: [],
|
||||
models: [],
|
||||
tools: [...allTools],
|
||||
mcpServerStatuses: [],
|
||||
systemMessage: undefined,
|
||||
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,
|
||||
systemMessage: config.rules?.join("\n"),
|
||||
contextProviders: [],
|
||||
modelsByRole: {
|
||||
chat: [],
|
||||
|
|
@ -158,7 +154,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,
|
||||
|
|
@ -166,7 +162,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 -
|
||||
|
|
@ -223,10 +250,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);
|
||||
}
|
||||
|
|
@ -237,31 +260,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")) {
|
||||
|
|
@ -273,59 +271,25 @@ async function configYamlToContinueConfig(
|
|||
}
|
||||
|
||||
if (model.roles?.includes("embed")) {
|
||||
const { provider, ...options } = model;
|
||||
const embeddingsProviderClass = allEmbeddingsProviders[provider];
|
||||
if (embeddingsProviderClass) {
|
||||
if (
|
||||
embeddingsProviderClass.name === "_TransformersJsEmbeddingsProvider"
|
||||
) {
|
||||
const { provider } = model;
|
||||
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({
|
||||
|
|
@ -349,7 +313,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) {
|
||||
|
|
@ -364,14 +328,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",
|
||||
);
|
||||
}
|
||||
|
|
@ -434,19 +399,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<ConfigResult<ContinueConfig>> {
|
||||
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<ConfigResult<ContinueConfig>> {
|
||||
const rawYaml =
|
||||
overrideConfigYaml === undefined
|
||||
? fs.readFileSync(
|
||||
|
|
@ -472,16 +449,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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
@ -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: [],
|
||||
};
|
||||
|
|
|
|||
606
core/core.ts
606
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,9 @@ import { TTS } from "./util/tts";
|
|||
|
||||
import {
|
||||
DiffLine,
|
||||
IdeSettings,
|
||||
ModelDescription,
|
||||
RangeInFile,
|
||||
type ContextItemId,
|
||||
type IDE,
|
||||
type IndexingProgressUpdate,
|
||||
|
|
@ -44,7 +41,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 +55,37 @@ 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<string>,
|
||||
msg: Message<ToCoreProtocol["streamDiffLines"][0]>,
|
||||
): AsyncGenerator<DiffLine> {
|
||||
const data = msg.data;
|
||||
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,
|
||||
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<CodebaseIndexer>;
|
||||
|
|
@ -118,8 +152,7 @@ export class Core {
|
|||
this.messenger,
|
||||
);
|
||||
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
mcpManager.onConnectionsRefreshed = async () => {
|
||||
MCPManagerSingleton.getInstance().onConnectionsRefreshed = async () => {
|
||||
await this.configHandler.reloadConfig();
|
||||
};
|
||||
|
||||
|
|
@ -210,6 +243,10 @@ export class Core {
|
|||
(..._) => Promise.resolve([]),
|
||||
);
|
||||
|
||||
this.registerMessageHandlers(ideSettingsPromise);
|
||||
}
|
||||
|
||||
private registerMessageHandlers(ideSettingsPromise: Promise<IdeSettings>) {
|
||||
const on = this.messenger.on.bind(this.messenger);
|
||||
|
||||
// Note, VsCode's in-process messenger doesn't do anything with this
|
||||
|
|
@ -329,7 +366,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 +398,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,13 +431,19 @@ export class Core {
|
|||
this.configHandler,
|
||||
this.abortedMessageIds,
|
||||
msg,
|
||||
ide,
|
||||
this.ide,
|
||||
this.messenger,
|
||||
),
|
||||
);
|
||||
|
||||
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,
|
||||
|
|
@ -495,31 +451,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;
|
||||
|
|
@ -530,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);
|
||||
});
|
||||
|
||||
|
|
@ -552,93 +488,13 @@ export class Core {
|
|||
this.completionProvider.cancel();
|
||||
});
|
||||
|
||||
async function* streamDiffLinesGenerator(
|
||||
configHandler: ConfigHandler,
|
||||
abortedMessageIds: Set<string>,
|
||||
msg: Message<ToCoreProtocol["streamDiffLines"][0]>,
|
||||
): AsyncGenerator<DiffLine> {
|
||||
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;
|
||||
on("completeOnboarding", this.handleCompleteOnboarding);
|
||||
|
||||
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("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();
|
||||
|
|
@ -649,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) {
|
||||
|
|
@ -681,63 +536,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);
|
||||
}
|
||||
|
|
@ -786,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) => {
|
||||
|
|
@ -805,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) => {
|
||||
|
|
@ -868,7 +667,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,
|
||||
|
|
@ -898,12 +702,15 @@ 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);
|
||||
|
||||
// File exceeds context length of the model
|
||||
if (tokens > llm.contextLength - llm.completionOptions!.maxTokens!) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -912,6 +719,259 @@ 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<{
|
||||
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.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();
|
||||
} 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 } = msg.data;
|
||||
|
||||
const llm = (await this.configHandler.loadConfig()).config
|
||||
?.selectedModelByRole.chat;
|
||||
|
||||
if (!llm) {
|
||||
throw new Error("No chat model selected");
|
||||
}
|
||||
|
||||
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(
|
||||
|
|
|
|||
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
49
core/llm/utils/__tests__/getSecureID.test.ts
Normal file
49
core/llm/utils/__tests__/getSecureID.test.ts
Normal file
|
|
@ -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('<!-- SID: test-uuid-1234 -->');
|
||||
});
|
||||
|
||||
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('<!-- SID: test-uuid-1234 -->');
|
||||
});
|
||||
|
||||
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('<!-- SID: persistent-uuid -->');
|
||||
});
|
||||
});
|
||||
8
core/llm/utils/getSecureID.ts
Normal file
8
core/llm/utils/getSecureID.ts
Normal file
|
|
@ -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 `<!-- SID: ${(getSecureID as any).uuid} -->`;
|
||||
}
|
||||
8
core/package-lock.json
generated
8
core/package-lock.json
generated
|
|
@ -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.71",
|
||||
"@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.71",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.71.tgz",
|
||||
"integrity": "sha512-c7KVaYfldaYHf2EqeqE9Oo1son33iTp6MAY+WRPJVs9XWmRWOA6Cn7YDf575FpwX6UsPCT/Eb0JJme8AC7UE6g==",
|
||||
"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",
|
||||
|
|
|
|||
|
|
@ -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.71",
|
||||
"@continuedev/config-yaml": "^1.0.77",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.18",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
|
|||
{
|
||||
text: string;
|
||||
streamId: string;
|
||||
curSelectedModelTitle: string;
|
||||
filepath?: string;
|
||||
toolCallId?: string;
|
||||
},
|
||||
|
|
@ -52,7 +51,6 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
|
|||
{
|
||||
prompt: MessageContent;
|
||||
range: RangeInFileWithContents;
|
||||
selectedModelTitle: string;
|
||||
},
|
||||
void,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ models:
|
|||
- name: My Voyage Reranker
|
||||
provider: voyage
|
||||
apiKey: <YOUR_VOYAGE_KEY>
|
||||
roles:
|
||||
- rerank
|
||||
|
||||
- name: My Starcoder
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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<ContinueExtensionSettings>()
|
||||
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>()
|
||||
continuePluginService.sendToWebview(messageType, responseMap["data"], messageType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -497,21 +497,18 @@ 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 (applyCodeBlockModel != null) {
|
||||
continuation.resume(applyCodeBlockModel)
|
||||
} else {
|
||||
val models =
|
||||
config["models"] as List<Map<String, Any>>
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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,14 @@ export class VsCodeMessenger {
|
|||
return;
|
||||
}
|
||||
|
||||
let llm: ILLM | null | undefined = config.selectedModelByRole.apply;
|
||||
let llm =
|
||||
config.selectedModelByRole.apply ?? config.selectedModelByRole.chat;
|
||||
|
||||
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;
|
||||
|
|
@ -229,7 +223,7 @@ export class VsCodeMessenger {
|
|||
|
||||
await verticalDiffManager.streamEdit(
|
||||
prompt,
|
||||
llm.title,
|
||||
llm,
|
||||
data.streamId,
|
||||
undefined,
|
||||
undefined,
|
||||
|
|
@ -292,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,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export async function getContextProvidersString(
|
|||
provider.description.displayTitle === selectedProvider.label,
|
||||
);
|
||||
|
||||
if (!provider) {
|
||||
if (!provider || !config.selectedModelByRole.chat) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
@ -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) =>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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<string | undefined> {
|
||||
if (this._curModelTitle) {
|
||||
return this._curModelTitle;
|
||||
}
|
||||
|
||||
private async getCurModel(): Promise<ILLM | null> {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
10
gui/package-lock.json
generated
10
gui/package-lock.json
generated
|
|
@ -7,7 +7,7 @@
|
|||
"name": "gui",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-yaml": "^1.0.71",
|
||||
"@continuedev/config-yaml": "^1.0.77",
|
||||
"@headlessui/react": "^2.2.0",
|
||||
"@heroicons/react": "^2.0.18",
|
||||
"@reduxjs/toolkit": "^2.3.0",
|
||||
|
|
@ -109,7 +109,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",
|
||||
|
|
@ -553,9 +553,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@continuedev/config-yaml": {
|
||||
"version": "1.0.71",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.71.tgz",
|
||||
"integrity": "sha512-c7KVaYfldaYHf2EqeqE9Oo1son33iTp6MAY+WRPJVs9XWmRWOA6Cn7YDf575FpwX6UsPCT/Eb0JJme8AC7UE6g==",
|
||||
"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",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
"test:watch": "vitest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@continuedev/config-yaml": "^1.0.71",
|
||||
"@continuedev/config-yaml": "^1.0.77",
|
||||
"@headlessui/react": "^2.2.0",
|
||||
"@heroicons/react": "^2.0.18",
|
||||
"@reduxjs/toolkit": "^2.3.0",
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export function OnboardingCard({ isDialog }: OnboardingCardProps) {
|
|||
|
||||
return (
|
||||
<ReusableCard
|
||||
showCloseButton={!isDialog && !!config.models.length}
|
||||
showCloseButton={!isDialog && !!config.modelsByRole.chat.length}
|
||||
onClose={() => onboardingCard.close()}
|
||||
testId="onboarding-card"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -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 { setDefaultModel } 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,7 +63,14 @@ function BestExperienceConfigForm({
|
|||
model: repoMapConfig,
|
||||
role: "repoMapFileSelection",
|
||||
});
|
||||
dispatch(setDefaultModel({ title: chatModelConfig.title, force: true }));
|
||||
|
||||
dispatch(
|
||||
updateSelectedModelByRole({
|
||||
selectedProfile,
|
||||
role: "chat",
|
||||
modelTitle: chatModelConfig.title,
|
||||
}),
|
||||
);
|
||||
|
||||
if (!!autocompleteApiKey) {
|
||||
await ideMessenger.request("addAutocompleteModel", {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) {
|
|||
|
||||
return (
|
||||
<ReusableCard
|
||||
showCloseButton={!isDialog && !!config.models.length}
|
||||
showCloseButton={!isDialog && !!config.modelsByRole.chat.length}
|
||||
onClose={() => onboardingCard.close()}
|
||||
>
|
||||
<div className="flex h-full w-full items-center justify-center">
|
||||
|
|
|
|||
|
|
@ -6,15 +6,16 @@ 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 { 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";
|
||||
import { useSubmitOnboarding } from "../hooks";
|
||||
import { setDefaultModel } from "../../../redux/slices/configSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
|
||||
const OLLAMA_CHECK_INTERVAL_MS = 3000;
|
||||
|
||||
|
|
@ -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(
|
||||
setDefaultModel({
|
||||
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,
|
||||
}),
|
||||
);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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") {
|
||||
|
|
|
|||
|
|
@ -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<HTMLInputElement | null>(null);
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const defaultModel = useAppSelector(selectSelectedChatModel);
|
||||
const useActiveFile = useAppSelector(selectUseActiveFile);
|
||||
const isInEditMode = useAppSelector(selectIsInEditMode);
|
||||
const hasCodeToEdit = useAppSelector(selectHasCodeToEdit);
|
||||
|
|
|
|||
|
|
@ -1,54 +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 {
|
||||
selectDefaultModel,
|
||||
setDefaultModel,
|
||||
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();
|
||||
const selectedChatModel = useAppSelector(selectDefaultModel);
|
||||
|
||||
function handleRoleUpdate(role: ModelRole, model: ModelDescription | null) {
|
||||
if (!selectedProfile) {
|
||||
return;
|
||||
}
|
||||
// Optimistic update
|
||||
dispatch(
|
||||
updateConfig({
|
||||
...config,
|
||||
selectedModelByRole: {
|
||||
...config.selectedModelByRole,
|
||||
[role]: model,
|
||||
},
|
||||
}),
|
||||
);
|
||||
ideMessenger.post("config/updateSelectedModel", {
|
||||
profileId: selectedProfile.id,
|
||||
role,
|
||||
title: model?.title ?? null,
|
||||
});
|
||||
}
|
||||
|
||||
// TODO use handleRoleUpdate for chat
|
||||
function handleChatModelSelection(model: ModelDescription | null) {
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
dispatch(setDefaultModel({ title: model.title }));
|
||||
|
||||
dispatch(
|
||||
updateSelectedModelByRole({
|
||||
role,
|
||||
selectedProfile,
|
||||
modelTitle: model.title,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
@ -58,16 +35,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)}
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Autocomplete"
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
|||
import useIsOSREnabled from "../../../hooks/useIsOSREnabled";
|
||||
import useUpdatingRef from "../../../hooks/useUpdatingRef";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import { selectDefaultModel } from "../../../redux/slices/configSlice";
|
||||
import { selectSelectedChatModel } from "../../../redux/slices/configSlice";
|
||||
import { selectIsInEditMode } from "../../../redux/slices/sessionSlice";
|
||||
import InputToolbar, { ToolbarOptions } from "../InputToolbar";
|
||||
import { ComboBoxItem } from "../types";
|
||||
|
|
@ -46,7 +46,7 @@ export function TipTapEditor(props: TipTapEditorProps) {
|
|||
|
||||
const isOSREnabled = useIsOSREnabled();
|
||||
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const defaultModel = useAppSelector(selectSelectedChatModel);
|
||||
const isStreaming = useAppSelector((state) => state.session.isStreaming);
|
||||
const isInEditMode = useAppSelector(selectIsInEditMode);
|
||||
const historyLength = useAppSelector((store) => store.session.history.length);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -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;
|
||||
`;
|
||||
|
|
@ -81,10 +82,10 @@ export default function StepContainerPreToolbar(
|
|||
const isNextCodeBlock = nextCodeBlockIndex === props.codeBlockIndex;
|
||||
const hasFileExtension = /\.[0-9a-z]+$/i.test(props.relativeFilepath);
|
||||
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const selectedChatModel = useAppSelector(selectSelectedChatModel);
|
||||
|
||||
async function onClickApply() {
|
||||
if (!defaultModel) {
|
||||
if (!selectedChatModel) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +98,6 @@ export default function StepContainerPreToolbar(
|
|||
streamId: props.codeBlockStreamId,
|
||||
filepath: fileUri,
|
||||
text: codeBlockContent,
|
||||
curSelectedModelTitle: defaultModel.title,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(() => {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
selectDefaultModel,
|
||||
setDefaultModel,
|
||||
} 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,9 +119,11 @@ function ModelOption({
|
|||
}
|
||||
|
||||
function ModelSelect() {
|
||||
const dispatch = useDispatch();
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const allModels = useAppSelector((state) => state.config.config.models);
|
||||
const dispatch = useAppDispatch();
|
||||
const selectedChatModel = useAppSelector(selectSelectedChatModel);
|
||||
const allChatModels = useAppSelector(
|
||||
(state) => state.config.config.modelsByRole.chat,
|
||||
);
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const [options, setOptions] = useState<Option[]>([]);
|
||||
const [sortedOptions, setSortedOptions] = useState<Option[]>([]);
|
||||
|
|
@ -142,7 +141,7 @@ function ModelSelect() {
|
|||
|
||||
useEffect(() => {
|
||||
setOptions(
|
||||
allModels
|
||||
allChatModels
|
||||
.filter((m) => !m.roles || m.roles.includes("chat"))
|
||||
.map((model) => {
|
||||
return {
|
||||
|
|
@ -152,19 +151,30 @@ function ModelSelect() {
|
|||
};
|
||||
}),
|
||||
);
|
||||
}, [allModels]);
|
||||
}, [allChatModels]);
|
||||
|
||||
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(setDefaultModel({ title: newModelTitle }));
|
||||
|
||||
dispatch(
|
||||
updateSelectedModelByRole({
|
||||
selectedProfile,
|
||||
role: "chat",
|
||||
modelTitle: newModelTitle,
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -172,7 +182,7 @@ function ModelSelect() {
|
|||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, [options, defaultModel]);
|
||||
}, [options, selectedChatModel]);
|
||||
|
||||
function onClickAddModel(e: MouseEvent) {
|
||||
e.stopPropagation();
|
||||
|
|
@ -195,11 +205,16 @@ function ModelSelect() {
|
|||
}
|
||||
|
||||
return (
|
||||
// <span className="line-clamp-1">Hiad sfasdfasdf asdfasdf</span>
|
||||
<Listbox
|
||||
onChange={async (val: string) => {
|
||||
if (val === defaultModel?.title) return;
|
||||
dispatch(setDefaultModel({ title: val }));
|
||||
if (val === selectedChatModel?.title) return;
|
||||
dispatch(
|
||||
updateSelectedModelByRole({
|
||||
selectedProfile,
|
||||
role: "chat",
|
||||
modelTitle: val,
|
||||
}),
|
||||
);
|
||||
}}
|
||||
>
|
||||
<div className="relative flex">
|
||||
|
|
@ -209,7 +224,7 @@ function ModelSelect() {
|
|||
className="h-[18px] gap-1 border-none text-gray-400"
|
||||
>
|
||||
<span className="line-clamp-1 hover:brightness-110">
|
||||
{modelSelectTitle(defaultModel) || "Select model"}
|
||||
{modelSelectTitle(selectedChatModel) || "Select model"}
|
||||
</span>
|
||||
<ChevronDownIcon
|
||||
className="h-2 w-2 flex-shrink-0 hover:brightness-110"
|
||||
|
|
@ -224,7 +239,7 @@ function ModelSelect() {
|
|||
idx={idx}
|
||||
key={idx}
|
||||
showMissingApiKeyMsg={option.apiKey === ""}
|
||||
isSelected={option.value === defaultModel?.title}
|
||||
isSelected={option.value === selectedChatModel?.title}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {
|
||||
ArrowPathRoundedSquareIcon,
|
||||
ArrowPathIcon,
|
||||
ArrowTopRightOnSquareIcon,
|
||||
BuildingOfficeIcon,
|
||||
ChevronDownIcon,
|
||||
|
|
@ -99,7 +99,7 @@ const AssistantSelectOption = ({
|
|||
fontSize: tinyFont,
|
||||
}}
|
||||
>
|
||||
<div className="flex w-full items-center justify-between bg-transparent">
|
||||
<div className="flex w-full items-center justify-between gap-2 bg-transparent">
|
||||
<div className="flex w-full items-center gap-1.5">
|
||||
<div className="flex h-4 w-4 flex-shrink-0">
|
||||
<AssistantIcon assistant={profile} />
|
||||
|
|
@ -291,6 +291,20 @@ export default function AssistantSelect() {
|
|||
|
||||
<Transition>
|
||||
<ListboxOptions className="pb-0">
|
||||
<div className="flex gap-1.5 px-2.5 py-1">
|
||||
<span>Assistants</span>
|
||||
<div
|
||||
className="flex cursor-pointer flex-row items-center gap-1 hover:brightness-125"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
refreshProfiles();
|
||||
buttonRef.current?.click();
|
||||
}}
|
||||
>
|
||||
<ArrowPathIcon className="h-2.5 w-2.5" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={`thin-scrollbar flex max-h-[300px] flex-col overflow-y-auto`}
|
||||
>
|
||||
|
|
@ -314,8 +328,9 @@ export default function AssistantSelect() {
|
|||
}}
|
||||
/>
|
||||
|
||||
<div className="flex flex-row items-center justify-between gap-1 pr-2">
|
||||
<div className="flex flex-row items-center">
|
||||
<ListboxOption
|
||||
className="w-full"
|
||||
value={"new-assistant"}
|
||||
fontSizeModifier={-2}
|
||||
onClick={session ? onNewAssistant : () => login(false)}
|
||||
|
|
@ -330,24 +345,6 @@ export default function AssistantSelect() {
|
|||
New Assistant
|
||||
</div>
|
||||
</ListboxOption>
|
||||
<div
|
||||
className="flex cursor-pointer flex-row items-center gap-1 hover:brightness-125"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
refreshProfiles();
|
||||
buttonRef.current?.click();
|
||||
}}
|
||||
>
|
||||
<ArrowPathRoundedSquareIcon className="h-3 w-3" />
|
||||
<span
|
||||
className="hidden sm:flex"
|
||||
style={{
|
||||
fontSize: tinyFont,
|
||||
}}
|
||||
>
|
||||
Refresh
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -1,20 +1,21 @@
|
|||
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";
|
||||
import {
|
||||
ProviderInfo,
|
||||
providers,
|
||||
} from "../pages/AddNewModel/configs/providers";
|
||||
import { useAppDispatch } from "../redux/hooks";
|
||||
import { updateSelectedModelByRole } from "../redux/thunks";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS, hasPassedFTL } from "../util/freeTrial";
|
||||
import { completionParamsInputs } from "../pages/AddNewModel/configs/completionParamsInputs";
|
||||
import { setDefaultModel } from "../redux/slices/configSlice";
|
||||
import { DisplayInfo } from "../pages/AddNewModel/configs/models";
|
||||
|
||||
interface QuickModelSetupProps {
|
||||
onDone: () => void;
|
||||
|
|
@ -33,13 +34,14 @@ function AddModelForm({
|
|||
const [selectedProvider, setSelectedProvider] = useState<ProviderInfo>(
|
||||
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(setDefaultModel({ title: model.title, force: true }));
|
||||
dispatch(
|
||||
updateSelectedModelByRole({
|
||||
selectedProfile,
|
||||
role: "chat",
|
||||
modelTitle: model.title,
|
||||
}),
|
||||
);
|
||||
|
||||
onDone();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
);
|
||||
|
|
@ -50,6 +50,7 @@ function useSetup() {
|
|||
organizations,
|
||||
selectedOrgId,
|
||||
} = result;
|
||||
debugger;
|
||||
if (isInitial && hasDoneInitialConfigLoad.current) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -253,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 &&
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ const ModelRoleSelector = ({
|
|||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const [hoveredIdx, setHoveredIdx] = useState<number | null>(null);
|
||||
|
||||
const noConfiguredModels = models.every(
|
||||
(model) => model.configurationStatus !== LLMConfigurationStatuses.VALID,
|
||||
);
|
||||
|
||||
function handleSelect(title: string | null) {
|
||||
onSelect(models.find((m) => m.title === title) ?? null);
|
||||
}
|
||||
|
|
@ -79,8 +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 ? (
|
||||
<span className="text-lightgray line-clamp-1 italic">{`No ${displayName} models${["Chat", "Apply", "Edit"].includes(displayName) ? ". Using chat model" : ""}`}</span>
|
||||
{models.length === 0 || noConfiguredModels ? (
|
||||
<span className="text-lightgray line-clamp-1 italic">
|
||||
{`No ${models.length === 0 ? "" : "valid "}${displayName} models${
|
||||
["Chat", "Apply", "Edit"].includes(displayName)
|
||||
? ". Using Chat model"
|
||||
: ""
|
||||
}`}
|
||||
</span>
|
||||
) : (
|
||||
<span className="line-clamp-1">
|
||||
{selectedModel?.title ?? `Select ${displayName} model`}
|
||||
|
|
|
|||
|
|
@ -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 selectedChatModel = useAppSelector(selectSelectedChatModel);
|
||||
const isStreaming = useAppSelector((state) => state.session.isStreaming);
|
||||
const [stepsOpen, setStepsOpen] = useState<(boolean | undefined)[]>([]);
|
||||
const mainTextInputRef = useRef<HTMLInputElement>(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 = [
|
||||
|
|
@ -259,7 +259,6 @@ export function Chat() {
|
|||
ideMessenger.post("edit/sendPrompt", {
|
||||
prompt,
|
||||
range: codeToEdit[0] as RangeInFileWithContents,
|
||||
selectedModelTitle: defaultModel.title,
|
||||
});
|
||||
|
||||
dispatch(submitEdit(prompt));
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
@ -21,7 +20,6 @@ const EMPTY_CONFIG: BrowserSerializedContinueConfig = {
|
|||
},
|
||||
],
|
||||
contextProviders: [],
|
||||
models: [],
|
||||
tools: [],
|
||||
mcpServerStatuses: [],
|
||||
usePlatform: true,
|
||||
|
|
@ -47,7 +45,6 @@ const EMPTY_CONFIG: BrowserSerializedContinueConfig = {
|
|||
|
||||
const initialState: ConfigState = {
|
||||
configError: undefined,
|
||||
defaultModelTitle: undefined,
|
||||
config: EMPTY_CONFIG,
|
||||
};
|
||||
|
||||
|
|
@ -70,12 +67,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 +77,29 @@ export const configSlice = createSlice({
|
|||
) => {
|
||||
state.config = config;
|
||||
},
|
||||
setDefaultModel: (
|
||||
state,
|
||||
{ payload }: PayloadAction<{ title: string; force?: boolean }>,
|
||||
) => {
|
||||
const model = state.config.models.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,
|
||||
};
|
||||
},
|
||||
},
|
||||
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 } = configSlice.actions;
|
||||
|
||||
export const {
|
||||
selectDefaultModel,
|
||||
selectDefaultModelContextLength,
|
||||
selectSelectedChatModelContextLength,
|
||||
selectUIConfig,
|
||||
selectSelectedChatModel,
|
||||
} = configSlice.selectors;
|
||||
|
||||
export default configSlice.reducer;
|
||||
|
|
|
|||
|
|
@ -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,8 +30,9 @@ export const callTool = createAsyncThunk<void, undefined, ThunkApiType>(
|
|||
return;
|
||||
}
|
||||
|
||||
const defaultModel = selectDefaultModel(state);
|
||||
if (!defaultModel) {
|
||||
const selectedChatModel = selectSelectedChatModel(state);
|
||||
|
||||
if (!selectedChatModel) {
|
||||
throw new Error("No model selected");
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +55,6 @@ export const callTool = createAsyncThunk<void, undefined, ThunkApiType>(
|
|||
args,
|
||||
extra.ideMessenger,
|
||||
state.session.activeToolStreamId[0],
|
||||
defaultModel.title,
|
||||
toolCallState.toolCallId,
|
||||
);
|
||||
} catch (e) {
|
||||
|
|
@ -77,7 +77,7 @@ export const callTool = createAsyncThunk<void, undefined, ThunkApiType>(
|
|||
} 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;
|
||||
|
|
@ -125,7 +125,6 @@ async function customGuiEditImpl(
|
|||
args: EditToolArgs,
|
||||
ideMessenger: IIdeMessenger,
|
||||
streamId: string,
|
||||
modelTitle: string,
|
||||
toolCallId: string,
|
||||
) {
|
||||
const firstUriMatch = await resolveRelativePathInDir(
|
||||
|
|
@ -138,7 +137,6 @@ async function customGuiEditImpl(
|
|||
const apply = await ideMessenger.request("applyToFile", {
|
||||
streamId,
|
||||
text: args.new_contents,
|
||||
curSelectedModelTitle: modelTitle,
|
||||
toolCallId,
|
||||
filepath: firstUriMatch,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,11 +37,12 @@ export const gatherContext = createAsyncThunk<
|
|||
{ dispatch, extra, getState },
|
||||
) => {
|
||||
const state = getState();
|
||||
const defaultModel = selectDefaultModel(state);
|
||||
const selectedChatModel = selectSelectedChatModel(state);
|
||||
|
||||
const defaultContextProviders =
|
||||
state.config.config.experimental?.defaultContext ?? [];
|
||||
|
||||
if (!defaultModel) {
|
||||
if (!selectedChatModel) {
|
||||
console.error(
|
||||
"gatherContext thunk: Cannot gather context, no model selected",
|
||||
);
|
||||
|
|
@ -57,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",
|
||||
|
|
@ -71,7 +72,7 @@ export const gatherContext = createAsyncThunk<
|
|||
query: "non-mention-usage",
|
||||
fullInput: "",
|
||||
selectedCode: [],
|
||||
selectedModelTitle: defaultModel.title,
|
||||
selectedModelTitle: selectedChatModel.title,
|
||||
},
|
||||
);
|
||||
if (currentFileResponse.status === "success") {
|
||||
|
|
|
|||
|
|
@ -5,3 +5,4 @@ export { streamNormalInput } from "./streamNormalInput";
|
|||
export { streamResponseThunk } from "./streamResponse";
|
||||
export { streamResponseAfterToolCall } from "./streamResponseAfterToolCall";
|
||||
export { streamThunkWrapper } from "./streamThunkWrapper";
|
||||
export { updateSelectedModelByRole } from "./updateSelectedModelByRole";
|
||||
|
|
|
|||
|
|
@ -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,8 +167,9 @@ 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);
|
||||
if (!state.config.config?.disableSessionTitles && defaultModel) {
|
||||
const selectedChatModel = selectSelectedChatModel(state);
|
||||
|
||||
if (!state.config.config?.disableSessionTitles && selectedChatModel) {
|
||||
let assistantResponse = state.session.history
|
||||
?.filter((h) => h.message.role === "assistant")[0]
|
||||
?.message?.content?.toString();
|
||||
|
|
@ -179,7 +180,7 @@ export const saveCurrentSession = createAsyncThunk<
|
|||
"chatDescriber/describe",
|
||||
{
|
||||
text: assistantResponse,
|
||||
selectedModelTitle: defaultModel.title,
|
||||
selectedModelTitle: selectedChatModel.title,
|
||||
},
|
||||
);
|
||||
if (result.status === "success" && result.content) {
|
||||
|
|
|
|||
|
|
@ -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,15 +29,16 @@ export const streamNormalInput = createAsyncThunk<
|
|||
) => {
|
||||
// Gather state
|
||||
const state = getState();
|
||||
const defaultModel = selectDefaultModel(state);
|
||||
const selectedChatModel = selectSelectedChatModel(state);
|
||||
|
||||
const toolSettings = state.ui.toolSettings;
|
||||
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(
|
||||
|
|
@ -51,7 +52,7 @@ export const streamNormalInput = createAsyncThunk<
|
|||
),
|
||||
}
|
||||
: {},
|
||||
title: defaultModel.title,
|
||||
title: selectedChatModel.title,
|
||||
messages,
|
||||
legacySlashCommandData,
|
||||
},
|
||||
|
|
@ -81,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,
|
||||
},
|
||||
});
|
||||
|
|
@ -93,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,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -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,11 +34,10 @@ export const streamResponseThunk = createAsyncThunk<
|
|||
await dispatch(
|
||||
streamThunkWrapper(async () => {
|
||||
const state = getState();
|
||||
const defaultModel = selectDefaultModel(state);
|
||||
const slashCommands = state.config.config.slashCommands || [];
|
||||
const selectedChatModel = selectSelectedChatModel(state);
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,9 +27,9 @@ export const streamResponseAfterToolCall = createAsyncThunk<
|
|||
streamThunkWrapper(async () => {
|
||||
const state = getState();
|
||||
const initialHistory = state.session.history;
|
||||
const defaultModel = selectDefaultModel(state);
|
||||
const selectedChatModel = selectSelectedChatModel(state);
|
||||
|
||||
if (!defaultModel) {
|
||||
if (!selectedChatModel) {
|
||||
throw new Error("No model selected");
|
||||
}
|
||||
|
||||
|
|
|
|||
58
gui/src/redux/thunks/updateSelectedModelByRole.ts
Normal file
58
gui/src/redux/thunks/updateSelectedModelByRole.ts
Normal file
|
|
@ -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,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
@ -9,7 +9,6 @@ class Calculator {
|
|||
}
|
||||
|
||||
subtract(number) {
|
||||
this.result -= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,3 +30,4 @@ class Test {
|
|||
return this
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
234
package-lock.json
generated
234
package-lock.json
generated
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1
packages/config-yaml/package-lock.json
generated
1
packages/config-yaml/package-lock.json
generated
|
|
@ -1049,6 +1049,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"
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
@ -92,12 +93,28 @@ describe("E2E Scenarios", () => {
|
|||
getContent: async function (fullSlug: FullSlug): Promise<string> {
|
||||
return fs
|
||||
.readFileSync(
|
||||
`./test/packages/${fullSlug.ownerSlug}/${fullSlug.packageSlug}.yaml`,
|
||||
`./src/__tests__/packages/${fullSlug.ownerSlug}/${fullSlug.packageSlug}.yaml`,
|
||||
)
|
||||
.toString();
|
||||
},
|
||||
};
|
||||
|
||||
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,
|
||||
{
|
||||
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",
|
||||
);
|
||||
|
||||
|
|
@ -176,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", () => {});
|
||||
});
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
name: Assistant with non-existing block
|
||||
version: 0.0.1
|
||||
schema: v1
|
||||
|
||||
rules:
|
||||
- uses: test-org/non-existing-package
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import {
|
|||
Rule,
|
||||
} from "../schemas/index.js";
|
||||
import { useProxyForUnrenderedSecrets } from "./clientRender.js";
|
||||
import { getBlockType } from "./getBlockType.js";
|
||||
|
||||
export function parseConfigYaml(configYaml: string): ConfigYaml {
|
||||
try {
|
||||
|
|
@ -178,11 +179,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;
|
||||
|
|
@ -239,7 +247,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);
|
||||
|
|
@ -277,6 +289,7 @@ export async function unrollAssistantFromContent(
|
|||
export async function unrollBlocks(
|
||||
assistant: ConfigYaml,
|
||||
registry: Registry,
|
||||
injectBlocks: FullSlug[] | undefined,
|
||||
): Promise<AssistantUnrolled> {
|
||||
const unrolledAssistant: AssistantUnrolled = {
|
||||
name: assistant.name,
|
||||
|
|
@ -296,16 +309,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
|
||||
|
|
@ -319,19 +339,26 @@ export async function unrollBlocks(
|
|||
|
||||
// Rules are a bit different because they can be strings, so hanlde separately
|
||||
if (assistant.rules) {
|
||||
const rules: Rule[] = [];
|
||||
const rules: (Rule | null)[] = [];
|
||||
for (const rule of assistant.rules) {
|
||||
if (typeof rule === "string" || !("uses" in rule)) {
|
||||
rules.push(rule);
|
||||
} else if ("uses" in rule) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -339,6 +366,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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,10 +48,20 @@ export const blockItemWrapperSchema = <T extends z.AnyZodObject>(schema: T) =>
|
|||
export const blockOrSchema = <T extends z.AnyZodObject>(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({
|
||||
|
|
@ -88,6 +98,18 @@ export const configYamlSchema = baseConfigYamlSchema.extend({
|
|||
export type ConfigYaml = z.infer<typeof configYamlSchema>;
|
||||
|
||||
export const assistantUnrolledSchema = baseConfigYamlSchema.extend({
|
||||
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(ruleSchema.nullable()).optional(),
|
||||
prompts: z.array(promptSchema.nullable()).optional(),
|
||||
docs: z.array(docSchema.nullable()).optional(),
|
||||
});
|
||||
|
||||
export type AssistantUnrolled = z.infer<typeof assistantUnrolledSchema>;
|
||||
|
||||
export const assistantUnrolledSchemaNonNullable = baseConfigYamlSchema.extend({
|
||||
models: z.array(modelSchema).optional(),
|
||||
context: z.array(contextSchema).optional(),
|
||||
data: z.array(dataSchema).optional(),
|
||||
|
|
@ -97,7 +119,20 @@ export const assistantUnrolledSchema = baseConfigYamlSchema.extend({
|
|||
docs: z.array(docSchema).optional(),
|
||||
});
|
||||
|
||||
export type AssistantUnrolled = z.infer<typeof assistantUnrolledSchema>;
|
||||
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([
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue