Skip to content

Commit 6b2cae1

Browse files
authored
Use a throttler instead of a debouncer for code completion (#8)
1 parent 0eb6e11 commit 6b2cae1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/provider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
IInlineCompletionProvider
55
} from '@jupyterlab/completer';
66

7-
import { Debouncer } from '@lumino/polling';
7+
import { Throttler } from '@lumino/polling';
88

99
import MistralClient, { CompletionRequest } from '@mistralai/mistralai';
1010

@@ -19,7 +19,7 @@ export class CodestralProvider implements IInlineCompletionProvider {
1919

2020
constructor(options: CodestralProvider.IOptions) {
2121
this._mistralClient = options.mistralClient;
22-
this._debouncer = new Debouncer(async (data: CompletionRequest) => {
22+
this._throttler = new Throttler(async (data: CompletionRequest) => {
2323
const response = await this._mistralClient.completion(data);
2424
const items = response.choices.map((choice: any) => {
2525
return { insertText: choice.message.content as string };
@@ -53,14 +53,14 @@ export class CodestralProvider implements IInlineCompletionProvider {
5353
};
5454

5555
try {
56-
return this._debouncer.invoke(data);
56+
return this._throttler.invoke(data);
5757
} catch (error) {
5858
console.error('Error fetching completions', error);
5959
return { items: [] };
6060
}
6161
}
6262

63-
private _debouncer: Debouncer;
63+
private _throttler: Throttler;
6464
private _mistralClient: MistralClient;
6565
}
6666

0 commit comments

Comments
 (0)