-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using auto_suggest for copilot-like completions #1913
Comments
I think I can work around the first and last issue by using my own processor separate from auto_suggest. However, the multiline thing seems to be a fundamental limitation in how processors work. I could just use the completion system but it's not particularly ideal for showing multiline completions, and also, I'd ideally like to have traditional tab-completions still available separately from the AI copilot completions. |
So it turns out completions don't actually support multi-line completions either (it also just replaces them with I realized that another issue with auto_suggest is that for AI completions you want to limit how often the suggestions are grabbed, either on a timer or based on a keyboard shortcut. The current code assumes they are cheap and grabs them with every text change. I ended up just copying and modifying the auto_suggest code because it was too incompatible with what I need, but I have something that works pretty well except for the multi-line issue. Any suggestions on how to build a version of |
Use buffer.on_text_changed and |
So I found a somewhat hacky workaround for multiline suggestions. In the processor, I can replace all the newlines in the suggestion with enough spaces so that the soft wrapping automatically makes it look like a multiple lines. This works well because the soft wrapping mechanisms seem so to be fairly robust. The only annoying thing about this is that there doesn't seem to be a way to actually get the width of a buffer in characters. The layout classes nominally has some attributes like The code is at https://github.com/asmeurer/mypython/blob/master/mypython/processors.py (with AI completion code itself at https://github.com/asmeurer/mypython/blob/master/mypython/ai.py and a few important pieces at https://github.com/asmeurer/mypython/blob/master/mypython/mypython.py and https://github.com/asmeurer/mypython/blob/master/mypython/keys.py as well) for anyone interested. Most of it is copied from the autosuggestion code from prompt-toolkit, but modified to generating and cycling through support multiple suggestions (a la copilot). |
I'd like to use
auto_suggest
for copilot like AI auto-completions. However, there seem to be some complications with doing this:^J
. Additionally, the transformers seem to work line-by-line, so it's not so clear how to even write something that could suggest multiple lines.AppendAutoSuggestions
processor is hard-coded in the input processorspython-prompt-toolkit/src/prompt_toolkit/widgets/base.py
Line 240 in 6695411
AutoSuggest
as that processor would try to handle anysuggestion
that is put on the buffer.The text was updated successfully, but these errors were encountered: