MVP
This commit is contained in:
parent
b22cd71542
commit
cd45150b11
46 changed files with 1166 additions and 1951 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;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {
|
|||
ModelDescription,
|
||||
SerializedContinueConfig,
|
||||
SlashCommandDescription,
|
||||
} from "../index.js";
|
||||
} from "../";
|
||||
|
||||
export const FREE_TRIAL_MODELS: ModelDescription[] = [
|
||||
{
|
||||
|
|
@ -91,7 +91,26 @@ export const defaultSlashCommandsJetBrains = [
|
|||
];
|
||||
|
||||
export const defaultConfig: SerializedContinueConfig = {
|
||||
models: [],
|
||||
/**
|
||||
* Add Sonnet + Codestral models into actual config
|
||||
* No API key - [`Add your API key here`]
|
||||
* - Chat model: add "No key" notification in model dropdown (beneath the model name, red alert, change trashcan to grey), free trial model comes first
|
||||
* - Autocomplete: add check to short circuit if model is codestral and no api key, add no api key info in quickpick
|
||||
*/
|
||||
models: [
|
||||
{
|
||||
model: "claude-3-5-sonnet-20240620",
|
||||
provider: "anthropic",
|
||||
apiKey: "",
|
||||
title: "Claude 3.5 Sonnet",
|
||||
},
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: "Codestral",
|
||||
provider: "mistral",
|
||||
model: "codestral-latest",
|
||||
apiKey: "",
|
||||
},
|
||||
customCommands: [
|
||||
{
|
||||
name: "test",
|
||||
|
|
@ -100,17 +119,25 @@ 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: [
|
||||
{
|
||||
model: "claude-3-5-sonnet-20240620",
|
||||
provider: "anthropic",
|
||||
apiKey: "",
|
||||
title: "Claude 3.5 Sonnet",
|
||||
},
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: "Codestral",
|
||||
provider: "mistral",
|
||||
model: "codestral-latest",
|
||||
apiKey: "",
|
||||
},
|
||||
customCommands: [
|
||||
{
|
||||
name: "test",
|
||||
|
|
@ -119,11 +146,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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -590,15 +590,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 +612,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 +635,16 @@ 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(({ title, apiKey }) => ({
|
||||
label:
|
||||
title === selected ? `$(check) ${title}` : title || "Unnamed Model",
|
||||
description:
|
||||
title === selected
|
||||
? `Currently selected${
|
||||
(apiKey === undefined || apiKey === "") &&
|
||||
" (API key required)"
|
||||
}`
|
||||
: undefined,
|
||||
})),
|
||||
];
|
||||
quickPick.onDidAccept(() => {
|
||||
|
|
@ -658,7 +663,7 @@ const commandsMap: (
|
|||
selectedOption === "$(gear) Configure autocomplete options"
|
||||
) {
|
||||
ide.openFile(getConfigJsonPath());
|
||||
} else if (autocompleteModelTitles.includes(selectedOption)) {
|
||||
} else if (autocompleteModels.includes(selectedOption)) {
|
||||
new GlobalContext().update(
|
||||
"selectedTabAutocompleteModel",
|
||||
selectedOption,
|
||||
|
|
|
|||
|
|
@ -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 />,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
|
|
|||
62
gui/src/components/ContinueLogo.tsx
Normal file
62
gui/src/components/ContinueLogo.tsx
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
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,7 +11,6 @@ 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,
|
||||
|
|
@ -27,6 +26,7 @@ import HeaderButtonWithText from "./HeaderButtonWithText";
|
|||
import ProgressBar from "./loaders/ProgressBar";
|
||||
import PostHogPageView from "./PosthogPageView";
|
||||
import ProfileSwitcher from "./ProfileSwitcher";
|
||||
import { isNewUserOnboarding } from "./OnboardingCard/utils";
|
||||
|
||||
const FOOTER_HEIGHT = "1.8em";
|
||||
|
||||
|
|
@ -102,12 +102,6 @@ const ProfileDropdownPortalDiv = styled.div`
|
|||
font-size: ${getFontSize() - 2};
|
||||
`;
|
||||
|
||||
const HIDE_FOOTER_ON_PAGES = [
|
||||
"/onboarding",
|
||||
"/localOnboarding",
|
||||
"/apiKeyOnboarding",
|
||||
];
|
||||
|
||||
const Layout = () => {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
|
@ -177,21 +171,21 @@ const Layout = () => {
|
|||
[location, navigate],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
"addApiKey",
|
||||
async () => {
|
||||
navigate("/apiKeyOnboarding");
|
||||
},
|
||||
[navigate],
|
||||
);
|
||||
// useWebviewListener(
|
||||
// "addApiKey",
|
||||
// async () => {
|
||||
// navigate("/apiKeyOnboarding");
|
||||
// },
|
||||
// [navigate],
|
||||
// );
|
||||
|
||||
useWebviewListener(
|
||||
"openOnboarding",
|
||||
async () => {
|
||||
navigate("/onboarding");
|
||||
},
|
||||
[navigate],
|
||||
);
|
||||
// useWebviewListener(
|
||||
// "openOnboarding",
|
||||
// async () => {
|
||||
// navigate("/onboarding");
|
||||
// },
|
||||
// [navigate],
|
||||
// );
|
||||
|
||||
useWebviewListener(
|
||||
"incrementFtc",
|
||||
|
|
@ -217,14 +211,11 @@ const Layout = () => {
|
|||
[navigate],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
isNewUserOnboarding() &&
|
||||
(location.pathname === "/" || location.pathname === "/index.html")
|
||||
) {
|
||||
navigate("/onboarding");
|
||||
}
|
||||
}, [location]);
|
||||
// useEffect(() => {
|
||||
// if (isNewUserOnboarding() && location.pathname === "/") {
|
||||
// navigate("/onboarding");
|
||||
// }
|
||||
// }, [location]);
|
||||
|
||||
return (
|
||||
<LayoutTopDiv>
|
||||
|
|
@ -252,33 +243,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
|
||||
|
|
|
|||
31
gui/src/components/LinkButton.tsx
Normal file
31
gui/src/components/LinkButton.tsx
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline";
|
||||
import { defaultBorderRadius, lightGray } from ".";
|
||||
import styled from "styled-components";
|
||||
|
||||
interface LinkButtonProps {
|
||||
onClick: () => void;
|
||||
url: string;
|
||||
}
|
||||
|
||||
const StyledLinkButton = 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;
|
||||
`;
|
||||
|
||||
function LinkButton({ onClick, url }: LinkButtonProps) {
|
||||
return (
|
||||
<StyledLinkButton onClick={onClick}>
|
||||
<p className="underline text-sm">{url}</p>
|
||||
<ArrowTopRightOnSquareIcon width={24} height={24} />
|
||||
</StyledLinkButton>
|
||||
);
|
||||
}
|
||||
|
||||
export default LinkButton;
|
||||
|
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
|
@ -6,7 +6,15 @@ import OnboardingCardTabs, {
|
|||
} from "./components/OnboardingCardTabs";
|
||||
import { XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, lightGray, vscBackground } from "../";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
parseColorForHex,
|
||||
VSC_FOREGROUND_VAR,
|
||||
vscBackground,
|
||||
vscForeground,
|
||||
vscInputBackground,
|
||||
} from "../";
|
||||
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
|
||||
import { hasPassedFTL } from "../../util/freeTrial";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
|
|
@ -14,17 +22,16 @@ import { useCompleteOnboarding } from "./utils";
|
|||
|
||||
const StyledCard = styled.div`
|
||||
margin: auto;
|
||||
border-style: solid;
|
||||
border-width: 1.5px;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
border-color: ${lightGray};
|
||||
padding: 1rem 1.5rem;
|
||||
box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.45);
|
||||
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);
|
||||
`;
|
||||
|
||||
const CloseButton = styled.button`
|
||||
border: none;
|
||||
background-color: ${vscBackground};
|
||||
background-color: inherit;
|
||||
color: ${lightGray};
|
||||
position: absolute;
|
||||
top: 0.6rem;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
import { useDispatch } from "react-redux";
|
||||
import {
|
||||
setShowDialog,
|
||||
setDialogMessage,
|
||||
} from "../../../redux/slices/uiStateSlice";
|
||||
import Alert from "../../gui/Alert";
|
||||
import AddModelForm from "../../../forms/AddModelForm";
|
||||
import { OnboardingTab } from "../tabs/types";
|
||||
|
||||
function AlternativeProviderAlert({ onComplete }: OnboardingTab) {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
function onOtherProviderClick() {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<AddModelForm onDone={onComplete} />));
|
||||
}
|
||||
|
||||
return (
|
||||
<Alert>
|
||||
<p className="font-semibold text-sm m-0">
|
||||
Prefer to use an alternative provider like OpenAI?
|
||||
</p>
|
||||
<p className="m-0 mt-1">
|
||||
<a
|
||||
className="text-inherit underline cursor-pointer hover:text-inherit"
|
||||
onClick={onOtherProviderClick}
|
||||
>
|
||||
Click here
|
||||
</a>{" "}
|
||||
to add a Chat model
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
export default AlternativeProviderAlert;
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
import { useContext, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
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 { OnboardingTab } from "../tabs/types";
|
||||
import { CubeIcon } from "@heroicons/react/24/outline";
|
||||
import { Button, Input, InputSubtext, lightGray } from "../..";
|
||||
import SubmitButtonSubtext from "./SubmitButtonSubtext";
|
||||
|
||||
const { anthropic: chatProvider, mistral: autocompleteProvider } = providers;
|
||||
const { claude35Sonnet: chatModel, codestral: autocompleteModel } = models;
|
||||
|
||||
interface BestExperienceConfigFormProps {
|
||||
onComplete: OnboardingTab["onComplete"];
|
||||
}
|
||||
|
||||
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/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">
|
||||
<div>
|
||||
<p className="text-lg font-bold leading-tight mb-2 flex flex-row justify-between gap-4 mb-2">
|
||||
Chat model
|
||||
<span
|
||||
className="flex items-center text-xs font-semibold"
|
||||
style={{ color: lightGray }}
|
||||
>
|
||||
<CubeIcon className="w-4 h-4 mr-1 flex-shrink-0 " />
|
||||
<span className="italic">{chatModel.title} </span>
|
||||
<span>by Anthropic</span>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<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>
|
||||
<p className="text-lg font-bold leading-tight mb-2 flex flex-row justify-between gap-4 mb-2">
|
||||
Autocomplete model
|
||||
<span
|
||||
className="flex items-center font-semibold"
|
||||
style={{ color: lightGray }}
|
||||
>
|
||||
<CubeIcon className="w-4 h-4 mr-1 flex-shrink-0" />
|
||||
<span className="text-xs">
|
||||
<span className="italic">{autocompleteModel.title} </span>
|
||||
<span>by Mistral</span>
|
||||
</span>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<div className="flex flex-col pb-4 w-full">
|
||||
<Input
|
||||
placeholder="Enter your Mistral 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 Mistral API key
|
||||
</InputSubtext>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-2 w-full">
|
||||
<Button className="w-full" type="submit" disabled={!chatApiKey}>
|
||||
Connect
|
||||
</Button>
|
||||
<SubmitButtonSubtext />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
export default BestExperienceConfigForm;
|
||||
|
|
@ -1,18 +1,12 @@
|
|||
import { ReactNode } from "react";
|
||||
import { CheckCircleIcon } from "@heroicons/react/24/solid";
|
||||
import { lightGray } from "../..";
|
||||
|
||||
interface CheckMarkHeaderProps {
|
||||
isComplete: boolean;
|
||||
isOptional?: boolean;
|
||||
children: ReactNode;
|
||||
title: string;
|
||||
}
|
||||
|
||||
export function CheckMarkHeader({
|
||||
isComplete,
|
||||
isOptional,
|
||||
children,
|
||||
}: CheckMarkHeaderProps) {
|
||||
export function CheckMarkHeader({ isComplete, title }: CheckMarkHeaderProps) {
|
||||
return (
|
||||
<div className="flex gap-4 items-center">
|
||||
{isComplete ? (
|
||||
|
|
@ -24,15 +18,12 @@ export function CheckMarkHeader({
|
|||
></CheckCircleIcon>
|
||||
) : (
|
||||
<div
|
||||
className="flex-none border border-solid rounded-full w-5 h-5 mt-1"
|
||||
className="flex-none border border-solid rounded-full w-5 h-5"
|
||||
style={{ borderColor: lightGray }}
|
||||
></div>
|
||||
)}
|
||||
|
||||
<div className={`flex flex-col ${isOptional ? "mb-3" : ""}`}>
|
||||
<h3 className={`${isOptional ? "mb-1" : ""}`}>{children}</h3>
|
||||
{isOptional && <i>Optional</i>}
|
||||
</div>
|
||||
<h2 className="text-base">{title}</h2>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,91 +1,32 @@
|
|||
import ReactDOM from "react-dom";
|
||||
import { useState, useContext } from "react";
|
||||
import { CheckIcon, CommandLineIcon } from "@heroicons/react/24/outline";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
Button,
|
||||
vscForeground,
|
||||
StyledTooltip,
|
||||
} from "../..";
|
||||
import { CommandLineIcon } from "@heroicons/react/24/outline";
|
||||
import { StyledTooltip } from "../..";
|
||||
import { useContext } from "react";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
|
||||
export type CopyToTerminalButtonProps = {
|
||||
children: string;
|
||||
command: string;
|
||||
};
|
||||
|
||||
export const StyledDiv = styled.div<{ clicked?: boolean }>`
|
||||
width: 100%;
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
display: flex;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
height: 32px;
|
||||
width: 100%;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
border: 1px solid ${lightGray};
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
&:hover {
|
||||
background-color: ${({ clicked }) => (clicked ? "#0f02" : "#fff1")};
|
||||
}
|
||||
${({ clicked }) => clicked && "background-color: #0f02;"}
|
||||
`;
|
||||
|
||||
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 function CopyToTerminalButton(props: CopyToTerminalButtonProps) {
|
||||
const [clicked, setClicked] = useState(false);
|
||||
|
||||
const id = `info-hover-${encodeURIComponent(props.children)}`;
|
||||
export function CopyToTerminalButton({ command }: CopyToTerminalButtonProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const id = `info-hover-${encodeURIComponent(command)}`;
|
||||
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
function onClick() {
|
||||
ideMessenger.ide.runCommand(command);
|
||||
ideMessenger.post("copyText", { text: command });
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-center justify-end" data-tooltip-id={id}>
|
||||
<StyledDiv
|
||||
clicked={clicked}
|
||||
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="text-green-700" />
|
||||
) : (
|
||||
<CommandLineIcon width="20px" height="20px" />
|
||||
)}
|
||||
|
||||
<pre>
|
||||
<code
|
||||
style={{
|
||||
color: vscForeground,
|
||||
backgroundColor: "transparent",
|
||||
}}
|
||||
>
|
||||
{props.children}
|
||||
</code>
|
||||
</pre>
|
||||
</StyledDiv>
|
||||
</div>
|
||||
<CommandLineIcon
|
||||
className="cursor-pointer"
|
||||
width={24}
|
||||
height={24}
|
||||
onClick={onClick}
|
||||
data-tooltip-id={id}
|
||||
/>
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<StyledTooltip id={id} place="top">
|
||||
|
|
|
|||
|
|
@ -1,130 +0,0 @@
|
|||
import { useContext, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import { Button, Input, 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 { OnboardingTab } from "../tabs/types";
|
||||
|
||||
const HelperText = styled.p`
|
||||
font-size: 0.8rem;
|
||||
color: ${lightGray};
|
||||
margin-top: 0.25rem;
|
||||
`;
|
||||
|
||||
const { anthropic: chatProvider, mistral: autocompleteProvider } = providers;
|
||||
const { claude35Sonnet: chatModel, codestral: autocompleteModel } = models;
|
||||
|
||||
interface DefaultModelConfigFormProps {
|
||||
onComplete: OnboardingTab["onComplete"];
|
||||
}
|
||||
|
||||
function DefaultModelConfigForm({ onComplete }: DefaultModelConfigFormProps) {
|
||||
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/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">
|
||||
<div>
|
||||
<h3 className={``}>
|
||||
Chat model: <code>{chatModel.title}</code>
|
||||
</h3>
|
||||
|
||||
<div className="flex flex-col items-start gap-3 sm:gap-6 sm:flex-row">
|
||||
<p className="leading-relaxed mt-0 flex-1">
|
||||
{chatModel.description}
|
||||
</p>
|
||||
<label className="block pb-4 w-full sm:flex-1">
|
||||
Anthropic API Key
|
||||
<Input
|
||||
className="w-full"
|
||||
placeholder="Enter your Anthropic API Key"
|
||||
value={chatApiKey}
|
||||
onChange={(e) => setChatApiKey(e.target.value)}
|
||||
/>
|
||||
<HelperText>
|
||||
<a href={chatProvider.apiKeyUrl} target="_blank underline">
|
||||
Click here
|
||||
</a>{" "}
|
||||
to create an Anthropic API key
|
||||
</HelperText>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div className="flex flex-col mb-4">
|
||||
<h3 className="mb-1">
|
||||
Autocomplete model: <code>{autocompleteModel.title}</code>
|
||||
</h3>
|
||||
<i>Optional</i>
|
||||
</div>
|
||||
<div className="flex flex-col items-start gap-3 sm:gap-6 sm:flex-row">
|
||||
<p className="leading-relaxed mt-0 flex-1">
|
||||
{autocompleteModel.description}
|
||||
</p>
|
||||
<label className="block pb-4 w-full sm:flex-1">
|
||||
Mistral API Key
|
||||
<Input
|
||||
className="w-full"
|
||||
placeholder="Enter your Mistral API Key"
|
||||
value={autocompleteApiKey}
|
||||
onChange={(e) => setAutocompleteApiKey(e.target.value)}
|
||||
/>
|
||||
<HelperText>
|
||||
<a href={autocompleteProvider.apiKeyUrl} target="_blank">
|
||||
Click here
|
||||
</a>{" "}
|
||||
to create a Mistral API key
|
||||
</HelperText>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-4 w-full">
|
||||
<Button className="w-full" type="submit" disabled={!chatApiKey}>
|
||||
Submit
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export default DefaultModelConfigForm;
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
import { StyledDiv } from "./CopyToTerminalButton";
|
||||
import OllamaLogo from "./OllamaLogo";
|
||||
|
||||
export interface DownloadOllamaButtonProps {
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
const OLLAMA_DOWNLOAD_URL = "https://ollama.com/download";
|
||||
|
||||
function DownloadOllamaButton({ onClick }: DownloadOllamaButtonProps) {
|
||||
return (
|
||||
<div className="flex items-center justify-end flex-1">
|
||||
<StyledDiv className="grid-cols-2">
|
||||
<OllamaLogo height={20} width={20} />
|
||||
<a
|
||||
className="flex items-center gap-2 text-inherit hover:text-inherit no-underline hover:no-underline"
|
||||
href={OLLAMA_DOWNLOAD_URL}
|
||||
target="_blank"
|
||||
onClick={onClick}
|
||||
>
|
||||
Download Ollama
|
||||
</a>
|
||||
</StyledDiv>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default DownloadOllamaButton;
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
import { CheckCircleIcon } from "@heroicons/react/24/solid";
|
||||
import { CopyToTerminalButton } from "./CopyToTerminalButton";
|
||||
|
||||
interface ModelDownloadProps {
|
||||
title: string;
|
||||
modelName: string;
|
||||
hasDownloaded: boolean;
|
||||
}
|
||||
|
||||
function ModelDownload({
|
||||
title,
|
||||
modelName,
|
||||
hasDownloaded,
|
||||
}: ModelDownloadProps) {
|
||||
const command = `ollama pull ${modelName}`;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<p className="text-lg font-bold leading-tight mb-2">{title}</p>
|
||||
<div className="flex justify-between items-center">
|
||||
<p className="font-mono">{command}</p>
|
||||
{hasDownloaded ? (
|
||||
<CheckCircleIcon
|
||||
width="24px"
|
||||
height="24px"
|
||||
className="text-emerald-600"
|
||||
/>
|
||||
) : (
|
||||
<CopyToTerminalButton command={command} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ModelDownload;
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,75 @@
|
|||
import {
|
||||
ArrowPathIcon,
|
||||
ArrowTopRightOnSquareIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { CheckCircleIcon } from "@heroicons/react/24/solid";
|
||||
import { useState, useContext } from "react";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { providers } from "../../../pages/AddNewModel/configs/providers";
|
||||
import { useDownloadOllamaModels } from "./useDownloadOllamaModels";
|
||||
import LinkButton from "../../LinkButton";
|
||||
|
||||
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,
|
||||
);
|
||||
|
||||
useDownloadOllamaModels((models) => {
|
||||
setStatus(OllamaConnectionStatuses.Verified);
|
||||
onConnectionVerified();
|
||||
});
|
||||
|
||||
function onClickDownload() {
|
||||
ideMessenger.post("openUrl", downloadUrl);
|
||||
setStatus(OllamaConnectionStatuses.Downloading);
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
case OllamaConnectionStatuses.WaitingToDownload:
|
||||
return (
|
||||
<div className="-mx-3">
|
||||
<LinkButton onClick={onClickDownload} url={downloadUrl} />
|
||||
</div>
|
||||
);
|
||||
case OllamaConnectionStatuses.Downloading:
|
||||
return (
|
||||
<div className="flex justify-between items-center ">
|
||||
<p className="text-sm w-3/4">
|
||||
Checking for connection to Ollama at http://localhost:11434
|
||||
</p>
|
||||
<ArrowPathIcon className="h-4 w-4 animate-spin-slow" />
|
||||
</div>
|
||||
);
|
||||
case OllamaConnectionStatuses.Verified:
|
||||
return (
|
||||
<div className="flex justify-between items-center">
|
||||
<p className="text-sm w-3/4">
|
||||
Ollama is running at http://localhost:11434
|
||||
</p>
|
||||
<CheckCircleIcon
|
||||
width="24px"
|
||||
height="24px"
|
||||
className="text-emerald-600"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default OllamaStatus;
|
||||
|
|
@ -38,9 +38,8 @@ const TabButton = styled.button<{ isActive: boolean }>`
|
|||
`
|
||||
border-style: solid;
|
||||
border-width: 0 0 2.5px 0;
|
||||
border-color: ${vscButtonBackground};
|
||||
color: ${vscButtonBackground};
|
||||
font-weight: medium;
|
||||
border-color: ${vscForeground};
|
||||
font-weight: bold;
|
||||
`}
|
||||
`;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
import { useContext, useState } from "react";
|
||||
import { Button, ButtonSubtext, Divider, Input, SecondaryButton } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { isJetBrains } from "../../../util";
|
||||
import { setLocalStorage } from "../../../util/localStorage";
|
||||
|
||||
interface QuickstartSubmitButtonProps {
|
||||
onComplete: (token: string) => void;
|
||||
}
|
||||
|
||||
function QuickstartSubmitButton({ onComplete }: QuickstartSubmitButtonProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const [jbGhAuthToken, setJbGhAuthToken] = useState("");
|
||||
const [showJetBrainsInput, setShowJetBrainsInput] = useState(false);
|
||||
|
||||
const handleTokenAcquisition = async (token: string) => {
|
||||
setLocalStorage("signedInToGh", true);
|
||||
onComplete(token);
|
||||
};
|
||||
|
||||
const openGitHubTokenPage = () => {
|
||||
ideMessenger.post(
|
||||
"openUrl",
|
||||
"https://github.com/settings/tokens/new?scopes=user:email&description=Continue%20Free%20Trial%20Token%20",
|
||||
);
|
||||
};
|
||||
|
||||
const getGitHubAuthToken = async () => {
|
||||
if (isJetBrains()) {
|
||||
setShowJetBrainsInput(true);
|
||||
} else {
|
||||
const result = await ideMessenger.request(
|
||||
"getGitHubAuthToken",
|
||||
undefined,
|
||||
);
|
||||
if (result.status === "success") {
|
||||
handleTokenAcquisition(result.content);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const submitJetBrainsToken = async () => {
|
||||
await ideMessenger.request("setGitHubAuthToken", { token: jbGhAuthToken });
|
||||
handleTokenAcquisition(jbGhAuthToken);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="mt-4 w-full">
|
||||
<Button
|
||||
onClick={getGitHubAuthToken}
|
||||
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>
|
||||
|
||||
{showJetBrainsInput && isJetBrains() && (
|
||||
<>
|
||||
<Divider className="my-8" />
|
||||
|
||||
<div className="flex justify-center mb-2">
|
||||
<SecondaryButton onClick={openGitHubTokenPage}>
|
||||
Get GitHub Token
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
<Input
|
||||
placeholder="Paste token here"
|
||||
value={jbGhAuthToken}
|
||||
onChange={(e) => setJbGhAuthToken(e.target.value)}
|
||||
/>
|
||||
<Button
|
||||
onClick={submitJetBrainsToken}
|
||||
disabled={!jbGhAuthToken}
|
||||
className="grid grid-flow-col items-center gap-2 w-full mt-2"
|
||||
>
|
||||
Submit Token
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default QuickstartSubmitButton;
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import { useContext } from "react";
|
||||
import { ButtonSubtext } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
|
||||
function SubmitButtonSubtext() {
|
||||
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 SubmitButtonSubtext;
|
||||
|
|
@ -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 useDownloadOllamaModels = (
|
||||
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]);
|
||||
};
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { usePostHog } from "posthog-js/react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
|
||||
import { getLocalStorage, setLocalStorage } from "../../../util/localStorage";
|
||||
|
||||
// Note that there is no "NotStarted" status since the
|
||||
// local storage value is null until onboarding begins
|
||||
|
|
@ -1,33 +1,12 @@
|
|||
import Alert from "../../gui/Alert";
|
||||
import DefaultModelConfigForm from "../components/DefaultModelConfigForm";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import BestExperienceConfigForm from "../components/BestExperienceConfigForm";
|
||||
import AlternativeProviderAlert from "../components/AlternativeProviderAlert";
|
||||
import { OnboardingTab } from "./types";
|
||||
|
||||
function OnboardingBestTab({ onComplete }: OnboardingTab) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div>
|
||||
<h1 className="text-xl">Model configuration</h1>
|
||||
<p className="text-base">
|
||||
Get started with our recommended configuration using the best models
|
||||
available
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Alert>
|
||||
Have an API key from OpenAI or another provider?{" "}
|
||||
<a
|
||||
className="text-inherit underline cursor-pointer hover:text-inherit"
|
||||
onClick={() => navigate("/addModel")}
|
||||
>
|
||||
Click here
|
||||
</a>{" "}
|
||||
to visit our general model configuration page.
|
||||
</Alert>
|
||||
|
||||
<DefaultModelConfigForm onComplete={onComplete} />
|
||||
<AlternativeProviderAlert onComplete={onComplete} />
|
||||
<BestExperienceConfigForm onComplete={onComplete} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,90 +1,39 @@
|
|||
import { ONBOARDING_LOCAL_MODEL_TITLE } from "core/config/onboarding";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { models } from "../../../pages/AddNewModel/configs/models";
|
||||
import { CheckMarkHeader } from "../components/CheckMarkHeader";
|
||||
import { CopyToTerminalButton } from "../components/CopyToTerminalButton";
|
||||
import DownloadOllamaButton from "../components/DownloadOllamaButton";
|
||||
import { Button } from "../..";
|
||||
import { OnboardingTab } from "./types";
|
||||
import SubmitButtonSubtext from "../components/SubmitButtonSubtext";
|
||||
import OllamaStatus from "../components/OllamaStatus";
|
||||
import ModelDownload from "../components/ModelDownload";
|
||||
import { useDownloadOllamaModels } from "../components/useDownloadOllamaModels";
|
||||
|
||||
enum OllamaConnectionStatuses {
|
||||
WaitingToDownload = "WaitingToDownload",
|
||||
Downloading = "Downloading",
|
||||
Verified = "Verified",
|
||||
}
|
||||
|
||||
const REFETCH_MODELS_INTERVAL_MS = 1000;
|
||||
const autocompleteModel = "starcoder2:3b";
|
||||
const {
|
||||
llama31Chat: { params: chatModel },
|
||||
} = models;
|
||||
const chatModel = "llama3.1";
|
||||
|
||||
function OnboardingLocalTab({ onComplete }: OnboardingTab) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [downloadedOllamaModels, setDownloadedOllamaModels] = useState<
|
||||
string[] | undefined
|
||||
>(undefined);
|
||||
|
||||
const [ollamaConnectionStatus, setOllamaConnectionStatus] =
|
||||
useState<OllamaConnectionStatuses>(
|
||||
OllamaConnectionStatuses.WaitingToDownload,
|
||||
);
|
||||
|
||||
const [hasLoadedChatModel, setHasLoadedChatModel] = useState(false);
|
||||
const [downloadedOllamaModels, setDownloadedOllamaModels] = useState<
|
||||
string[]
|
||||
>([]);
|
||||
|
||||
const isOllamaConnected =
|
||||
ollamaConnectionStatus === OllamaConnectionStatuses.Verified;
|
||||
const [isOllamaConnected, setIsOllamaConnected] = useState(false);
|
||||
|
||||
function isModelDownloaded(model: string) {
|
||||
if (!downloadedOllamaModels) {
|
||||
return false;
|
||||
}
|
||||
const hasDownloadedChatModel = downloadedOllamaModels.some((ollamaModel) =>
|
||||
ollamaModel.startsWith(chatModel),
|
||||
);
|
||||
|
||||
return downloadedOllamaModels.some(
|
||||
(ollamaModel) => ollamaModel.startsWith(model), // We use `startsWith` to ignore trailing tags like `:latest`
|
||||
);
|
||||
}
|
||||
|
||||
function renderOllamaConnectionStatus(status: OllamaConnectionStatuses) {
|
||||
switch (status) {
|
||||
case OllamaConnectionStatuses.WaitingToDownload:
|
||||
return (
|
||||
<div className="flex flex-col items-start gap-3 xs:gap-6 xs:flex-row">
|
||||
<p className="leading-relaxed mt-0 w-full xs:w-auto flex-1">
|
||||
Download, install, and start Ollama
|
||||
</p>
|
||||
|
||||
<div className="w-full xs:w-auto flex-1">
|
||||
<DownloadOllamaButton
|
||||
onClick={() =>
|
||||
setOllamaConnectionStatus(
|
||||
OllamaConnectionStatuses.Downloading,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
case OllamaConnectionStatuses.Downloading:
|
||||
return <p>Checking for connection to Ollama...</p>;
|
||||
|
||||
case OllamaConnectionStatuses.Verified:
|
||||
return <></>;
|
||||
|
||||
default:
|
||||
return <></>;
|
||||
}
|
||||
}
|
||||
const hasDownloadedAutocompleteModel = downloadedOllamaModels.some(
|
||||
(ollamaModel) => ollamaModel.startsWith(chatModel),
|
||||
);
|
||||
|
||||
/**
|
||||
* The first time we detect that a chat model has been loaded,
|
||||
* we send an empty request to load it
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (!hasLoadedChatModel && isModelDownloaded(chatModel.model)) {
|
||||
if (!hasLoadedChatModel && hasDownloadedChatModel) {
|
||||
ideMessenger.post("llm/complete", {
|
||||
completionOptions: {},
|
||||
prompt: "",
|
||||
|
|
@ -93,108 +42,44 @@ function OnboardingLocalTab({ onComplete }: OnboardingTab) {
|
|||
|
||||
setHasLoadedChatModel(true);
|
||||
}
|
||||
}, [downloadedOllamaModels]);
|
||||
}, [downloadedOllamaModels, isOllamaConnected]);
|
||||
|
||||
/**
|
||||
* 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,
|
||||
});
|
||||
useDownloadOllamaModels((models) => {
|
||||
setDownloadedOllamaModels(models);
|
||||
});
|
||||
|
||||
if (Array.isArray(models)) {
|
||||
// If we got a response, the connection has been verified
|
||||
if (!isOllamaConnected) {
|
||||
setOllamaConnectionStatus(OllamaConnectionStatuses.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);
|
||||
};
|
||||
}, []);
|
||||
function onConnectionVerified() {
|
||||
setIsOllamaConnected(true);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-5">
|
||||
<div>
|
||||
<h1 className="text-xl">Download Ollama & install models</h1>
|
||||
<p className="text-base">
|
||||
Get started with the best open source models available
|
||||
</p>
|
||||
<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>
|
||||
|
||||
<div>
|
||||
<CheckMarkHeader isComplete={isOllamaConnected}>
|
||||
Download Ollama
|
||||
</CheckMarkHeader>
|
||||
{renderOllamaConnectionStatus(ollamaConnectionStatus)}
|
||||
</div>
|
||||
<div>
|
||||
<CheckMarkHeader isComplete={isModelDownloaded(chatModel.title)}>
|
||||
Chat model: <code>{chatModel.title}</code>
|
||||
</CheckMarkHeader>
|
||||
{!isModelDownloaded(chatModel.model) && (
|
||||
<div className="flex flex-col items-start gap-3 xs:gap-6 xs:flex-row">
|
||||
<p className="leading-relaxed mt-0 w-full xs:w-auto flex-1">
|
||||
Latest open-source model trained by Meta
|
||||
</p>
|
||||
<ModelDownload
|
||||
title="Download Chat model"
|
||||
modelName={chatModel}
|
||||
hasDownloaded={hasDownloadedChatModel}
|
||||
/>
|
||||
|
||||
<div className="w-full xs:w-auto flex-1">
|
||||
<CopyToTerminalButton>
|
||||
{`ollama run ${chatModel.model}`}
|
||||
</CopyToTerminalButton>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<CheckMarkHeader
|
||||
isOptional
|
||||
isComplete={isModelDownloaded(autocompleteModel)}
|
||||
>
|
||||
Autcomplete model: <code>{autocompleteModel}</code>
|
||||
</CheckMarkHeader>
|
||||
|
||||
{!isModelDownloaded(autocompleteModel) && (
|
||||
<div className="flex flex-col items-start gap-3 xs:gap-6 xs:flex-row">
|
||||
<p className="leading-relaxed mt-0 w-full xs:w-auto flex-1">
|
||||
State-of-the-art 3B parameter autocomplete model trained by
|
||||
Hugging Face
|
||||
</p>
|
||||
|
||||
<div className="w-full xs:w-auto flex-1">
|
||||
<CopyToTerminalButton>
|
||||
{`ollama run ${autocompleteModel}`}
|
||||
</CopyToTerminalButton>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<ModelDownload
|
||||
title="Download Autocomplete model"
|
||||
modelName={autocompleteModel}
|
||||
hasDownloaded={hasDownloadedAutocompleteModel}
|
||||
/>
|
||||
|
||||
<div className="mt-4 w-full">
|
||||
<Button
|
||||
onClick={onComplete}
|
||||
className="w-full"
|
||||
disabled={!isModelDownloaded(chatModel.title)}
|
||||
disabled={!hasDownloadedChatModel}
|
||||
>
|
||||
Complete
|
||||
Connect
|
||||
</Button>
|
||||
<SubmitButtonSubtext />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,37 +1,23 @@
|
|||
import styled from "styled-components";
|
||||
import { Button, lightGray } from "../..";
|
||||
import { Cog6ToothIcon } from "@heroicons/react/24/outline";
|
||||
import { OnboardingTab } from "./types";
|
||||
|
||||
const ButtonSubtext = styled.p`
|
||||
margin-top: 0;
|
||||
text-align: center;
|
||||
color: ${lightGray};
|
||||
`;
|
||||
import ContinueLogo from "../../ContinueLogo";
|
||||
import QuickStartSubmitButton from "../components/QuickStartSubmitButton";
|
||||
|
||||
function OnboardingQuickstartTab({ onComplete }: OnboardingTab) {
|
||||
return (
|
||||
<div className="flex justify-center items-center">
|
||||
<div className="flex flex-col items-center justify-center w-3/4 text-center">
|
||||
<h1 className="text-2xl mb-0">Welcome to Continue</h1>
|
||||
<p className="text-base">
|
||||
Let's find the setup that works best for you. You can always update
|
||||
your configuration after onboarding by clicking the{" "}
|
||||
<Cog6ToothIcon className="inline-block h-4 w-4 align-middle px-0.5" />{" "}
|
||||
icon in the bottom-right corner.
|
||||
<ContinueLogo height={75} />
|
||||
|
||||
<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-base">
|
||||
After set up, we'll walk you through how to use Continue in a sample
|
||||
file.
|
||||
<p className="text-sm">
|
||||
To prevent abuse, we'll ask you to sign in to GitHub.
|
||||
</p>
|
||||
|
||||
<div className="mt-4 w-full">
|
||||
<Button className="w-full" onClick={onComplete}>
|
||||
Get started using our API keys
|
||||
</Button>
|
||||
<ButtonSubtext>You'll receive 50 requests for free</ButtonSubtext>
|
||||
</div>
|
||||
<QuickStartSubmitButton onComplete={onComplete} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {
|
|||
ExclamationCircleIcon,
|
||||
} from "@heroicons/react/24/solid";
|
||||
import { ReactNode } from "react";
|
||||
import { vscBackground } from "..";
|
||||
|
||||
type AlertTypes = "info" | "success" | "warning" | "error";
|
||||
|
||||
|
|
@ -15,43 +16,35 @@ export interface AlertProps {
|
|||
|
||||
type AlertConfig = {
|
||||
[key in AlertTypes]: {
|
||||
bgColor: string;
|
||||
Icon: any;
|
||||
};
|
||||
};
|
||||
|
||||
const ALERT_CONFIGS: AlertConfig = {
|
||||
info: {
|
||||
bgColor: "bg-blue-400",
|
||||
Icon: InformationCircleIcon,
|
||||
},
|
||||
success: {
|
||||
bgColor: "bg-green-400",
|
||||
Icon: CheckCircleIcon,
|
||||
},
|
||||
warning: {
|
||||
bgColor: "bg-yellow-400",
|
||||
Icon: ExclamationTriangleIcon,
|
||||
},
|
||||
error: {
|
||||
bgColor: "bg-red-400",
|
||||
Icon: ExclamationCircleIcon,
|
||||
},
|
||||
};
|
||||
|
||||
function Alert({ children, type = "info" }: AlertProps) {
|
||||
const { bgColor, Icon } = ALERT_CONFIGS[type];
|
||||
const { Icon } = ALERT_CONFIGS[type];
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`py-2 px-4 rounded-lg drop-shadow-none ${bgColor} border-l-4`}
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<div className="flex-shrink-0">
|
||||
<Icon className="w-6 h-6 text-blue-700" />
|
||||
</div>
|
||||
<div className="ml-3">
|
||||
<p className="text-sm text-slate-800 my-3">{children}</p>
|
||||
<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 h-6" style={{ color: vscBackground }} />
|
||||
|
||||
<div className="ml-3" style={{ color: vscBackground }}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -121,17 +121,24 @@ export function parseColorForHex(colorVar: string): string {
|
|||
return hex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use logo in dev that includes text
|
||||
*
|
||||
*/
|
||||
|
||||
export const Button = styled.button`
|
||||
padding: 10px 12px;
|
||||
margin: 8px 0;
|
||||
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 +150,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 +163,23 @@ export const SecondaryButton = styled.button`
|
|||
|
||||
&:hover:enabled {
|
||||
cursor: pointer;
|
||||
background-color: ${vscInputBackground};
|
||||
background-color: ${vscBackground};
|
||||
opacity: 0.9;
|
||||
}
|
||||
`;
|
||||
|
||||
export const InputSubtext = styled.p`
|
||||
font-size: 0.75rem;
|
||||
color: ${lightGray};
|
||||
margin-top: 0.25rem;
|
||||
`;
|
||||
|
||||
export const ButtonSubtext = styled.p`
|
||||
margin-top: 0;
|
||||
text-align: center;
|
||||
color: ${lightGray};
|
||||
`;
|
||||
|
||||
export const CustomScrollbarDiv = styled.div`
|
||||
scrollbar-base-color: transparent;
|
||||
scrollbar-width: thin;
|
||||
|
|
@ -261,8 +282,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 +292,7 @@ export const Input = styled.input`
|
|||
|
||||
&:focus {
|
||||
background: ${vscInputBackground};
|
||||
outline: 1px solid ${vscInputBorderFocus};
|
||||
outline: 1px solid ${lightGray};
|
||||
}
|
||||
|
||||
&:invalid {
|
||||
|
|
@ -377,3 +398,8 @@ export const HeaderButton = styled.button<{
|
|||
gap: 4px;
|
||||
padding: 2px;
|
||||
`;
|
||||
|
||||
export const Divider = styled.div`
|
||||
height: 1px;
|
||||
background-color: ${lightGray};
|
||||
`;
|
||||
|
|
|
|||
|
|
@ -58,9 +58,11 @@ import {
|
|||
} from "./getSuggestion";
|
||||
import { ComboBoxItem } from "./types";
|
||||
|
||||
const InputBoxDiv = styled.div`
|
||||
const InputBoxDiv = styled.div<{ disabled?: boolean }>`
|
||||
resize: none;
|
||||
|
||||
opacity: ${(props) => (props.disabled ? 0.5 : 1)};
|
||||
pointer-events: ${(props) => (props.disabled ? "none" : "auto")};
|
||||
cursor: ${(props) => (props.disabled ? "not-allowed" : "text")};
|
||||
padding: 8px 12px;
|
||||
padding-bottom: 4px;
|
||||
font-family: inherit;
|
||||
|
|
@ -158,6 +160,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);
|
||||
|
|
@ -212,6 +215,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> {
|
||||
|
|
@ -259,6 +276,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,
|
||||
|
|
@ -299,10 +326,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() {
|
||||
|
|
@ -796,6 +820,7 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
|
||||
return (
|
||||
<InputBoxDiv
|
||||
disabled={!hasDefaultModel}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Alt") {
|
||||
setOptionKeyHeld(true);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ export function TutorialCard({ onClose }: TutorialCardProps) {
|
|||
<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,6 +29,7 @@ import {
|
|||
isMetaEquivalentKeyPressed,
|
||||
} from "../../util";
|
||||
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
|
||||
import AddModelForm from "../../forms/AddModelForm";
|
||||
|
||||
const MAX_HEIGHT_PX = 300;
|
||||
const StyledListboxButton = styled(Listbox.Button)`
|
||||
|
|
@ -45,7 +51,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,43 +63,73 @@ 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 StyledTrashIcon = styled(TrashIcon)<{ 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};
|
||||
}
|
||||
`;
|
||||
|
||||
const Divider = styled.div`
|
||||
height: 1px;
|
||||
background-color: ${lightGray};
|
||||
margin: 4px;
|
||||
const StyledCog6ToothIcon = styled(Cog6ToothIcon)<{ hovered: boolean }>`
|
||||
width: 1.2em;
|
||||
height: 1.2em;
|
||||
cursor: pointer;
|
||||
padding: 4px;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
opacity: ${(props) => (props.hovered ? 0.75 : 0)};
|
||||
visibility: ${(props) => (props.hovered ? "visible" : "hidden")};
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
background-color: ${lightGray}33;
|
||||
}
|
||||
`;
|
||||
|
||||
function ModelOption({
|
||||
option,
|
||||
idx,
|
||||
showDelete,
|
||||
showMissingApiKeyMsg,
|
||||
}: {
|
||||
option: Option;
|
||||
idx: number;
|
||||
showMissingApiKeyMsg: boolean;
|
||||
showDelete?: boolean;
|
||||
}) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
|
@ -121,30 +157,48 @@ 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-1">
|
||||
<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 gap-1 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-[10px]">
|
||||
API key required
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</StyledListboxOption>
|
||||
);
|
||||
|
|
@ -164,6 +218,7 @@ function modelSelectTitle(model: any): string {
|
|||
interface Option {
|
||||
value: string;
|
||||
title: string;
|
||||
apiKey: string;
|
||||
}
|
||||
|
||||
function ModelSelect() {
|
||||
|
|
@ -172,26 +227,43 @@ function ModelSelect() {
|
|||
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 +283,30 @@ 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 = () => {
|
||||
if (buttonRef.current) {
|
||||
const rect = buttonRef.current.getBoundingClientRect();
|
||||
const spaceBelow = window.innerHeight - rect.bottom;
|
||||
const spaceAbove = rect.top;
|
||||
const dropdownHeight = MAX_HEIGHT_PX;
|
||||
function onClickAddModel(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow);
|
||||
}
|
||||
};
|
||||
|
||||
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 +329,14 @@ function ModelSelect() {
|
|||
</span>
|
||||
</StyledListboxButton>
|
||||
<StyledListboxOptions showAbove={showAbove}>
|
||||
<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 +344,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-2">
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { Listbox } from "@headlessui/react";
|
|||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscBackground,
|
||||
vscButtonBackground,
|
||||
vscForeground,
|
||||
|
|
@ -25,7 +26,7 @@ export const StyledListboxButton = styled(Listbox.Button)`
|
|||
padding-bottom: 0.5rem;
|
||||
|
||||
border-radius: 0.5em;
|
||||
border: 1px solid ${vscButtonBackground};
|
||||
border: 1px solid ${lightGray};
|
||||
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
|
|
|
|||
211
gui/src/forms/AddModelForm.tsx
Normal file
211
gui/src/forms/AddModelForm.tsx
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
import { useContext, useEffect, useState } from "react";
|
||||
import { FormProvider, useForm } from "react-hook-form";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Input, Button, InputSubtext } from "../components";
|
||||
import QuickSetupListBox from "../components/modelSelection/quickSetup/QuickSetupListBox";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import {
|
||||
ProviderInfo,
|
||||
providers,
|
||||
} from "../pages/AddNewModel/configs/providers";
|
||||
import { setDefaultModel } from "../redux/slices/stateSlice";
|
||||
import { hasPassedFTL, FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial";
|
||||
import SubmitButtonSubtext from "../components/OnboardingCard/components/SubmitButtonSubtext";
|
||||
import Alert from "../components/gui/Alert";
|
||||
import LinkButton from "../components/LinkButton";
|
||||
|
||||
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) {
|
||||
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 } : {}),
|
||||
};
|
||||
|
||||
debugger;
|
||||
|
||||
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>
|
||||
<QuickSetupListBox
|
||||
selectedProvider={selectedProvider}
|
||||
setSelectedProvider={setSelectedProvider}
|
||||
options={Object.entries(providers)
|
||||
.filter(
|
||||
([key]) => !["freetrial", "openai-aiohttp"].includes(key),
|
||||
)
|
||||
.map(([, provider]) => provider)}
|
||||
></QuickSetupListBox>
|
||||
<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>
|
||||
|
||||
<LinkButton
|
||||
onClick={onClickDownloadProvider}
|
||||
url={selectedProvider.downloadUrl}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium">Model</label>
|
||||
<QuickSetupListBox
|
||||
selectedProvider={selectedModel}
|
||||
setSelectedProvider={setSelectedModel}
|
||||
options={
|
||||
Object.entries(providers).find(
|
||||
([, provider]) => provider.title === selectedProvider.title,
|
||||
)?.[1].packages
|
||||
}
|
||||
></QuickSetupListBox>
|
||||
</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>
|
||||
<SubmitButtonSubtext />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</FormProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default AddModelForm;
|
||||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -223,11 +223,11 @@ function GUI() {
|
|||
if (u) {
|
||||
setLocalStorage("ftc", u + 1);
|
||||
|
||||
if (u >= FREE_TRIAL_LIMIT_REQUESTS) {
|
||||
navigate("/onboarding");
|
||||
posthog?.capture("ftc_reached");
|
||||
return;
|
||||
}
|
||||
// if (u >= FREE_TRIAL_LIMIT_REQUESTS) {
|
||||
// navigate("/onboarding");
|
||||
// posthog?.capture("ftc_reached");
|
||||
// return;
|
||||
// }
|
||||
} else {
|
||||
setLocalStorage("ftc", 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 { useCompleteOnboarding } from "./utils";
|
||||
import DefaultModelConfigForm from "../../components/OnboardingCard/components/DefaultModelConfigForm";
|
||||
|
||||
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,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};
|
||||
`}
|
||||
`;
|
||||
|
|
@ -9,6 +9,9 @@ module.exports = {
|
|||
],
|
||||
theme: {
|
||||
extend: {
|
||||
animation: {
|
||||
"spin-slow": "spin 3s linear infinite",
|
||||
},
|
||||
colors: {
|
||||
"vsc-background": "rgb(var(--vsc-background) / <alpha-value>)",
|
||||
"secondary-dark": "rgb(var(--secondary-dark) / <alpha-value>)",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue