🔊 improve error logs for tab-autocomplete
This commit is contained in:
parent
2ed16c5163
commit
cc41c87eec
5 changed files with 31 additions and 7 deletions
2
docs/static/schemas/config.json
vendored
2
docs/static/schemas/config.json
vendored
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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<string> = 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue