feat: Ai Assisted Code Suggestions: provides alternative (multiple) suggestions for Inline code completion
Problem to solve
The current GitLab workflow extension only provides one patch of inline suggestions. However, the competitor's product GitHub Copilot can switch between multiple suggestions via shortcut Alt+]
and Alt+[
. As shown in the following snapshot, we can switch between previous or next suggestions and press Tab to accept.
The current GitLab workflow extension always returns a single suggestion and thus prevents the user from getting other results. I believe this feature will benefit user experience since AI's suggestion is not always helpful every time.
Proposal
According to OpenAI API documentation, one can get multiple completions by setting the value of n
. Also, I believe the VS Code API InlineCompletionItemProvider
do support multiple suggestions, the desired return type for the provider is a list ProviderResult<InlineCompletionList | InlineCompletionItem[]>
, as we can see the Next
and Previous
shortcuts are used to cycle through the suggestions, so this feature should be low-hanging fruit.
Further details
We need OpenAI API to return multiple completion candidates, so we need to change this implementation. GitHub copilot also set stream=true
in OpenAI API for returning multiple suggestions.
Links / references
- VS Code API: https://code.visualstudio.com/api/references/vscode-api#InlineCompletionItemProvider
- OpenAI API: https://beta.openai.com/docs/api-reference/completions
- GitHub Copilot docs: https://beta.openai.com/docs/api-reference/completions