|
|
@ -111,17 +111,13 @@ export function activate(context: vscode.ExtensionContext) { |
|
|
|
config = vscode.workspace.getConfiguration("dumbpilot"); |
|
|
|
config = vscode.workspace.getConfiguration("dumbpilot"); |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
let completion_enabled: boolean = config.get("completionEnabled") as boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: work with local configurations
|
|
|
|
// TODO: work with local configurations
|
|
|
|
let disposable = vscode.commands.registerCommand("dumbpilot.enableCompletion", () => { |
|
|
|
let disposable = vscode.commands.registerCommand("dumbpilot.enableCompletion", () => { |
|
|
|
completion_enabled = true; |
|
|
|
|
|
|
|
config.update("completionEnabled", true); |
|
|
|
config.update("completionEnabled", true); |
|
|
|
}); |
|
|
|
}); |
|
|
|
context.subscriptions.push(disposable); |
|
|
|
context.subscriptions.push(disposable); |
|
|
|
|
|
|
|
|
|
|
|
disposable = vscode.commands.registerCommand("dumbpilot.disableCompletion", () => { |
|
|
|
disposable = vscode.commands.registerCommand("dumbpilot.disableCompletion", () => { |
|
|
|
completion_enabled = false; |
|
|
|
|
|
|
|
config.update("completionEnabled", false); |
|
|
|
config.update("completionEnabled", false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -131,11 +127,12 @@ export function activate(context: vscode.ExtensionContext) { |
|
|
|
const provider: vscode.InlineCompletionItemProvider = { |
|
|
|
const provider: vscode.InlineCompletionItemProvider = { |
|
|
|
async provideInlineCompletionItems(document, position, context, token) { |
|
|
|
async provideInlineCompletionItems(document, position, context, token) { |
|
|
|
|
|
|
|
|
|
|
|
if (completion_enabled === false) { |
|
|
|
// disable if predictive completion is disabled
|
|
|
|
|
|
|
|
if (config.get("completionEnabled") as boolean === false) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Since for every completion we want to query the server, we want to filter out
|
|
|
|
// Since for every completion we will query the server, we want to filter out
|
|
|
|
// automatic completion invokes
|
|
|
|
// automatic completion invokes
|
|
|
|
if (context.triggerKind === vscode.InlineCompletionTriggerKind.Automatic) { |
|
|
|
if (context.triggerKind === vscode.InlineCompletionTriggerKind.Automatic) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
@ -224,6 +221,9 @@ export function activate(context: vscode.ExtensionContext) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data = await response.json() as llamaData; |
|
|
|
data = await response.json() as llamaData; |
|
|
|
|
|
|
|
const gen_tokens = data.timings.predicted_n; |
|
|
|
|
|
|
|
const gen_time = (data.timings.predicted_ms / 1000).toFixed(2); |
|
|
|
|
|
|
|
showMessageWithTimeout(`predicted ${gen_tokens} tokens in ${gen_time} seconds`, 1500); |
|
|
|
|
|
|
|
|
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|
const err = e as TypeError; |
|
|
|
const err = e as TypeError; |
|
|
|