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 000000000..aecb2a27b Binary files /dev/null and b/gui/public/logos/fireworks.png differ diff --git a/gui/src/App.tsx b/gui/src/App.tsx index c015b54b0..3997e4a10 100644 --- a/gui/src/App.tsx +++ b/gui/src/App.tsx @@ -17,6 +17,7 @@ import useSubmenuContextProviders from "./hooks/useSubmenuContextProviders"; import { useVscTheme } from "./hooks/useVscTheme"; import GUI from "./pages/gui"; import LocalOnboarding from "./pages/localOnboarding"; +import ApiKeyAutocompleteOnboarding from "./pages/onboarding/apiKeyAutocompleteOnboarding"; import ApiKeyOnboarding from "./pages/onboarding/apiKeyOnboarding"; import ExistingUserOnboarding from "./pages/onboarding/existingUserOnboarding"; import Onboarding from "./pages/onboarding/onboarding"; @@ -88,6 +89,10 @@ const router = createMemoryRouter([ path: "/apiKeyOnboarding", element: , }, + { + 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("/"); + }} + > )}