don't display Ollama warnings to users that haven't explicitly configured it

This commit is contained in:
Nate 2024-11-01 15:16:47 -07:00
parent bc2ab48c8a
commit 7b5c907533

View file

@ -2,17 +2,12 @@ import type { ILLM } from "core";
import { ConfigHandler } from "core/config/ConfigHandler";
import Ollama from "core/llm/llms/Ollama";
import { GlobalContext } from "core/util/GlobalContext";
import * as vscode from "vscode";
export class TabAutocompleteModel {
private _llm: ILLM | undefined;
private defaultTag = "starcoder2:3b";
private defaultTagName = "Starcoder2 3b";
private globalContext: GlobalContext = new GlobalContext();
private shownOllamaWarning = false;
private shownDeepseekWarning = false;
constructor(private configHandler: ConfigHandler) {}
clearLlm() {
@ -27,49 +22,9 @@ export class TabAutocompleteModel {
try {
const models = await llm.listModels();
if (!models.includes(this.defaultTag)) {
if (!this.shownDeepseekWarning) {
vscode.window
.showWarningMessage(
`Your local Ollama instance doesn't yet have ${this.defaultTagName}. To download this model, run \`ollama run ${this.defaultTag}\` (recommended). If you'd like to use a custom model for tab autocomplete, learn more in the docs`,
"Documentation",
"Copy Command",
)
.then((value) => {
if (value === "Documentation") {
vscode.env.openExternal(
vscode.Uri.parse(
"https://docs.continue.dev/features/tab-autocomplete",
),
);
} else if (value === "Copy Command") {
vscode.env.clipboard.writeText(`ollama run ${this.defaultTag}`);
}
});
this.shownDeepseekWarning = true;
}
return undefined;
}
} catch (e) {
if (!this.shownOllamaWarning) {
vscode.window
.showWarningMessage(
"Continue failed to connect to Ollama, which is used by default for tab-autocomplete. If you haven't downloaded it yet, you can do so at https://ollama.ai (recommended). If you'd like to use a custom model for tab autocomplete, learn more in the docs",
"Download Ollama",
"Documentation",
)
.then((value) => {
if (value === "Documentation") {
vscode.env.openExternal(
vscode.Uri.parse(
"https://docs.continue.dev/features/tab-autocomplete",
),
);
} else if (value === "Download Ollama") {
vscode.env.openExternal(vscode.Uri.parse("https://ollama.ai"));
}
});
this.shownOllamaWarning = true;
}
return undefined;
}