From 4f9b4e4e4c2180c00aefde9cf635313d365150f0 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Mon, 27 May 2024 20:09:07 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20autocomplete=20model=20onboardin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.ts | 21 +- core/index.d.ts | 1 + core/llm/llms/Fireworks.ts | 18 ++ core/llm/llms/index.ts | 2 + core/protocol/core.ts | 2 + core/protocol/passThrough.ts | 1 + .../toolWindow/ContinueBrowser.kt | 3 +- extensions/vscode/config_schema.json | 18 ++ gui/public/logos/fireworks.png | Bin 0 -> 6809 bytes gui/src/App.tsx | 5 + .../quickSetup/GitHubSignInButton.tsx | 87 +++++++ .../quickSetup/QuickModelSetup.tsx | 3 +- .../quickSetup/QuickSetupListBox.tsx | 75 +------ .../quickSetup/StyledListbox.tsx | 90 ++++++++ .../apiKeyAutocompleteOnboarding.tsx | 212 ++++++++++++++++++ gui/src/pages/onboarding/apiKeyOnboarding.tsx | 2 +- gui/src/pages/onboarding/onboarding.tsx | 95 +------- 17 files changed, 481 insertions(+), 154 deletions(-) create mode 100644 core/llm/llms/Fireworks.ts create mode 100644 gui/public/logos/fireworks.png create mode 100644 gui/src/components/modelSelection/quickSetup/GitHubSignInButton.tsx create mode 100644 gui/src/components/modelSelection/quickSetup/StyledListbox.tsx create mode 100644 gui/src/pages/onboarding/apiKeyAutocompleteOnboarding.tsx diff --git a/core/core.ts b/core/core.ts index ae749784b..8fb168655 100644 --- a/core/core.ts +++ b/core/core.ts @@ -14,6 +14,7 @@ import { ContinueServerClient } from "./continueServer/stubs/client"; import { indexDocs } from "./indexing/docs"; import TransformersJsEmbeddingsProvider from "./indexing/embeddings/TransformersJsEmbeddingsProvider"; import { CodebaseIndexer, PauseToken } from "./indexing/indexCodebase"; +import Ollama from "./llm/llms/Ollama"; import { FromCoreProtocol, ToCoreProtocol } from "./protocol"; import { GlobalContext } from "./util/GlobalContext"; import { logDevData } from "./util/devdata"; @@ -357,7 +358,15 @@ export class Core { const model = config.models.find((model) => model.title === msg.data.title) ?? config.models.find((model) => model.title?.startsWith(msg.data.title)); - return model?.listModels(); + if (model) { + return model.listModels(); + } else { + if (msg.data.title === "Ollama") { + return new Ollama({ model: "" }).listModels(); + } else { + return undefined; + } + } }); async function* runNodeJsSlashCommand( @@ -484,6 +493,16 @@ export class Core { this.configHandler.reloadConfig(); }); + on("addAutocompleteModel", (msg) => { + editConfigJson((config) => { + return { + ...config, + tabAutocompleteModel: msg.data.model, + }; + }); + this.configHandler.reloadConfig(); + }); + on("stats/getTokensPerDay", async (msg) => { const rows = await DevDataSqliteDb.getTokensPerDay(); return rows; diff --git a/core/index.d.ts b/core/index.d.ts index 9ee880c4c..859e428c9 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -530,6 +530,7 @@ type ModelProvider = | "flowise" | "groq" | "continue-proxy" + | "fireworks" | "custom"; export type ModelName = diff --git a/core/llm/llms/Fireworks.ts b/core/llm/llms/Fireworks.ts new file mode 100644 index 000000000..02a310761 --- /dev/null +++ b/core/llm/llms/Fireworks.ts @@ -0,0 +1,18 @@ +import { LLMOptions, ModelProvider } from "../../index.js"; +import OpenAI from "./OpenAI.js"; + +class Fireworks extends OpenAI { + static providerName: ModelProvider = "fireworks"; + static defaultOptions: Partial = { + apiBase: "https://api.fireworks.ai/inference/v1", + }; + + private static modelConversion: { [key: string]: string } = { + "starcoder-7b": "accounts/fireworks/models/starcoder-7b", + }; + protected _convertModelName(model: string): string { + return Fireworks.modelConversion[model] ?? model; + } +} + +export default Fireworks; diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index 37a4398f7..33165263b 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -12,6 +12,7 @@ import Anthropic from "./Anthropic.js"; import Bedrock from "./Bedrock.js"; import Cohere from "./Cohere.js"; import DeepInfra from "./DeepInfra.js"; +import Fireworks from "./Fireworks.js"; import Flowise from "./Flowise.js"; import FreeTrial from "./FreeTrial.js"; import Gemini from "./Gemini.js"; @@ -96,6 +97,7 @@ const LLMs = [ DeepInfra, Flowise, Groq, + Fireworks, ContinueProxy, ]; diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 899996a0b..ff5e4cc86 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -6,6 +6,7 @@ import { DiffLine, LLMFullCompletionOptions, MessageContent, + ModelDescription, PersistedSessionInfo, RangeInFile, SerializedContinueConfig, @@ -133,4 +134,5 @@ export type ToCoreFromIdeOrWebviewProtocol = { }, void, ]; + addAutocompleteModel: [{ model: ModelDescription }, void]; }; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index aa5f1f457..cd7672f89 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -37,6 +37,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "index/setPaused", "index/forceReIndex", "completeOnboarding", + "addAutocompleteModel", ]; // Message types to pass through from core to webview diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt index 2cbf3bfce..2fc80f374 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt @@ -65,7 +65,8 @@ class ContinueBrowser(val project: Project, url: String, useOsr: Boolean = false "stats/getTokensPerModel", "index/setPaused", "index/forceReIndex", - "completeOnboarding" + "completeOnboarding", + "addAutocompleteModel" ) private fun registerAppSchemeHandler() { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 58e74819b..e28d50a30 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -149,6 +149,7 @@ "deepinfra", "flowise", "groq", + "fireworks", "continue-proxy" ], "markdownEnumDescriptions": [ @@ -825,6 +826,23 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["fireworks"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "enum": ["starcoder-7b"] + } + } + } + }, { "if": { "properties": { diff --git a/gui/public/logos/fireworks.png b/gui/public/logos/fireworks.png new file mode 100644 index 0000000000000000000000000000000000000000..aecb2a27b6e97b719ca700e0eac5f1513139a8ec GIT binary patch literal 6809 zcmd^E_ct8g)3yk!cUJF2?_HGDqFXIW^xj!DdRcu%Cw!EMPIPwl7M&nbLez~CMDH!~ zdjF2^4|nFAInT_QIrq-J=gyO;r=v!IOM{DshDMDxBmYEVm-@OU$KOr6~I?t z4UASlO}CGRMq{9^tY{cyd1Mh1`qrrJX)#Y-1Mibw7P+%XrZIzx9x?H@kqSSPVYvyh zM$=__o@f>l{mpFTTXIDbjsNmm$;r>4!+4+2b2nZn#wJ@H8tHLAo3p+zs!f(&rcX_o zO8l|c&q!0B&d(F^g*M;xwOp^eh5eBUxwboM!>IsaqQlT$j8WPpDWb*A#$iT*`-!FX zjzvd6U|K>!uTI>ic%m8 z{-#`1K(OToxpcv?H-MB=~7=pA`$P_<{7n27ikMqC*?%!g4zD)@z9FwFA-pgqgxsCTSIf1 zzu!{V;VO5Sg5iXluW_CtNhs>U|Q6VnQ zC~GJq#&4HS)oU` zY+~r27aWhQSziEkZu|a7|L!z5_-Pd8SX9EpH|iy@xQ^!Ma;Kiz@l=oZ++d00nGgt7 zIAD*^Y%_+hI|yUrtN3o!YvmwegJh96kFkiVgA{8NL}kxq^E3()nn~TP0QHaoG?@3# zm%IElA+Q?dI5RZ4eHCe@@=qM_qqV{ZFRD{_TusgAX#QhAN%7EV^Ufi;^RJc+ z{$#VQFZG|4(}fcb`sBwYG>WEwa?~zl8hbAdPM*vE6x#hY$m|{Tw$o$l*1>JRTtm9I zDJqqfHW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K(8+&Qsacd^F*%0ETNu(*ZS&8dWXhkj8iX*31Q3Qhhc)cNmL!W$JcwY3Dg8bYnH)9~dXU&?(>0WU;2smy3gUw~?u3FB|g5}^i&7k1o;;YYDomiEbm%@b z;RMM}I$N$Qaupve>DE1B4QHc)~X^~v>*{?5~eH6EuP@5E%FCk6>vWt8yEGL6Fx zRKK@LhN=)g)aO7und#<|-ArJW_&kzs3LtFZ+XP~5H{E?Na=ys+ug~ttqg=dDG`+-R zfdDDh!;7I5Ba$HrXyhIeblmrA*@YG)rIYCPXQ#XGiNzaCQX+!WhhMvyOKtBg?_XUl z{YM?556TF4pV2!@*7@fpv, }, + { + path: "/apiKeyAutocompleteOnboarding", + element: , + }, ], }, ]); diff --git a/gui/src/components/modelSelection/quickSetup/GitHubSignInButton.tsx b/gui/src/components/modelSelection/quickSetup/GitHubSignInButton.tsx new file mode 100644 index 000000000..e362bb8a8 --- /dev/null +++ b/gui/src/components/modelSelection/quickSetup/GitHubSignInButton.tsx @@ -0,0 +1,87 @@ +import { useContext, useState } from "react"; +import { useNavigate } from "react-router-dom"; +import { Button, Input, SecondaryButton, vscForeground } from "../.."; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { isJetBrains } from "../../../util"; + +interface GitHubSignInButtonProps { + onComplete: (token: string) => void; +} + +function GitHubSignInButton(props: GitHubSignInButtonProps) { + const ideMessenger = useContext(IdeMessengerContext); + const navigate = useNavigate(); + + const [jbGhAuthToken, setJbGhAuthToken] = useState(""); + + return isJetBrains() ? ( +
+
+ { + ideMessenger.post( + "openUrl", + "https://github.com/settings/tokens/new?scopes=user:email&description=Continue%20Free%20Trial%20Token%20", + ); + }} + className="grid grid-flow-col items-center gap-2" + > + + + + Generate Token + +
+ setJbGhAuthToken(e.target.value)} + /> + +
+ ) : ( +
+ { + const token = await ideMessenger.request( + "getGitHubAuthToken", + undefined, + ); + props.onComplete(token); + }} + className="grid grid-flow-col items-center gap-2" + > + + + + Sign in with GitHub + +
+ ); +} + +export default GitHubSignInButton; diff --git a/gui/src/components/modelSelection/quickSetup/QuickModelSetup.tsx b/gui/src/components/modelSelection/quickSetup/QuickModelSetup.tsx index f002c3dfa..400c432ee 100644 --- a/gui/src/components/modelSelection/quickSetup/QuickModelSetup.tsx +++ b/gui/src/components/modelSelection/quickSetup/QuickModelSetup.tsx @@ -12,6 +12,7 @@ import QuickSetupListBox from "./QuickSetupListBox"; interface QuickModelSetupProps { onDone: () => void; + hideFreeTrialLimitMessage?: boolean; } function QuickModelSetup(props: QuickModelSetupProps) { @@ -41,7 +42,7 @@ function QuickModelSetup(props: QuickModelSetupProps) { : "Add a new model"} */} - {getLocalStorage("ftc") > ftl() && ( + {!props.hideFreeTrialLimitMessage && getLocalStorage("ftc") > ftl() && (

You've reached the free trial limit of {ftl()} free inputs. To keep using Continue, you can either use your own API key, or use a local diff --git a/gui/src/components/modelSelection/quickSetup/QuickSetupListBox.tsx b/gui/src/components/modelSelection/quickSetup/QuickSetupListBox.tsx index 9b53c7794..8e643de6d 100644 --- a/gui/src/components/modelSelection/quickSetup/QuickSetupListBox.tsx +++ b/gui/src/components/modelSelection/quickSetup/QuickSetupListBox.tsx @@ -1,70 +1,13 @@ -import { Listbox, Transition } from "@headlessui/react"; +import { Transition } from "@headlessui/react"; import { CheckIcon, ChevronUpDownIcon } from "@heroicons/react/24/outline"; import { Dispatch, Fragment, SetStateAction } from "react"; -import styled from "styled-components"; -import { - defaultBorderRadius, - vscBackground, - vscButtonBackground, - vscForeground, - vscInputBackground, - vscListActiveBackground, - vscListActiveForeground, -} from "../.."; import { DisplayInfo } from "../../../util/modelData"; - -const StyledListbox = styled(Listbox)` - background-color: ${vscBackground}; -`; - -const StyledListboxButton = styled(Listbox.Button)` - cursor: pointer; - background-color: ${vscBackground}; - text-align: left; - border: 1px solid ${vscButtonBackground}; - margin: 0; - height: 100%; - width: 100%; - - display: grid; - grid-template-columns: 1fr auto; - align-items: center; - - color: ${vscForeground}; - - &:focus { - outline: none; - } - - &:hover { - background-color: ${vscInputBackground}; - } -`; - -const StyledListboxOptions = styled(Listbox.Options)` - background-color: ${vscInputBackground}; - padding: 0; - - border-radius: ${defaultBorderRadius}; - overflow-y: scroll; - z-index: 10; -`; - -const StyledListboxOption = styled(Listbox.Option)<{ selected: boolean }>` - background-color: ${({ selected }) => - selected ? vscListActiveBackground : vscInputBackground}; - cursor: pointer; - padding: 6px 8px; - - display: flex; - gap: 8px; - align-items: center; - - &:hover { - background-color: ${vscListActiveBackground}; - color: ${vscListActiveForeground}; - } -`; +import { + StyledListbox, + StyledListboxButton, + StyledListboxOption, + StyledListboxOptions, +} from "./StyledListbox"; interface QuickSetupListBoxProps { selectedProvider: DisplayInfo; @@ -80,7 +23,7 @@ function QuickSetupListBox({ return (

- + {window.vscMediaUrl && selectedProvider.icon && ( - + {options.map((option, index) => ( ` + background-color: ${({ selected }) => + selected ? vscListActiveBackground : vscInputBackground}; + cursor: pointer; + padding: 6px 8px; + + display: flex; + gap: 8px; + align-items: center; + + &:hover { + background-color: ${vscListActiveBackground}; + color: ${vscListActiveForeground}; + } +`; diff --git a/gui/src/pages/onboarding/apiKeyAutocompleteOnboarding.tsx b/gui/src/pages/onboarding/apiKeyAutocompleteOnboarding.tsx new file mode 100644 index 000000000..14592adc1 --- /dev/null +++ b/gui/src/pages/onboarding/apiKeyAutocompleteOnboarding.tsx @@ -0,0 +1,212 @@ +import { Transition } from "@headlessui/react"; +import { CheckIcon, ChevronUpDownIcon } from "@heroicons/react/24/outline"; +import { ModelProvider } from "core"; +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"; + +interface AutocompleteOption { + provider: ModelProvider; + title: string; + icon?: string; +} + +const AUTOCOMPLETE_PROVIDER_OPTIONS: AutocompleteOption[] = [ + { + provider: "free-trial", + title: "Free Trial", + 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 ( + +
+ + + {window.vscMediaUrl && selectedProvider.icon && ( + + )} + {selectedProvider.title} + + + + + + + {AUTOCOMPLETE_PROVIDER_OPTIONS.map((option, index) => ( + + `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 && ( + + )} + {option.title} + + {selected ? ( + + + ) : null} + + )} + + ))} + + +
+
+ ); +} + +function ApiKeyAutocompleteOnboarding() { + const ideMessenger = useContext(IdeMessengerContext); + const navigate = useNavigate(); + + const [selectedProvider, setSelectedProvider] = useState( + AUTOCOMPLETE_PROVIDER_OPTIONS[0], + ); + + const [apiKeyValue, setApiKeyValue] = useState(""); + + return ( +
+

Autocomplete Model

+

+ Tab autocomplete requires a separate model. Currently we are supporting + free usage by signing in with GitHub. Alternatively, select another + option from the dropdown. +

+
+
+ + + +
+
+ {selectedProvider.provider === "ollama" && ( +
+ +
+ )} + {selectedProvider.provider === "free-trial" && ( +
+

Sign in to GitHub to try autocomplete for free

+ { + await ideMessenger.request("addAutocompleteModel", { + model: { + title: "Autocomplete Trial", + provider: "free-trial", + model: "starcoder-7b", + }, + }); + navigate("/"); + }} + > +
+ )} + {selectedProvider.provider === "fireworks" && ( +
+

Paste your API key

+ { + ideMessenger.post("openUrl", "https://fireworks.ai/api-keys"); + }} + > + Get API Key + + { + setApiKeyValue(e.target.value); + }} + /> + +
+ )} +
+ ); +} + +export default ApiKeyAutocompleteOnboarding; diff --git a/gui/src/pages/onboarding/apiKeyOnboarding.tsx b/gui/src/pages/onboarding/apiKeyOnboarding.tsx index a0d6c761c..5aa0fc6c7 100644 --- a/gui/src/pages/onboarding/apiKeyOnboarding.tsx +++ b/gui/src/pages/onboarding/apiKeyOnboarding.tsx @@ -23,7 +23,7 @@ function ApiKeyOnboarding() { { ideMessenger.post("showTutorial", undefined); - navigate("/"); + navigate("/apiKeyAutocompleteOnboarding"); }} >
diff --git a/gui/src/pages/onboarding/onboarding.tsx b/gui/src/pages/onboarding/onboarding.tsx index d2da11a84..b48fa7ac2 100644 --- a/gui/src/pages/onboarding/onboarding.tsx +++ b/gui/src/pages/onboarding/onboarding.tsx @@ -1,15 +1,9 @@ import { useContext, useState } from "react"; import { useNavigate } from "react-router-dom"; -import { - Button, - Input, - SecondaryButton, - greenButtonColor, - vscForeground, -} from "../../components"; +import { greenButtonColor } from "../../components"; import { ftl } from "../../components/dialogs/FTCDialog"; +import GitHubSignInButton from "../../components/modelSelection/quickSetup/GitHubSignInButton"; import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { isJetBrains } from "../../util"; import { getLocalStorage, setLocalStorage } from "../../util/localStorage"; import { Div, StyledButton } from "./components"; @@ -22,8 +16,6 @@ function Onboarding() { const [selected, setSelected] = useState(-1); - const [jbGhAuthToken, setJbGhAuthToken] = useState(""); - return (
{getLocalStorage("ftc") > ftl() ? ( @@ -139,80 +131,15 @@ function Onboarding() {

OR sign in with GitHub to try 25 free requests

- {isJetBrains() ? ( -
-
- { - ideMessenger.post( - "openUrl", - "https://github.com/settings/tokens/new?scopes=user:email&description=Continue%20Free%20Trial%20Token%20", - ); - }} - className="grid grid-flow-col items-center gap-2" - > - - - - Generate Token - -
- setJbGhAuthToken(e.target.value)} - /> - -
- ) : ( -
- { - await ideMessenger.request("getGitHubAuthToken", undefined); - setLocalStorage("onboardingComplete", true); - await ideMessenger.request("completeOnboarding", { - mode: "freeTrial", - }); - navigate("/"); - }} - className="grid grid-flow-col items-center gap-2" - > - - - - Sign in with GitHub - -
- )} + { + setLocalStorage("onboardingComplete", true); + await ideMessenger.request("completeOnboarding", { + mode: "freeTrial", + }); + navigate("/"); + }} + > )}