diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index cf6f3b298..f810e3a18 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -114,11 +114,12 @@ export class CompletionProvider { this.loggingService.markDisplayed(completionId, outcome); } - private async _getAutocompleteOptions() { + private async _getAutocompleteOptions(llm: ILLM) { const { config } = await this.configHandler.loadConfig(); const options = { ...DEFAULT_AUTOCOMPLETE_OPTS, ...config?.tabAutocompleteOptions, + ...llm.autocompleteOptions, }; return options; } @@ -136,15 +137,19 @@ export class CompletionProvider { token = controller.signal; } const startTime = Date.now(); - const options = await this._getAutocompleteOptions(); - // Debounce - if (await this.debouncer.delayAndShouldDebounce(options.debounceDelay)) { + // NOTE: There shouldn't be too big of a performance penalty here. + // If this ends up introducing too big of a bottleneck, + // we should consider a more clever way of passing llm to _getAutocompleteOptions. + const llm = await this._prepareLlm(); + if (!llm) { return undefined; } - const llm = await this._prepareLlm(); - if (!llm) { + const options = await this._getAutocompleteOptions(llm); + + // Debounce + if (await this.debouncer.delayAndShouldDebounce(options.debounceDelay)) { return undefined; }