From cc41c87eec8fd1e16b4bf9f1f5938014b7a92aab Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 1 Feb 2024 10:37:06 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20improve=20error=20logs=20for=20t?= =?UTF-8?q?ab-autocomplete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/static/schemas/config.json | 2 +- extensions/vscode/config_schema.json | 2 +- extensions/vscode/src/continueIdeClient.ts | 3 ++- .../src/lang-server/completionProvider.ts | 18 ++++++++++++++++-- extensions/vscode/src/loadConfig.ts | 13 +++++++++++-- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 5109cbd3d..8f7aa2958 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1310,7 +1310,7 @@ }, "tabAutocompleteModel": { "title": "Tab Autocomplete Model", - "markdownDescription": "The model used for tab autocompletion. If undefined, Continue will not do tab autocompletion.", + "markdownDescription": "The model used for tab autocompletion. If undefined, Continue will default to using deepseek-coder:1.3b-base on a local Ollama instance. Learn more in the documentation [here](https://continue.dev/docs/walkthroughs/tab-autocomplete).", "default": { "title": "Tab Autocomplete Model", "provider": "ollama", diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 5109cbd3d..7ade0f136 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1310,7 +1310,7 @@ }, "tabAutocompleteModel": { "title": "Tab Autocomplete Model", - "markdownDescription": "The model used for tab autocompletion. If undefined, Continue will not do tab autocompletion.", + "markdownDescription": "The model used for tab autocompletion. If undefined, Continue will default to using deepseek-coder:1.3b-base on a local Ollama instance.", "default": { "title": "Tab Autocomplete Model", "provider": "ollama", diff --git a/extensions/vscode/src/continueIdeClient.ts b/extensions/vscode/src/continueIdeClient.ts index 8dcf30215..9b4c5b773 100644 --- a/extensions/vscode/src/continueIdeClient.ts +++ b/extensions/vscode/src/continueIdeClient.ts @@ -5,7 +5,7 @@ import * as path from "path"; import * as vscode from "vscode"; import { debugPanelWebview, getSidebarContent } from "./debugPanel"; import { diffManager } from "./diff/horizontal"; -import { configHandler } from "./loadConfig"; +import { TabAutocompleteModel, configHandler } from "./loadConfig"; import { SuggestionRanges, acceptSuggestionCommand, @@ -49,6 +49,7 @@ class IdeProtocolClient { const configJson = JSON.parse(config); this.configUpdate(configJson); configHandler.reloadConfig(); + TabAutocompleteModel.clearLlm(); } else if ( filepath.endsWith(".continueignore") || filepath.endsWith(".gitignore") diff --git a/extensions/vscode/src/lang-server/completionProvider.ts b/extensions/vscode/src/lang-server/completionProvider.ts index ec302696f..a97851c6f 100644 --- a/extensions/vscode/src/lang-server/completionProvider.ts +++ b/extensions/vscode/src/lang-server/completionProvider.ts @@ -191,8 +191,20 @@ async function getTabCompletion( modelName: llm.model, completionOptions, }; - } catch (e) { + } catch (e: any) { console.warn("Error generating autocompletion: ", e); + if (!ContinueCompletionProvider.errorsShown.has(e.message)) { + ContinueCompletionProvider.errorsShown.add(e.message); + vscode.window.showErrorMessage(e.message, "Documentation").then((val) => { + if (val === "Documentation") { + vscode.env.openExternal( + vscode.Uri.parse( + "https://continue.dev/docs/walkthroughs/tab-autocomplete" + ) + ); + } + }); + } return undefined; } } @@ -204,6 +216,8 @@ export class ContinueCompletionProvider private static debouncing: boolean = false; private static lastUUID: string | undefined = undefined; + public static errorsShown: Set = new Set(); + public async provideInlineCompletionItems( document: vscode.TextDocument, position: vscode.Position, @@ -271,7 +285,7 @@ export class ContinueCompletionProvider ), ]; } catch (e: any) { - console.log("Error getting autocompletion: ", e.message); + console.warn("Error getting autocompletion: ", e.message); } finally { setupStatusBar(true, false); } diff --git a/extensions/vscode/src/loadConfig.ts b/extensions/vscode/src/loadConfig.ts index 1d403245a..4b34f7ca3 100644 --- a/extensions/vscode/src/loadConfig.ts +++ b/extensions/vscode/src/loadConfig.ts @@ -86,8 +86,13 @@ function setupLlm(llm: ILLM): ILLM { if (!resp.ok) { let text = await resp.text(); if (resp.status === 404 && !resp.url.includes("/v1")) { - text = - "This may mean that you forgot to add '/v1' to the end of your 'apiBase' in config.json."; + if (text.includes("try pulling it first")) { + const model = JSON.parse(text).error.split(" ")[1].slice(1, -1); + text = `The model "${model}" was not found. To download it, run \`ollama run ${model}\`.`; + } else { + text = + "This may mean that you forgot to add '/v1' to the end of your 'apiBase' in config.json."; + } } throw new Error( `HTTP ${resp.status} ${resp.statusText} from ${resp.url}\n\n${text}` @@ -143,6 +148,10 @@ export class TabAutocompleteModel { private static shownOllamaWarning: boolean = false; private static shownDeepseekWarning: boolean = false; + static clearLlm() { + TabAutocompleteModel._llm = undefined; + } + static async getDefaultTabAutocompleteModel() { const llm = new Ollama({ model: TabAutocompleteModel.defaultTag,