Merge pull request #2232 from continuedev/pe/onboarding-refactor
feat: `OnboardingCard`
This commit is contained in:
commit
3bdf28bc7a
92 changed files with 2124 additions and 2385 deletions
|
|
@ -311,10 +311,17 @@ export class CompletionProvider {
|
|||
|
||||
// Get completion
|
||||
const llm = await this.getLlm();
|
||||
|
||||
if (!llm) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Ignore empty API keys for Mistral since we currently write
|
||||
// a template provider without one during onboarding
|
||||
if (llm.providerName === "mistral" && llm.apiKey === "") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Set temperature (but don't overrride)
|
||||
if (llm.completionOptions.temperature === undefined) {
|
||||
llm.completionOptions.temperature = 0.01;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,13 @@ import {
|
|||
IdeSettings,
|
||||
ILLM,
|
||||
} from "../index.js";
|
||||
import Ollama from "../llm/llms/Ollama.js";
|
||||
import { GlobalContext } from "../util/GlobalContext.js";
|
||||
import { finalToBrowserConfig } from "./load.js";
|
||||
import {
|
||||
LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
} from "./onboarding.js";
|
||||
import ControlPlaneProfileLoader from "./profile/ControlPlaneProfileLoader.js";
|
||||
import { IProfileLoader } from "./profile/IProfileLoader.js";
|
||||
import LocalProfileLoader from "./profile/LocalProfileLoader.js";
|
||||
|
|
@ -279,9 +284,18 @@ export class ConfigHandler {
|
|||
|
||||
async llmFromTitle(title?: string): Promise<ILLM> {
|
||||
const config = await this.loadConfig();
|
||||
const model =
|
||||
config.models.find((m) => m.title === title) || config.models[0];
|
||||
const model = config.models.find((m) => m.title === title);
|
||||
if (!model) {
|
||||
if (title === ONBOARDING_LOCAL_MODEL_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 > 0) {
|
||||
return config.models[0];
|
||||
}
|
||||
|
||||
throw new Error("No model found");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,28 @@ import {
|
|||
ModelDescription,
|
||||
SerializedContinueConfig,
|
||||
SlashCommandDescription,
|
||||
} from "../index.js";
|
||||
} from "../";
|
||||
|
||||
export const DEFAULT_CHAT_MODEL_CONFIG: ModelDescription = {
|
||||
model: "claude-3-5-sonnet-20240620",
|
||||
provider: "anthropic",
|
||||
apiKey: "",
|
||||
title: "Claude 3.5 Sonnet",
|
||||
};
|
||||
|
||||
export const DEFAULT_AUTOCOMPLETE_MODEL_CONFIG: ModelDescription = {
|
||||
title: "Codestral",
|
||||
provider: "mistral",
|
||||
model: "codestral-latest",
|
||||
apiKey: "",
|
||||
};
|
||||
|
||||
export const FREE_TRIAL_MODELS: ModelDescription[] = [
|
||||
{
|
||||
title: "Claude 3 Sonnet (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "claude-3-sonnet-20240229",
|
||||
},
|
||||
{
|
||||
title: "GPT-4o (Free Trial)",
|
||||
provider: "free-trial",
|
||||
|
|
@ -25,11 +44,6 @@ export const FREE_TRIAL_MODELS: ModelDescription[] = [
|
|||
provider: "free-trial",
|
||||
model: "codestral",
|
||||
},
|
||||
{
|
||||
title: "Claude 3 Sonnet (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "claude-3-sonnet-20240229",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultContextProvidersVsCode: ContextProviderWithParams[] = [
|
||||
|
|
@ -91,7 +105,8 @@ export const defaultSlashCommandsJetBrains = [
|
|||
];
|
||||
|
||||
export const defaultConfig: SerializedContinueConfig = {
|
||||
models: [],
|
||||
models: [DEFAULT_CHAT_MODEL_CONFIG],
|
||||
tabAutocompleteModel: DEFAULT_AUTOCOMPLETE_MODEL_CONFIG,
|
||||
customCommands: [
|
||||
{
|
||||
name: "test",
|
||||
|
|
@ -100,17 +115,13 @@ export const defaultConfig: SerializedContinueConfig = {
|
|||
description: "Write unit tests for highlighted code",
|
||||
},
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: "Starcoder2 3b",
|
||||
provider: "ollama",
|
||||
model: "starcoder2:3b",
|
||||
},
|
||||
contextProviders: defaultContextProvidersVsCode,
|
||||
slashCommands: defaultSlashCommandsVscode,
|
||||
};
|
||||
|
||||
export const defaultConfigJetBrains: SerializedContinueConfig = {
|
||||
models: FREE_TRIAL_MODELS,
|
||||
models: [DEFAULT_CHAT_MODEL_CONFIG],
|
||||
tabAutocompleteModel: DEFAULT_AUTOCOMPLETE_MODEL_CONFIG,
|
||||
customCommands: [
|
||||
{
|
||||
name: "test",
|
||||
|
|
@ -119,11 +130,6 @@ export const defaultConfigJetBrains: SerializedContinueConfig = {
|
|||
description: "Write unit tests for highlighted code",
|
||||
},
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: "Starcoder2 3b",
|
||||
provider: "ollama",
|
||||
model: "starcoder2:3b",
|
||||
},
|
||||
contextProviders: defaultContextProvidersJetBrains,
|
||||
slashCommands: defaultSlashCommandsJetBrains,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ async function intermediateToFinalConfig(
|
|||
(model) => model.providerName === "free-trial",
|
||||
);
|
||||
if (freeTrialModels.length > 0) {
|
||||
const ghAuthToken = await ide.getGitHubAuthToken();
|
||||
const ghAuthToken = await ide.getGitHubAuthToken({});
|
||||
for (const model of freeTrialModels) {
|
||||
(model as FreeTrial).setupGhAuthToken(ghAuthToken);
|
||||
}
|
||||
|
|
@ -341,7 +341,7 @@ async function intermediateToFinalConfig(
|
|||
// This shouldn't happen
|
||||
throw new Error("Free trial cannot be used with control plane");
|
||||
}
|
||||
const ghAuthToken = await ide.getGitHubAuthToken();
|
||||
const ghAuthToken = await ide.getGitHubAuthToken({});
|
||||
(llm as FreeTrial).setupGhAuthToken(ghAuthToken);
|
||||
}
|
||||
return llm;
|
||||
|
|
|
|||
|
|
@ -1,56 +1,51 @@
|
|||
import { SerializedContinueConfig } from "../index.js";
|
||||
import { FREE_TRIAL_MODELS } from "./default.js";
|
||||
import { SerializedContinueConfig } from "../";
|
||||
import { FREE_TRIAL_MODELS } from "./default";
|
||||
|
||||
export const TRIAL_FIM_MODEL = "codestral-latest";
|
||||
export const ONBOARDING_LOCAL_MODEL_TITLE = "Ollama";
|
||||
export const LOCAL_ONBOARDING_FIM_MODEL = "starcoder2:3b";
|
||||
export const LOCAL_ONBOARDING_CHAT_MODEL = "llama3.1:8b";
|
||||
export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B";
|
||||
|
||||
export function setupApiKeysMode(
|
||||
/**
|
||||
* We set the "best" chat + autocopmlete models by default
|
||||
* whenever a user doesn't have a config.json
|
||||
*/
|
||||
export function setupBestConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
return {
|
||||
...config,
|
||||
models: config.models.filter((model) => model.provider !== "free-trial"),
|
||||
embeddingsProvider: {
|
||||
provider: "free-trial",
|
||||
},
|
||||
reranker: {
|
||||
name: "free-trial",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function setupLocalMode(
|
||||
export function setupLocalConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
return {
|
||||
...config,
|
||||
models: [
|
||||
{
|
||||
title: "Llama 3",
|
||||
title: LOCAL_ONBOARDING_CHAT_TITLE,
|
||||
provider: "ollama",
|
||||
model: "llama3",
|
||||
},
|
||||
{
|
||||
title: ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
provider: "ollama",
|
||||
model: "AUTODETECT",
|
||||
model: LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
},
|
||||
...config.models.filter((model) => model.provider !== "free-trial"),
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: "Starcoder 3b",
|
||||
provider: "ollama",
|
||||
model: "starcoder2:3b",
|
||||
model: LOCAL_ONBOARDING_FIM_MODEL,
|
||||
},
|
||||
embeddingsProvider: {
|
||||
provider: "ollama",
|
||||
model: "nomic-embed-text",
|
||||
},
|
||||
reranker: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function setupFreeTrialMode(
|
||||
export function setupQuickstartConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
return {
|
||||
|
|
@ -73,16 +68,16 @@ export function setupFreeTrialMode(
|
|||
};
|
||||
}
|
||||
|
||||
export function setupLocalAfterFreeTrial(
|
||||
export function setupLocalConfigAfterFreeTrial(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
return {
|
||||
...config,
|
||||
models: [
|
||||
{
|
||||
title: "Llama 3",
|
||||
title: LOCAL_ONBOARDING_CHAT_TITLE,
|
||||
provider: "ollama",
|
||||
model: "llama3",
|
||||
model: LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
},
|
||||
{
|
||||
title: ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
|
|
|
|||
32
core/core.ts
32
core/core.ts
|
|
@ -3,10 +3,10 @@ import type { ContextItemId, IDE, IndexingProgressUpdate } from ".";
|
|||
import { CompletionProvider } from "./autocomplete/completionProvider";
|
||||
import { ConfigHandler } from "./config/ConfigHandler";
|
||||
import {
|
||||
setupApiKeysMode,
|
||||
setupFreeTrialMode,
|
||||
setupLocalAfterFreeTrial,
|
||||
setupLocalMode,
|
||||
setupBestConfig,
|
||||
setupLocalConfig,
|
||||
setupLocalConfigAfterFreeTrial,
|
||||
setupQuickstartConfig,
|
||||
} from "./config/onboarding";
|
||||
import { createNewPromptFile } from "./config/promptFile";
|
||||
import { addModel, addOpenAIKey, deleteModel } from "./config/util";
|
||||
|
|
@ -468,7 +468,7 @@ export class Core {
|
|||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(`Error listing Ollama models: ${e}`);
|
||||
console.debug(`Error listing Ollama models: ${e}`);
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
|
@ -606,31 +606,27 @@ export class Core {
|
|||
on("completeOnboarding", (msg) => {
|
||||
const mode = msg.data.mode;
|
||||
|
||||
Telemetry.capture("onboardingSelection", {
|
||||
mode,
|
||||
});
|
||||
|
||||
if (mode === "custom") {
|
||||
if (mode === "Custom") {
|
||||
return;
|
||||
}
|
||||
|
||||
let editConfigJsonCallback: Parameters<typeof editConfigJson>[0];
|
||||
|
||||
switch (mode) {
|
||||
case "local":
|
||||
editConfigJsonCallback = setupLocalMode;
|
||||
case "Local":
|
||||
editConfigJsonCallback = setupLocalConfig;
|
||||
break;
|
||||
|
||||
case "freeTrial":
|
||||
editConfigJsonCallback = setupFreeTrialMode;
|
||||
case "Quickstart":
|
||||
editConfigJsonCallback = setupQuickstartConfig;
|
||||
break;
|
||||
|
||||
case "localAfterFreeTrial":
|
||||
editConfigJsonCallback = setupLocalAfterFreeTrial;
|
||||
case "LocalAfterFreeTrial":
|
||||
editConfigJsonCallback = setupLocalConfigAfterFreeTrial;
|
||||
break;
|
||||
|
||||
case "apiKeys":
|
||||
editConfigJsonCallback = setupApiKeysMode;
|
||||
case "Best":
|
||||
editConfigJsonCallback = setupBestConfig;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
4
core/index.d.ts
vendored
4
core/index.d.ts
vendored
|
|
@ -1,3 +1,5 @@
|
|||
import { GetGhTokenArgs } from "./protocol/ide";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
ide?: "vscode";
|
||||
|
|
@ -509,7 +511,7 @@ export interface IDE {
|
|||
getGitRootPath(dir: string): Promise<string | undefined>;
|
||||
listDir(dir: string): Promise<[string, FileType][]>;
|
||||
getLastModified(files: string[]): Promise<{ [path: string]: number }>;
|
||||
getGitHubAuthToken(): Promise<string | undefined>;
|
||||
getGitHubAuthToken(args: GetGhTokenArgs): Promise<string | undefined>;
|
||||
|
||||
// LSP
|
||||
gotoDefinition(location: Location): Promise<RangeInFile[]>;
|
||||
|
|
|
|||
|
|
@ -325,6 +325,20 @@ ${prompt}`;
|
|||
) {
|
||||
text =
|
||||
"You may need to add pre-paid credits before using the OpenAI API.";
|
||||
} else if (
|
||||
resp.status === 401 &&
|
||||
(resp.url.includes("api.mistral.ai") ||
|
||||
resp.url.includes("codestral.mistral.ai"))
|
||||
) {
|
||||
if (resp.url.includes("codestral.mistral.ai")) {
|
||||
throw new Error(
|
||||
`You are using a Mistral API key, which is not compatible with the Codestral API. Please either obtain a Codestral API key, or use the Mistral API by setting "apiBase" to "https://api.mistral.ai/v1" in config.json.`,
|
||||
);
|
||||
} else {
|
||||
throw new Error(
|
||||
`You are using a Codestral API key, which is not compatible with the Mistral API. Please either obtain a Mistral API key, or use the the Codestral API by setting "apiBase" to "https://codestral.mistral.ai/v1" in config.json.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
throw new Error(
|
||||
`HTTP ${resp.status} ${resp.statusText} from ${resp.url}\n\n${text}`,
|
||||
|
|
@ -334,8 +348,14 @@ ${prompt}`;
|
|||
return resp;
|
||||
} catch (e: any) {
|
||||
// Errors to ignore
|
||||
if (!e.message.includes("/api/show")) {
|
||||
console.warn(
|
||||
if (e.message.includes("/api/tags")) {
|
||||
throw new Error(`Error fetching tags: ${e.message}`);
|
||||
} else if (e.message.includes("/api/show")) {
|
||||
throw new Error(
|
||||
`HTTP ${e.response.status} ${e.response.statusText} from ${e.response.url}\n\n${e.response.body}`,
|
||||
);
|
||||
} else {
|
||||
console.debug(
|
||||
`${e.message}\n\nCode: ${e.code}\nError number: ${e.errno}\nSyscall: ${e.erroredSysCall}\nType: ${e.type}\n\n${e.stack}`,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,13 @@ export type ProtocolGeneratorType<T> = AsyncGenerator<{
|
|||
content: T;
|
||||
}>;
|
||||
|
||||
export type OnboardingModes =
|
||||
| "Local"
|
||||
| "Best"
|
||||
| "Custom"
|
||||
| "Quickstart"
|
||||
| "LocalAfterFreeTrial";
|
||||
|
||||
export interface ListHistoryOptions {
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
|
|
@ -137,13 +144,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
"index/indexingProgressBarInitialized": [undefined, void];
|
||||
completeOnboarding: [
|
||||
{
|
||||
mode:
|
||||
| "local"
|
||||
| "apiKeys"
|
||||
| "custom"
|
||||
| "freeTrial"
|
||||
| "localAfterFreeTrial"
|
||||
| "bestExperience";
|
||||
mode: OnboardingModes;
|
||||
},
|
||||
void,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { ControlPlaneSessionInfo } from "../control-plane/client";
|
||||
import type {
|
||||
ContinueRcJson,
|
||||
DiffLine,
|
||||
FileType,
|
||||
IDE,
|
||||
IdeInfo,
|
||||
IdeSettings,
|
||||
IndexTag,
|
||||
|
|
@ -11,8 +11,12 @@ import type {
|
|||
Range,
|
||||
RangeInFile,
|
||||
Thread,
|
||||
IDE,
|
||||
} from "../";
|
||||
import { ControlPlaneSessionInfo } from "../control-plane/client";
|
||||
|
||||
export interface GetGhTokenArgs {
|
||||
force?: boolean;
|
||||
}
|
||||
|
||||
export type ToIdeFromWebviewOrCoreProtocol = {
|
||||
// Methods from IDE type
|
||||
|
|
@ -78,7 +82,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
|
||||
gotoDefinition: [{ location: Location }, RangeInFile[]];
|
||||
|
||||
getGitHubAuthToken: [undefined, string | undefined];
|
||||
getGitHubAuthToken: [GetGhTokenArgs, string | undefined];
|
||||
getControlPlaneSessionInfo: [
|
||||
{ silent: boolean },
|
||||
ControlPlaneSessionInfo | undefined,
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
|||
setColors: [{ [key: string]: string }, void];
|
||||
"jetbrains/editorInsetRefresh": [undefined, void];
|
||||
addApiKey: [undefined, void];
|
||||
setupLocalModel: [undefined, void];
|
||||
setupLocalConfig: [undefined, void];
|
||||
incrementFtc: [undefined, void];
|
||||
openOnboarding: [undefined, void];
|
||||
openOnboardingCard: [undefined, void];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import {
|
|||
ToastType,
|
||||
} from "../index.d.js";
|
||||
|
||||
import { GetGhTokenArgs } from "../protocol/ide.js";
|
||||
import { getContinueGlobalPath } from "./paths.js";
|
||||
|
||||
class FileSystemIde implements IDE {
|
||||
|
|
@ -50,7 +51,7 @@ class FileSystemIde implements IDE {
|
|||
enableDebugLogs: false,
|
||||
};
|
||||
}
|
||||
async getGitHubAuthToken(): Promise<string | undefined> {
|
||||
async getGitHubAuthToken(args: GetGhTokenArgs): Promise<string | undefined> {
|
||||
return undefined;
|
||||
}
|
||||
async getLastModified(files: string[]): Promise<{ [path: string]: number }> {
|
||||
|
|
@ -76,8 +77,8 @@ class FileSystemIde implements IDE {
|
|||
dirent.isDirectory()
|
||||
? (2 as FileType.Directory)
|
||||
: dirent.isSymbolicLink()
|
||||
? (64 as FileType.SymbolicLink)
|
||||
: (1 as FileType.File),
|
||||
? (64 as FileType.SymbolicLink)
|
||||
: (1 as FileType.File),
|
||||
]);
|
||||
return Promise.resolve(all);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@ import type {
|
|||
Range,
|
||||
RangeInFile,
|
||||
Thread,
|
||||
ToastType,
|
||||
} from "../index.js";
|
||||
import { ToIdeFromWebviewOrCoreProtocol } from "../protocol/ide.js";
|
||||
import {
|
||||
GetGhTokenArgs,
|
||||
ToIdeFromWebviewOrCoreProtocol,
|
||||
} from "../protocol/ide.js";
|
||||
import { FromIdeProtocol } from "../protocol/index.js";
|
||||
|
||||
export class MessageIde implements IDE {
|
||||
|
|
@ -43,8 +45,8 @@ export class MessageIde implements IDE {
|
|||
getIdeSettings(): Promise<IdeSettings> {
|
||||
return this.request("getIdeSettings", undefined);
|
||||
}
|
||||
getGitHubAuthToken(): Promise<string | undefined> {
|
||||
return this.request("getGitHubAuthToken", undefined);
|
||||
getGitHubAuthToken(args: GetGhTokenArgs): Promise<string | undefined> {
|
||||
return this.request("getGitHubAuthToken", args);
|
||||
}
|
||||
getLastModified(files: string[]): Promise<{ [path: string]: number }> {
|
||||
return this.request("getLastModified", { files });
|
||||
|
|
@ -58,7 +60,7 @@ export class MessageIde implements IDE {
|
|||
|
||||
showToast: IDE["showToast"] = (...params) => {
|
||||
return this.request("showToast", params);
|
||||
}
|
||||
};
|
||||
|
||||
getRepoName(dir: string): Promise<string | undefined> {
|
||||
return this.request("getRepoName", { dir });
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ export class ReverseMessageIde {
|
|||
}
|
||||
|
||||
private initializeListeners() {
|
||||
this.on("getGitHubAuthToken", () => {
|
||||
return this.ide.getGitHubAuthToken();
|
||||
this.on("getGitHubAuthToken", (data) => {
|
||||
return this.ide.getGitHubAuthToken(data);
|
||||
});
|
||||
|
||||
this.on("getLastModified", (data) => {
|
||||
|
|
|
|||
2
docs/static/schemas/config.json
vendored
2
docs/static/schemas/config.json
vendored
|
|
@ -2094,8 +2094,8 @@
|
|||
"cohere",
|
||||
"free-trial",
|
||||
"gemini",
|
||||
"nvidia",
|
||||
"voyage",
|
||||
"nvidia",
|
||||
"bedrock"
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -654,7 +654,7 @@ class IdeProtocolClient (
|
|||
|
||||
if (ghAuthToken == null) {
|
||||
// Open a dialog so user can enter their GitHub token
|
||||
continuePluginService.sendToWebview("openOnboarding", null, uuid())
|
||||
continuePluginService.sendToWebview("openOnboardingCard", null, uuid())
|
||||
respond(null)
|
||||
} else {
|
||||
respond(ghAuthToken)
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ open class ContinueExtensionSettings : PersistentStateComponent<ContinueExtensio
|
|||
private fun syncRemoteConfig() {
|
||||
val state = instance.continueState
|
||||
|
||||
if (state.remoteConfigServerUrl != null) {
|
||||
if (state.remoteConfigServerUrl != null && state.remoteConfigServerUrl!!.isNotEmpty()) {
|
||||
// download remote config as json file
|
||||
|
||||
val client = OkHttpClient()
|
||||
|
|
|
|||
|
|
@ -2137,7 +2137,7 @@
|
|||
"if": {
|
||||
"properties": {
|
||||
"provider": {
|
||||
"enum": ["cohere", "voyage", "gemini", "nvidia"]
|
||||
"enum": ["cohere", "voyage", "nvidia", "gemini"]
|
||||
}
|
||||
},
|
||||
"required": ["provider"]
|
||||
|
|
|
|||
|
|
@ -2377,8 +2377,8 @@
|
|||
"enum": [
|
||||
"cohere",
|
||||
"voyage",
|
||||
"gemini",
|
||||
"nvidia"
|
||||
"nvidia",
|
||||
"gemini"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
|||
BIN
extensions/vscode/media/move-to-right-sidebar.gif
Normal file
BIN
extensions/vscode/media/move-to-right-sidebar.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 755 KiB |
|
|
@ -1,21 +1,8 @@
|
|||
# 👋 Welcome to Continue
|
||||
# Move Continue to the right sidebar
|
||||
|
||||
## ❗️ Before you get started
|
||||

|
||||
|
||||
Continue is currently in the left sidebar, but we recommend moving it to the right. This way it won't cover your file explorer.
|
||||
Continue is currently in the left sidebar, but we recommend moving it to the right.
|
||||
This way it won't cover your file explorer.
|
||||
|
||||
You can move it back at any time. If you close the sidebar, it can be re-opened with <kbd>Cmd/Ctrl</kbd> + <kbd>L</kbd>.
|
||||
|
||||

|
||||
|
||||
## 🔑 Most important shortcuts
|
||||
|
||||
> If you'd prefer different keys, these shortcuts can be customized in VS Code settings.
|
||||
|
||||
<kbd>Cmd/Ctrl</kbd> + <kbd>L</kbd> = Select code
|
||||
|
||||
<kbd>Cmd/Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>L</kbd> = Select code for follow-up
|
||||
|
||||
<kbd>Cmd/Ctrl</kbd> + <kbd>I</kbd> = Quick edit
|
||||
|
||||
<kbd>Cmd/Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>R</kbd> = Automatically debug terminal
|
||||
|
|
|
|||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.208",
|
||||
"version": "0.9.209",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.208",
|
||||
"version": "0.9.209",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ import type {
|
|||
Problem,
|
||||
RangeInFile,
|
||||
Thread,
|
||||
ToastType,
|
||||
} from "core";
|
||||
import { Range } from "core";
|
||||
import { walkDir } from "core/indexing/walkDir";
|
||||
import { GetGhTokenArgs } from "core/protocol/ide";
|
||||
import {
|
||||
editConfigJson,
|
||||
getConfigJsonPath,
|
||||
|
|
@ -76,7 +76,7 @@ class VsCodeIde implements IDE {
|
|||
private authToken: string | undefined;
|
||||
private askedForAuth = false;
|
||||
|
||||
async getGitHubAuthToken(): Promise<string | undefined> {
|
||||
async getGitHubAuthToken(args: GetGhTokenArgs): Promise<string | undefined> {
|
||||
// Saved auth token
|
||||
if (this.authToken) {
|
||||
return this.authToken;
|
||||
|
|
@ -92,6 +92,14 @@ class VsCodeIde implements IDE {
|
|||
}
|
||||
|
||||
try {
|
||||
if (args.force) {
|
||||
this.askedForAuth = true;
|
||||
this.authToken = await vscode.authentication
|
||||
.getSession("github", [], { createIfNone: true })
|
||||
.then((session) => session.accessToken);
|
||||
return this.authToken;
|
||||
}
|
||||
|
||||
// If we haven't asked yet, give explanation of what is happening and why
|
||||
// But don't wait to return this immediately
|
||||
// We will use a callback to refresh the config
|
||||
|
|
@ -109,7 +117,7 @@ class VsCodeIde implements IDE {
|
|||
"continue.continueGUIView.focus",
|
||||
);
|
||||
(await this.vscodeWebviewProtocolPromise).request(
|
||||
"openOnboarding",
|
||||
"openOnboardingCard",
|
||||
undefined,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export class ContinueCompletionProvider
|
|||
showFreeTrialLoginMessage(
|
||||
e.message,
|
||||
this.configHandler.reloadConfig.bind(this.configHandler),
|
||||
() => this.webviewProtocol.request("openOnboarding", undefined),
|
||||
() => this.webviewProtocol.request("openOnboardingCard", undefined),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ export class ContinueCompletionProvider
|
|||
),
|
||||
);
|
||||
} else if (val === "Download Ollama") {
|
||||
vscode.env.openExternal(vscode.Uri.parse("https://ollama.ai"));
|
||||
vscode.env.openExternal(vscode.Uri.parse("https://ollama.ai/download"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {
|
|||
CONTINUE_WORKSPACE_KEY,
|
||||
getContinueWorkspaceConfig,
|
||||
} from "../util/workspaceConfig";
|
||||
import { ILLM } from "core";
|
||||
|
||||
export enum StatusBarStatus {
|
||||
Disabled,
|
||||
|
|
@ -134,3 +135,37 @@ export function monitorBatteryChanges(battery: Battery): vscode.Disposable {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function getAutocompleteStatusBarDescription(
|
||||
selected: string | undefined,
|
||||
{ title, apiKey, providerName }: ILLM,
|
||||
): string | undefined {
|
||||
if (title !== selected) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let description = "Currently selected";
|
||||
|
||||
// Only set for Mistral since our default config includes Codestral without
|
||||
// an API key
|
||||
if ((apiKey === undefined || apiKey === "") && providerName === "mistral") {
|
||||
description += " (Missing API key)";
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
export function getAutocompleteStatusBarTitle(
|
||||
selected: string | undefined,
|
||||
{ title }: ILLM,
|
||||
): string {
|
||||
if (!title) {
|
||||
return "Unnamed Model";
|
||||
}
|
||||
|
||||
if (title === selected) {
|
||||
return `$(check) ${title}`;
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import * as fs from "node:fs";
|
|||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import * as vscode from "vscode";
|
||||
|
||||
import { ContextMenuConfig, IDE } from "core";
|
||||
import { CompletionProvider } from "core/autocomplete/completionProvider";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
|
|
@ -16,6 +15,8 @@ import { Telemetry } from "core/util/posthog";
|
|||
import readLastLines from "read-last-lines";
|
||||
import {
|
||||
StatusBarStatus,
|
||||
getAutocompleteStatusBarDescription,
|
||||
getAutocompleteStatusBarTitle,
|
||||
getStatusBarStatus,
|
||||
getStatusBarStatusFromQuickPickItemLabel,
|
||||
quickPickStatusText,
|
||||
|
|
@ -590,15 +591,13 @@ const commandsMap: (
|
|||
const quickPick = vscode.window.createQuickPick();
|
||||
const autocompleteModels =
|
||||
(await configHandler.loadConfig())?.tabAutocompleteModels ?? [];
|
||||
const autocompleteModelTitles = autocompleteModels
|
||||
.map((model) => model.title)
|
||||
.filter((t) => t !== undefined) as string[];
|
||||
|
||||
let selected = new GlobalContext().get("selectedTabAutocompleteModel");
|
||||
if (
|
||||
!selected ||
|
||||
!autocompleteModelTitles.some((title) => title === selected)
|
||||
!autocompleteModels.some((model) => model.title === selected)
|
||||
) {
|
||||
selected = autocompleteModelTitles[0];
|
||||
selected = autocompleteModels[0].title;
|
||||
}
|
||||
|
||||
// Toggle between Disabled, Paused, and Enabled
|
||||
|
|
@ -614,8 +613,8 @@ const commandsMap: (
|
|||
currentStatus === StatusBarStatus.Paused
|
||||
? StatusBarStatus.Enabled
|
||||
: currentStatus === StatusBarStatus.Disabled
|
||||
? StatusBarStatus.Paused
|
||||
: StatusBarStatus.Disabled;
|
||||
? StatusBarStatus.Paused
|
||||
: StatusBarStatus.Disabled;
|
||||
} else {
|
||||
// Toggle between Disabled and Enabled
|
||||
targetStatus =
|
||||
|
|
@ -637,9 +636,9 @@ const commandsMap: (
|
|||
kind: vscode.QuickPickItemKind.Separator,
|
||||
label: "Switch model",
|
||||
},
|
||||
...autocompleteModelTitles.map((title) => ({
|
||||
label: title === selected ? `$(check) ${title}` : title,
|
||||
description: title === selected ? "Currently selected" : undefined,
|
||||
...autocompleteModels.map((model) => ({
|
||||
label: getAutocompleteStatusBarTitle(selected, model),
|
||||
description: getAutocompleteStatusBarDescription(selected, model),
|
||||
})),
|
||||
];
|
||||
quickPick.onDidAccept(() => {
|
||||
|
|
@ -658,7 +657,9 @@ const commandsMap: (
|
|||
selectedOption === "$(gear) Configure autocomplete options"
|
||||
) {
|
||||
ide.openFile(getConfigJsonPath());
|
||||
} else if (autocompleteModelTitles.includes(selectedOption)) {
|
||||
} else if (
|
||||
autocompleteModels.some((model) => model.title === selectedOption)
|
||||
) {
|
||||
new GlobalContext().update(
|
||||
"selectedTabAutocompleteModel",
|
||||
selectedOption,
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ import * as fs from "node:fs";
|
|||
import * as path from "node:path";
|
||||
import * as vscode from "vscode";
|
||||
import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
import {
|
||||
getControlPlaneSessionInfo,
|
||||
WorkOsAuthProvider,
|
||||
} from "../stubs/WorkOsAuthProvider";
|
||||
import { getExtensionUri } from "../util/vscode";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
import { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
|
||||
/**
|
||||
|
|
@ -172,7 +172,9 @@ export class VsCodeMessenger {
|
|||
const doc = await vscode.workspace.openTextDocument(
|
||||
vscode.Uri.file(tutorialPath),
|
||||
);
|
||||
await vscode.window.showTextDocument(doc);
|
||||
await vscode.window.showTextDocument(doc, {
|
||||
preview: false,
|
||||
});
|
||||
});
|
||||
|
||||
this.onWebview("openUrl", (msg) => {
|
||||
|
|
@ -286,7 +288,7 @@ export class VsCodeMessenger {
|
|||
this.ide.showToast(...msg.data);
|
||||
});
|
||||
this.onWebviewOrCore("getGitHubAuthToken", (msg) =>
|
||||
ide.getGitHubAuthToken(),
|
||||
ide.getGitHubAuthToken(msg.data),
|
||||
);
|
||||
this.onWebviewOrCore("getControlPlaneSessionInfo", async (msg) => {
|
||||
return getControlPlaneSessionInfo(msg.data.silent);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { FileEdit, RangeInFile, Thread, ToastType } from "core";
|
||||
import type { FileEdit, RangeInFile, Thread } from "core";
|
||||
import path from "node:path";
|
||||
import * as vscode from "vscode";
|
||||
import { threadStopped } from "../debug/debug";
|
||||
|
|
@ -137,7 +137,12 @@ export class VsCodeIdeUtils {
|
|||
|
||||
openFile(filepath: string, range?: vscode.Range) {
|
||||
// vscode has a builtin open/get open files
|
||||
return openEditorAndRevealRange(filepath, range, vscode.ViewColumn.One);
|
||||
return openEditorAndRevealRange(
|
||||
filepath,
|
||||
range,
|
||||
vscode.ViewColumn.One,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
async fileExists(filepath: string): Promise<boolean> {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import * as vscode from "vscode";
|
|||
export function showFreeTrialLoginMessage(
|
||||
message: string,
|
||||
reloadConfig: () => void,
|
||||
openOnboarding: () => void,
|
||||
openOnboardingCard: () => void,
|
||||
) {
|
||||
vscode.window
|
||||
.showInformationMessage(message, "Sign In", "Use API key / local model")
|
||||
|
|
@ -17,7 +17,7 @@ export function showFreeTrialLoginMessage(
|
|||
reloadConfig();
|
||||
});
|
||||
} else if (selection === "Use API key / local model") {
|
||||
openOnboarding();
|
||||
openOnboardingCard();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,9 +125,13 @@ function windowsToPosix(windowsPath: string): string {
|
|||
function isWindowsLocalButNotRemote(): boolean {
|
||||
return (
|
||||
vscode.env.remoteName !== undefined &&
|
||||
["wsl", "ssh-remote", "dev-container", "attached-container", "tunnel"].includes(
|
||||
vscode.env.remoteName,
|
||||
) &&
|
||||
[
|
||||
"wsl",
|
||||
"ssh-remote",
|
||||
"dev-container",
|
||||
"attached-container",
|
||||
"tunnel",
|
||||
].includes(vscode.env.remoteName) &&
|
||||
process.platform === "win32"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,12 +137,12 @@ export class VsCodeWebviewProtocol
|
|||
if (selection === "Add API Key") {
|
||||
this.request("addApiKey", undefined);
|
||||
} else if (selection === "Use Local Model") {
|
||||
this.request("setupLocalModel", undefined);
|
||||
this.request("setupLocalConfig", undefined);
|
||||
}
|
||||
});
|
||||
} else if (message.includes("Please sign in with GitHub")) {
|
||||
showFreeTrialLoginMessage(message, this.reloadConfig, () =>
|
||||
this.request("openOnboarding", undefined),
|
||||
this.request("openOnboardingCard", undefined),
|
||||
);
|
||||
} else {
|
||||
Telemetry.capture(
|
||||
|
|
|
|||
|
|
@ -13,10 +13,6 @@ import History from "./pages/history";
|
|||
import MigrationPage from "./pages/migration";
|
||||
import MonacoPage from "./pages/monaco";
|
||||
import { default as More, default as MorePage } from "./pages/more";
|
||||
import ApiKeyAutocompleteOnboarding from "./pages/onboarding/apiKeyAutocompleteOnboarding";
|
||||
import ApiKeysOnboarding from "./pages/onboarding/ApiKeysOnboarding";
|
||||
import LocalOnboarding from "./pages/onboarding/LocalOnboarding";
|
||||
import Onboarding from "./pages/onboarding/Onboarding";
|
||||
import SettingsPage from "./pages/settings";
|
||||
import Stats from "./pages/stats";
|
||||
|
||||
|
|
@ -66,26 +62,10 @@ const router = createMemoryRouter([
|
|||
path: "/monaco",
|
||||
element: <MonacoPage />,
|
||||
},
|
||||
{
|
||||
path: "/onboarding",
|
||||
element: <Onboarding />,
|
||||
},
|
||||
{
|
||||
path: "/localOnboarding",
|
||||
element: <LocalOnboarding />,
|
||||
},
|
||||
{
|
||||
path: "/migration",
|
||||
element: <MigrationPage />,
|
||||
},
|
||||
{
|
||||
path: "/apiKeysOnboarding",
|
||||
element: <ApiKeysOnboarding />,
|
||||
},
|
||||
{
|
||||
path: "/apiKeyAutocompleteOnboarding",
|
||||
element: <ApiKeyAutocompleteOnboarding />,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
|
|
|||
21
gui/src/components/AddModelButtonSubtext.tsx
Normal file
21
gui/src/components/AddModelButtonSubtext.tsx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { useContext } from "react";
|
||||
import { ButtonSubtext } from ".";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
|
||||
function AddModelButtonSubtext() {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
return (
|
||||
<ButtonSubtext>
|
||||
This will update your{" "}
|
||||
<span
|
||||
className="underline cursor-pointer"
|
||||
onClick={() => ideMessenger.post("openConfigJson", undefined)}
|
||||
>
|
||||
config file
|
||||
</span>
|
||||
</ButtonSubtext>
|
||||
);
|
||||
}
|
||||
|
||||
export default AddModelButtonSubtext;
|
||||
63
gui/src/components/ContinueLogo.tsx
Normal file
63
gui/src/components/ContinueLogo.tsx
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import { vscForeground } from ".";
|
||||
|
||||
interface ContinueLogoProps {
|
||||
height?: number;
|
||||
width?: number;
|
||||
}
|
||||
|
||||
export default function ContinueLogo({
|
||||
height = 987,
|
||||
width = 299,
|
||||
}: ContinueLogoProps) {
|
||||
return (
|
||||
<svg
|
||||
width={width}
|
||||
height={height}
|
||||
viewBox="0 0 987 299"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M199.142 100.633L191.304 114.263L211.044 148.774C211.334 149.065 211.334 149.355 211.334 149.645C211.334 149.935 211.334 150.225 211.044 150.515L191.304 185.026L199.142 198.656L227.3 149.645L199.142 100.633ZM188.401 112.523L196.239 98.8928H180.563L172.725 112.523H188.401ZM172.435 116.003L190.723 147.904H206.399L188.111 116.003H172.435ZM188.401 182.996L206.689 151.095H191.014L172.725 182.996H188.401ZM172.435 186.766L180.273 200.396H195.949L188.111 186.766H172.435ZM119.311 203.586C119.021 203.586 118.73 203.586 118.44 203.296C118.15 203.006 117.859 203.006 117.859 202.716L97.8292 168.205H82.1533L110.312 217.217H166.919L159.081 203.586H119.311ZM161.984 201.846L169.822 215.477L177.66 201.846L169.822 188.216L161.984 201.846ZM166.919 186.476H130.052L122.214 200.106H158.791L166.919 186.476ZM127.149 184.736L108.86 152.835L101.022 166.465L119.311 198.366L127.149 184.736ZM82.1533 164.725H97.8292L105.667 151.095H89.9913L82.1533 164.725ZM117.569 96.5728C117.569 96.2827 117.859 95.9927 118.15 95.9927C118.44 95.9927 118.73 95.7027 119.021 95.7027H158.791L166.629 82.0723H110.312L82.1533 131.084H97.8292L117.569 96.5728ZM105.667 148.194L97.8292 134.564H82.1533L89.9913 148.194H105.667ZM119.021 100.923L100.732 132.824L108.57 146.454L126.859 114.553L119.021 100.923ZM159.081 99.1828H122.214L130.052 112.813H166.919L159.081 99.1828ZM169.822 111.073L177.66 97.4428L169.822 83.8123L161.984 97.4428L169.822 111.073Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
|
||||
<path
|
||||
d="M512.369 123.254C501.918 123.254 493.5 128.184 487.984 136.884H486.533V126.154H473.76V203.587H486.533V158.345C486.533 144.715 497.854 134.854 510.917 134.854C523.981 134.854 532.109 144.425 532.109 157.475V203.877H544.882V157.475C544.592 137.754 532.109 123.254 512.369 123.254Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
<path
|
||||
d="M419.475 122.964C395.09 122.964 377.673 140.364 377.673 164.725C377.673 189.086 394.8 206.777 419.475 206.777C444.15 206.777 461.278 189.376 461.278 164.725C461.278 140.074 443.57 122.964 419.475 122.964ZM419.475 195.176C402.638 195.176 390.446 182.416 390.446 164.725C390.446 147.035 402.348 134.564 419.475 134.564C436.603 134.564 448.214 147.325 448.214 164.725C448.214 182.126 436.022 195.176 419.475 195.176Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
<path
|
||||
d="M354.449 170.235C349.224 184.736 334.128 195.466 317.582 195.466C293.197 195.466 275.489 176.325 275.489 149.645C275.489 122.964 292.907 104.113 317.582 104.113C334.709 104.113 350.095 115.423 354.739 131.084H368.964C363.738 108.463 341.966 91.6426 317.582 91.6426C285.069 91.6426 261.555 116.003 261.555 149.645C261.265 183.286 285.069 207.646 317.582 207.646C341.966 207.646 363.448 191.986 368.673 170.235H354.449Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
<path
|
||||
d="M579.137 183.287V136.305H599.167V126.155H579.137L579.427 101.214H569.557L566.654 126.155H554.171V136.305H566.654V183.867C566.654 197.497 575.073 206.777 588.136 206.777C591.91 206.777 597.135 205.907 600.618 204.747V194.307C597.716 195.177 593.651 195.757 591.329 195.757C583.781 195.757 579.137 190.537 579.137 183.287Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
<path
|
||||
d="M797.438 171.396C797.438 185.026 786.116 194.887 773.053 194.887C759.99 194.887 752.152 185.606 752.152 172.266V126.154H739.379V172.266C739.379 191.987 751.862 206.487 771.602 206.487C781.762 206.487 790.471 201.557 795.986 193.147H797.438V203.877H810.211V126.154H797.438V171.396Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
<path
|
||||
d="M691.19 123.254C680.74 123.254 672.321 128.184 666.805 136.884H665.354V126.154H652.581V203.587H665.354V158.345C665.354 144.715 676.675 134.854 689.739 134.854C702.802 134.854 710.93 144.425 710.93 157.475V203.877H723.703V157.475C723.703 137.754 710.93 123.254 691.19 123.254Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
<path
|
||||
d="M630.809 126.154H618.036V203.587H630.809V126.154Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
<path
|
||||
d="M904.847 164.145C904.847 140.364 887.72 123.254 864.206 123.254C840.692 123.254 822.984 140.364 822.984 164.145C822.984 189.086 840.402 207.067 864.786 207.067C881.914 207.067 896.138 198.946 902.234 185.896L891.784 180.676C886.849 189.956 876.688 195.756 865.077 195.756C849.11 195.756 837.789 185.316 836.047 169.655H904.847C904.847 167.335 904.847 165.595 904.847 164.145ZM836.047 158.055C838.079 144.135 849.11 134.854 863.335 134.854C877.559 134.854 888.881 144.135 891.203 158.055H836.047Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
<path
|
||||
d="M624.423 93.3828C618.907 93.3828 615.133 97.1529 615.133 102.373C615.133 107.593 618.907 111.653 624.423 111.653C629.938 111.653 633.422 107.883 633.422 102.373C633.422 96.8629 629.648 93.3828 624.423 93.3828Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
|
@ -11,11 +11,11 @@ import {
|
|||
} from ".";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { isNewUserOnboarding } from "../pages/onboarding/utils";
|
||||
import { defaultModelSelector } from "../redux/selectors/modelSelectors";
|
||||
import {
|
||||
setBottomMessage,
|
||||
setBottomMessageCloseTimeout,
|
||||
setOnboardingCard,
|
||||
setShowDialog,
|
||||
} from "../redux/slices/uiStateSlice";
|
||||
import { RootState } from "../redux/store";
|
||||
|
|
@ -27,6 +27,8 @@ import HeaderButtonWithText from "./HeaderButtonWithText";
|
|||
import ProgressBar from "./loaders/ProgressBar";
|
||||
import PostHogPageView from "./PosthogPageView";
|
||||
import ProfileSwitcher from "./ProfileSwitcher";
|
||||
import { isNewUserOnboarding } from "./OnboardingCard/utils";
|
||||
import { useOnboardingCard } from "./OnboardingCard";
|
||||
|
||||
const FOOTER_HEIGHT = "1.8em";
|
||||
|
||||
|
|
@ -102,17 +104,12 @@ const ProfileDropdownPortalDiv = styled.div`
|
|||
font-size: ${getFontSize() - 2};
|
||||
`;
|
||||
|
||||
const HIDE_FOOTER_ON_PAGES = [
|
||||
"/onboarding",
|
||||
"/localOnboarding",
|
||||
"/apiKeyOnboarding",
|
||||
];
|
||||
|
||||
const Layout = () => {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const dispatch = useDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const onboardingCard = useOnboardingCard();
|
||||
|
||||
const dialogMessage = useSelector(
|
||||
(state: RootState) => state.uiState.dialogMessage,
|
||||
|
|
@ -177,22 +174,6 @@ const Layout = () => {
|
|||
[location, navigate],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
"addApiKey",
|
||||
async () => {
|
||||
navigate("/apiKeyOnboarding");
|
||||
},
|
||||
[navigate],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
"openOnboarding",
|
||||
async () => {
|
||||
navigate("/onboarding");
|
||||
},
|
||||
[navigate],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
"incrementFtc",
|
||||
async () => {
|
||||
|
|
@ -207,14 +188,19 @@ const Layout = () => {
|
|||
);
|
||||
|
||||
useWebviewListener(
|
||||
"setupLocalModel",
|
||||
"openOnboardingCard",
|
||||
async () => {
|
||||
ideMessenger.post("completeOnboarding", {
|
||||
mode: "localAfterFreeTrial",
|
||||
});
|
||||
navigate("/localOnboarding");
|
||||
onboardingCard.open("Best");
|
||||
},
|
||||
[navigate],
|
||||
[],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
"setupLocalConfig",
|
||||
async () => {
|
||||
onboardingCard.open("Local");
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -222,7 +208,7 @@ const Layout = () => {
|
|||
isNewUserOnboarding() &&
|
||||
(location.pathname === "/" || location.pathname === "/index.html")
|
||||
) {
|
||||
navigate("/onboarding");
|
||||
onboardingCard.open("Quickstart");
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
|
|
@ -252,33 +238,31 @@ const Layout = () => {
|
|||
<Outlet />
|
||||
<ModelDropdownPortalDiv id="model-select-top-div"></ModelDropdownPortalDiv>
|
||||
<ProfileDropdownPortalDiv id="profile-select-top-div"></ProfileDropdownPortalDiv>
|
||||
{HIDE_FOOTER_ON_PAGES.includes(location.pathname) || (
|
||||
<Footer>
|
||||
<div className="mr-auto flex flex-grow gap-2 items-center overflow-hidden">
|
||||
{defaultModel?.provider === "free-trial" && (
|
||||
<ProgressBar
|
||||
completed={parseInt(localStorage.getItem("ftc") || "0")}
|
||||
total={FREE_TRIAL_LIMIT_REQUESTS}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<Footer>
|
||||
<div className="mr-auto flex flex-grow gap-2 items-center overflow-hidden">
|
||||
{defaultModel?.provider === "free-trial" && (
|
||||
<ProgressBar
|
||||
completed={parseInt(localStorage.getItem("ftc") || "0")}
|
||||
total={FREE_TRIAL_LIMIT_REQUESTS}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ProfileSwitcher />
|
||||
<HeaderButtonWithText
|
||||
tooltipPlacement="top-end"
|
||||
text="More"
|
||||
onClick={() => {
|
||||
if (location.pathname === "/help") {
|
||||
navigate("/");
|
||||
} else {
|
||||
navigate("/help");
|
||||
}
|
||||
}}
|
||||
>
|
||||
<EllipsisHorizontalCircleIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
</Footer>
|
||||
)}
|
||||
<ProfileSwitcher />
|
||||
<HeaderButtonWithText
|
||||
tooltipPlacement="top-end"
|
||||
text="More"
|
||||
onClick={() => {
|
||||
if (location.pathname === "/help") {
|
||||
navigate("/");
|
||||
} else {
|
||||
navigate("/help");
|
||||
}
|
||||
}}
|
||||
>
|
||||
<EllipsisHorizontalCircleIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
</Footer>
|
||||
</GridDiv>
|
||||
|
||||
<BottomMessageDiv
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
export default function Logo({
|
||||
height,
|
||||
width,
|
||||
}: {
|
||||
height: number;
|
||||
width: number;
|
||||
}) {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={width}
|
||||
height={height}
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
>
|
||||
<path
|
||||
d="M20.5286 3.26811L19.1512 5.65694L22.6328 11.6849C22.6582 11.7306 22.6735 11.7866 22.6735 11.8374C22.6735 11.8882 22.6582 11.9441 22.6328 11.9899L19.1512 18.0229L20.5286 20.4117L25.4791 11.8374L20.5286 3.26303V3.26811ZM18.6176 5.3469L19.995 2.95807H17.2402L15.8628 5.3469H18.6227H18.6176ZM15.8577 5.96697L19.075 11.5324H21.8298L18.6176 5.96697H15.8577ZM18.6176 17.7179L21.8298 12.1474H19.075L15.8577 17.7179H18.6176ZM15.8577 18.338L17.2351 20.7167H19.9899L18.6125 18.338H15.8526H15.8577ZM6.52098 21.3063C6.46507 21.3063 6.41424 21.291 6.3685 21.2656C6.32276 21.2402 6.28209 21.1995 6.25668 21.1538L2.77002 15.1207H0.0152482L4.9657 23.69H14.8615L13.4841 21.3063H6.52606H6.52098ZM14.0178 20.9962L15.3952 23.38L16.7726 20.9911L15.3952 18.6023L14.0178 20.9911V20.9962ZM14.8615 18.2974H8.43712L7.05973 20.6862H13.4841L14.8615 18.2974ZM7.89836 17.9924L4.68108 12.4219L3.30369 14.8107L6.52098 20.3812L7.89836 17.9924ZM0.0101654 14.5007H2.76494L4.14232 12.1118H1.39263L0.0101654 14.5007ZM6.24143 2.5413C6.26685 2.49556 6.30751 2.4549 6.35325 2.42948C6.399 2.40407 6.4549 2.38882 6.50573 2.38882H13.474L14.8514 0H4.95045L0 8.57435H2.75477L6.23127 2.54638L6.24143 2.5413ZM4.14232 11.5782L2.76494 9.18934H0.0101654L1.38755 11.5782H4.14232ZM6.51081 3.31386L3.29861 8.8793L4.67599 11.2681L7.8882 5.70268L6.51081 3.31386ZM13.4791 3.00382H7.04448L8.42187 5.39264H14.8564L13.4791 3.00382ZM15.3952 5.0826L16.7675 2.69886L15.3952 0.310038L14.0178 2.69378L15.3952 5.0826Z"
|
||||
fill="currentColor"
|
||||
></path>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
64
gui/src/components/OnboardingCard/OnboardingCard.tsx
Normal file
64
gui/src/components/OnboardingCard/OnboardingCard.tsx
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import * as Tabs from "./tabs";
|
||||
import OnboardingCardTabs, { TabTitle } from "./components/OnboardingCardTabs";
|
||||
import { XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import styled from "styled-components";
|
||||
import { CloseButton, defaultBorderRadius, vscInputBackground } from "../";
|
||||
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
|
||||
import { useOnboardingCard } from "./hooks/useOnboardingCard";
|
||||
|
||||
const StyledCard = styled.div`
|
||||
margin: auto;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
padding: 1rem 1.5rem;
|
||||
background-color: ${vscInputBackground};
|
||||
box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1),
|
||||
0 8px 10px -6px rgb(0 0 0 / 0.1);
|
||||
`;
|
||||
|
||||
export interface OnboardingCardState {
|
||||
show?: boolean;
|
||||
activeTab?: TabTitle;
|
||||
}
|
||||
|
||||
export const defaultOnboardingCardState: OnboardingCardState = {
|
||||
show: false,
|
||||
activeTab: "Quickstart",
|
||||
};
|
||||
|
||||
export type OnboardingCardProps = Pick<OnboardingCardState, "activeTab">;
|
||||
|
||||
function OnboardingCard(props: OnboardingCardProps) {
|
||||
const onboardingCard = useOnboardingCard();
|
||||
|
||||
function renderTabContent() {
|
||||
switch (onboardingCard.activeTab) {
|
||||
case "Quickstart":
|
||||
return <Tabs.Quickstart />;
|
||||
case "Best":
|
||||
return <Tabs.Best />;
|
||||
case "Local":
|
||||
return <Tabs.Local />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (getLocalStorage("onboardingStatus") === undefined) {
|
||||
setLocalStorage("onboardingStatus", "Started");
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledCard className="relative">
|
||||
<OnboardingCardTabs
|
||||
activeTab={onboardingCard.activeTab}
|
||||
onTabClick={onboardingCard.setActiveTab}
|
||||
/>
|
||||
<CloseButton onClick={onboardingCard.close}>
|
||||
<XMarkIcon className="h-5 w-5" />
|
||||
</CloseButton>
|
||||
<div className="content py-4">{renderTabContent()}</div>
|
||||
</StyledCard>
|
||||
);
|
||||
}
|
||||
|
||||
export default OnboardingCard;
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
import { CubeIcon } from "@heroicons/react/24/outline";
|
||||
import { DEFAULT_CHAT_MODEL_CONFIG } from "core/config/default";
|
||||
import { useContext, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Button, Input, InputSubtext, lightGray } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { models } from "../../../pages/AddNewModel/configs/models";
|
||||
import { providers } from "../../../pages/AddNewModel/configs/providers";
|
||||
import { setDefaultModel } from "../../../redux/slices/stateSlice";
|
||||
import AddModelButtonSubtext from "../../AddModelButtonSubtext";
|
||||
|
||||
const { anthropic: chatProvider, mistral: autocompleteProvider } = providers;
|
||||
const { claude35Sonnet: chatModel, codestral: autocompleteModel } = models;
|
||||
|
||||
interface BestExperienceConfigFormProps {
|
||||
onComplete: () => void;
|
||||
}
|
||||
|
||||
function BestExperienceConfigForm({
|
||||
onComplete,
|
||||
}: BestExperienceConfigFormProps) {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [autocompleteApiKey, setAutocompleteApiKey] = useState("");
|
||||
const [chatApiKey, setChatApiKey] = useState("");
|
||||
|
||||
async function handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const chatModelConfig = {
|
||||
model: chatModel.params.model,
|
||||
provider: chatProvider.provider,
|
||||
apiKey: chatApiKey,
|
||||
title: chatModel.params.title,
|
||||
};
|
||||
|
||||
const autocompleteModelConfig = {
|
||||
title: autocompleteModel.params.title,
|
||||
provider: autocompleteProvider.provider,
|
||||
model: autocompleteModel.params.model,
|
||||
apiKey: autocompleteApiKey,
|
||||
};
|
||||
|
||||
ideMessenger.post("config/deleteModel", {
|
||||
title: DEFAULT_CHAT_MODEL_CONFIG.title,
|
||||
});
|
||||
ideMessenger.post("config/addModel", { model: chatModelConfig });
|
||||
dispatch(setDefaultModel({ title: chatModelConfig.title, force: true }));
|
||||
|
||||
if (!!autocompleteApiKey) {
|
||||
await ideMessenger.request("addAutocompleteModel", {
|
||||
model: autocompleteModelConfig,
|
||||
});
|
||||
}
|
||||
|
||||
onComplete();
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div className="flex flex-col gap-3">
|
||||
<div>
|
||||
<div className="text-lg font-bold mb-1 flex flex-row justify-between gap-4">
|
||||
<label className="text-lg font-bold">Chat model</label>
|
||||
<div
|
||||
className="flex items-center text-xs font-semibold justify-end"
|
||||
style={{ color: lightGray }}
|
||||
>
|
||||
<CubeIcon className="w-4 h-4 mr-1 flex-shrink-0" />
|
||||
<span className="italic text-right inline">
|
||||
{chatModel.title}{" "}
|
||||
<span className="max-xs:hidden">by Anthropic</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col pb-4 w-full">
|
||||
<Input
|
||||
placeholder="Enter your Anthropic API Key"
|
||||
value={chatApiKey}
|
||||
onChange={(e) => setChatApiKey(e.target.value)}
|
||||
/>
|
||||
<InputSubtext>
|
||||
<a
|
||||
href={chatProvider.apiKeyUrl}
|
||||
target="_blank"
|
||||
className="text-inherit underline cursor-pointer hover:text-inherit"
|
||||
>
|
||||
Click here
|
||||
</a>{" "}
|
||||
to create an Anthropic API key
|
||||
</InputSubtext>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div className="text-lg font-bold mb-1 flex flex-row justify-between gap-4">
|
||||
<label className="text-lg font-bold">Autocomplete model</label>
|
||||
<div
|
||||
className="flex items-center text-xs font-semibold"
|
||||
style={{ color: lightGray }}
|
||||
>
|
||||
<CubeIcon className="w-4 h-4 mr-1 flex-shrink-0 inline" />
|
||||
<span className="italic text-right">
|
||||
{autocompleteModel.title}{" "}
|
||||
<span className="max-xs:hidden">by Mistral</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col pb-4 w-full">
|
||||
<Input
|
||||
placeholder="Enter your Codestral API Key"
|
||||
value={autocompleteApiKey}
|
||||
onChange={(e) => setAutocompleteApiKey(e.target.value)}
|
||||
/>
|
||||
<InputSubtext>
|
||||
<a
|
||||
href={autocompleteProvider.apiKeyUrl}
|
||||
target="_blank"
|
||||
className="text-inherit underline cursor-pointer hover:text-inherit"
|
||||
>
|
||||
Click here
|
||||
</a>{" "}
|
||||
to create a Codestral API key
|
||||
</InputSubtext>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-2 w-full">
|
||||
<Button className="w-full" type="submit" disabled={!chatApiKey}>
|
||||
Connect
|
||||
</Button>
|
||||
<AddModelButtonSubtext />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
export default BestExperienceConfigForm;
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useState } from "react";
|
||||
import { StyledActionButton, Input, Button, ButtonSubtext } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { setShowDialog } from "../../../redux/slices/uiStateSlice";
|
||||
import { useDispatch } from "react-redux";
|
||||
|
||||
interface JetBrainsFetchGitHubTokenDialogProps {
|
||||
onComplete: () => void;
|
||||
}
|
||||
|
||||
const GITHUB_AUTH_URL =
|
||||
"https://github.com/settings/tokens/new?scopes=user:email&description=Continue%20Free%20Trial%20Token%20";
|
||||
|
||||
function JetBrainsFetchGitHubTokenDialog({
|
||||
onComplete,
|
||||
}: JetBrainsFetchGitHubTokenDialogProps) {
|
||||
const dispatch = useDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const [jbGhAuthToken, setJbGhAuthToken] = useState("");
|
||||
const [hasClickedGitHubButton, setHasClickedGitHubButton] = useState(false);
|
||||
|
||||
async function submitJetBrainsToken() {
|
||||
await ideMessenger.request("setGitHubAuthToken", {
|
||||
token: jbGhAuthToken,
|
||||
});
|
||||
dispatch(setShowDialog(false));
|
||||
onComplete();
|
||||
}
|
||||
|
||||
function openGitHubTokenPage() {
|
||||
ideMessenger.post("openUrl", GITHUB_AUTH_URL);
|
||||
setHasClickedGitHubButton(true);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="p-8 flex flex-col gap-3">
|
||||
<div className="text-center">
|
||||
<h1 className="my-0">Sign in with GitHub</h1>
|
||||
<p>
|
||||
Continue will request read access to your GitHub email so that we can
|
||||
prevent abuse of the free trial. If you prefer not to sign in, you can
|
||||
use Continue with your own API keys or local model.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-3">
|
||||
{hasClickedGitHubButton ? (
|
||||
<div className="flex flex-col items-start">
|
||||
<label className="text-sm">Token</label>
|
||||
<Input
|
||||
className="flex-1"
|
||||
placeholder="Enter your GitHub token"
|
||||
value={jbGhAuthToken}
|
||||
onChange={(e) => setJbGhAuthToken(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<StyledActionButton onClick={openGitHubTokenPage}>
|
||||
<p className="text-sm">Get GitHub token</p>
|
||||
<ArrowTopRightOnSquareIcon width={24} height={24} />
|
||||
</StyledActionButton>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<Button
|
||||
onClick={submitJetBrainsToken}
|
||||
disabled={!jbGhAuthToken}
|
||||
className="grid grid-flow-col items-center gap-2 w-full mt-2"
|
||||
>
|
||||
Get started using our API keys
|
||||
</Button>
|
||||
<ButtonSubtext>
|
||||
Try 50 chat and 2k autocomplete requests
|
||||
</ButtonSubtext>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default JetBrainsFetchGitHubTokenDialog;
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { CheckCircleIcon } from "@heroicons/react/24/solid";
|
||||
|
||||
interface OllamaCompletedStepProps {
|
||||
text: string;
|
||||
}
|
||||
|
||||
function OllamaCompletedStep({ text }: OllamaCompletedStepProps) {
|
||||
return (
|
||||
<div className="flex justify-between items-center">
|
||||
<p className="text-sm w-3/4 font-mono">{text}</p>
|
||||
<CheckCircleIcon width={24} height={24} className="text-emerald-600" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default OllamaCompletedStep;
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
import { CommandLineIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext } from "react";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import ReactDOM from "react-dom";
|
||||
import { StyledActionButton, StyledTooltip } from "../..";
|
||||
import OllamaCompletedStep from "./OllamaCompletedStep";
|
||||
|
||||
interface OllamaModelDownloadProps {
|
||||
title: string;
|
||||
modelName: string;
|
||||
hasDownloaded: boolean;
|
||||
}
|
||||
|
||||
function OllamaModelDownload({
|
||||
title,
|
||||
modelName,
|
||||
hasDownloaded,
|
||||
}: OllamaModelDownloadProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const command = `ollama pull ${modelName}`;
|
||||
const id = `info-hover-${encodeURIComponent(command)}`;
|
||||
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
|
||||
|
||||
function onClick() {
|
||||
ideMessenger.ide.runCommand(command);
|
||||
ideMessenger.post("copyText", { text: command });
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<p className="text-lg font-bold leading-tight mb-2">{title}</p>
|
||||
{hasDownloaded ? (
|
||||
<OllamaCompletedStep text={command} />
|
||||
) : (
|
||||
<>
|
||||
<StyledActionButton data-tooltip-id={id} onClick={onClick}>
|
||||
<p className="font-mono">{command}</p>
|
||||
<CommandLineIcon width={24} height={24} />
|
||||
</StyledActionButton>
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<StyledTooltip id={id} place="top">
|
||||
Copy into terminal
|
||||
</StyledTooltip>,
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default OllamaModelDownload;
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
import {
|
||||
ArrowPathIcon,
|
||||
ArrowTopRightOnSquareIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useState, useContext } from "react";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { providers } from "../../../pages/AddNewModel/configs/providers";
|
||||
import { useCheckOllamaModels } from "../hooks/useCheckOllamaModels";
|
||||
import { StyledActionButton } from "../..";
|
||||
import OllamaCompletedStep from "./OllamaCompletedStep";
|
||||
|
||||
export enum OllamaConnectionStatuses {
|
||||
WaitingToDownload = "WaitingToDownload",
|
||||
Downloading = "Downloading",
|
||||
Verified = "Verified",
|
||||
}
|
||||
|
||||
interface OllamaStatusProps {
|
||||
onConnectionVerified: () => void;
|
||||
}
|
||||
|
||||
const {
|
||||
ollama: { downloadUrl },
|
||||
} = providers;
|
||||
|
||||
function OllamaStatus({ onConnectionVerified }: OllamaStatusProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [status, setStatus] = useState<OllamaConnectionStatuses>(
|
||||
OllamaConnectionStatuses.WaitingToDownload,
|
||||
);
|
||||
|
||||
useCheckOllamaModels((models) => {
|
||||
setStatus(OllamaConnectionStatuses.Verified);
|
||||
onConnectionVerified();
|
||||
});
|
||||
|
||||
function onClickDownload() {
|
||||
ideMessenger.post("openUrl", downloadUrl);
|
||||
setStatus(OllamaConnectionStatuses.Downloading);
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
case OllamaConnectionStatuses.WaitingToDownload:
|
||||
return (
|
||||
<StyledActionButton onClick={onClickDownload}>
|
||||
<p className="underline text-sm">{downloadUrl}</p>
|
||||
<ArrowTopRightOnSquareIcon width={24} height={24} />
|
||||
</StyledActionButton>
|
||||
);
|
||||
case OllamaConnectionStatuses.Downloading:
|
||||
return (
|
||||
<div className="flex justify-between items-center">
|
||||
<p className="text-sm w-3/4 font-mono">
|
||||
Checking for connection to Ollama at http://localhost:11434
|
||||
</p>
|
||||
<ArrowPathIcon className="h-4 w-4 animate-spin-slow mr-1" />
|
||||
</div>
|
||||
);
|
||||
case OllamaConnectionStatuses.Verified:
|
||||
return (
|
||||
<OllamaCompletedStep text="Ollama is running at http://localhost:11434" />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default OllamaStatus;
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
import styled from "styled-components";
|
||||
import { vscButtonBackground, vscForeground } from "../..";
|
||||
import { hasPassedFTL } from "../../../util/freeTrial";
|
||||
|
||||
interface OnboardingCardTabsProps {
|
||||
activeTab: TabTitle;
|
||||
onTabClick: (tabName: TabTitle) => void;
|
||||
}
|
||||
|
||||
export type TabTitle = "Quickstart" | "Best" | "Local";
|
||||
|
||||
export const TabTitles: { [k in TabTitle]: { xs: string; default: string } } = {
|
||||
Quickstart: {
|
||||
xs: "Quickstart",
|
||||
default: "Quickstart",
|
||||
},
|
||||
Best: {
|
||||
xs: "Best",
|
||||
default: "Best experience",
|
||||
},
|
||||
Local: {
|
||||
xs: "Local",
|
||||
default: "Local with Ollama",
|
||||
},
|
||||
};
|
||||
|
||||
const TabButton = styled.button<{ isActive: boolean }>`
|
||||
padding: 1rem 1rem 0.5rem 1rem;
|
||||
margin-bottom: -1px;
|
||||
focus: outline-none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
color: ${vscForeground};
|
||||
border: none;
|
||||
|
||||
${({ isActive }) =>
|
||||
isActive &&
|
||||
`
|
||||
border-style: solid;
|
||||
border-width: 0 0 2.5px 0;
|
||||
border-color: ${vscForeground};
|
||||
font-weight: bold;
|
||||
`}
|
||||
`;
|
||||
|
||||
const TabList = styled.div`
|
||||
border-style: solid;
|
||||
border-width: 0 0 0.5px 0;
|
||||
border-color: ${vscForeground};
|
||||
`;
|
||||
|
||||
function OnboardingCardTabs({
|
||||
activeTab,
|
||||
onTabClick,
|
||||
}: OnboardingCardTabsProps) {
|
||||
return (
|
||||
<TabList>
|
||||
{Object.entries(TabTitles).map(([tabType, titles]) => {
|
||||
if (hasPassedFTL() && tabType === "Quickstart") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return (
|
||||
<TabButton
|
||||
key={tabType}
|
||||
isActive={activeTab === tabType}
|
||||
onClick={() => onTabClick(tabType as TabTitle)}
|
||||
>
|
||||
<p className="hidden xs:block m-0 font-medium">{titles.default}</p>
|
||||
<p className="block xs:hidden m-0 font-medium">{titles.xs}</p>
|
||||
</TabButton>
|
||||
);
|
||||
})}
|
||||
</TabList>
|
||||
);
|
||||
}
|
||||
|
||||
export default OnboardingCardTabs;
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
import { useDispatch } from "react-redux";
|
||||
import AddModelForm from "../../../forms/AddModelForm";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../../redux/slices/uiStateSlice";
|
||||
import Alert from "../../gui/Alert";
|
||||
import { useSubmitOnboarding } from "../hooks";
|
||||
|
||||
function ProviderAlert() {
|
||||
const dispatch = useDispatch();
|
||||
const { submitOnboarding } = useSubmitOnboarding("Custom");
|
||||
|
||||
function onClick() {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<AddModelForm onDone={submitOnboarding} />));
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Alert type="info">
|
||||
<p className="font-semibold text-sm m-0">
|
||||
Prefer to use an different provider like OpenAI?
|
||||
</p>
|
||||
<p className="m-0 mt-1">
|
||||
<a
|
||||
className="text-inherit underline cursor-pointer hover:text-inherit"
|
||||
onClick={onClick}
|
||||
>
|
||||
Click here
|
||||
</a>{" "}
|
||||
to add a Chat model from OpenAI, Gemini, and more
|
||||
</p>
|
||||
</Alert>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ProviderAlert;
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
import { FREE_TRIAL_MODELS } from "core/config/default";
|
||||
import { useContext } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Button, ButtonSubtext } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { setDefaultModel } from "../../../redux/slices/stateSlice";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../../redux/slices/uiStateSlice";
|
||||
import { isJetBrains } from "../../../util";
|
||||
import { useSubmitOnboarding } from "../hooks";
|
||||
import JetBrainsFetchGitHubTokenDialog from "./JetBrainsFetchGitHubTokenDialog";
|
||||
|
||||
function QuickstartSubmitButton() {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const { submitOnboarding } = useSubmitOnboarding("Quickstart");
|
||||
|
||||
function onComplete() {
|
||||
submitOnboarding();
|
||||
|
||||
// Set Sonnet as the default model
|
||||
dispatch(
|
||||
setDefaultModel({ title: FREE_TRIAL_MODELS[0].title, force: true }),
|
||||
);
|
||||
}
|
||||
|
||||
function openJetBrainsDialog() {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<JetBrainsFetchGitHubTokenDialog onComplete={onComplete} />,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async function fetchGitHubAuthToken() {
|
||||
const result = await ideMessenger.request("getGitHubAuthToken", {
|
||||
force: true,
|
||||
});
|
||||
if (result.status === "success") {
|
||||
onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
async function onClick() {
|
||||
if (isJetBrains()) {
|
||||
openJetBrainsDialog();
|
||||
} else {
|
||||
await fetchGitHubAuthToken();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mt-4 w-full">
|
||||
<Button
|
||||
onClick={onClick}
|
||||
className="grid grid-flow-col items-center gap-2 w-full"
|
||||
>
|
||||
Get started using our API keys
|
||||
</Button>
|
||||
<ButtonSubtext>Try 50 chat and 2k autocomplete requests</ButtonSubtext>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default QuickstartSubmitButton;
|
||||
2
gui/src/components/OnboardingCard/hooks/index.ts
Normal file
2
gui/src/components/OnboardingCard/hooks/index.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export * from "./useCheckOllamaModels";
|
||||
export * from "./useSubmitOnboarding";
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import { useContext, useEffect } from "react";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { ONBOARDING_LOCAL_MODEL_TITLE } from "core/config/onboarding";
|
||||
|
||||
const CHECK_OLLAMA_CONNECTION_INTERVAL = 1000;
|
||||
|
||||
export const useCheckOllamaModels = (
|
||||
onDownloadedModels: (models: string[]) => void,
|
||||
) => {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchDownloadedModels = async () => {
|
||||
const result = (await ideMessenger.request("llm/listModels", {
|
||||
title: ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
})) as any;
|
||||
|
||||
if (result.status === "success") {
|
||||
const models = result.content;
|
||||
|
||||
if (Array.isArray(models)) {
|
||||
onDownloadedModels(models);
|
||||
clearInterval(interval);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fetchDownloadedModels();
|
||||
|
||||
const interval = setInterval(
|
||||
fetchDownloadedModels,
|
||||
CHECK_OLLAMA_CONNECTION_INTERVAL,
|
||||
);
|
||||
|
||||
return () => {
|
||||
if (interval) {
|
||||
clearInterval(interval);
|
||||
}
|
||||
};
|
||||
}, [ideMessenger, onDownloadedModels]);
|
||||
};
|
||||
67
gui/src/components/OnboardingCard/hooks/useOnboardingCard.ts
Normal file
67
gui/src/components/OnboardingCard/hooks/useOnboardingCard.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { TabTitle } from "../components/OnboardingCardTabs";
|
||||
import useHistory from "../../../hooks/useHistory";
|
||||
import { setOnboardingCard } from "../../../redux/slices/uiStateSlice";
|
||||
import { OnboardingCardState } from "..";
|
||||
import { RootState } from "../../../redux/store";
|
||||
import { getLocalStorage, setLocalStorage } from "../../../util/localStorage";
|
||||
|
||||
export interface UseOnboardingCard {
|
||||
show: OnboardingCardState["show"];
|
||||
activeTab: OnboardingCardState["activeTab"];
|
||||
setActiveTab: (tab: TabTitle) => void;
|
||||
open: (tab: TabTitle) => void;
|
||||
close: () => void;
|
||||
}
|
||||
|
||||
export function useOnboardingCard(): UseOnboardingCard {
|
||||
const navigate = useNavigate();
|
||||
const dispatch = useDispatch();
|
||||
const { saveSession } = useHistory(dispatch);
|
||||
|
||||
const onboardingCard = useSelector(
|
||||
(state: RootState) => state.uiState.onboardingCard,
|
||||
);
|
||||
|
||||
const onboardingStatus = getLocalStorage("onboardingStatus");
|
||||
const hasDismissedOnboardingCard = getLocalStorage(
|
||||
"hasDismissedOnboardingCard",
|
||||
);
|
||||
|
||||
let show: boolean;
|
||||
|
||||
// Always show if we explicitly want to, e.g. passing free trial
|
||||
// and setting up keys
|
||||
if (onboardingCard.show) {
|
||||
show = true;
|
||||
} else {
|
||||
show = onboardingStatus !== "Completed" && !hasDismissedOnboardingCard;
|
||||
}
|
||||
|
||||
function open(tab: TabTitle) {
|
||||
navigate("/");
|
||||
|
||||
// Used to clear the chat panel before showing onboarding card
|
||||
saveSession();
|
||||
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: tab }));
|
||||
}
|
||||
|
||||
function close() {
|
||||
setLocalStorage("hasDismissedOnboardingCard", true);
|
||||
dispatch(setOnboardingCard({ show: false }));
|
||||
}
|
||||
|
||||
function setActiveTab(tab: TabTitle) {
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: tab }));
|
||||
}
|
||||
|
||||
return {
|
||||
show,
|
||||
setActiveTab,
|
||||
open,
|
||||
close,
|
||||
activeTab: onboardingCard.activeTab,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
import { usePostHog } from "posthog-js/react";
|
||||
import { useContext } from "react";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { getLocalStorage, setLocalStorage } from "../../../util/localStorage";
|
||||
import { OnboardingModes } from "core/protocol/core";
|
||||
import { useTutorialCard } from "../../../hooks/useTutorialCard";
|
||||
import { useOnboardingCard } from "./useOnboardingCard";
|
||||
|
||||
export function useSubmitOnboarding(mode: OnboardingModes) {
|
||||
const posthog = usePostHog();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { openTutorialCard } = useTutorialCard();
|
||||
const { close: closeOnboardingCard } = useOnboardingCard();
|
||||
|
||||
function submitOnboarding() {
|
||||
const onboardingStatus = getLocalStorage("onboardingStatus");
|
||||
|
||||
// Always close the onboarding card and update config.json
|
||||
closeOnboardingCard();
|
||||
ideMessenger.post("completeOnboarding", {
|
||||
mode,
|
||||
});
|
||||
|
||||
if (onboardingStatus === "Started") {
|
||||
// Telemetry
|
||||
posthog.capture("Onboarding Step", { status: "Completed" });
|
||||
posthog.capture("onboardingSelection", {
|
||||
mode,
|
||||
});
|
||||
|
||||
// Local state
|
||||
setLocalStorage("onboardingStatus", "Completed");
|
||||
|
||||
// Show tutorial card
|
||||
openTutorialCard();
|
||||
|
||||
// Move to next step in onboarding
|
||||
ideMessenger.post("showTutorial", undefined);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
submitOnboarding,
|
||||
};
|
||||
}
|
||||
4
gui/src/components/OnboardingCard/index.ts
Normal file
4
gui/src/components/OnboardingCard/index.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export * from "./OnboardingCard";
|
||||
export { default } from "./OnboardingCard";
|
||||
export * from "./utils";
|
||||
export * from "./hooks/useOnboardingCard";
|
||||
16
gui/src/components/OnboardingCard/tabs/OnboardingBestTab.tsx
Normal file
16
gui/src/components/OnboardingCard/tabs/OnboardingBestTab.tsx
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import BestExperienceConfigForm from "../components/BestExperienceConfigForm";
|
||||
import ProviderAlert from "../components/ProviderAlert";
|
||||
import { useSubmitOnboarding } from "../hooks";
|
||||
|
||||
function OnboardingBestTab() {
|
||||
const { submitOnboarding } = useSubmitOnboarding("Best");
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-8">
|
||||
<ProviderAlert />
|
||||
<BestExperienceConfigForm onComplete={submitOnboarding} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default OnboardingBestTab;
|
||||
106
gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx
Normal file
106
gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
import {
|
||||
LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
LOCAL_ONBOARDING_CHAT_TITLE,
|
||||
LOCAL_ONBOARDING_FIM_MODEL,
|
||||
ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
} from "core/config/onboarding";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Button } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { setDefaultModel } from "../../../redux/slices/stateSlice";
|
||||
import { hasPassedFTL } from "../../../util/freeTrial";
|
||||
import AddModelButtonSubtext from "../../AddModelButtonSubtext";
|
||||
import OllamaModelDownload from "../components/OllamaModelDownload";
|
||||
import OllamaStatus from "../components/OllamaStatus";
|
||||
import { useCheckOllamaModels, useSubmitOnboarding } from "../hooks";
|
||||
|
||||
function OnboardingLocalTab() {
|
||||
const dispatch = useDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { submitOnboarding } = useSubmitOnboarding(
|
||||
hasPassedFTL() ? "LocalAfterFreeTrial" : "Local",
|
||||
);
|
||||
const [hasLoadedChatModel, setHasLoadedChatModel] = useState(false);
|
||||
const [downloadedOllamaModels, setDownloadedOllamaModels] = useState<
|
||||
string[]
|
||||
>([]);
|
||||
|
||||
const [isOllamaConnected, setIsOllamaConnected] = useState(false);
|
||||
|
||||
const hasDownloadedChatModel = downloadedOllamaModels.some((ollamaModel) =>
|
||||
ollamaModel.startsWith(LOCAL_ONBOARDING_CHAT_MODEL),
|
||||
);
|
||||
|
||||
const hasDownloadedAutocompleteModel = downloadedOllamaModels.some(
|
||||
(ollamaModel) => ollamaModel.startsWith(LOCAL_ONBOARDING_CHAT_MODEL),
|
||||
);
|
||||
|
||||
/**
|
||||
* The first time we detect that a chat model has been loaded,
|
||||
* we send an empty request to load it
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (!hasLoadedChatModel && hasDownloadedChatModel) {
|
||||
ideMessenger.post("llm/complete", {
|
||||
completionOptions: {},
|
||||
prompt: "",
|
||||
title: ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
});
|
||||
|
||||
setHasLoadedChatModel(true);
|
||||
}
|
||||
}, [downloadedOllamaModels, isOllamaConnected]);
|
||||
|
||||
useCheckOllamaModels((models) => {
|
||||
setDownloadedOllamaModels(models);
|
||||
});
|
||||
|
||||
function onConnectionVerified() {
|
||||
setIsOllamaConnected(true);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex flex-col">
|
||||
<p className="text-lg font-bold leading-tight mb-2">Install Ollama</p>
|
||||
<OllamaStatus onConnectionVerified={onConnectionVerified} />
|
||||
</div>
|
||||
|
||||
<OllamaModelDownload
|
||||
title="Download Chat model"
|
||||
modelName={LOCAL_ONBOARDING_CHAT_MODEL}
|
||||
hasDownloaded={hasDownloadedChatModel}
|
||||
/>
|
||||
|
||||
<OllamaModelDownload
|
||||
title="Download Autocomplete model"
|
||||
modelName={LOCAL_ONBOARDING_FIM_MODEL}
|
||||
hasDownloaded={hasDownloadedAutocompleteModel}
|
||||
/>
|
||||
|
||||
<div className="mt-4 w-full">
|
||||
<Button
|
||||
onClick={() => {
|
||||
submitOnboarding();
|
||||
|
||||
// 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
|
||||
}),
|
||||
);
|
||||
}}
|
||||
className="w-full"
|
||||
disabled={!hasDownloadedChatModel}
|
||||
>
|
||||
Connect
|
||||
</Button>
|
||||
<AddModelButtonSubtext />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default OnboardingLocalTab;
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import ContinueLogo from "../../ContinueLogo";
|
||||
import QuickStartSubmitButton from "../components/QuickStartSubmitButton";
|
||||
|
||||
function OnboardingQuickstartTab() {
|
||||
return (
|
||||
<div className="flex justify-center items-center">
|
||||
<div className="flex flex-col items-center justify-center w-3/4 text-center">
|
||||
<div className="mr-5">
|
||||
<ContinueLogo height={75} />
|
||||
</div>
|
||||
|
||||
<p className="text-sm">
|
||||
Quickly get up and running using our API keys. After this trial, we'll
|
||||
help you set up your own models.
|
||||
</p>
|
||||
|
||||
<p className="text-sm">
|
||||
To prevent abuse, we'll ask you to sign in to GitHub.
|
||||
</p>
|
||||
|
||||
<QuickStartSubmitButton />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default OnboardingQuickstartTab;
|
||||
3
gui/src/components/OnboardingCard/tabs/index.ts
Normal file
3
gui/src/components/OnboardingCard/tabs/index.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export { default as Best } from "./OnboardingBestTab";
|
||||
export { default as Local } from "./OnboardingLocalTab";
|
||||
export { default as Quickstart } from "./OnboardingQuickstartTab";
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
import { usePostHog } from "posthog-js/react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
|
||||
|
||||
// Note that there is no "NotStarted" status since the
|
||||
|
|
@ -22,27 +20,3 @@ export function isNewUserOnboarding() {
|
|||
|
||||
return onboardingStatus === undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Telemetry, status tracking, and routing logic for new user onboarding.
|
||||
*/
|
||||
export function useCompleteOnboarding() {
|
||||
const posthog = usePostHog();
|
||||
const navigate = useNavigate();
|
||||
|
||||
function completeOnboarding() {
|
||||
const onboardingStatus = getLocalStorage("onboardingStatus");
|
||||
|
||||
if (onboardingStatus === "Started") {
|
||||
setLocalStorage("onboardingStatus", "Completed");
|
||||
setLocalStorage("showTutorialCard", true);
|
||||
posthog.capture("Onboarding Step", { status: "Completed" });
|
||||
}
|
||||
|
||||
navigate("/");
|
||||
}
|
||||
|
||||
return {
|
||||
completeOnboarding,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import { Button, SecondaryButton } from "..";
|
||||
import { Button, lightGray, SecondaryButton } from "..";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
|
|
@ -41,6 +41,7 @@ function ConfirmationDialog(props: ConfirmationDialogProps) {
|
|||
<GridDiv>
|
||||
{!!props.hideCancelButton || (
|
||||
<SecondaryButton
|
||||
style={{ color: lightGray }}
|
||||
onClick={() => {
|
||||
props.onCancel?.();
|
||||
dispatch(setShowDialog(false));
|
||||
|
|
|
|||
|
|
@ -1,72 +0,0 @@
|
|||
import React, { useContext } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import { Button, Input } from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { setDefaultModel } from "../../redux/slices/stateSlice";
|
||||
import { setShowDialog } from "../../redux/slices/uiStateSlice";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial";
|
||||
|
||||
const GridDiv = styled.div`
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: 8px;
|
||||
align-items: center;
|
||||
`;
|
||||
|
||||
export const ftl = () => {
|
||||
// const ftc = parseInt(localStorage.getItem("ftc"));
|
||||
return 50;
|
||||
};
|
||||
|
||||
function FTCDialog() {
|
||||
const navigate = useNavigate();
|
||||
const [apiKey, setApiKey] = React.useState("");
|
||||
const dispatch = useDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<h3>Free Trial Limit Reached</h3>
|
||||
<p>
|
||||
You've reached the free trial limit of {FREE_TRIAL_LIMIT_REQUESTS} free
|
||||
inputs. To keep using Continue, you can either use your own API key, or
|
||||
use a local LLM. To read more about the options, see our{" "}
|
||||
<a href="https://docs.continue.dev/setup/overview" target="_blank">
|
||||
documentation
|
||||
</a>
|
||||
.
|
||||
</p>
|
||||
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="Enter your OpenAI API key"
|
||||
value={apiKey}
|
||||
onChange={(e) => setApiKey(e.target.value)}
|
||||
/>
|
||||
<GridDiv>
|
||||
<Button
|
||||
onClick={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
navigate("/models");
|
||||
}}
|
||||
>
|
||||
Select model
|
||||
</Button>
|
||||
<Button
|
||||
disabled={!apiKey}
|
||||
onClick={() => {
|
||||
ideMessenger.post("config/addOpenAiKey", apiKey);
|
||||
dispatch(setShowDialog(false));
|
||||
dispatch(setDefaultModel({ title: "GPT-4" }));
|
||||
}}
|
||||
>
|
||||
Use my API key
|
||||
</Button>
|
||||
</GridDiv>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default FTCDialog;
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
import React, { useContext } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import { Button, Input } from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { setDefaultModel } from "../../redux/slices/stateSlice";
|
||||
import { setShowDialog } from "../../redux/slices/uiStateSlice";
|
||||
|
||||
const GridDiv = styled.div`
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: 8px;
|
||||
align-items: center;
|
||||
`;
|
||||
|
||||
function SetupLocalOrKeyDialog() {
|
||||
const navigate = useNavigate();
|
||||
const [apiKey, setApiKey] = React.useState("");
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<h3>Set up your own model</h3>
|
||||
<p>
|
||||
To keep using Continue after your free inputs, you can either use your
|
||||
own API key, or use a local LLM. To read more about the options, see our{" "}
|
||||
<a
|
||||
className="cursor-pointer"
|
||||
onClick={() =>
|
||||
ideMessenger.request(
|
||||
"openUrl",
|
||||
"https://docs.continue.dev/reference/Model%20Providers/freetrial",
|
||||
)
|
||||
}
|
||||
>
|
||||
documentation
|
||||
</a>
|
||||
.
|
||||
</p>
|
||||
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="Enter your OpenAI API key"
|
||||
value={apiKey}
|
||||
onChange={(e) => setApiKey(e.target.value)}
|
||||
/>
|
||||
<Button
|
||||
className="w-full"
|
||||
disabled={!apiKey}
|
||||
onClick={() => {
|
||||
ideMessenger.post("config/addOpenAiKey", apiKey);
|
||||
dispatch(setShowDialog(false));
|
||||
dispatch(setDefaultModel({ title: "GPT-4" }));
|
||||
}}
|
||||
>
|
||||
Use my OpenAI API key
|
||||
</Button>
|
||||
<div className="text-center">— OR —</div>
|
||||
<GridDiv>
|
||||
<Button
|
||||
onClick={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
ideMessenger.request("completeOnboarding", {
|
||||
mode: "localAfterFreeTrial",
|
||||
});
|
||||
navigate("/localOnboarding");
|
||||
}}
|
||||
>
|
||||
Use local model
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
navigate("/models");
|
||||
}}
|
||||
>
|
||||
View all options
|
||||
</Button>
|
||||
</GridDiv>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default SetupLocalOrKeyDialog;
|
||||
|
|
@ -2,6 +2,7 @@ import React, { isValidElement, useEffect } from "react";
|
|||
import ReactMarkdown from "react-markdown";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
CloseButton,
|
||||
VSC_BACKGROUND_VAR,
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
|
|
@ -9,6 +10,16 @@ import {
|
|||
vscBackground,
|
||||
vscForeground,
|
||||
} from "..";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setShowDialog } from "../../redux/slices/uiStateSlice";
|
||||
import { XMarkIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
interface TextDialogProps {
|
||||
showDialog: boolean;
|
||||
onEnter: () => void;
|
||||
onClose: () => void;
|
||||
message?: string | JSX.Element;
|
||||
}
|
||||
|
||||
const ScreenCover = styled.div`
|
||||
position: fixed;
|
||||
|
|
@ -38,12 +49,9 @@ const Dialog = styled.div`
|
|||
// overflow: hidden;
|
||||
`;
|
||||
|
||||
const TextDialog = (props: {
|
||||
showDialog: boolean;
|
||||
onEnter: () => void;
|
||||
onClose: () => void;
|
||||
message?: string | JSX.Element;
|
||||
}) => {
|
||||
const TextDialog = (props: TextDialogProps) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === "Escape") {
|
||||
|
|
@ -62,18 +70,16 @@ const TextDialog = (props: {
|
|||
}
|
||||
|
||||
return (
|
||||
<ScreenCover
|
||||
onClick={() => {
|
||||
props.onClose();
|
||||
}}
|
||||
hidden={!props.showDialog}
|
||||
>
|
||||
<ScreenCover onClick={props.onClose} hidden={!props.showDialog}>
|
||||
<DialogContainer
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<Dialog>
|
||||
<CloseButton onClick={props.onClose}>
|
||||
<XMarkIcon className="h-5 w-5" />
|
||||
</CloseButton>
|
||||
{typeof props.message === "string" ? (
|
||||
<ReactMarkdown>{props.message || ""}</ReactMarkdown>
|
||||
) : !React.isValidElement(props.message) ? null : (
|
||||
|
|
|
|||
57
gui/src/components/gui/Alert.tsx
Normal file
57
gui/src/components/gui/Alert.tsx
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import {
|
||||
InformationCircleIcon,
|
||||
ExclamationTriangleIcon,
|
||||
CheckCircleIcon,
|
||||
ExclamationCircleIcon,
|
||||
} from "@heroicons/react/24/solid";
|
||||
import { ReactNode } from "react";
|
||||
import { vscBackground } from "..";
|
||||
|
||||
type AlertTypes = "info" | "success" | "warning" | "error";
|
||||
|
||||
export interface AlertProps {
|
||||
children?: ReactNode;
|
||||
type?: AlertTypes;
|
||||
}
|
||||
|
||||
type AlertConfig = {
|
||||
[key in AlertTypes]: {
|
||||
Icon: any;
|
||||
};
|
||||
};
|
||||
|
||||
const ALERT_CONFIGS: AlertConfig = {
|
||||
info: {
|
||||
Icon: InformationCircleIcon,
|
||||
},
|
||||
success: {
|
||||
Icon: CheckCircleIcon,
|
||||
},
|
||||
warning: {
|
||||
Icon: ExclamationTriangleIcon,
|
||||
},
|
||||
error: {
|
||||
Icon: ExclamationCircleIcon,
|
||||
},
|
||||
};
|
||||
|
||||
function Alert({ children, type = "info" }: AlertProps) {
|
||||
const { Icon } = ALERT_CONFIGS[type];
|
||||
|
||||
return (
|
||||
<div className="p-4 rounded-lg shadow-none border-l-4 bg-[color:var(--vscode-editor-foreground)] opacity-70">
|
||||
<div className="flex items-start">
|
||||
<Icon
|
||||
className="w-6 min-w-5 h-6 min-h-5"
|
||||
style={{ color: vscBackground }}
|
||||
/>
|
||||
|
||||
<div className="ml-3" style={{ color: vscBackground }}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Alert;
|
||||
|
|
@ -127,11 +127,13 @@ export const Button = styled.button`
|
|||
border-radius: ${defaultBorderRadius};
|
||||
|
||||
border: none;
|
||||
color: ${vscForeground};
|
||||
background-color: ${vscButtonBackground};
|
||||
color: ${vscBackground};
|
||||
background-color: ${vscForeground};
|
||||
|
||||
&:disabled {
|
||||
color: gray;
|
||||
color: ${vscBackground};
|
||||
opacity: 0.5;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&:hover:enabled {
|
||||
|
|
@ -143,11 +145,12 @@ export const Button = styled.button`
|
|||
export const SecondaryButton = styled.button`
|
||||
padding: 10px 12px;
|
||||
margin: 8px 0;
|
||||
height: 2.5rem;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
|
||||
border: 1px solid ${vscInputBorder};
|
||||
border: 1px solid ${vscForeground};
|
||||
color: ${vscForeground};
|
||||
background-color: ${vscBackground};
|
||||
background-color: inherit;
|
||||
|
||||
&:disabled {
|
||||
color: gray;
|
||||
|
|
@ -155,10 +158,25 @@ export const SecondaryButton = styled.button`
|
|||
|
||||
&:hover:enabled {
|
||||
cursor: pointer;
|
||||
background-color: ${vscInputBackground};
|
||||
background-color: ${vscBackground};
|
||||
opacity: 0.9;
|
||||
}
|
||||
`;
|
||||
|
||||
export const InputSubtext = styled.span`
|
||||
font-size: 0.75rem;
|
||||
line-height: 1rem;
|
||||
color: ${lightGray};
|
||||
margin-top: 0.25rem;
|
||||
`;
|
||||
|
||||
export const ButtonSubtext = styled.span`
|
||||
display: block;
|
||||
margin-top: 0;
|
||||
text-align: center;
|
||||
color: ${lightGray};
|
||||
`;
|
||||
|
||||
export const CustomScrollbarDiv = styled.div`
|
||||
scrollbar-base-color: transparent;
|
||||
scrollbar-width: thin;
|
||||
|
|
@ -261,8 +279,8 @@ export const HelperText = styled.p`
|
|||
export const Input = styled.input`
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
margin: 8px 0;
|
||||
box-sizing: border-box;
|
||||
margin: 4px 0px;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
outline: 1px solid ${lightGray};
|
||||
border: none;
|
||||
|
|
@ -271,7 +289,7 @@ export const Input = styled.input`
|
|||
|
||||
&:focus {
|
||||
background: ${vscInputBackground};
|
||||
outline: 1px solid ${vscFocusBorder};
|
||||
outline: 1px solid ${lightGray};
|
||||
}
|
||||
|
||||
&:invalid {
|
||||
|
|
@ -368,7 +386,7 @@ export const HeaderButton = styled.button<{
|
|||
&:hover {
|
||||
background-color: ${({ inverted, hoverBackgroundColor }) =>
|
||||
typeof inverted === "undefined" || inverted
|
||||
? (hoverBackgroundColor ?? vscInputBackground)
|
||||
? hoverBackgroundColor ?? vscInputBackground
|
||||
: "transparent"};
|
||||
}
|
||||
display: flex;
|
||||
|
|
@ -377,3 +395,34 @@ export const HeaderButton = styled.button<{
|
|||
gap: 4px;
|
||||
padding: 2px;
|
||||
`;
|
||||
|
||||
export const Divider = styled.div`
|
||||
height: 1px;
|
||||
background-color: ${lightGray};
|
||||
`;
|
||||
|
||||
export const StyledActionButton = styled.div`
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
transition: background-color 200ms;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
padding: 2px 12px;
|
||||
background-color: ${lightGray}33;
|
||||
background-opacity: 0.1;
|
||||
`;
|
||||
|
||||
export const CloseButton = styled.button`
|
||||
border: none;
|
||||
background-color: inherit;
|
||||
color: ${lightGray};
|
||||
position: absolute;
|
||||
top: 0.6rem;
|
||||
right: 1rem;
|
||||
padding: 0.25rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
import { ExclamationCircleIcon } from "@heroicons/react/24/outline";
|
||||
import ReactDOM from "react-dom";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import { StyledTooltip, lightGray, vscForeground } from "..";
|
||||
import AddModelForm from "../../forms/AddModelForm";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import { getFontSize } from "../../util";
|
||||
import QuickModelSetup from "../modelSelection/quickSetup/QuickModelSetup";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial";
|
||||
|
||||
const ProgressBarWrapper = styled.div`
|
||||
|
|
@ -58,6 +59,27 @@ const ProgressBar = ({ completed, total }: ProgressBarProps) => {
|
|||
|
||||
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
|
||||
|
||||
if (completed > total) {
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="flex items-center gap-1 cursor-default"
|
||||
data-tooltip-id="usage_progress_bar"
|
||||
>
|
||||
<ExclamationCircleIcon width="18px" height="18px" color="red" />
|
||||
Trial limit reached
|
||||
</div>
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<StyledTooltip id="usage_progress_bar" place="top">
|
||||
Configure a model above in order to continue
|
||||
</StyledTooltip>,
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<GridDiv
|
||||
|
|
@ -66,7 +88,7 @@ const ProgressBar = ({ completed, total }: ProgressBarProps) => {
|
|||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<QuickModelSetup
|
||||
<AddModelForm
|
||||
onDone={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
navigate("/");
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ import { ComboBoxItem } from "./types";
|
|||
|
||||
const InputBoxDiv = styled.div`
|
||||
resize: none;
|
||||
|
||||
padding: 8px 12px;
|
||||
padding-bottom: 4px;
|
||||
font-family: inherit;
|
||||
|
|
@ -155,6 +154,7 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
|
||||
const posthog = usePostHog();
|
||||
const [isEditorFocused, setIsEditorFocused] = useState(false);
|
||||
const [hasDefaultModel, setHasDefaultModel] = useState(true);
|
||||
|
||||
const inSubmenuRef = useRef<string | undefined>(undefined);
|
||||
const inDropdownRef = useRef(false);
|
||||
|
|
@ -209,6 +209,20 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
const active = useSelector((state: RootState) => state.state.active);
|
||||
const activeRef = useUpdatingRef(active);
|
||||
|
||||
// Only set `hasDefaultModel` after a timeout to prevent jank
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
setHasDefaultModel(
|
||||
!!defaultModel &&
|
||||
defaultModel.apiKey !== undefined &&
|
||||
defaultModel.apiKey !== "",
|
||||
);
|
||||
}, 3500);
|
||||
|
||||
// Cleanup function to clear the timeout if the component unmounts
|
||||
return () => clearTimeout(timer);
|
||||
}, [defaultModel]);
|
||||
|
||||
async function handleImageFile(
|
||||
file: File,
|
||||
): Promise<[HTMLImageElement, string] | undefined> {
|
||||
|
|
@ -256,6 +270,16 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
|
||||
const { prevRef, nextRef, addRef } = useInputHistory();
|
||||
|
||||
function getPlaceholder() {
|
||||
if (!hasDefaultModel) {
|
||||
return "Configure a Chat model to get started";
|
||||
}
|
||||
|
||||
return historyLengthRef.current === 0
|
||||
? "Ask anything, '/' for slash commands, '@' to add context"
|
||||
: "Ask a follow-up";
|
||||
}
|
||||
|
||||
const editor: Editor = useEditor({
|
||||
extensions: [
|
||||
Document,
|
||||
|
|
@ -296,10 +320,7 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
},
|
||||
}),
|
||||
Placeholder.configure({
|
||||
placeholder: () =>
|
||||
historyLengthRef.current === 0
|
||||
? "Ask anything, '/' for slash commands, '@' to add context"
|
||||
: "Ask a follow-up",
|
||||
placeholder: getPlaceholder,
|
||||
}),
|
||||
Paragraph.extend({
|
||||
addKeyboardShortcuts() {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {
|
|||
XMarkIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, lightGray } from "..";
|
||||
import { defaultBorderRadius, lightGray, vscBackground } from "..";
|
||||
import { getMetaKeyLabel } from "../../util";
|
||||
|
||||
interface TutorialCardProps {
|
||||
|
|
@ -16,25 +16,35 @@ interface TutorialCardProps {
|
|||
const TutorialCardDiv = styled.div`
|
||||
border: 1px solid ${lightGray};
|
||||
border-radius: ${defaultBorderRadius};
|
||||
background-color: ${vscBackground};
|
||||
padding: 1rem 2.5rem 1rem 2rem;
|
||||
margin: 1rem;
|
||||
max-width: 28rem;
|
||||
position: relative;
|
||||
`;
|
||||
|
||||
const CloseButton = styled.button`
|
||||
border: none;
|
||||
background-color: ${vscBackground};
|
||||
color: ${lightGray};
|
||||
position: absolute;
|
||||
top: 0.4rem;
|
||||
right: 0.5rem;
|
||||
padding: 0.25rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
export function TutorialCard({ onClose }: TutorialCardProps) {
|
||||
return (
|
||||
<TutorialCardDiv>
|
||||
<div
|
||||
onClick={onClose}
|
||||
className="absolute top-2 right-2 p-1 text-gray-400 hover:text-gray-600 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 bg-white rounded-full cursor-pointer shadow-sm"
|
||||
role="button"
|
||||
aria-label="Close"
|
||||
>
|
||||
<XMarkIcon width="1.2em" height="1.2em" />
|
||||
</div>
|
||||
<CloseButton onClick={onClose}>
|
||||
<XMarkIcon className="h-5 w-5" />
|
||||
</CloseButton>
|
||||
|
||||
<ul className="text-gray-300 space-y-4 pl-0">
|
||||
<ul className="space-y-4 pl-0" style={{ color: lightGray }}>
|
||||
<li className="flex items-start">
|
||||
<PencilSquareIcon
|
||||
width="1.4em"
|
||||
|
|
|
|||
|
|
@ -1,305 +0,0 @@
|
|||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import {
|
||||
ChevronUpDownIcon,
|
||||
PlusIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { Fragment, useContext, useEffect, useState } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscBackground,
|
||||
vscForeground,
|
||||
vscInputBackground,
|
||||
vscListActiveBackground,
|
||||
vscListActiveForeground,
|
||||
} from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { defaultModelSelector } from "../../redux/selectors/modelSelectors";
|
||||
import { setDefaultModel } from "../../redux/slices/stateSlice";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import { RootState } from "../../redux/store";
|
||||
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import HeaderButtonWithText from "../HeaderButtonWithText";
|
||||
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
|
||||
|
||||
const GridDiv = styled.div`
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
border: 0.5px solid ${lightGray};
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
const StyledPlusIcon = styled(PlusIcon)`
|
||||
background-color: ${vscBackground};
|
||||
cursor: pointer;
|
||||
margin: 0px;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
height: 100%;
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscInputBackground};
|
||||
}
|
||||
border-left: 0.5px solid ${lightGray};
|
||||
`;
|
||||
|
||||
const StyledListbox = styled(Listbox)`
|
||||
background-color: ${vscBackground};
|
||||
padding: 0;
|
||||
min-width: 80px;
|
||||
`;
|
||||
|
||||
const StyledListboxButton = styled(Listbox.Button)`
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
background-color: ${vscBackground};
|
||||
text-align: left;
|
||||
border: none;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
max-width: 180px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
|
||||
color: ${vscForeground};
|
||||
|
||||
padding: 4px 8px;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscInputBackground};
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledListboxOptions = styled(Listbox.Options)`
|
||||
background-color: ${vscInputBackground};
|
||||
padding: 0;
|
||||
|
||||
position: absolute;
|
||||
bottom: calc(100% - 16px);
|
||||
max-width: 100%;
|
||||
max-height: 80vh;
|
||||
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow-y: scroll;
|
||||
`;
|
||||
|
||||
const StyledListboxOption = styled(Listbox.Option)<{ selected: boolean }>`
|
||||
background-color: ${({ selected }) =>
|
||||
selected ? vscListActiveBackground : vscInputBackground};
|
||||
cursor: pointer;
|
||||
padding: 6px 8px;
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscListActiveBackground};
|
||||
color: ${vscListActiveForeground};
|
||||
}
|
||||
`;
|
||||
|
||||
function ListBoxOption({
|
||||
option,
|
||||
idx,
|
||||
showDelete,
|
||||
}: {
|
||||
option: Option;
|
||||
idx: number;
|
||||
showDelete?: boolean;
|
||||
}) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const [hovered, setHovered] = useState(false);
|
||||
|
||||
return (
|
||||
<StyledListboxOption
|
||||
key={idx}
|
||||
selected={
|
||||
option.value ===
|
||||
JSON.stringify({
|
||||
t: "default",
|
||||
idx: -1,
|
||||
})
|
||||
}
|
||||
value={option.value}
|
||||
onMouseEnter={() => {
|
||||
setHovered(true);
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
setHovered(false);
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-3 h-5 relative">
|
||||
<span>{option.title}</span>
|
||||
{hovered && showDelete && (
|
||||
<HeaderButtonWithText
|
||||
text={undefined}
|
||||
onClick={(e) => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
text={`Are you sure you want to delete this model? (${option.title})`}
|
||||
onConfirm={() => {
|
||||
ideMessenger.post("config/deleteModel", {
|
||||
title: option.title,
|
||||
});
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}}
|
||||
backgroundColor={vscInputBackground}
|
||||
hoverBackgroundColor={vscBackground}
|
||||
className="absolute right-0 p-1"
|
||||
>
|
||||
<TrashIcon width="1.2em" height="1.2em" />
|
||||
</HeaderButtonWithText>
|
||||
)}
|
||||
</div>
|
||||
</StyledListboxOption>
|
||||
);
|
||||
}
|
||||
|
||||
function modelSelectTitle(model: any): string {
|
||||
if (model?.title) return model?.title;
|
||||
if (model?.model !== undefined && model?.model.trim() !== "") {
|
||||
if (model?.class_name) {
|
||||
return `${model?.class_name} - ${model?.model}`;
|
||||
}
|
||||
return model?.model;
|
||||
}
|
||||
return model?.class_name;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
value: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
function ModelSelect(props: {}) {
|
||||
const dispatch = useDispatch();
|
||||
const defaultModel = useSelector(defaultModelSelector);
|
||||
const allModels = useSelector(
|
||||
(state: RootState) => state.state.config.models,
|
||||
);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [options, setOptions] = useState<Option[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
setOptions(
|
||||
allModels.map((model) => {
|
||||
return {
|
||||
value: model.title,
|
||||
title: modelSelectTitle(model),
|
||||
};
|
||||
}),
|
||||
);
|
||||
}, [allModels]);
|
||||
|
||||
const topDiv = document.getElementById("model-select-top-div");
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === "'" && isMetaEquivalentKeyPressed(event)) {
|
||||
const direction = event.shiftKey ? -1 : 1;
|
||||
const currentIndex = options.findIndex(
|
||||
(option) => option.value === defaultModel?.title,
|
||||
);
|
||||
let nextIndex = (currentIndex + 1 * direction) % options.length;
|
||||
if (nextIndex < 0) nextIndex = options.length - 1;
|
||||
dispatch(setDefaultModel({ title: options[nextIndex].value }));
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, [options, defaultModel]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<GridDiv>
|
||||
<StyledListbox
|
||||
value={"GPT-4"}
|
||||
onChange={(val: string) => {
|
||||
if (val === defaultModel?.title) return;
|
||||
dispatch(setDefaultModel({ title: val }));
|
||||
// TODO
|
||||
// client?.setModelForRoleFromTitle("default", val);
|
||||
}}
|
||||
defaultValue={"GPT-4"}
|
||||
>
|
||||
<div className="relative">
|
||||
<StyledListboxButton>
|
||||
<div>{modelSelectTitle(defaultModel)}</div>
|
||||
<div className="pointer-events-none flex items-center">
|
||||
<ChevronUpDownIcon
|
||||
className="h-5 w-5 text-gray-400"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
</StyledListboxButton>
|
||||
{topDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<Transition
|
||||
as={Fragment}
|
||||
leave="transition ease-in duration-100"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<StyledListboxOptions>
|
||||
{options.map((option, idx) => (
|
||||
<ListBoxOption
|
||||
option={option}
|
||||
idx={idx}
|
||||
key={idx}
|
||||
showDelete={options.length > 1}
|
||||
/>
|
||||
))}
|
||||
{options.length === 0 && <i>No models found</i>}
|
||||
<i className="text-xs ml-2" style={{ color: lightGray }}>
|
||||
{getMetaKeyLabel()}' to toggle
|
||||
</i>
|
||||
</StyledListboxOptions>
|
||||
</Transition>,
|
||||
topDiv,
|
||||
)}
|
||||
</div>
|
||||
</StyledListbox>
|
||||
|
||||
<StyledPlusIcon
|
||||
width="1.3em"
|
||||
height="1.3em"
|
||||
onClick={() => {
|
||||
navigate("/addModel");
|
||||
}}
|
||||
/>
|
||||
</GridDiv>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default ModelSelect;
|
||||
|
|
@ -1,15 +1,20 @@
|
|||
import { Listbox } from "@headlessui/react";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
Cog6ToothIcon,
|
||||
CubeIcon,
|
||||
PlusIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, lightGray, vscInputBackground } from "..";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
Divider,
|
||||
lightGray,
|
||||
vscInputBackground,
|
||||
} from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { defaultModelSelector } from "../../redux/selectors/modelSelectors";
|
||||
import { setDefaultModel } from "../../redux/slices/stateSlice";
|
||||
|
|
@ -24,8 +29,23 @@ import {
|
|||
isMetaEquivalentKeyPressed,
|
||||
} from "../../util";
|
||||
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
|
||||
import AddModelForm from "../../forms/AddModelForm";
|
||||
|
||||
interface ModelOptionProps {
|
||||
option: Option;
|
||||
idx: number;
|
||||
showMissingApiKeyMsg: boolean;
|
||||
showDelete?: boolean;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
value: string;
|
||||
title: string;
|
||||
apiKey: string;
|
||||
}
|
||||
|
||||
const MAX_HEIGHT_PX = 300;
|
||||
|
||||
const StyledListboxButton = styled(Listbox.Button)`
|
||||
font-family: inherit;
|
||||
display: flex;
|
||||
|
|
@ -45,7 +65,7 @@ const StyledListboxOptions = styled(Listbox.Options)<{ showAbove: boolean }>`
|
|||
margin-top: 4px;
|
||||
position: absolute;
|
||||
list-style: none;
|
||||
padding: 4px;
|
||||
padding: 0px;
|
||||
white-space: nowrap;
|
||||
cursor: default;
|
||||
|
||||
|
|
@ -57,45 +77,69 @@ const StyledListboxOptions = styled(Listbox.Options)<{ showAbove: boolean }>`
|
|||
background-color: ${vscInputBackground};
|
||||
|
||||
max-height: ${MAX_HEIGHT_PX}px;
|
||||
overflow-y: auto;
|
||||
overflow-y: scroll;
|
||||
|
||||
scrollbar-width: none;
|
||||
|
||||
${(props) => (props.showAbove ? "bottom: 100%;" : "top: 100%;")}
|
||||
`;
|
||||
|
||||
const StyledListboxOption = styled(Listbox.Option)`
|
||||
cursor: pointer;
|
||||
const StyledListboxOption = styled(Listbox.Option)<{ isDisabled?: boolean }>`
|
||||
border-radius: ${defaultBorderRadius};
|
||||
padding: 6px;
|
||||
padding: 8px 12px;
|
||||
|
||||
&:hover {
|
||||
background: ${(props) => `${lightGray}33`};
|
||||
}
|
||||
${({ isDisabled }) =>
|
||||
!isDisabled &&
|
||||
`
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: ${lightGray}33;
|
||||
}
|
||||
`}
|
||||
|
||||
${({ isDisabled }) =>
|
||||
isDisabled &&
|
||||
`
|
||||
opacity: 0.5;
|
||||
`}
|
||||
`;
|
||||
|
||||
const StyledTrashIcon = styled(TrashIcon)`
|
||||
const IconBase = styled.div<{ hovered: boolean }>`
|
||||
width: 1.2em;
|
||||
height: 1.2em;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
margin-left: 8px;
|
||||
padding: 4px;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
opacity: ${(props) => (props.hovered ? 0.75 : 0)};
|
||||
visibility: ${(props) => (props.hovered ? "visible" : "hidden")};
|
||||
|
||||
&:hover {
|
||||
color: red;
|
||||
opacity: 1;
|
||||
background-color: ${lightGray}33;
|
||||
}
|
||||
`;
|
||||
|
||||
const Divider = styled.div`
|
||||
height: 1px;
|
||||
background-color: ${lightGray};
|
||||
margin: 4px;
|
||||
`;
|
||||
const StyledTrashIcon = styled(IconBase).attrs({ as: TrashIcon })``;
|
||||
const StyledCog6ToothIcon = styled(IconBase).attrs({ as: Cog6ToothIcon })``;
|
||||
|
||||
function modelSelectTitle(model: any): string {
|
||||
if (model?.title) return model?.title;
|
||||
if (model?.model !== undefined && model?.model.trim() !== "") {
|
||||
if (model?.class_name) {
|
||||
return `${model?.class_name} - ${model?.model}`;
|
||||
}
|
||||
return model?.model;
|
||||
}
|
||||
return model?.class_name;
|
||||
}
|
||||
|
||||
function ModelOption({
|
||||
option,
|
||||
idx,
|
||||
showDelete,
|
||||
}: {
|
||||
option: Option;
|
||||
idx: number;
|
||||
showDelete?: boolean;
|
||||
}) {
|
||||
showMissingApiKeyMsg,
|
||||
}: ModelOptionProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
|
|
@ -121,77 +165,96 @@ function ModelOption({
|
|||
);
|
||||
}
|
||||
|
||||
function onClickGear(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
ideMessenger.post("openConfigJson", undefined);
|
||||
}
|
||||
|
||||
function handleOptionClick(e) {
|
||||
if (showMissingApiKeyMsg) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledListboxOption
|
||||
key={idx}
|
||||
value={option.value}
|
||||
onMouseEnter={() => {
|
||||
setHovered(true);
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
setHovered(false);
|
||||
}}
|
||||
isDisabled={showMissingApiKeyMsg}
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
onClick={handleOptionClick}
|
||||
>
|
||||
<div className="flex items-center justify-between w-full">
|
||||
<div className="flex items-center pr-4">
|
||||
<CubeIcon className="w-4 h-4 mr-2 flex-shrink-0" />
|
||||
<span>{option.title}</span>
|
||||
<div className="flex flex-col w-full gap-0.5">
|
||||
<div className="flex items-center justify-between w-full">
|
||||
<div className="flex items-center flex-grow">
|
||||
<CubeIcon className="w-4 h-4 mr-2 flex-shrink-0" />
|
||||
<span className="flex-grow">{option.title}</span>
|
||||
</div>
|
||||
<div className="flex items-center ml-2">
|
||||
<StyledCog6ToothIcon hovered={hovered} onClick={onClickGear} />
|
||||
{showDelete && (
|
||||
<StyledTrashIcon hovered={hovered} onClick={onClickDelete} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<StyledTrashIcon
|
||||
style={{ visibility: hovered && showDelete ? "visible" : "hidden" }}
|
||||
className="ml-auto"
|
||||
width="1.2em"
|
||||
height="1.2em"
|
||||
onClick={onClickDelete}
|
||||
/>
|
||||
{showMissingApiKeyMsg && (
|
||||
<span className="ml-6 text-xs italic text-[8px]">
|
||||
Missing API key
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</StyledListboxOption>
|
||||
);
|
||||
}
|
||||
|
||||
function modelSelectTitle(model: any): string {
|
||||
if (model?.title) return model?.title;
|
||||
if (model?.model !== undefined && model?.model.trim() !== "") {
|
||||
if (model?.class_name) {
|
||||
return `${model?.class_name} - ${model?.model}`;
|
||||
}
|
||||
return model?.model;
|
||||
}
|
||||
return model?.class_name;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
value: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
function ModelSelect() {
|
||||
const dispatch = useDispatch();
|
||||
const defaultModel = useSelector(defaultModelSelector);
|
||||
const allModels = useSelector(
|
||||
(state: RootState) => state.state.config.models,
|
||||
);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const [showAbove, setShowAbove] = useState(false);
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const [options, setOptions] = useState<Option[]>([]);
|
||||
|
||||
const [sortedOptions, setSortedOptions] = useState<Option[]>([]);
|
||||
const selectedProfileId = useSelector(
|
||||
(store: RootState) => store.state.selectedProfileId,
|
||||
);
|
||||
|
||||
// Sort so that options without an API key are at the end
|
||||
useEffect(() => {
|
||||
const enabledOptions = options.filter((option) => option.apiKey !== "");
|
||||
const disabledOptions = options.filter((option) => option.apiKey === "");
|
||||
|
||||
const sorted = [...enabledOptions, ...disabledOptions];
|
||||
|
||||
setSortedOptions(sorted);
|
||||
}, [options]);
|
||||
|
||||
useEffect(() => {
|
||||
setOptions(
|
||||
allModels.map((model) => {
|
||||
return {
|
||||
value: model.title,
|
||||
title: modelSelectTitle(model),
|
||||
apiKey: model.apiKey,
|
||||
};
|
||||
}),
|
||||
);
|
||||
}, [allModels]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => calculatePosition();
|
||||
window.addEventListener("resize", handleResize);
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === "'" && isMetaEquivalentKeyPressed(event)) {
|
||||
|
|
@ -211,27 +274,34 @@ function ModelSelect() {
|
|||
};
|
||||
}, [options, defaultModel]);
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
function calculatePosition() {
|
||||
const rect = buttonRef.current.getBoundingClientRect();
|
||||
const spaceBelow = window.innerHeight - rect.bottom;
|
||||
const spaceAbove = rect.top;
|
||||
const dropdownHeight = MAX_HEIGHT_PX;
|
||||
|
||||
const [showAbove, setShowAbove] = useState(false);
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow);
|
||||
}
|
||||
|
||||
const calculatePosition = () => {
|
||||
function onClickAddModel(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
// Close the dropdown
|
||||
if (buttonRef.current) {
|
||||
const rect = buttonRef.current.getBoundingClientRect();
|
||||
const spaceBelow = window.innerHeight - rect.bottom;
|
||||
const spaceAbove = rect.top;
|
||||
const dropdownHeight = MAX_HEIGHT_PX;
|
||||
|
||||
setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow);
|
||||
buttonRef.current.click();
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => calculatePosition();
|
||||
window.addEventListener("resize", handleResize);
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}, []);
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<AddModelForm
|
||||
onDone={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Listbox
|
||||
|
|
@ -254,13 +324,14 @@ function ModelSelect() {
|
|||
</span>
|
||||
</StyledListboxButton>
|
||||
<StyledListboxOptions showAbove={showAbove} className="z-50">
|
||||
<div className={`max-h-[${MAX_HEIGHT_PX}px] overflow-y-auto`}>
|
||||
{options.map((option, idx) => (
|
||||
<div className={`max-h-[${MAX_HEIGHT_PX}px]`}>
|
||||
{sortedOptions.map((option, idx) => (
|
||||
<ModelOption
|
||||
option={option}
|
||||
idx={idx}
|
||||
key={idx}
|
||||
showDelete={options.length > 1}
|
||||
showMissingApiKeyMsg={option.apiKey === ""}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
|
@ -268,37 +339,26 @@ function ModelSelect() {
|
|||
<div className="mt-auto">
|
||||
{selectedProfileId === "local" && (
|
||||
<>
|
||||
{options.length > 0 && <Divider />}
|
||||
{options.length > 0 && <Divider className="!my-0" />}
|
||||
|
||||
<StyledListboxOption
|
||||
key={options.length}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
navigate("/addModel");
|
||||
}}
|
||||
onClick={onClickAddModel}
|
||||
value={"addModel" as any}
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<div className="flex items-center py-0.5">
|
||||
<PlusIcon className="w-4 h-4 mr-2" />
|
||||
Add Model
|
||||
Add Chat model
|
||||
</div>
|
||||
</StyledListboxOption>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Divider />
|
||||
<Divider className="!my-0" />
|
||||
|
||||
<i
|
||||
style={{
|
||||
color: lightGray,
|
||||
padding: "4px",
|
||||
marginTop: "4px",
|
||||
display: "block",
|
||||
}}
|
||||
>
|
||||
{getMetaKeyLabel()}' to toggle
|
||||
</i>
|
||||
<span className="block px-3 py-3" style={{ color: lightGray }}>
|
||||
<code>{getMetaKeyLabel()} + '</code> to toggle
|
||||
</span>
|
||||
</div>
|
||||
</StyledListboxOptions>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,30 +1,114 @@
|
|||
import { Transition } from "@headlessui/react";
|
||||
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/react/24/outline";
|
||||
import { Dispatch, Fragment, SetStateAction } from "react";
|
||||
|
||||
import { Listbox } from "@headlessui/react";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
StyledListbox,
|
||||
StyledListboxButton,
|
||||
StyledListboxOption,
|
||||
StyledListboxOptions,
|
||||
} from "./StyledListbox";
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscBackground,
|
||||
vscButtonBackground,
|
||||
vscForeground,
|
||||
vscInputBackground,
|
||||
vscListActiveBackground,
|
||||
vscListActiveForeground,
|
||||
} from "..";
|
||||
|
||||
export const StyledListbox = styled(Listbox)`
|
||||
background-color: ${vscBackground};
|
||||
`;
|
||||
|
||||
export const StyledListboxButton = styled(Listbox.Button)`
|
||||
cursor: pointer;
|
||||
background-color: ${vscBackground};
|
||||
text-align: left;
|
||||
|
||||
padding-left: 0.75rem;
|
||||
padding-right: 2.5rem;
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem;
|
||||
|
||||
border-radius: 0.5em;
|
||||
border: 1px solid ${lightGray};
|
||||
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
position: relative;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
|
||||
color: ${vscForeground};
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscInputBackground};
|
||||
}
|
||||
`;
|
||||
|
||||
export const StyledListboxOptions = styled(Listbox.Options)`
|
||||
background-color: ${vscInputBackground};
|
||||
padding: 0;
|
||||
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
|
||||
margin-top: 0.25rem;
|
||||
|
||||
max-height: 15rem;
|
||||
overflow: auto;
|
||||
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow-y: scroll;
|
||||
z-index: 10;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
`;
|
||||
|
||||
export const StyledListboxOption = styled(Listbox.Option)<{
|
||||
selected: boolean;
|
||||
}>`
|
||||
background-color: ${({ selected }) =>
|
||||
selected ? vscListActiveBackground : vscInputBackground};
|
||||
cursor: pointer;
|
||||
padding: 6px 8px;
|
||||
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscListActiveBackground};
|
||||
color: ${vscListActiveForeground};
|
||||
}
|
||||
`;
|
||||
|
||||
interface DisplayInfo {
|
||||
title: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
interface QuickSetupListBoxProps {
|
||||
interface ModelSelectionListboxProps {
|
||||
selectedProvider: DisplayInfo;
|
||||
setSelectedProvider: Dispatch<SetStateAction<DisplayInfo>>;
|
||||
options: DisplayInfo[];
|
||||
}
|
||||
|
||||
function QuickSetupListBox({
|
||||
function ModelSelectionListbox({
|
||||
selectedProvider,
|
||||
setSelectedProvider,
|
||||
options,
|
||||
}: QuickSetupListBoxProps) {
|
||||
}: ModelSelectionListboxProps) {
|
||||
return (
|
||||
<StyledListbox value={selectedProvider} onChange={setSelectedProvider}>
|
||||
<div className="relative mt-1">
|
||||
|
|
@ -91,4 +175,4 @@ function QuickSetupListBox({
|
|||
);
|
||||
}
|
||||
|
||||
export default QuickSetupListBox;
|
||||
export default ModelSelectionListbox;
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
import { useContext, useState } from "react";
|
||||
import { Button, Input, SecondaryButton, vscForeground } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { isJetBrains } from "../../../util";
|
||||
import { setLocalStorage } from "../../../util/localStorage";
|
||||
|
||||
interface GitHubSignInButtonProps {
|
||||
onComplete: (token: string) => void;
|
||||
}
|
||||
|
||||
function GitHubSignInButton(props: GitHubSignInButtonProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [jbGhAuthToken, setJbGhAuthToken] = useState("");
|
||||
|
||||
return isJetBrains() ? (
|
||||
<div className="text-center">
|
||||
<div className="flex justify-center">
|
||||
<SecondaryButton
|
||||
onClick={() => {
|
||||
ideMessenger.post(
|
||||
"openUrl",
|
||||
"https://github.com/settings/tokens/new?scopes=user:email&description=Continue%20Free%20Trial%20Token%20",
|
||||
);
|
||||
}}
|
||||
className="grid grid-flow-col items-center gap-2"
|
||||
>
|
||||
<svg
|
||||
viewBox="0 0 98 96"
|
||||
height={24}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
</svg>
|
||||
Generate Token
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
<Input
|
||||
placeholder="Paste token here"
|
||||
value={jbGhAuthToken}
|
||||
onChange={(e) => setJbGhAuthToken(e.target.value)}
|
||||
/>
|
||||
<Button
|
||||
disabled={!jbGhAuthToken}
|
||||
onClick={async () => {
|
||||
await ideMessenger.request("setGitHubAuthToken", {
|
||||
token: jbGhAuthToken,
|
||||
});
|
||||
setLocalStorage("signedInToGh", true);
|
||||
props.onComplete(jbGhAuthToken);
|
||||
}}
|
||||
>
|
||||
Continue
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex justify-center">
|
||||
<SecondaryButton
|
||||
onClick={async () => {
|
||||
const result = await ideMessenger.request(
|
||||
"getGitHubAuthToken",
|
||||
undefined,
|
||||
);
|
||||
if (result.status === "success") {
|
||||
setLocalStorage("signedInToGh", true);
|
||||
props.onComplete(result.content);
|
||||
}
|
||||
}}
|
||||
className="grid grid-flow-col items-center gap-2"
|
||||
>
|
||||
<svg viewBox="0 0 98 96" height={24} xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
</svg>
|
||||
Sign in with GitHub
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default GitHubSignInButton;
|
||||
|
|
@ -1,163 +0,0 @@
|
|||
import { useContext, useEffect, useState } from "react";
|
||||
import { FormProvider, useForm } from "react-hook-form";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Button, Input, SecondaryButton } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import {
|
||||
ProviderInfo,
|
||||
providers,
|
||||
} from "../../../pages/AddNewModel/configs/providers";
|
||||
import { setDefaultModel } from "../../../redux/slices/stateSlice";
|
||||
import {
|
||||
FREE_TRIAL_LIMIT_REQUESTS,
|
||||
hasPassedFTL,
|
||||
} from "../../../util/freeTrial";
|
||||
import QuickSetupListBox from "./QuickSetupListBox";
|
||||
|
||||
interface QuickModelSetupProps {
|
||||
onDone: () => void;
|
||||
hideFreeTrialLimitMessage?: boolean;
|
||||
}
|
||||
|
||||
function QuickModelSetup(props: QuickModelSetupProps) {
|
||||
const [selectedProvider, setSelectedProvider] = useState<ProviderInfo>(
|
||||
providers["openai"]!,
|
||||
);
|
||||
const [selectedModel, setSelectedModel] = useState(
|
||||
selectedProvider.packages[0],
|
||||
);
|
||||
const formMethods = useForm();
|
||||
const dispatch = useDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedModel(selectedProvider.packages[0]);
|
||||
}, [selectedProvider]);
|
||||
|
||||
const [hasAddedModel, setHasAddedModel] = useState(false);
|
||||
|
||||
return (
|
||||
<FormProvider {...formMethods}>
|
||||
<div className="p-4">
|
||||
{!props.hideFreeTrialLimitMessage && hasPassedFTL() && (
|
||||
<p className="text-sm text-gray-500">
|
||||
You've reached the free trial limit of {FREE_TRIAL_LIMIT_REQUESTS}{" "}
|
||||
free inputs. To keep using Continue, you can either use your own API
|
||||
key, or use a local LLM. To read more about the options, see our{" "}
|
||||
<a
|
||||
href="https://docs.continue.dev/setup/overview"
|
||||
target="_blank"
|
||||
onClick={() =>
|
||||
ideMessenger.post(
|
||||
"openUrl",
|
||||
"https://docs.continue.dev/setup/overview",
|
||||
)
|
||||
}
|
||||
>
|
||||
documentation
|
||||
</a>
|
||||
.
|
||||
</p>
|
||||
)}
|
||||
|
||||
<h4>1. Select a provider</h4>
|
||||
<QuickSetupListBox
|
||||
selectedProvider={selectedProvider}
|
||||
setSelectedProvider={setSelectedProvider}
|
||||
options={Object.entries(providers)
|
||||
.filter(([key]) => !["freetrial", "openai-aiohttp"].includes(key))
|
||||
.map(([, provider]) => provider)}
|
||||
></QuickSetupListBox>
|
||||
|
||||
<h4>2. Select a model</h4>
|
||||
<QuickSetupListBox
|
||||
selectedProvider={selectedModel}
|
||||
setSelectedProvider={setSelectedModel}
|
||||
options={
|
||||
Object.entries(providers).find(
|
||||
([, provider]) => provider.title === selectedProvider.title,
|
||||
)?.[1].packages
|
||||
}
|
||||
></QuickSetupListBox>
|
||||
|
||||
{selectedProvider.apiKeyUrl && (
|
||||
<>
|
||||
<h4>3. Paste your API key</h4>
|
||||
{selectedModel.params.model.startsWith("codestral") && (
|
||||
<i>
|
||||
Note: Codestral requires a different API key from other Mistral
|
||||
models
|
||||
</i>
|
||||
)}
|
||||
<SecondaryButton
|
||||
className="w-full border-2 border-solid"
|
||||
onClick={() => {
|
||||
let apiKeyUrl = selectedProvider.apiKeyUrl;
|
||||
if (selectedModel.params.model.startsWith("codestral")) {
|
||||
apiKeyUrl = "https://console.mistral.ai/codestral";
|
||||
}
|
||||
if (apiKeyUrl) {
|
||||
ideMessenger.post("openUrl", apiKeyUrl);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Get API Key
|
||||
</SecondaryButton>
|
||||
<Input
|
||||
id="apiKey"
|
||||
className="w-full"
|
||||
placeholder="Enter API Key"
|
||||
{...formMethods.register("apiKey", { required: true })}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{selectedProvider.downloadUrl && (
|
||||
<>
|
||||
<h4>3. Download {selectedProvider.title}</h4>
|
||||
<SecondaryButton
|
||||
className="w-full border-2 border-solid"
|
||||
onClick={() => {
|
||||
selectedProvider.downloadUrl &&
|
||||
ideMessenger.post("openUrl", selectedProvider.downloadUrl);
|
||||
}}
|
||||
>
|
||||
Download {selectedProvider.title}
|
||||
</SecondaryButton>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Button
|
||||
disabled={
|
||||
selectedProvider.apiKeyUrl && !formMethods.watch("apiKey")
|
||||
}
|
||||
onClick={() => {
|
||||
const model = {
|
||||
...selectedProvider.params,
|
||||
...selectedModel.params,
|
||||
provider: selectedProvider.provider,
|
||||
apiKey: formMethods.watch("apiKey"),
|
||||
title: selectedModel.title,
|
||||
};
|
||||
ideMessenger.post("config/addModel", { model });
|
||||
dispatch(setDefaultModel({ title: model.title, force: true }));
|
||||
setHasAddedModel(true);
|
||||
}}
|
||||
className="w-full"
|
||||
>
|
||||
Add Model
|
||||
</Button>
|
||||
<Button
|
||||
onClick={props.onDone}
|
||||
className="w-full"
|
||||
disabled={!hasAddedModel}
|
||||
>
|
||||
Done
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</FormProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default QuickModelSetup;
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
import { Listbox } from "@headlessui/react";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
vscBackground,
|
||||
vscButtonBackground,
|
||||
vscForeground,
|
||||
vscInputBackground,
|
||||
vscListActiveBackground,
|
||||
vscListActiveForeground,
|
||||
} from "../..";
|
||||
|
||||
export const StyledListbox = styled(Listbox)`
|
||||
background-color: ${vscBackground};
|
||||
`;
|
||||
|
||||
export const StyledListboxButton = styled(Listbox.Button)`
|
||||
cursor: pointer;
|
||||
background-color: ${vscBackground};
|
||||
text-align: left;
|
||||
|
||||
padding-left: 0.75rem;
|
||||
padding-right: 2.5rem;
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem;
|
||||
|
||||
border-radius: 0.5em;
|
||||
border: 1px solid ${vscButtonBackground};
|
||||
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
position: relative;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
|
||||
color: ${vscForeground};
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscInputBackground};
|
||||
}
|
||||
`;
|
||||
|
||||
export const StyledListboxOptions = styled(Listbox.Options)`
|
||||
background-color: ${vscInputBackground};
|
||||
padding: 0;
|
||||
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
|
||||
margin-top: 0.25rem;
|
||||
|
||||
max-height: 15rem;
|
||||
overflow: auto;
|
||||
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow-y: scroll;
|
||||
z-index: 10;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
`;
|
||||
|
||||
export const StyledListboxOption = styled(Listbox.Option)<{
|
||||
selected: boolean;
|
||||
}>`
|
||||
background-color: ${({ selected }) =>
|
||||
selected ? vscListActiveBackground : vscInputBackground};
|
||||
cursor: pointer;
|
||||
padding: 6px 8px;
|
||||
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscListActiveBackground};
|
||||
color: ${vscListActiveForeground};
|
||||
}
|
||||
`;
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
214
gui/src/forms/AddModelForm.tsx
Normal file
214
gui/src/forms/AddModelForm.tsx
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
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 { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import {
|
||||
ProviderInfo,
|
||||
providers,
|
||||
} from "../pages/AddNewModel/configs/providers";
|
||||
import { setDefaultModel } from "../redux/slices/stateSlice";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS, hasPassedFTL } from "../util/freeTrial";
|
||||
|
||||
interface QuickModelSetupProps {
|
||||
onDone: () => void;
|
||||
hideFreeTrialLimitMessage?: boolean;
|
||||
}
|
||||
|
||||
function AddModelForm({
|
||||
onDone,
|
||||
hideFreeTrialLimitMessage,
|
||||
}: QuickModelSetupProps) {
|
||||
const [selectedProvider, setSelectedProvider] = useState<ProviderInfo>(
|
||||
providers["openai"]!,
|
||||
);
|
||||
|
||||
const [selectedModel, setSelectedModel] = useState(
|
||||
selectedProvider.packages[0],
|
||||
);
|
||||
|
||||
const formMethods = useForm();
|
||||
const dispatch = useDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const selectedProviderApiKeyUrl = selectedModel.params.model.startsWith(
|
||||
"codestral",
|
||||
)
|
||||
? "https://console.mistral.ai/codestral"
|
||||
: selectedProvider.apiKeyUrl;
|
||||
|
||||
function isDisabled() {
|
||||
if (
|
||||
selectedProvider.downloadUrl ||
|
||||
selectedProvider.provider === "free-trial"
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const apiKey = formMethods.watch("apiKey");
|
||||
return typeof apiKey === "undefined" || apiKey.length === 0;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedModel(selectedProvider.packages[0]);
|
||||
}, [selectedProvider]);
|
||||
|
||||
function onSubmit() {
|
||||
const apiKey = formMethods.watch("apiKey");
|
||||
const hasValidApiKey = apiKey !== undefined && apiKey !== "";
|
||||
|
||||
const model = {
|
||||
...selectedProvider.params,
|
||||
...selectedModel.params,
|
||||
provider: selectedProvider.provider,
|
||||
title: selectedModel.title,
|
||||
...(hasValidApiKey ? { apiKey } : {}),
|
||||
};
|
||||
|
||||
ideMessenger.post("config/addModel", { model });
|
||||
ideMessenger.post("openConfigJson", undefined);
|
||||
|
||||
dispatch(setDefaultModel({ title: model.title, force: true }));
|
||||
|
||||
onDone();
|
||||
}
|
||||
|
||||
function onClickDownloadProvider() {
|
||||
selectedProvider.downloadUrl &&
|
||||
ideMessenger.post("openUrl", selectedProvider.downloadUrl);
|
||||
}
|
||||
|
||||
return (
|
||||
<FormProvider {...formMethods}>
|
||||
<form onSubmit={formMethods.handleSubmit(onSubmit)}>
|
||||
<div className="p-6 max-w-md mx-auto">
|
||||
<h1 className="text-center mb-0">Add Chat model</h1>
|
||||
{!hideFreeTrialLimitMessage && hasPassedFTL() && (
|
||||
<p className="text-sm text-gray-500">
|
||||
You've reached the free trial limit of {FREE_TRIAL_LIMIT_REQUESTS}{" "}
|
||||
free inputs. To keep using Continue, you can either use your own
|
||||
API key, or use a local LLM. To read more about the options, see
|
||||
our{" "}
|
||||
<a
|
||||
href="https://docs.continue.dev/setup/overview"
|
||||
target="_blank"
|
||||
onClick={() =>
|
||||
ideMessenger.post(
|
||||
"openUrl",
|
||||
"https://docs.continue.dev/setup/overview",
|
||||
)
|
||||
}
|
||||
>
|
||||
documentation
|
||||
</a>
|
||||
.
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="flex flex-col gap-6 my-8">
|
||||
<div>
|
||||
<label className="block text-sm font-medium">Provider</label>
|
||||
<ModelSelectionListbox
|
||||
selectedProvider={selectedProvider}
|
||||
setSelectedProvider={setSelectedProvider}
|
||||
options={Object.entries(providers)
|
||||
.filter(
|
||||
([key]) => !["freetrial", "openai-aiohttp"].includes(key),
|
||||
)
|
||||
.map(([, provider]) => provider)}
|
||||
></ModelSelectionListbox>
|
||||
<InputSubtext className="mb-0">
|
||||
Don't see your provider?{" "}
|
||||
<a
|
||||
href={null}
|
||||
target="_blank"
|
||||
className="text-inherit underline cursor-pointer hover:text-inherit"
|
||||
>
|
||||
Click here
|
||||
</a>{" "}
|
||||
to view the full list
|
||||
</InputSubtext>
|
||||
</div>
|
||||
|
||||
{selectedProvider.downloadUrl && (
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-1">
|
||||
Install provider
|
||||
</label>
|
||||
|
||||
<StyledActionButton onClick={onClickDownloadProvider}>
|
||||
<p className="underline text-sm">
|
||||
{selectedProvider.downloadUrl}
|
||||
</p>
|
||||
<ArrowTopRightOnSquareIcon width={24} height={24} />
|
||||
</StyledActionButton>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium">Model</label>
|
||||
<ModelSelectionListbox
|
||||
selectedProvider={selectedModel}
|
||||
setSelectedProvider={setSelectedModel}
|
||||
options={
|
||||
Object.entries(providers).find(
|
||||
([, provider]) => provider.title === selectedProvider.title,
|
||||
)?.[1].packages
|
||||
}
|
||||
></ModelSelectionListbox>
|
||||
</div>
|
||||
|
||||
{selectedModel.params.model.startsWith("codestral") && (
|
||||
<div className="my-2">
|
||||
<Alert>
|
||||
<p className="font-bold text-sm m-0">Codestral API key</p>
|
||||
<p className="m-0 mt-1">
|
||||
Note that codestral requires a different API key from other
|
||||
Mistral models
|
||||
</p>
|
||||
</Alert>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{selectedProvider.apiKeyUrl && (
|
||||
<div>
|
||||
<>
|
||||
<label className="block text-sm font-medium">API key</label>
|
||||
<Input
|
||||
id="apiKey"
|
||||
className="w-full"
|
||||
placeholder={`Enter your ${selectedProvider.title} API key`}
|
||||
{...formMethods.register("apiKey")}
|
||||
/>
|
||||
<InputSubtext className="mb-0">
|
||||
<a
|
||||
href={selectedProviderApiKeyUrl}
|
||||
target="_blank"
|
||||
className="text-inherit underline cursor-pointer hover:text-inherit"
|
||||
>
|
||||
Click here
|
||||
</a>{" "}
|
||||
to create a {selectedProvider.title} API key
|
||||
</InputSubtext>
|
||||
</>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-4 w-full">
|
||||
<Button type="submit" className="w-full" disabled={isDisabled()}>
|
||||
Connect
|
||||
</Button>
|
||||
<AddModelButtonSubtext />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</FormProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default AddModelForm;
|
||||
32
gui/src/hooks/useTutorialCard.ts
Normal file
32
gui/src/hooks/useTutorialCard.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { useState } from "react";
|
||||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
|
||||
export type UseTutorialCard = {
|
||||
showTutorialCard: boolean;
|
||||
closeTutorialCard: () => void;
|
||||
openTutorialCard: () => void;
|
||||
};
|
||||
|
||||
export function useTutorialCard(): UseTutorialCard {
|
||||
const posthog = usePostHog();
|
||||
|
||||
const [showTutorialCard, setShowTutorialCard] = useState<boolean>(
|
||||
getLocalStorage("showTutorialCard"),
|
||||
);
|
||||
|
||||
function closeTutorialCard() {
|
||||
posthog.capture("closedTutorialCard");
|
||||
setLocalStorage("showTutorialCard", false);
|
||||
setShowTutorialCard(false);
|
||||
}
|
||||
|
||||
function openTutorialCard() {
|
||||
setLocalStorage("showTutorialCard", true);
|
||||
setShowTutorialCard(true);
|
||||
}
|
||||
|
||||
return { showTutorialCard, closeTutorialCard, openTutorialCard };
|
||||
}
|
||||
|
||||
export default UseTutorialCard;
|
||||
|
|
@ -54,7 +54,7 @@ const hljsToTextMate: Record<string, string[]> = {
|
|||
};
|
||||
|
||||
function constructTheme(
|
||||
tmTheme: typeof window.fullColorTheme
|
||||
tmTheme: typeof window.fullColorTheme,
|
||||
): Record<string, string> {
|
||||
const rules = tmTheme["rules"] || [];
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ function fallbackTheme() {
|
|||
|
||||
export function useVscTheme() {
|
||||
const [theme, setTheme] = useState<any>(
|
||||
constructTheme(window.fullColorTheme || {})
|
||||
constructTheme(window.fullColorTheme || {}),
|
||||
);
|
||||
|
||||
useWebviewListener("setTheme", async (data) => {
|
||||
|
|
|
|||
|
|
@ -19,18 +19,8 @@ body,
|
|||
#root {
|
||||
height: 100%;
|
||||
background-color: var(--vscode-editor-background);
|
||||
font-family:
|
||||
system-ui,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Segoe UI",
|
||||
Roboto,
|
||||
Oxygen,
|
||||
Ubuntu,
|
||||
Cantarell,
|
||||
"Open Sans",
|
||||
"Helvetica Neue",
|
||||
sans-serif;
|
||||
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
codestral: {
|
||||
title: "Codestral",
|
||||
description:
|
||||
"Codestral is an advanced generative model created by Mistral AI, tailored for coding tasks like fill-in-the-middle and code completion. Trained on more than 80 programming languages, Codestral demonstrates proficiency in both widely-used and less-common languages.",
|
||||
"Codestral is an advanced generative model created by Mistral AI, tailored for coding tasks like fill-in-the-middle and code completion.",
|
||||
params: {
|
||||
title: "Codestral",
|
||||
model: "codestral-latest",
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
|
|||
],
|
||||
},
|
||||
mistral: {
|
||||
title: "Mistral API",
|
||||
title: "Mistral",
|
||||
provider: "mistral",
|
||||
description:
|
||||
"The Mistral API provides seamless access to their models, including Codestral, Mistral 8x22B, Mistral Large, and more.",
|
||||
|
|
@ -202,7 +202,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
|
|||
description:
|
||||
"One of the fastest ways to get started with local models on Mac, Linux, or Windows",
|
||||
longDescription:
|
||||
'To get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama run <MODEL_NAME>`. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.json (e.g. `model="codellama:7b-instruct"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.',
|
||||
'To get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/download) and open the application\n2. Open a terminal and run `ollama run <MODEL_NAME>`. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.json (e.g. `model="codellama:7b-instruct"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.',
|
||||
icon: "ollama.png",
|
||||
tags: [ModelProviderTags.Local, ModelProviderTags.OpenSource],
|
||||
packages: [
|
||||
|
|
@ -219,7 +219,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
|
|||
...completionParamsInputsConfigs,
|
||||
{ ...apiBaseInput, defaultValue: "http://localhost:11434" },
|
||||
],
|
||||
downloadUrl: "https://ollama.ai/",
|
||||
downloadUrl: "https://ollama.ai/download",
|
||||
},
|
||||
cohere: {
|
||||
title: "Cohere",
|
||||
|
|
@ -490,28 +490,28 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
|
|||
key: "watsonxUrl",
|
||||
label: "watsonx URL",
|
||||
placeholder: "e.g. http://us-south.dataplatform.cloud.ibm.com",
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
inputType: "text",
|
||||
key: "watsonxProjectId",
|
||||
label: "watsonx Project ID",
|
||||
placeholder: "Enter your project ID",
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
inputType: "text",
|
||||
key: "watsonxCreds",
|
||||
label: "watsonx API key",
|
||||
placeholder: "Enter your API key (SaaS) or ZenApiKey (Software)",
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
inputType: "text",
|
||||
key: "watsonxApiVersion",
|
||||
label: "watsonx API version",
|
||||
placeholder: "Enter the API Version",
|
||||
defaultValue: "2023-05-29"
|
||||
defaultValue: "2023-05-29",
|
||||
},
|
||||
{
|
||||
inputType: "text",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import {
|
|||
} from "react";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
Button,
|
||||
|
|
@ -32,9 +31,13 @@ import TimelineItem from "../components/gui/TimelineItem";
|
|||
import ContinueInputBox from "../components/mainInput/ContinueInputBox";
|
||||
import { defaultInputModifiers } from "../components/mainInput/inputModifiers";
|
||||
import { TutorialCard } from "../components/mainInput/TutorialCard";
|
||||
import OnboardingCard, {
|
||||
useOnboardingCard,
|
||||
} from "../components/OnboardingCard";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import useChatHandler from "../hooks/useChatHandler";
|
||||
import useHistory from "../hooks/useHistory";
|
||||
import { useTutorialCard } from "../hooks/useTutorialCard";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { defaultModelSelector } from "../redux/selectors/modelSelectors";
|
||||
import {
|
||||
|
|
@ -93,24 +96,10 @@ const StepsDiv = styled.div`
|
|||
position: relative;
|
||||
}
|
||||
|
||||
// Gray, vertical line on the left ("thread")
|
||||
// &::before {
|
||||
// content: "";
|
||||
// position: absolute;
|
||||
// height: calc(100% - 12px);
|
||||
// border-left: 2px solid ${lightGray};
|
||||
// left: 28px;
|
||||
// z-index: 0;
|
||||
// bottom: 12px;
|
||||
// }
|
||||
|
||||
.thread-message {
|
||||
margin: 8px 4px 0 4px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
// .thread-message:not(:first-child) {
|
||||
// border-top: 1px solid ${lightGray}22;
|
||||
// }
|
||||
`;
|
||||
|
||||
const NewSessionButton = styled.div`
|
||||
|
|
@ -155,9 +144,11 @@ function fallbackRender({ error, resetErrorBoundary }: any) {
|
|||
function GUI() {
|
||||
const posthog = usePostHog();
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const onboardingCard = useOnboardingCard();
|
||||
const { showTutorialCard, closeTutorialCard } = useTutorialCard();
|
||||
|
||||
const sessionState = useSelector((state: RootState) => state.state);
|
||||
|
||||
const defaultModel = useSelector(defaultModelSelector);
|
||||
|
|
@ -174,16 +165,6 @@ function GUI() {
|
|||
|
||||
const state = useSelector((state: RootState) => state.state);
|
||||
|
||||
const [showTutorialCard, setShowTutorialCard] = useState<boolean>(
|
||||
getLocalStorage("showTutorialCard") ?? true,
|
||||
);
|
||||
|
||||
const onCloseTutorialCard = () => {
|
||||
posthog.capture("closedTutorialCard");
|
||||
setLocalStorage("showTutorialCard", false);
|
||||
setShowTutorialCard(false);
|
||||
};
|
||||
|
||||
const handleScroll = () => {
|
||||
// Temporary fix to account for additional height when code blocks are added
|
||||
const OFFSET_HERUISTIC = 300;
|
||||
|
|
@ -237,8 +218,12 @@ function GUI() {
|
|||
setLocalStorage("ftc", u + 1);
|
||||
|
||||
if (u >= FREE_TRIAL_LIMIT_REQUESTS) {
|
||||
navigate("/onboarding");
|
||||
onboardingCard.open("Best");
|
||||
posthog?.capture("ftc_reached");
|
||||
ideMessenger.ide.showToast(
|
||||
"info",
|
||||
"You've reached the free trial limit. Please configure a model to continue.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -508,9 +493,15 @@ function GUI() {
|
|||
</div>
|
||||
) : null}
|
||||
|
||||
{!!showTutorialCard && (
|
||||
{onboardingCard.show && (
|
||||
<div className="mt-10 mx-2">
|
||||
<OnboardingCard activeTab={onboardingCard.activeTab} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showTutorialCard !== false && !onboardingCard.open && (
|
||||
<div className="flex justify-center w-full">
|
||||
<TutorialCard onClose={onCloseTutorialCard} />
|
||||
<TutorialCard onClose={closeTutorialCard} />
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -8,11 +8,55 @@ import IndexingProgressBar from "../components/loaders/IndexingProgressBar";
|
|||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { useNavigationListener } from "../hooks/useNavigationListener";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setOnboardingCard } from "../redux/slices/uiStateSlice";
|
||||
import useHistory from "../hooks/useHistory";
|
||||
|
||||
interface MoreActionRowProps {
|
||||
title: string;
|
||||
description: string;
|
||||
buttonText: string;
|
||||
onClick?: () => void;
|
||||
href?: string;
|
||||
}
|
||||
|
||||
function MoreActionRow({
|
||||
title,
|
||||
description,
|
||||
buttonText,
|
||||
onClick,
|
||||
href,
|
||||
}: MoreActionRowProps) {
|
||||
const ButtonOrLink = href ? "a" : "div";
|
||||
const buttonProps = href
|
||||
? { href, target: "_blank", className: "no-underline w-1/2" }
|
||||
: { className: "w-1/2" };
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2 w-full">
|
||||
<div className="w-1/2 pr-4">
|
||||
<h3 className="my-0">{title}</h3>
|
||||
<p>{description}</p>
|
||||
</div>
|
||||
<ButtonOrLink {...buttonProps}>
|
||||
<SecondaryButton
|
||||
className="grid grid-flow-col items-center gap-2 w-full"
|
||||
onClick={onClick}
|
||||
>
|
||||
{buttonText}
|
||||
</SecondaryButton>
|
||||
</ButtonOrLink>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MorePage() {
|
||||
useNavigationListener();
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { saveSession } = useHistory(dispatch);
|
||||
|
||||
const [indexingState, setIndexingState] = useState<IndexingProgressUpdate>({
|
||||
desc: "Loading indexing config",
|
||||
|
|
@ -62,92 +106,46 @@ function MorePage() {
|
|||
Help Center
|
||||
</h3>
|
||||
<div className="p-6 flex flex-col gap-6">
|
||||
<div className="grid grid-cols-3 gap-4 items-center">
|
||||
<div className="col-span-2">
|
||||
<h3 className="my-0">Documentation</h3>
|
||||
<p>
|
||||
Visit the documentation site to learn how to configure and use
|
||||
Continue.
|
||||
</p>
|
||||
</div>
|
||||
<a
|
||||
className="col-span-1 "
|
||||
href="https://docs.continue.dev/"
|
||||
target="_blank"
|
||||
>
|
||||
<SecondaryButton className="w-full">View docs</SecondaryButton>
|
||||
</a>
|
||||
</div>
|
||||
<MoreActionRow
|
||||
title="Documentation"
|
||||
description="Visit the documentation site to learn how to configure and use Continue"
|
||||
buttonText="View docs"
|
||||
href="https://docs.continue.dev/"
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-3 gap-4 items-center">
|
||||
<div className="col-span-2">
|
||||
<h3 className="my-0">Tutorial</h3>
|
||||
<p>
|
||||
Open the tutorial to get a quick walkthrough of the most commonly
|
||||
used features in Continue.
|
||||
</p>
|
||||
</div>
|
||||
<SecondaryButton
|
||||
className="col-span-1 w-full"
|
||||
onClick={() => {
|
||||
ideMessenger.post("showTutorial", undefined);
|
||||
}}
|
||||
>
|
||||
Open tutorial
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
<MoreActionRow
|
||||
title="Quickstart"
|
||||
description="Reopen the quickstart and tutorial file"
|
||||
buttonText="Open quickstart"
|
||||
onClick={() => {
|
||||
navigate("/");
|
||||
// Used to clear the chat panel before showing onboarding card
|
||||
saveSession();
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: "Best" }));
|
||||
ideMessenger.post("showTutorial", undefined);
|
||||
}}
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-3 gap-4 items-center">
|
||||
<div className="col-span-2">
|
||||
<h3 className="my-0">Token usage stats</h3>
|
||||
<p>
|
||||
See how many tokens you're using each day and how they're
|
||||
distributed across your models.
|
||||
</p>
|
||||
</div>
|
||||
<SecondaryButton
|
||||
className="col-span-1"
|
||||
onClick={() => {
|
||||
navigate("/stats");
|
||||
}}
|
||||
>
|
||||
View token usage
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
<MoreActionRow
|
||||
title="Token usage stats"
|
||||
description="See how many tokens you're using each day and how they're distributed across your models"
|
||||
buttonText="View token usage"
|
||||
onClick={() => navigate("/stats")}
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-3 gap-4 items-center w-full">
|
||||
<div className="col-span-2">
|
||||
<h3 className="my-0">Have an issue?</h3>
|
||||
<p>Let us know on GitHub and we'll do our best to resolve it.</p>
|
||||
</div>
|
||||
<a
|
||||
href="https://github.com/continuedev/continue/issues/new/choose"
|
||||
target="_blank"
|
||||
className="no-underline"
|
||||
>
|
||||
<SecondaryButton className="grid grid-flow-col items-center gap-2 w-full">
|
||||
Create a GitHub issue
|
||||
</SecondaryButton>
|
||||
</a>
|
||||
</div>
|
||||
<MoreActionRow
|
||||
title="Have an issue?"
|
||||
description="Let us know on GitHub and we'll do our best to resolve it"
|
||||
buttonText="Create a GitHub issue"
|
||||
href="https://github.com/continuedev/continue/issues/new/choose"
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-3 gap-4 items-center w-full">
|
||||
<div className="col-span-2">
|
||||
<h3 className="my-0">Join the community!</h3>
|
||||
<p>
|
||||
Join us on Discord to stay up-to-date on the latest developments
|
||||
</p>
|
||||
</div>
|
||||
<a
|
||||
href="https://discord.gg/vapESyrFmJ"
|
||||
target="_blank"
|
||||
className="no-underline"
|
||||
>
|
||||
<SecondaryButton className="grid grid-flow-col items-center gap-2 w-full">
|
||||
Continue Discord
|
||||
</SecondaryButton>
|
||||
</a>
|
||||
</div>
|
||||
<MoreActionRow
|
||||
title="Join the community!"
|
||||
description="Join us on Discord to stay up-to-date on the latest developments"
|
||||
buttonText="Continue Discord"
|
||||
href="https://discord.gg/vapESyrFmJ"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<h3
|
||||
|
|
|
|||
|
|
@ -1,66 +0,0 @@
|
|||
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import QuickModelSetup from "../../components/modelSelection/quickSetup/QuickModelSetup";
|
||||
import Toggle from "../../components/modelSelection/Toggle";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { getLocalStorage } from "../../util/localStorage";
|
||||
import DefaultModelConfigForm from "./DefaultModelConfigForm";
|
||||
import { useCompleteOnboarding } from "./utils";
|
||||
|
||||
function ApiKeysOnboarding() {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [isBestToggle, setIsBestToggle] = useState(true);
|
||||
|
||||
const { completeOnboarding } = useCompleteOnboarding();
|
||||
|
||||
return (
|
||||
<div className="p-8 overflow-y-scroll">
|
||||
<div>
|
||||
<ArrowLeftIcon
|
||||
width="1.2em"
|
||||
height="1.2em"
|
||||
onClick={() => navigate(-1)}
|
||||
className="inline-block cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="pb-4 text-center">
|
||||
<h1>Model setup</h1>
|
||||
<p>
|
||||
Choose between our default configuration that includes the best models
|
||||
available, or configure your own setup.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Toggle
|
||||
selected={isBestToggle}
|
||||
optionOne={"Best models"}
|
||||
optionTwo={"Configure your own"}
|
||||
onClick={() => {
|
||||
setIsBestToggle((prev) => !prev);
|
||||
}}
|
||||
/>
|
||||
|
||||
{isBestToggle && <DefaultModelConfigForm />}
|
||||
|
||||
{!isBestToggle && (
|
||||
<QuickModelSetup
|
||||
onDone={() => {
|
||||
ideMessenger.post("showTutorial", undefined);
|
||||
|
||||
if (getLocalStorage("signedInToGh")) {
|
||||
completeOnboarding();
|
||||
} else {
|
||||
navigate("/apiKeyAutocompleteOnboarding");
|
||||
}
|
||||
}}
|
||||
></QuickModelSetup>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ApiKeysOnboarding;
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
import { CheckCircleIcon as CheckCircleIconSolid } from "@heroicons/react/24/solid";
|
||||
import { lightGray } from "../../components";
|
||||
|
||||
export function CheckMarkHeader(props: {
|
||||
children: string;
|
||||
isComplete: boolean;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex gap-4 items-center">
|
||||
{props.isComplete ? (
|
||||
<CheckCircleIconSolid
|
||||
width="24px"
|
||||
height="24px"
|
||||
color="#0b0"
|
||||
className="flex-none"
|
||||
></CheckCircleIconSolid>
|
||||
) : (
|
||||
<div
|
||||
className="flex-none border border-solid rounded-full w-5 h-5 mt-1"
|
||||
style={{ borderColor: lightGray }}
|
||||
></div>
|
||||
)}
|
||||
<h3>{props.children}</h3>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
import ReactDOM from "react-dom";
|
||||
import { useState, useContext } from "react";
|
||||
import { CheckIcon, CommandLineIcon } from "@heroicons/react/24/outline";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
StyledTooltip,
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscForeground,
|
||||
} from "../../components";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
|
||||
export type CopyToTerminalButtonProps = {
|
||||
children: string;
|
||||
};
|
||||
|
||||
const StyledDiv = styled.div<{ clicked: boolean }>`
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
display: flex;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
width: fit-content;
|
||||
gap: 8px;
|
||||
|
||||
${({ clicked }) => clicked && "background-color: #0f02;"}
|
||||
|
||||
align-items: center;
|
||||
|
||||
border: 1px solid ${lightGray};
|
||||
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
background-color: ${({ clicked }) => (clicked ? "#0f02" : "#fff1")};
|
||||
}
|
||||
`;
|
||||
|
||||
export function CopyToTerminalButton(props: CopyToTerminalButtonProps) {
|
||||
const [clicked, setClicked] = useState(false);
|
||||
|
||||
const id = `info-hover-${encodeURIComponent(props.children)}`;
|
||||
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="flex items-center justify-center mt-8"
|
||||
data-tooltip-id={id}
|
||||
>
|
||||
<StyledDiv
|
||||
clicked={clicked}
|
||||
style={{ border: `0.5px solid ${lightGray}` }}
|
||||
className="grid-cols-2"
|
||||
onClick={() => {
|
||||
ideMessenger.ide.runCommand(props.children);
|
||||
setClicked(true);
|
||||
setTimeout(() => setClicked(false), 2000);
|
||||
ideMessenger.post("copyText", { text: props.children });
|
||||
}}
|
||||
>
|
||||
{clicked ? (
|
||||
<CheckIcon
|
||||
width="20px"
|
||||
height="20px"
|
||||
className="cursor-pointer hover:bg-white"
|
||||
color="#0b0"
|
||||
/>
|
||||
) : (
|
||||
<CommandLineIcon
|
||||
width="20px"
|
||||
height="20px"
|
||||
className="cursor-pointer hover:bg-white"
|
||||
/>
|
||||
)}
|
||||
|
||||
<pre>
|
||||
<code
|
||||
style={{
|
||||
color: vscForeground,
|
||||
backgroundColor: "transparent",
|
||||
}}
|
||||
>
|
||||
{props.children}
|
||||
</code>
|
||||
</pre>
|
||||
</StyledDiv>
|
||||
</div>
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<StyledTooltip id={id} place="top">
|
||||
Copy to terminal
|
||||
</StyledTooltip>,
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
import { useContext, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import { Input, lightGray } from "../../components";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { setDefaultModel } from "../../redux/slices/stateSlice";
|
||||
import { models } from "../AddNewModel/configs/models";
|
||||
import { providers } from "../AddNewModel/configs/providers";
|
||||
import { StyledButton } from "./components";
|
||||
import { useCompleteOnboarding } from "./utils";
|
||||
|
||||
const HelperText = styled.p`
|
||||
font-size: 0.8rem;
|
||||
color: ${lightGray};
|
||||
margin-top: 0.25rem;
|
||||
`;
|
||||
|
||||
function DefaultModelConfigForm() {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [mistralApiKey, setMistralApiKey] = useState("");
|
||||
const [anthropicApiKey, setAnthropicApiKey] = useState("");
|
||||
|
||||
const { completeOnboarding } = useCompleteOnboarding();
|
||||
|
||||
const isFormComplete = !!mistralApiKey && !!anthropicApiKey;
|
||||
|
||||
const { anthropic, mistral } = providers;
|
||||
const { claude35Sonnet: chatModel, codestral: autocompleteModel } = models;
|
||||
|
||||
async function handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const chatModelConfig = {
|
||||
model: chatModel.params.model,
|
||||
provider: anthropic.provider,
|
||||
apiKey: anthropicApiKey,
|
||||
title: chatModel.params.title,
|
||||
};
|
||||
|
||||
const autocompleteModelConfig = {
|
||||
title: autocompleteModel.params.title,
|
||||
provider: mistral.provider,
|
||||
model: autocompleteModel.params.model,
|
||||
apiKey: mistralApiKey,
|
||||
};
|
||||
|
||||
ideMessenger.post("config/addModel", { model: chatModelConfig });
|
||||
|
||||
dispatch(setDefaultModel({ title: chatModelConfig.title, force: true }));
|
||||
|
||||
await ideMessenger.request("addAutocompleteModel", {
|
||||
model: autocompleteModelConfig,
|
||||
});
|
||||
|
||||
ideMessenger.post("showTutorial", undefined);
|
||||
|
||||
completeOnboarding();
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="pt-8">
|
||||
<div>
|
||||
<h2>
|
||||
Chat model - <i>{chatModel.title}</i>
|
||||
</h2>
|
||||
|
||||
<p className="pb-6">{chatModel.description}</p>
|
||||
|
||||
<label className="block pb-4">
|
||||
Anthropic API Key
|
||||
<Input
|
||||
className="w-full"
|
||||
placeholder="Enter your Anthropic API Key"
|
||||
value={anthropicApiKey}
|
||||
onChange={(e) => setAnthropicApiKey(e.target.value)}
|
||||
/>
|
||||
<HelperText>
|
||||
<a href={anthropic.apiKeyUrl} target="_blank">
|
||||
Click here
|
||||
</a>{" "}
|
||||
to create an Anthropic API key
|
||||
</HelperText>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>
|
||||
Autocomplete model - <i>{autocompleteModel.title}</i>
|
||||
</h2>
|
||||
|
||||
<p className="pb-6">{autocompleteModel.description}</p>
|
||||
|
||||
<label className="block pb-8">
|
||||
Mistral API Key (<i>{autocompleteModel.title}</i>)
|
||||
<Input
|
||||
className="w-full"
|
||||
placeholder="Enter your Mistral API Key"
|
||||
value={mistralApiKey}
|
||||
onChange={(e) => setMistralApiKey(e.target.value)}
|
||||
/>
|
||||
<HelperText>
|
||||
<a href={mistral.apiKeyUrl} target="_blank">
|
||||
Click here
|
||||
</a>{" "}
|
||||
to create a Mistral API key
|
||||
</HelperText>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end">
|
||||
<StyledButton type="submit" disabled={!isFormComplete}>
|
||||
Done
|
||||
</StyledButton>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export default DefaultModelConfigForm;
|
||||
|
|
@ -1,229 +0,0 @@
|
|||
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { ONBOARDING_LOCAL_MODEL_TITLE } from "core/config/onboarding";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { CheckMarkHeader } from "./CheckMarkHeader";
|
||||
import { StyledButton } from "./components";
|
||||
import { CopyToTerminalButton } from "./CopyToTerminalButton";
|
||||
import { useCompleteOnboarding } from "./utils";
|
||||
|
||||
type OllamaConnectionStatuses =
|
||||
| "waiting_to_download"
|
||||
| "downloading"
|
||||
| "verified";
|
||||
|
||||
enum DefaultLocalModels {
|
||||
Chat = "llama3",
|
||||
Autocomplete = "starcoder2:3b",
|
||||
Embeddings = "nomic-embed-text",
|
||||
}
|
||||
|
||||
const OLLAMA_DOWNLOAD_URL = "https://ollama.com/download";
|
||||
const REFETCH_MODELS_INTERVAL_MS = 1000;
|
||||
|
||||
function LocalOnboarding() {
|
||||
const navigate = useNavigate();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [downloadedOllamaModels, setDownloadedOllamaModels] = useState<
|
||||
string[] | undefined
|
||||
>(undefined);
|
||||
|
||||
const [ollamaConnectionStatus, setOllamaConnectionStatus] =
|
||||
useState<OllamaConnectionStatuses>("waiting_to_download");
|
||||
|
||||
const [hasLoadedChatModel, setHasLoadedChatModel] = useState(false);
|
||||
|
||||
const { completeOnboarding } = useCompleteOnboarding();
|
||||
|
||||
const isOllamaConnected = ollamaConnectionStatus === "verified";
|
||||
|
||||
function isModelDownloaded(model: string) {
|
||||
if (!downloadedOllamaModels) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return downloadedOllamaModels.some(
|
||||
(ollamaModel) => ollamaModel.startsWith(model), // We use `startsWith` to ignore trailing tags like `:latest`
|
||||
);
|
||||
}
|
||||
|
||||
function renderOllamaConnectionStatus(status: OllamaConnectionStatuses) {
|
||||
switch (status) {
|
||||
case "waiting_to_download":
|
||||
return (
|
||||
<div className="pb-6">
|
||||
<a
|
||||
href={OLLAMA_DOWNLOAD_URL}
|
||||
target="_blank"
|
||||
onClick={() => setOllamaConnectionStatus("downloading")}
|
||||
>
|
||||
Click here to download Ollama from their site.
|
||||
</a>
|
||||
|
||||
<p className="leading-relaxed">
|
||||
Once downloaded, start the application. This page will refresh
|
||||
once you've started Ollama.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
case "downloading":
|
||||
return <p className="pb-6">Checking for connection to Ollama...</p>;
|
||||
|
||||
case "verified":
|
||||
return <></>;
|
||||
|
||||
default:
|
||||
return <></>;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The first time we detect that a chat model has been loaded,
|
||||
* we send an empty request to load it
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (!hasLoadedChatModel && isModelDownloaded(DefaultLocalModels.Chat)) {
|
||||
ideMessenger.post("llm/complete", {
|
||||
completionOptions: {},
|
||||
prompt: "",
|
||||
title: ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
});
|
||||
|
||||
setHasLoadedChatModel(true);
|
||||
}
|
||||
}, [downloadedOllamaModels]);
|
||||
|
||||
/**
|
||||
* Sets up an interval that runs every `REFETCH_MODELS_INTERVAL_MS`
|
||||
* to fetch the list of downloaded models and update state.
|
||||
*/
|
||||
useEffect(() => {
|
||||
const fetchDownloadedModels = async () => {
|
||||
const models = await ideMessenger.request("llm/listModels", {
|
||||
title: ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
});
|
||||
|
||||
if (Array.isArray(models)) {
|
||||
// If we got a response, the connection has been verified
|
||||
if (!isOllamaConnected) {
|
||||
setOllamaConnectionStatus("verified");
|
||||
}
|
||||
|
||||
setDownloadedOllamaModels(models);
|
||||
}
|
||||
};
|
||||
|
||||
// Immediately invoke to try to minimize jank if a user already has
|
||||
// the models installed. A better fix would be to not load the onboarding
|
||||
// steps until we've first checked if the user already has the models installed.
|
||||
fetchDownloadedModels();
|
||||
|
||||
const interval = setInterval(
|
||||
fetchDownloadedModels,
|
||||
REFETCH_MODELS_INTERVAL_MS,
|
||||
);
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="p-8 overflow-y-scroll">
|
||||
<div>
|
||||
<ArrowLeftIcon
|
||||
width="1.2em"
|
||||
height="1.2em"
|
||||
onClick={() => navigate(-1)}
|
||||
className="inline-block cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<h1 className="text-center">Set up your local LLM</h1>
|
||||
|
||||
<div>
|
||||
<CheckMarkHeader isComplete={isOllamaConnected}>
|
||||
1. Download and start Ollama
|
||||
</CheckMarkHeader>
|
||||
|
||||
{renderOllamaConnectionStatus(ollamaConnectionStatus)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<CheckMarkHeader
|
||||
isComplete={isModelDownloaded(DefaultLocalModels.Chat)}
|
||||
>
|
||||
2. Download a model for chat
|
||||
</CheckMarkHeader>
|
||||
{!isModelDownloaded(DefaultLocalModels.Chat) && (
|
||||
<div className="pb-6">
|
||||
<p className="leading-relaxed">
|
||||
We recommend using <code>{DefaultLocalModels.Chat}</code>, the
|
||||
latest open-source model trained by Meta.
|
||||
</p>
|
||||
|
||||
<CopyToTerminalButton>
|
||||
{` ollama run ${DefaultLocalModels.Chat}`}
|
||||
</CopyToTerminalButton>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<CheckMarkHeader
|
||||
isComplete={isModelDownloaded(DefaultLocalModels.Autocomplete)}
|
||||
>
|
||||
3. Download a model for tab autocomplete
|
||||
</CheckMarkHeader>
|
||||
|
||||
{!isModelDownloaded(DefaultLocalModels.Autocomplete) && (
|
||||
<div className="pb-6">
|
||||
<p className="leading-relaxed">
|
||||
We recommend using <code>{DefaultLocalModels.Autocomplete}</code>,
|
||||
a state-of-the-art 3B parameter autocomplete model trained by
|
||||
Hugging Face.
|
||||
</p>
|
||||
|
||||
<CopyToTerminalButton>
|
||||
{`ollama run ${DefaultLocalModels.Autocomplete}`}
|
||||
</CopyToTerminalButton>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<CheckMarkHeader
|
||||
isComplete={isModelDownloaded(DefaultLocalModels.Embeddings)}
|
||||
>
|
||||
4. Download a model for embeddings
|
||||
</CheckMarkHeader>
|
||||
|
||||
{!isModelDownloaded(DefaultLocalModels.Embeddings) && (
|
||||
<div className="pb-6">
|
||||
<p className="leading-relaxed">
|
||||
We recommend using <code>{DefaultLocalModels.Embeddings}</code>, a
|
||||
8192 context-length that outperforms OpenAI <code>ada-002</code>{" "}
|
||||
and <code>text-embedding-3-small</code>
|
||||
on both short and long context tasks.
|
||||
</p>
|
||||
|
||||
<CopyToTerminalButton>
|
||||
{`ollama pull ${DefaultLocalModels.Embeddings}`}
|
||||
</CopyToTerminalButton>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col justify-end mt-4">
|
||||
<StyledButton onClick={completeOnboarding}>
|
||||
Complete onboarding
|
||||
</StyledButton>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default LocalOnboarding;
|
||||
|
|
@ -1,223 +0,0 @@
|
|||
import {
|
||||
CheckBadgeIcon,
|
||||
Cog6ToothIcon,
|
||||
ComputerDesktopIcon,
|
||||
GiftIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { ToCoreFromIdeOrWebviewProtocol } from "core/protocol/core";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { lightGray } from "../../components";
|
||||
import ConfirmationDialog from "../../components/dialogs/ConfirmationDialog";
|
||||
import GitHubSignInButton from "../../components/modelSelection/quickSetup/GitHubSignInButton";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import { isJetBrains } from "../../util";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS, hasPassedFTL } from "../../util/freeTrial";
|
||||
import { Div, StyledButton } from "./components";
|
||||
import { isNewUserOnboarding, useCompleteOnboarding } from "./utils";
|
||||
import { setLocalStorage } from "../../util/localStorage";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
|
||||
type OnboardingMode =
|
||||
ToCoreFromIdeOrWebviewProtocol["completeOnboarding"][0]["mode"];
|
||||
|
||||
function Onboarding() {
|
||||
const navigate = useNavigate();
|
||||
const dispatch = useDispatch();
|
||||
const posthog = usePostHog();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [hasSignedIntoGh, setHasSignedIntoGh] = useState(false);
|
||||
const [selectedOnboardingMode, setSlectedOnboardingMode] = useState<
|
||||
OnboardingMode | undefined
|
||||
>(undefined);
|
||||
|
||||
const { completeOnboarding } = useCompleteOnboarding();
|
||||
|
||||
function onSubmit() {
|
||||
ideMessenger.post("completeOnboarding", {
|
||||
mode: selectedOnboardingMode,
|
||||
});
|
||||
|
||||
/**
|
||||
* "completeOnboarding" above will update the config with our
|
||||
* new embeddings provider. If it's not the default local provider,
|
||||
* we need to re-index the codebase.
|
||||
*/
|
||||
if (selectedOnboardingMode !== "local") {
|
||||
ideMessenger.post("index/forceReIndex", undefined);
|
||||
}
|
||||
|
||||
switch (selectedOnboardingMode) {
|
||||
case "local":
|
||||
navigate("/localOnboarding");
|
||||
break;
|
||||
|
||||
case "apiKeys":
|
||||
navigate("/apiKeysOnboarding");
|
||||
break;
|
||||
|
||||
case "freeTrial":
|
||||
completeOnboarding();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isNewUserOnboarding()) {
|
||||
posthog.capture("Onboarding Step", { status: "Started" });
|
||||
setLocalStorage("onboardingStatus", "Started");
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="max-w-96 mx-auto leading-normal">
|
||||
<div className="leading-relaxed">
|
||||
<h1 className="text-center">Welcome to Continue</h1>
|
||||
<p className="text-center ">
|
||||
Let's find the setup that works best for you. You can update your
|
||||
configuration after onboarding by clicking the
|
||||
<Cog6ToothIcon className="inline-block h-5 w-5 align-middle px-1" />
|
||||
icon in the bottom-right corner of Continue.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-6 pb-8 pt-4">
|
||||
{(!hasPassedFTL() || isJetBrains()) && (
|
||||
<Div
|
||||
selected={selectedOnboardingMode === "freeTrial"}
|
||||
onClick={() => setSlectedOnboardingMode("freeTrial")}
|
||||
>
|
||||
<h3>
|
||||
<GiftIcon
|
||||
width="1.4em"
|
||||
height="1.4em"
|
||||
className="align-middle pr-2"
|
||||
/>
|
||||
Free trial
|
||||
</h3>
|
||||
<p>
|
||||
Start your free trial of {FREE_TRIAL_LIMIT_REQUESTS} requests by
|
||||
signing into GitHub.
|
||||
</p>
|
||||
|
||||
<ul className="pl-4 mb-0">
|
||||
<li>
|
||||
<b>Chat:</b> Llama 3 with Ollama, LM Studio, etc.
|
||||
</li>
|
||||
<li>
|
||||
<b>Embeddings:</b> Nomic Embed
|
||||
</li>
|
||||
<li>
|
||||
<b>Autocomplete:</b> Starcoder2 3B
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{!hasSignedIntoGh && (
|
||||
<div className="flex justify-center py-3">
|
||||
<GitHubSignInButton
|
||||
onComplete={() => setHasSignedIntoGh(true)}
|
||||
></GitHubSignInButton>
|
||||
</div>
|
||||
)}
|
||||
</Div>
|
||||
)}
|
||||
<Div
|
||||
selected={selectedOnboardingMode === "local"}
|
||||
onClick={() => setSlectedOnboardingMode("local")}
|
||||
>
|
||||
<h3>
|
||||
<ComputerDesktopIcon
|
||||
width="1.4em"
|
||||
height="1.4em"
|
||||
className="align-middle pr-2"
|
||||
/>
|
||||
Local models
|
||||
</h3>
|
||||
<p>
|
||||
No code will leave your computer, but less powerful models are used.
|
||||
</p>
|
||||
|
||||
<ul className="pl-4 ">
|
||||
<li>
|
||||
<b>Chat:</b> Llama 3 with Ollama, LM Studio, etc.
|
||||
</li>
|
||||
<li>
|
||||
<b>Embeddings:</b> Nomic Embed
|
||||
</li>
|
||||
<li>
|
||||
<b>Autocomplete:</b> Starcoder2 3B
|
||||
</li>
|
||||
</ul>
|
||||
</Div>
|
||||
|
||||
<Div
|
||||
selected={selectedOnboardingMode === "apiKeys"}
|
||||
onClick={() => setSlectedOnboardingMode("apiKeys")}
|
||||
>
|
||||
<h3>
|
||||
<CheckBadgeIcon
|
||||
width="1.4em"
|
||||
height="1.4em"
|
||||
className="align-middle pr-2"
|
||||
/>
|
||||
Best experience
|
||||
</h3>
|
||||
<p>
|
||||
Start with the most powerful models available, or customize your own
|
||||
configuration.
|
||||
</p>
|
||||
|
||||
<ul className="pl-4 ">
|
||||
<li>
|
||||
<b>Chat:</b> Claude 3.5 Sonnet
|
||||
</li>
|
||||
<li>
|
||||
<b>Embeddings:</b> Voyage Code 2
|
||||
</li>
|
||||
<li>
|
||||
<b>Autocomplete:</b> Codestral
|
||||
</li>
|
||||
</ul>
|
||||
</Div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end">
|
||||
<div className="flex items-center gap-4 ml-auto">
|
||||
<div
|
||||
className="cursor-pointer"
|
||||
style={{ color: lightGray }}
|
||||
onClick={(e) => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
text="Are you sure you want to skip onboarding? Unless you are an existing user or already have a config.json we don't recommend this."
|
||||
onConfirm={() => {
|
||||
completeOnboarding();
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
}}
|
||||
>
|
||||
Skip
|
||||
</div>
|
||||
<StyledButton disabled={!selectedOnboardingMode} onClick={onSubmit}>
|
||||
Continue
|
||||
</StyledButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Onboarding;
|
||||
|
|
@ -1,218 +0,0 @@
|
|||
import { Transition } from "@headlessui/react";
|
||||
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/react/24/outline";
|
||||
import { ModelProvider } from "core";
|
||||
import { TRIAL_FIM_MODEL } from "core/config/onboarding";
|
||||
import { Fragment, useContext, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Button, Input, SecondaryButton } from "../../components";
|
||||
import GitHubSignInButton from "../../components/modelSelection/quickSetup/GitHubSignInButton";
|
||||
import {
|
||||
StyledListbox,
|
||||
StyledListboxButton,
|
||||
StyledListboxOption,
|
||||
StyledListboxOptions,
|
||||
} from "../../components/modelSelection/quickSetup/StyledListbox";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useCompleteOnboarding } from "./utils";
|
||||
|
||||
interface AutocompleteOption {
|
||||
provider: ModelProvider;
|
||||
title: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
const AUTOCOMPLETE_PROVIDER_OPTIONS: AutocompleteOption[] = [
|
||||
{
|
||||
provider: "free-trial",
|
||||
title: "Free Trial (Codestral)",
|
||||
// icon: "fireworks.png",
|
||||
},
|
||||
{
|
||||
provider: "fireworks",
|
||||
title: "Fireworks AI",
|
||||
// icon: "fireworks.png",
|
||||
},
|
||||
{
|
||||
provider: "ollama",
|
||||
title: "Ollama",
|
||||
icon: "ollama.png",
|
||||
},
|
||||
];
|
||||
|
||||
interface AutocompleteModelDropdownProps {
|
||||
selectedProvider: AutocompleteOption;
|
||||
setSelectedProvider: any;
|
||||
}
|
||||
|
||||
function AutocompleteModelDropdown({
|
||||
selectedProvider,
|
||||
setSelectedProvider,
|
||||
}: AutocompleteModelDropdownProps) {
|
||||
return (
|
||||
<StyledListbox value={selectedProvider} onChange={setSelectedProvider}>
|
||||
<div className="relative mt-1">
|
||||
<StyledListboxButton>
|
||||
<span className="flex items-center">
|
||||
{window.vscMediaUrl && selectedProvider.icon && (
|
||||
<img
|
||||
src={`${window.vscMediaUrl}/logos/${selectedProvider.icon}`}
|
||||
height="24px"
|
||||
style={{ marginRight: "10px" }}
|
||||
/>
|
||||
)}
|
||||
<span className="text-md">{selectedProvider.title}</span>
|
||||
</span>
|
||||
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
||||
<ChevronUpDownIcon
|
||||
className="h-5 w-5 text-gray-400"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
</StyledListboxButton>
|
||||
<Transition
|
||||
as={Fragment}
|
||||
leave="transition ease-in duration-100"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<StyledListboxOptions>
|
||||
{AUTOCOMPLETE_PROVIDER_OPTIONS.map((option, index) => (
|
||||
<StyledListboxOption
|
||||
selected={selectedProvider.title === option.title}
|
||||
key={index}
|
||||
className={({ active }: { active: boolean }) =>
|
||||
`relative cursor-default select-none py-2 pl-10 pr-4 ${
|
||||
active ? "bg-amber-100 text-amber-900" : "text-gray-900"
|
||||
}`
|
||||
}
|
||||
value={option}
|
||||
>
|
||||
{({ selected }) => (
|
||||
<>
|
||||
{window.vscMediaUrl && option.icon && (
|
||||
<img
|
||||
src={`${window.vscMediaUrl}/logos/${option.icon}`}
|
||||
height="24px"
|
||||
style={{ marginRight: "10px" }}
|
||||
/>
|
||||
)}
|
||||
<span className="text-md">{option.title}</span>
|
||||
|
||||
{selected ? (
|
||||
<span className="inset-y-0 ml-auto flex items-center pl-3 text-amber-600">
|
||||
<CheckIcon className="h-5 w-5" aria-hidden="true" />
|
||||
</span>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
</StyledListboxOption>
|
||||
))}
|
||||
</StyledListboxOptions>
|
||||
</Transition>
|
||||
</div>
|
||||
</StyledListbox>
|
||||
);
|
||||
}
|
||||
|
||||
function ApiKeyAutocompleteOnboarding() {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [selectedProvider, setSelectedProvider] = useState<AutocompleteOption>(
|
||||
AUTOCOMPLETE_PROVIDER_OPTIONS[0],
|
||||
);
|
||||
|
||||
const [apiKeyValue, setApiKeyValue] = useState<string>("");
|
||||
|
||||
const { completeOnboarding } = useCompleteOnboarding();
|
||||
|
||||
return (
|
||||
<div className="p-2 max-w-96 mt-16 mx-auto">
|
||||
<h1 className="text-center">Autocomplete Model</h1>
|
||||
<p className="text-center">
|
||||
Tab autocomplete requires a separate model. Currently we are supporting
|
||||
free usage by signing in with GitHub. Alternatively, select another
|
||||
option from the dropdown.
|
||||
</p>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<AutocompleteModelDropdown
|
||||
selectedProvider={selectedProvider}
|
||||
setSelectedProvider={setSelectedProvider}
|
||||
></AutocompleteModelDropdown>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
{selectedProvider.provider === "ollama" && (
|
||||
<div className="text-center">
|
||||
<Button
|
||||
onClick={() => {
|
||||
navigate("/localOnboarding");
|
||||
}}
|
||||
>
|
||||
Set up Ollama
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{selectedProvider.provider === "free-trial" && (
|
||||
<div className="text-center">
|
||||
<p>Sign in to GitHub to try autocomplete for free</p>
|
||||
<GitHubSignInButton
|
||||
onComplete={async (token) => {
|
||||
await ideMessenger.request("addAutocompleteModel", {
|
||||
model: {
|
||||
title: "Autocomplete Trial",
|
||||
provider: "free-trial",
|
||||
model: TRIAL_FIM_MODEL,
|
||||
},
|
||||
});
|
||||
|
||||
completeOnboarding();
|
||||
}}
|
||||
></GitHubSignInButton>
|
||||
</div>
|
||||
)}
|
||||
{selectedProvider.provider === "fireworks" && (
|
||||
<div className="text-center">
|
||||
<h4>Paste your API key</h4>
|
||||
<SecondaryButton
|
||||
className="w-full border-2 border-solid"
|
||||
onClick={() => {
|
||||
ideMessenger.post("openUrl", "https://fireworks.ai/api-keys");
|
||||
}}
|
||||
>
|
||||
Get API Key
|
||||
</SecondaryButton>
|
||||
<Input
|
||||
id="apiKey"
|
||||
className="w-full"
|
||||
placeholder="Enter API Key"
|
||||
value={apiKeyValue}
|
||||
onChange={(e) => {
|
||||
setApiKeyValue(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
await ideMessenger.request("addAutocompleteModel", {
|
||||
model: {
|
||||
title: "Fireworks Autocomplete",
|
||||
provider: "fireworks",
|
||||
model: "starcoder-7b",
|
||||
apiKey: apiKeyValue,
|
||||
},
|
||||
});
|
||||
|
||||
completeOnboarding();
|
||||
}}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ApiKeyAutocompleteOnboarding;
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
import styled from "styled-components";
|
||||
import {
|
||||
Button,
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscForeground,
|
||||
} from "../../components";
|
||||
|
||||
export const StyledButton = styled(Button)<{ blurColor?: string }>`
|
||||
background-color: transparent;
|
||||
color: ${vscForeground};
|
||||
border: 1px solid ${lightGray}cc;
|
||||
|
||||
&:hover {
|
||||
border: 1px solid ${lightGray};
|
||||
background-color: ${lightGray}22;
|
||||
}
|
||||
`;
|
||||
|
||||
export const Div = styled.div<{
|
||||
selected: boolean;
|
||||
}>`
|
||||
border: 1px solid ${lightGray};
|
||||
border-radius: ${defaultBorderRadius};
|
||||
transition: all 0.2s;
|
||||
padding-left: 16px;
|
||||
padding-right: 16px;
|
||||
|
||||
&:hover {
|
||||
${(props) => (props.selected ? "" : `background-color: ${lightGray}22;`)}
|
||||
box-shadow: 0 0 4px 0px ${lightGray};
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
${(props) =>
|
||||
props.selected &&
|
||||
`
|
||||
background-color: ${lightGray}44;
|
||||
box-shadow: 0 0 4px 0px ${lightGray};
|
||||
`}
|
||||
`;
|
||||
|
|
@ -1,4 +1,9 @@
|
|||
import { PayloadAction, createSlice } from "@reduxjs/toolkit";
|
||||
import {
|
||||
defaultOnboardingCardState,
|
||||
OnboardingCardState,
|
||||
} from "../../components/OnboardingCard";
|
||||
|
||||
type UiState = {
|
||||
bottomMessage: JSX.Element | undefined;
|
||||
bottomMessageCloseTimeout: NodeJS.Timeout | undefined;
|
||||
|
|
@ -6,6 +11,7 @@ type UiState = {
|
|||
showDialog: boolean;
|
||||
dialogMessage: string | JSX.Element | undefined;
|
||||
dialogEntryOn: boolean;
|
||||
onboardingCard: OnboardingCardState;
|
||||
};
|
||||
|
||||
export const uiStateSlice = createSlice({
|
||||
|
|
@ -17,8 +23,15 @@ export const uiStateSlice = createSlice({
|
|||
dialogMessage: "",
|
||||
dialogEntryOn: false,
|
||||
displayBottomMessageOnBottom: true,
|
||||
onboardingCard: defaultOnboardingCardState,
|
||||
} as UiState,
|
||||
reducers: {
|
||||
setOnboardingCard: (
|
||||
state,
|
||||
action: PayloadAction<Partial<OnboardingCardState>>,
|
||||
) => {
|
||||
state.onboardingCard = { ...state.onboardingCard, ...action.payload };
|
||||
},
|
||||
setBottomMessage: (
|
||||
state,
|
||||
action: PayloadAction<UiState["bottomMessage"]>,
|
||||
|
|
@ -59,6 +72,7 @@ export const uiStateSlice = createSlice({
|
|||
});
|
||||
|
||||
export const {
|
||||
setOnboardingCard,
|
||||
setBottomMessage,
|
||||
setBottomMessageCloseTimeout,
|
||||
setDialogMessage,
|
||||
|
|
@ -66,4 +80,5 @@ export const {
|
|||
setShowDialog,
|
||||
setDisplayBottomMessageOnBottom,
|
||||
} = uiStateSlice.actions;
|
||||
|
||||
export default uiStateSlice.reducer;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { getLocalStorage } from "./localStorage";
|
||||
import _ from "lodash";
|
||||
import { getLocalStorage } from "./localStorage";
|
||||
|
||||
type Platform = "mac" | "linux" | "windows" | "unknown";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import { JSONContent } from "@tiptap/react";
|
||||
import { IndexingProgressUpdate } from "core";
|
||||
import { OnboardingStatus } from "../pages/onboarding/utils";
|
||||
import { OnboardingStatus } from "../components/OnboardingCard";
|
||||
|
||||
type LocalStorageTypes = {
|
||||
onboardingStatus?: OnboardingStatus;
|
||||
hasDismissedOnboardingCard: boolean;
|
||||
mainTextEntryCounter: number;
|
||||
ide: "vscode" | "jetbrains";
|
||||
ftc: number;
|
||||
|
|
@ -12,8 +13,6 @@ type LocalStorageTypes = {
|
|||
inputHistory: JSONContent[];
|
||||
extensionVersion: string;
|
||||
indexingState: IndexingProgressUpdate;
|
||||
signedInToGh: boolean;
|
||||
isOnboardingInProgress: boolean;
|
||||
showTutorialCard: boolean;
|
||||
shownProfilesIntroduction: boolean;
|
||||
disableIndexing: boolean;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
/** @type {import('tailwindcss').Config} */
|
||||
const defaultTheme = require("tailwindcss/defaultTheme");
|
||||
|
||||
module.exports = {
|
||||
content: [
|
||||
|
|
@ -7,10 +8,18 @@ module.exports = {
|
|||
"./src/*.{js,ts,jsx,tsx}",
|
||||
],
|
||||
theme: {
|
||||
extend: {},
|
||||
colors: {
|
||||
"vsc-background": "rgb(var(--vsc-background) / <alpha-value>)",
|
||||
"secondary-dark": "rgb(var(--secondary-dark) / <alpha-value>)",
|
||||
screens: {
|
||||
xs: "425px",
|
||||
...defaultTheme.screens,
|
||||
},
|
||||
extend: {
|
||||
animation: {
|
||||
"spin-slow": "spin 30s linear infinite",
|
||||
},
|
||||
colors: {
|
||||
"vsc-background": "rgb(var(--vsc-background) / <alpha-value>)",
|
||||
"secondary-dark": "rgb(var(--secondary-dark) / <alpha-value>)",
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue