Merge pull request #4008 from continuedev/dallin/ollama-embedder
Ollama embedder and Onboarding Style fixes
This commit is contained in:
commit
4f4ea97b74
9 changed files with 54 additions and 71 deletions
|
|
@ -27,7 +27,7 @@ import { localPathToUri } from "../util/pathToUri.js";
|
|||
|
||||
import {
|
||||
LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
LOCAL_ONBOARDING_PROVIDER_TITLE,
|
||||
} from "./onboarding.js";
|
||||
import ControlPlaneProfileLoader from "./profile/ControlPlaneProfileLoader.js";
|
||||
import LocalProfileLoader from "./profile/LocalProfileLoader.js";
|
||||
|
|
@ -401,7 +401,7 @@ export class ConfigHandler {
|
|||
const { config } = await this.loadConfig();
|
||||
const model = config?.models.find((m) => m.title === title);
|
||||
if (!model) {
|
||||
if (title === ONBOARDING_LOCAL_MODEL_TITLE) {
|
||||
if (title === LOCAL_ONBOARDING_PROVIDER_TITLE) {
|
||||
// Special case, make calls to Ollama before we have it in the config
|
||||
const ollama = new Ollama({
|
||||
model: LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ import { SerializedContinueConfig } from "../";
|
|||
import { FREE_TRIAL_MODELS } from "./default";
|
||||
|
||||
export const TRIAL_FIM_MODEL = "codestral-latest";
|
||||
export const ONBOARDING_LOCAL_MODEL_TITLE = "Ollama";
|
||||
export const LOCAL_ONBOARDING_PROVIDER_TITLE = "Ollama";
|
||||
export const LOCAL_ONBOARDING_FIM_MODEL = "qwen2.5-coder:1.5b-base";
|
||||
export const LOCAL_ONBOARDING_FIM_TITLE = "Qwen2.5-Coder 1.5B";
|
||||
export const LOCAL_ONBOARDING_CHAT_MODEL = "llama3.1:8b";
|
||||
export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B";
|
||||
export const LOCAL_ONBOARDING_EMBEDDINGS_MODEL = "nomic-embed-text:latest";
|
||||
|
||||
/**
|
||||
* We set the "best" chat + autocopmlete models by default
|
||||
|
|
@ -35,13 +37,13 @@ export function setupLocalConfig(
|
|||
...config.models.filter((model) => model.provider !== "free-trial"),
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: "Qwen2.5-Coder 1.5B",
|
||||
title: LOCAL_ONBOARDING_FIM_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_FIM_MODEL,
|
||||
},
|
||||
embeddingsProvider: {
|
||||
provider: "ollama",
|
||||
model: "nomic-embed-text",
|
||||
model: LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
@ -68,24 +70,3 @@ export function setupQuickstartConfig(
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function setupLocalConfigAfterFreeTrial(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
return {
|
||||
...config,
|
||||
models: [
|
||||
{
|
||||
title: LOCAL_ONBOARDING_CHAT_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
},
|
||||
{
|
||||
title: ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
provider: "ollama",
|
||||
model: "AUTODETECT",
|
||||
},
|
||||
...config.models.filter((model) => model.provider !== "free-trial"),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import { SYSTEM_PROMPT_DOT_FILE } from "./config/getSystemPromptDotFile";
|
|||
import {
|
||||
setupBestConfig,
|
||||
setupLocalConfig,
|
||||
setupLocalConfigAfterFreeTrial,
|
||||
setupQuickstartConfig,
|
||||
} from "./config/onboarding";
|
||||
import { addContextProvider, addModel, deleteModel } from "./config/util";
|
||||
|
|
@ -748,10 +747,6 @@ export class Core {
|
|||
editConfigJsonCallback = setupQuickstartConfig;
|
||||
break;
|
||||
|
||||
case "LocalAfterFreeTrial":
|
||||
editConfigJsonCallback = setupLocalConfigAfterFreeTrial;
|
||||
break;
|
||||
|
||||
case "Best":
|
||||
editConfigJsonCallback = setupBestConfig;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -28,12 +28,7 @@ import type {
|
|||
ToolCall,
|
||||
} from "../";
|
||||
|
||||
export type OnboardingModes =
|
||||
| "Local"
|
||||
| "Best"
|
||||
| "Custom"
|
||||
| "Quickstart"
|
||||
| "LocalAfterFreeTrial";
|
||||
export type OnboardingModes = "Local" | "Best" | "Custom" | "Quickstart";
|
||||
|
||||
export interface ListHistoryOptions {
|
||||
offset?: number;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ interface OllamaCompletedStepProps {
|
|||
function OllamaCompletedStep({ text }: OllamaCompletedStepProps) {
|
||||
return (
|
||||
<div className="flex items-center justify-between">
|
||||
<p className="mr-1 w-3/4 truncate font-mono text-sm">{text}</p>
|
||||
<p className="lines mr-1 w-3/4 font-mono text-sm leading-none">{text}</p>
|
||||
<CheckCircleIcon width={24} height={24} className="text-emerald-600" />
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ function OllamaModelDownload({
|
|||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<p className="mb-2 text-lg font-bold leading-tight">{title}</p>
|
||||
<p className="mb-1 mt-4 text-base font-semibold sm:text-lg">{title}</p>
|
||||
{hasDownloaded ? (
|
||||
<OllamaCompletedStep text={command} />
|
||||
) : (
|
||||
<>
|
||||
<StyledActionButton data-tooltip-id={id} onClick={onClick}>
|
||||
<p className="truncate font-mono text-xs">{command}</p>
|
||||
<p className="lines m-0 px-0 py-2 font-mono text-xs">{command}</p>
|
||||
<CommandLineIcon width={24} height={24} />
|
||||
</StyledActionButton>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import {
|
|||
ArrowPathIcon,
|
||||
ArrowTopRightOnSquareIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useState, useContext } from "react";
|
||||
import { useState, useContext, useEffect } from "react";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { providers } from "../../../pages/AddNewModel/configs/providers";
|
||||
import { StyledActionButton } from "../..";
|
||||
|
|
@ -19,10 +19,15 @@ export function OllamaStatus({ isOllamaConnected }: OllamaStatusProps) {
|
|||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [status, setStatus] = useState<OllamaConnectionStatuses>(
|
||||
isOllamaConnected
|
||||
? OllamaConnectionStatuses.Connected
|
||||
: OllamaConnectionStatuses.WaitingToDownload,
|
||||
OllamaConnectionStatuses.WaitingToDownload,
|
||||
);
|
||||
useEffect(() => {
|
||||
if (isOllamaConnected) {
|
||||
setStatus(OllamaConnectionStatuses.Connected);
|
||||
} else if (status !== OllamaConnectionStatuses.Downloading) {
|
||||
setStatus(OllamaConnectionStatuses.WaitingToDownload);
|
||||
}
|
||||
}, [status, isOllamaConnected]);
|
||||
|
||||
function onClickDownload() {
|
||||
ideMessenger.post("openUrl", downloadUrl);
|
||||
|
|
@ -33,14 +38,14 @@ export function OllamaStatus({ isOllamaConnected }: OllamaStatusProps) {
|
|||
case OllamaConnectionStatuses.WaitingToDownload:
|
||||
return (
|
||||
<StyledActionButton onClick={onClickDownload}>
|
||||
<p className="mr-1 text-sm underline">{downloadUrl}</p>
|
||||
<p className="lines lines-1 mr-1 text-sm underline">{downloadUrl}</p>
|
||||
<ArrowTopRightOnSquareIcon width={24} height={24} />
|
||||
</StyledActionButton>
|
||||
);
|
||||
case OllamaConnectionStatuses.Downloading:
|
||||
return (
|
||||
<div className="flex items-center justify-between">
|
||||
<p className="mr-1 w-3/4 font-mono text-sm">
|
||||
<p className="lines mr-1 w-3/4 font-mono text-sm">
|
||||
Checking for connection to Ollama at http://localhost:11434
|
||||
</p>
|
||||
<ArrowPathIcon className="animate-spin-slow mr-1 h-4 w-4" />
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) {
|
|||
isDialog={isDialog}
|
||||
/>
|
||||
) : (
|
||||
<div className="mt-4">
|
||||
<div className="mt-4 flex flex-col">
|
||||
<Alert type="info">
|
||||
By choosing this option, Continue will be configured by a local{" "}
|
||||
<code>config.yaml</code> file. If you're just looking to use
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import {
|
||||
LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
LOCAL_ONBOARDING_CHAT_TITLE,
|
||||
LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
|
||||
LOCAL_ONBOARDING_FIM_MODEL,
|
||||
ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
LOCAL_ONBOARDING_PROVIDER_TITLE,
|
||||
} from "core/config/onboarding";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Button } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { hasPassedFTL } from "../../../util/freeTrial";
|
||||
import AddModelButtonSubtext from "../../AddModelButtonSubtext";
|
||||
import OllamaModelDownload from "../components/OllamaModelDownload";
|
||||
import { OllamaStatus } from "../components/OllamaStatus";
|
||||
|
|
@ -25,10 +25,7 @@ interface OnboardingLocalTabProps {
|
|||
function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
||||
const dispatch = useDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { submitOnboarding } = useSubmitOnboarding(
|
||||
hasPassedFTL() ? "LocalAfterFreeTrial" : "Local",
|
||||
isDialog,
|
||||
);
|
||||
const { submitOnboarding } = useSubmitOnboarding("Local", isDialog);
|
||||
const [hasLoadedChatModel, setHasLoadedChatModel] = useState(false);
|
||||
const [downloadedOllamaModels, setDownloadedOllamaModels] = useState<
|
||||
string[]
|
||||
|
|
@ -37,17 +34,28 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
|||
const [isOllamaConnected, setIsOllamaConnected] = useState(false);
|
||||
|
||||
const hasDownloadedChatModel = Array.isArray(downloadedOllamaModels)
|
||||
? downloadedOllamaModels.some((ollamaModel) =>
|
||||
ollamaModel.startsWith(LOCAL_ONBOARDING_CHAT_MODEL),
|
||||
? downloadedOllamaModels.some(
|
||||
(ollamaModel) => ollamaModel === LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
)
|
||||
: false;
|
||||
|
||||
const hasDownloadedAutocompleteModel = Array.isArray(downloadedOllamaModels)
|
||||
? downloadedOllamaModels.some((ollamaModel) =>
|
||||
ollamaModel.startsWith(LOCAL_ONBOARDING_CHAT_MODEL),
|
||||
? downloadedOllamaModels.some(
|
||||
(ollamaModel) => ollamaModel === LOCAL_ONBOARDING_FIM_MODEL,
|
||||
)
|
||||
: false;
|
||||
|
||||
const hasDownloadedEmbeddingsModel = Array.isArray(downloadedOllamaModels)
|
||||
? downloadedOllamaModels.some(
|
||||
(ollamaModel) => ollamaModel === LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
|
||||
)
|
||||
: false;
|
||||
|
||||
const allDownloaded =
|
||||
hasDownloadedAutocompleteModel &&
|
||||
hasDownloadedChatModel &&
|
||||
hasDownloadedEmbeddingsModel;
|
||||
|
||||
/**
|
||||
* The first time we detect that a chat model has been loaded,
|
||||
* we send an empty request to load it
|
||||
|
|
@ -57,7 +65,7 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
|||
ideMessenger.post("llm/complete", {
|
||||
completionOptions: {},
|
||||
prompt: "",
|
||||
title: ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
title: LOCAL_ONBOARDING_PROVIDER_TITLE,
|
||||
});
|
||||
|
||||
setHasLoadedChatModel(true);
|
||||
|
|
@ -68,18 +76,11 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
|||
const fetchDownloadedModels = async () => {
|
||||
try {
|
||||
const result = await ideMessenger.request("llm/listModels", {
|
||||
title: ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
title: LOCAL_ONBOARDING_PROVIDER_TITLE,
|
||||
});
|
||||
if (result.status === "success") {
|
||||
// TODO - temporary fix, see notes
|
||||
// https://github.com/continuedev/continue/pull/3059
|
||||
if (Array.isArray(result.content)) {
|
||||
setDownloadedOllamaModels(result.content);
|
||||
setIsOllamaConnected(true);
|
||||
} else {
|
||||
setDownloadedOllamaModels([]);
|
||||
setIsOllamaConnected(false);
|
||||
}
|
||||
setDownloadedOllamaModels(result.content ?? []);
|
||||
setIsOllamaConnected(!!result.content);
|
||||
} else {
|
||||
throw new Error("Failed to fetch models");
|
||||
}
|
||||
|
|
@ -100,9 +101,9 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
|||
}, []);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="mt-3 flex flex-col gap-1 px-2">
|
||||
<div className="flex flex-col">
|
||||
<p className="mb-2 text-lg font-bold leading-tight">Install Ollama</p>
|
||||
<p className="mb-0 text-lg font-bold leading-tight">Install Ollama</p>
|
||||
<OllamaStatus isOllamaConnected={isOllamaConnected} />
|
||||
</div>
|
||||
|
||||
|
|
@ -118,6 +119,12 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
|||
hasDownloaded={hasDownloadedAutocompleteModel}
|
||||
/>
|
||||
|
||||
<OllamaModelDownload
|
||||
title="Download Embeddings model"
|
||||
modelName={LOCAL_ONBOARDING_EMBEDDINGS_MODEL}
|
||||
hasDownloaded={hasDownloadedEmbeddingsModel}
|
||||
/>
|
||||
|
||||
<div className="mt-4 w-full">
|
||||
<Button
|
||||
onClick={() => {
|
||||
|
|
@ -137,7 +144,7 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
|||
);
|
||||
}}
|
||||
className="w-full"
|
||||
disabled={!hasDownloadedChatModel}
|
||||
disabled={!allDownloaded}
|
||||
>
|
||||
Connect
|
||||
</Button>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue