local onboarding edits
This commit is contained in:
parent
c6eb626c82
commit
4e38172202
5 changed files with 47 additions and 28 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,11 @@ 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_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
|
||||
|
|
|
|||
|
|
@ -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-lg font-semibold">{title}</p>
|
||||
{hasDownloaded ? (
|
||||
<OllamaCompletedStep text={command} />
|
||||
) : (
|
||||
<>
|
||||
<StyledActionButton data-tooltip-id={id} onClick={onClick}>
|
||||
<p className="truncate font-mono text-xs">{command}</p>
|
||||
<p className="m-0 truncate p-0 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);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
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";
|
||||
|
|
@ -33,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
|
||||
|
|
@ -53,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);
|
||||
|
|
@ -64,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");
|
||||
}
|
||||
|
|
@ -96,9 +101,11 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
|||
}, []);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="mt-3 flex flex-col gap-1">
|
||||
<div className="flex flex-col">
|
||||
<p className="mb-2 text-lg font-bold leading-tight">Install Ollama</p>
|
||||
<p className="mb-0 mt-2 text-lg font-bold leading-tight">
|
||||
Install Ollama
|
||||
</p>
|
||||
<OllamaStatus isOllamaConnected={isOllamaConnected} />
|
||||
</div>
|
||||
|
||||
|
|
@ -114,6 +121,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={() => {
|
||||
|
|
@ -133,7 +146,7 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
|||
);
|
||||
}}
|
||||
className="w-full"
|
||||
disabled={!hasDownloadedChatModel}
|
||||
disabled={!allDownloaded}
|
||||
>
|
||||
Connect
|
||||
</Button>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue