prepare the LLM first, then use it to get per-model autocompleteOptions

This commit is contained in:
Jacob Kim 2025-06-03 14:52:25 -07:00
parent c2a616573e
commit 2af7850205

View file

@ -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;
}