switch over to YAML for new users
This commit is contained in:
parent
cd10f4d2a2
commit
8f65021ce9
12 changed files with 93 additions and 213 deletions
|
|
@ -1,93 +1,37 @@
|
|||
import {
|
||||
ContextProviderWithParams,
|
||||
ModelDescription,
|
||||
SerializedContinueConfig,
|
||||
SlashCommandDescription,
|
||||
} from "../";
|
||||
import { ConfigYaml } from "@continuedev/config-yaml";
|
||||
|
||||
export const FREE_TRIAL_MODELS: ModelDescription[] = [
|
||||
{
|
||||
title: "Claude 3.5 Sonnet (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "GPT-4o (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gpt-4o",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "Llama3.1 70b (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "llama3.1-70b",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "Codestral (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "codestral-latest",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
export const defaultContextProvidersVsCode: NonNullable<
|
||||
ConfigYaml["context"]
|
||||
>[number][] = [
|
||||
{ provider: "code" },
|
||||
{ provider: "docs" },
|
||||
{ provider: "diff" },
|
||||
{ provider: "terminal" },
|
||||
{ provider: "problems" },
|
||||
{ provider: "folder" },
|
||||
{ provider: "codebase" },
|
||||
];
|
||||
|
||||
export const defaultContextProvidersVsCode: ContextProviderWithParams[] = [
|
||||
{ name: "code", params: {} },
|
||||
{ name: "docs", params: {} },
|
||||
{ name: "diff", params: {} },
|
||||
{ name: "terminal", params: {} },
|
||||
{ name: "problems", params: {} },
|
||||
{ name: "folder", params: {} },
|
||||
{ name: "codebase", params: {} },
|
||||
export const defaultContextProvidersJetBrains: NonNullable<
|
||||
ConfigYaml["context"]
|
||||
>[number][] = [
|
||||
{ provider: "diff" },
|
||||
{ provider: "folder" },
|
||||
{ provider: "codebase" },
|
||||
];
|
||||
|
||||
export const defaultContextProvidersJetBrains: ContextProviderWithParams[] = [
|
||||
{ name: "diff", params: {} },
|
||||
{ name: "folder", params: {} },
|
||||
{ name: "codebase", params: {} },
|
||||
];
|
||||
|
||||
export const defaultSlashCommandsVscode: SlashCommandDescription[] = [
|
||||
{
|
||||
name: "share",
|
||||
description: "Export the current chat session to markdown",
|
||||
},
|
||||
{
|
||||
name: "cmd",
|
||||
description: "Generate a shell command",
|
||||
},
|
||||
{
|
||||
name: "commit",
|
||||
description: "Generate a git commit message",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultSlashCommandsJetBrains = [
|
||||
{
|
||||
name: "share",
|
||||
description: "Export the current chat session to markdown",
|
||||
},
|
||||
{
|
||||
name: "commit",
|
||||
description: "Generate a git commit message",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultConfig: SerializedContinueConfig = {
|
||||
export const defaultConfig: ConfigYaml = {
|
||||
name: "Local Assistant",
|
||||
version: "1.0.0",
|
||||
schema: "v1",
|
||||
models: [],
|
||||
contextProviders: defaultContextProvidersVsCode,
|
||||
slashCommands: defaultSlashCommandsVscode,
|
||||
data: [],
|
||||
context: defaultContextProvidersVsCode,
|
||||
};
|
||||
|
||||
export const defaultConfigJetBrains: SerializedContinueConfig = {
|
||||
export const defaultConfigJetBrains: ConfigYaml = {
|
||||
name: "Local Assistant",
|
||||
version: "1.0.0",
|
||||
schema: "v1",
|
||||
models: [],
|
||||
contextProviders: defaultContextProvidersJetBrains,
|
||||
slashCommands: defaultSlashCommandsJetBrains,
|
||||
data: [],
|
||||
context: defaultContextProvidersJetBrains,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -70,12 +70,6 @@ import {
|
|||
} from "../util/paths";
|
||||
import { localPathToUri } from "../util/pathToUri";
|
||||
|
||||
import {
|
||||
defaultContextProvidersJetBrains,
|
||||
defaultContextProvidersVsCode,
|
||||
defaultSlashCommandsJetBrains,
|
||||
defaultSlashCommandsVscode,
|
||||
} from "./default";
|
||||
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
|
||||
import { modifyAnyConfigWithSharedConfig } from "./sharedConfig";
|
||||
import { getModelByRole, isSupportedLanceDbCpuTargetForLinux } from "./util";
|
||||
|
|
@ -122,7 +116,7 @@ function loadSerializedConfig(
|
|||
let config: SerializedContinueConfig = overrideConfigJson!;
|
||||
if (!config) {
|
||||
try {
|
||||
config = resolveSerializedConfig(getConfigJsonPath(ideType));
|
||||
config = resolveSerializedConfig(getConfigJsonPath());
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to parse config.json: ${e}`);
|
||||
}
|
||||
|
|
@ -162,16 +156,6 @@ function loadSerializedConfig(
|
|||
);
|
||||
}
|
||||
|
||||
// Set defaults if undefined (this lets us keep config.json uncluttered for new users)
|
||||
config.contextProviders ??=
|
||||
ideType === "vscode"
|
||||
? [...defaultContextProvidersVsCode]
|
||||
: [...defaultContextProvidersJetBrains];
|
||||
config.slashCommands ??=
|
||||
ideType === "vscode"
|
||||
? [...defaultSlashCommandsVscode]
|
||||
: [...defaultSlashCommandsJetBrains];
|
||||
|
||||
if (os.platform() === "linux" && !isSupportedLanceDbCpuTargetForLinux(ide)) {
|
||||
config.disableIndexing = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import { SerializedContinueConfig } from "../";
|
||||
|
||||
import { FREE_TRIAL_MODELS } from "./default";
|
||||
import { ConfigYaml } from "@continuedev/config-yaml";
|
||||
|
||||
export const TRIAL_FIM_MODEL = "codestral-latest";
|
||||
export const LOCAL_ONBOARDING_PROVIDER_TITLE = "Ollama";
|
||||
|
|
@ -9,64 +7,46 @@ export const LOCAL_ONBOARDING_FIM_TITLE = "Qwen2.5-Coder 1.5B";
|
|||
export const LOCAL_ONBOARDING_CHAT_MODEL = "llama3.1:8b";
|
||||
export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B";
|
||||
export const LOCAL_ONBOARDING_EMBEDDINGS_MODEL = "nomic-embed-text:latest";
|
||||
export const LOCAL_ONBOARDING_EMBEDDINGS_TITLE = "Nomic Embed";
|
||||
|
||||
/**
|
||||
* We set the "best" chat + autocopmlete models by default
|
||||
* whenever a user doesn't have a config.json
|
||||
*/
|
||||
export function setupBestConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
export function setupBestConfig(config: ConfigYaml): ConfigYaml {
|
||||
return {
|
||||
...config,
|
||||
models: config.models.filter((model) => model.provider !== "free-trial"),
|
||||
models: config.models,
|
||||
};
|
||||
}
|
||||
|
||||
export function setupLocalConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
export function setupLocalConfig(config: ConfigYaml): ConfigYaml {
|
||||
return {
|
||||
...config,
|
||||
models: [
|
||||
{
|
||||
title: LOCAL_ONBOARDING_CHAT_TITLE,
|
||||
name: LOCAL_ONBOARDING_CHAT_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
roles: ["chat", "edit", "apply"],
|
||||
},
|
||||
...config.models.filter((model) => model.provider !== "free-trial"),
|
||||
{
|
||||
name: LOCAL_ONBOARDING_FIM_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_FIM_MODEL,
|
||||
roles: ["autocomplete"],
|
||||
},
|
||||
{
|
||||
name: LOCAL_ONBOARDING_EMBEDDINGS_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
|
||||
roles: ["embed"],
|
||||
},
|
||||
...(config.models ?? []),
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: LOCAL_ONBOARDING_FIM_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_FIM_MODEL,
|
||||
},
|
||||
embeddingsProvider: {
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function setupQuickstartConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
return {
|
||||
...config,
|
||||
models: [
|
||||
...FREE_TRIAL_MODELS,
|
||||
...config.models.filter((model) => model.provider !== "free-trial"),
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: "Tab Autocomplete",
|
||||
provider: "free-trial",
|
||||
model: TRIAL_FIM_MODEL,
|
||||
},
|
||||
embeddingsProvider: {
|
||||
provider: "free-trial",
|
||||
},
|
||||
reranker: {
|
||||
name: "free-trial",
|
||||
},
|
||||
};
|
||||
export function setupQuickstartConfig(config: ConfigYaml): ConfigYaml {
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export default async function doLoadConfig(
|
|||
|
||||
// Migrations for old config files
|
||||
// Removes
|
||||
const configJsonPath = getConfigJsonPath(ideInfo.ideType);
|
||||
const configJsonPath = getConfigJsonPath();
|
||||
if (fs.existsSync(configJsonPath)) {
|
||||
migrateJsonSharedConfig(configJsonPath, ide);
|
||||
}
|
||||
|
|
|
|||
19
core/core.ts
19
core/core.ts
|
|
@ -29,7 +29,11 @@ import { ChatDescriber } from "./util/chatDescriber";
|
|||
import { clipboardCache } from "./util/clipboardCache";
|
||||
import { GlobalContext } from "./util/GlobalContext";
|
||||
import historyManager from "./util/history";
|
||||
import { editConfigJson, migrateV1DevDataFiles } from "./util/paths";
|
||||
import {
|
||||
editConfigJson,
|
||||
editConfigYaml,
|
||||
migrateV1DevDataFiles,
|
||||
} from "./util/paths";
|
||||
import { Telemetry } from "./util/posthog";
|
||||
import { getSymbolsForManyFiles } from "./util/treeSitter";
|
||||
import { TTS } from "./util/tts";
|
||||
|
|
@ -607,27 +611,27 @@ export class Core {
|
|||
return;
|
||||
}
|
||||
|
||||
let editConfigJsonCallback: Parameters<typeof editConfigJson>[0];
|
||||
let editConfigYamlCallback: Parameters<typeof editConfigYaml>[0];
|
||||
|
||||
switch (mode) {
|
||||
case "Local":
|
||||
editConfigJsonCallback = setupLocalConfig;
|
||||
editConfigYamlCallback = setupLocalConfig;
|
||||
break;
|
||||
|
||||
case "Quickstart":
|
||||
editConfigJsonCallback = setupQuickstartConfig;
|
||||
editConfigYamlCallback = setupQuickstartConfig;
|
||||
break;
|
||||
|
||||
case "Best":
|
||||
editConfigJsonCallback = setupBestConfig;
|
||||
editConfigYamlCallback = setupBestConfig;
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error(`Invalid mode: ${mode}`);
|
||||
editConfigJsonCallback = (config) => config;
|
||||
editConfigYamlCallback = (config) => config;
|
||||
}
|
||||
|
||||
editConfigJson(editConfigJsonCallback);
|
||||
editConfigYaml(editConfigYamlCallback);
|
||||
|
||||
void this.configHandler.reloadConfig();
|
||||
});
|
||||
|
|
@ -979,4 +983,3 @@ export class Core {
|
|||
|
||||
// private
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
import { DevEventName } from "@continuedev/config-yaml";
|
||||
import { ConfigYaml, DevEventName } from "@continuedev/config-yaml";
|
||||
import * as JSONC from "comment-json";
|
||||
import dotenv from "dotenv";
|
||||
|
||||
|
|
@ -91,27 +92,20 @@ export function getSessionsListPath(): string {
|
|||
return filepath;
|
||||
}
|
||||
|
||||
export function getConfigJsonPath(ideType: IdeType = "vscode"): string {
|
||||
export function getConfigJsonPath(): string {
|
||||
const p = path.join(getContinueGlobalPath(), "config.json");
|
||||
if (!fs.existsSync(p)) {
|
||||
if (ideType === "jetbrains") {
|
||||
fs.writeFileSync(p, JSON.stringify(defaultConfigJetBrains, null, 2));
|
||||
} else {
|
||||
fs.writeFileSync(p, JSON.stringify(defaultConfig, null, 2));
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
export function getConfigYamlPath(ideType?: IdeType): string {
|
||||
const p = path.join(getContinueGlobalPath(), "config.yaml");
|
||||
// if (!fs.existsSync(p)) {
|
||||
// if (ideType === "jetbrains") {
|
||||
// fs.writeFileSync(p, YAML.stringify(defaultConfigYamlJetBrains));
|
||||
// } else {
|
||||
// fs.writeFileSync(p, YAML.stringify(defaultConfigYaml));
|
||||
// }
|
||||
// }
|
||||
if (!fs.existsSync(p) && !fs.existsSync(getConfigJsonPath())) {
|
||||
if (ideType === "jetbrains") {
|
||||
fs.writeFileSync(p, YAML.stringify(defaultConfigJetBrains));
|
||||
} else {
|
||||
fs.writeFileSync(p, YAML.stringify(defaultConfig));
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
@ -248,6 +242,20 @@ export function editConfigJson(
|
|||
}
|
||||
}
|
||||
|
||||
export function editConfigYaml(
|
||||
callback: (config: ConfigYaml) => ConfigYaml,
|
||||
): void {
|
||||
const config = fs.readFileSync(getConfigYamlPath(), "utf8");
|
||||
let configYaml = YAML.parse(config);
|
||||
// Check if it's an object
|
||||
if (typeof configYaml === "object" && configYaml !== null) {
|
||||
configYaml = callback(configYaml as any) as any;
|
||||
fs.writeFileSync(getConfigYamlPath(), YAML.stringify(configYaml));
|
||||
} else {
|
||||
console.warn("config.yaml is not a valid object");
|
||||
}
|
||||
}
|
||||
|
||||
function getMigrationsFolderPath(): string {
|
||||
const migrationsPath = path.join(getContinueGlobalPath(), ".migrations");
|
||||
if (!fs.existsSync(migrationsPath)) {
|
||||
|
|
|
|||
|
|
@ -1,32 +1,5 @@
|
|||
import { SlashCommandDescription } from "core";
|
||||
import {
|
||||
defaultSlashCommandsJetBrains,
|
||||
defaultSlashCommandsVscode,
|
||||
} from "core/config/default";
|
||||
import { isJetBrains } from "../../util";
|
||||
|
||||
/**
|
||||
* The commands filtered here are currently inserted into the slash commands array during
|
||||
* intermediary config loading, but once we get the actual prompts for an assistant,
|
||||
* they are overwritten.
|
||||
*
|
||||
* Additionally, these default commands are all deprecated.
|
||||
*
|
||||
* If we don't manually filter them out, then they are displayed in the UI
|
||||
* while the assistant is still loading.
|
||||
*
|
||||
* Once these commands are no longer inserted during intermediary config loading,
|
||||
* this function can be removed.
|
||||
*/
|
||||
export function isDeprecatedCommandName(command: SlashCommandDescription) {
|
||||
const defaultCommands = isJetBrains()
|
||||
? defaultSlashCommandsJetBrains
|
||||
: defaultSlashCommandsVscode;
|
||||
|
||||
return !defaultCommands.find(
|
||||
(defaultCommand) => defaultCommand.name === command.name,
|
||||
);
|
||||
}
|
||||
import {} from "core/config/default";
|
||||
|
||||
/**
|
||||
* Sorts commands with bookmarked ones first
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { FREE_TRIAL_MODELS } from "core/config/default";
|
||||
import { useContext } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Button, ButtonSubtext } from "../..";
|
||||
|
|
@ -7,7 +6,6 @@ import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
|||
import { isJetBrains } from "../../../util";
|
||||
import { useSubmitOnboarding } from "../hooks";
|
||||
import JetBrainsFetchGitHubTokenDialog from "./JetBrainsFetchGitHubTokenDialog";
|
||||
import { setDefaultModel } from "../../../redux/slices/configSlice";
|
||||
|
||||
interface QuickstartSubmitButtonProps {
|
||||
isDialog?: boolean;
|
||||
|
|
@ -21,10 +19,6 @@ function QuickstartSubmitButton({ isDialog }: QuickstartSubmitButtonProps) {
|
|||
|
||||
function onComplete() {
|
||||
submitOnboarding();
|
||||
|
||||
// Set Sonnet as the default model
|
||||
const title = FREE_TRIAL_MODELS[0].title;
|
||||
dispatch(setDefaultModel({ title, force: true }));
|
||||
}
|
||||
|
||||
function openJetBrainsDialog() {
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) {
|
|||
<div className="mt-4 flex flex-col">
|
||||
<Alert type="info">
|
||||
By choosing this option, Continue will be configured by a local{" "}
|
||||
<code>config.yaml</code> file. If you're just looking to use
|
||||
Ollama and still want to manage your configuration through
|
||||
Continue, click{" "}
|
||||
<code className="text-vsc-background">config.yaml</code> file. If
|
||||
you're just looking to use Ollama and still want to manage your
|
||||
configuration through Continue, click{" "}
|
||||
<a href="#" onClick={() => setCurrentTab("main")}>
|
||||
here
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
const currentTarget = e.currentTarget;
|
||||
const relatedTarget = e.relatedTarget as Node | null;
|
||||
|
||||
if (relatedTarget && currentTarget.contains(relatedTarget)) {
|
||||
if (relatedTarget && currentTarget?.contains(relatedTarget)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ function ModeSelect() {
|
|||
<span className="">Agent</span>
|
||||
</div>
|
||||
{mode === "agent" && <CheckIcon className="ml-auto h-3 w-3" />}
|
||||
{!agentModeSupported && <span>(Not supported)</span>}
|
||||
{!agentModeSupported && <span> (Not supported)</span>}
|
||||
</ListboxOption>
|
||||
|
||||
<ListboxOption value="chat">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { ProfileDescription } from "core/config/ConfigHandler";
|
||||
import { isDeprecatedCommandName } from "../../../components/ConversationStarters/utils";
|
||||
import { ThunkApiType } from "../../store";
|
||||
import {
|
||||
initializeProfilePreferences,
|
||||
|
|
@ -98,15 +97,10 @@ export const initializeProfilePreferencesThunk = createAsyncThunk<
|
|||
"profiles/initializeProfilePreferences",
|
||||
async (data, { getState, dispatch }) => {
|
||||
const { profileId } = data;
|
||||
const state = getState();
|
||||
|
||||
// Get slash commands from config
|
||||
const defaultSlashCommands =
|
||||
state.config.config.slashCommands.filter(isDeprecatedCommandName) ?? [];
|
||||
|
||||
dispatch(
|
||||
initializeProfilePreferences({
|
||||
defaultSlashCommands,
|
||||
defaultSlashCommands: [],
|
||||
profileId,
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue