huggingface / llm-vscode

LLM powered development for VSCode
Apache License 2.0
1.23k stars 133 forks source link

feat: add ```llm.requestDelay``` setting #103

Closed davidpissarra closed 11 months ago

davidpissarra commented 1 year ago

This PR introduces the setting llm.requestDelay. It represents the minimum time interval between requests. This setting avoids unnecessary API calls, typically when the user is still typing. For instance, if requestDelay is set to 2, the extension waits 2 seconds for something to be typed, otherwise makes an API call. Prior to this PR, every single character typed would result in a new call, overloading the API with many irrelevant requests, and most of the time making the user wait for all requests to be satisfied even if not needed anymore.

davidpissarra commented 1 year ago

An example of the current issue follows (different prompts with every typed character arriving at the rest API, which is cumbersome):

Screenshot 2023-11-04 at 21 35 08
McPatate commented 1 year ago

Hello, thank you for opening this PR.

Two things:

The plugin uses vscode.InlineCompletionItemProvider to handle the triggering of fetching completions. It already has a mechanism to buffer keypresses and delay requests, but it doesn't seem configurable and has a pretty low threshold. Additionally, requests are cancelled every time a new request is sent, in a remote endpoint setup it seems to work well, but I can see why in local setups that wouldn't, given there is no network overhead.

pacman100 commented 1 year ago

This is definitely a great feature to have. For the time being, I am using a manual invocation shortcut to overcome this issue but this PR is a great way of resolving it.

antoinejeannot commented 11 months ago

Up, this really is a neat feature that will definitely help use local copilots. thanks @davidpissarra

McPatate commented 11 months ago

This was done in https://github.com/huggingface/llm-vscode/pull/111, closing