zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
31.54k stars 1.87k forks source link

[Feature Request] AI Auto Complete 🔥 #736

Open fire17 opened 1 year ago

fire17 commented 1 year ago

Hi there! Let me just say that I'm in love with this project, anyone not using this it's like they're still on notepad lol

Anyway, I'm currently researching how to elevate the terminal further with ai. The 2 major things I'm currently targeting is: https://github.com/wunderwuzzi23/yolo-ai-cmdbot And https://github.com/Aesthetikx/openai_pipe

But as a lover of zsh-autosuggestions, I'm now thinking... you could possibly add some config that we can enter our api keys (or target a local foss llm, should be modular) and get "copilot" like autocomplete inline the terminal. You guys already figured out how to integrate well with the term so this should be almost plug and play for you, right before you load the suggestion, call the api.

Draft for priming: You are a professional on a linux terminal, and your job is to autocomplete or autosuggest the rest of the line that is already partially typed by the user in the terminal. Your default is to autocomplete the last entry directly from recent command history. If there is nothing to complete based on the command history, try to suggest the best completion based on the current path and context.\n [Recent Terminal Output] {insert recent terminal outputs last N lines}\n [Recent Command History] {Insert history}\n [Filtered Commands] {list of all options for autocomplete that you already filtered like when we use up/down arrows}\n Do not give any commentary, no insights, no explanations or anything else. Simply finish the rest of the command! [Partially Typed User Command] {enter current typed text}

Should be cheap to run with 3.5turbo or just local gpt varient, might not be for everyone but I'd love to opt in for this, and you guys have the best ux and interface with the terminal, so I think you're up for the challenge

Hope you like it :) Let me know what you think Thanks a lot and have a good one! All the best!

nperspective commented 1 year ago

Following! I'm working on this with a friend in a private repo with zsh-autosuggestions (+Copilot) as my vision.

Here's another similar existing solution: https://github.com/tom-doerr/zsh_codex (https://www.kiera.ai/)

ericfreese commented 1 year ago

You should be able to hook this in pretty easily by implementing a new suggestion strategy and specifying it in your configuration. See e.g. https://github.com/zsh-users/zsh-autosuggestions/blob/a411ef3e0992d4839f0732ebeb9823024afaaaa8/src/strategies/completion.zsh

fire17 commented 1 year ago

Following! I'm working on this with a friend in a private repo with zsh-autosuggestions (+Copilot) as my vision.

Here's another similar existing solution: https://github.com/tom-doerr/zsh_codex (https://www.kiera.ai/)

That's awesome to hear! would love to get a repo link so I can follow @nperspective Also can you try to make it generic and model agnostic? So it work with not only copilot but also any openai model ai and also free local llms 🙏

Also Thanks for the links !

bamos commented 7 months ago

Hi all, if anybody here is still interested in this, I hacked in an LLM to generate suggestions in this fork! I'm still experimenting with it and put some more details at the top of the README there :)

pablospe commented 1 month ago

Hi all, if anybody here is still interested in this, I hacked in an LLM to generate suggestions in this fork! I'm still experimenting with it and put some more details at the top of the README there :)

@bamos The fork was removed, right?

bamos commented 1 month ago

Hi all, if anybody here is still interested in this, I hacked in an LLM to generate suggestions in this fork! I'm still experimenting with it and put some more details at the top of the README there :)

@bamos The fork was removed, right?

Yeah, I ended up not continuing to use it and found the history autosuggestion more useful. I made the fork private and can add you or anybody else that is interested

OskarSzafer commented 1 month ago

Hi everyone! I've been working on a project to integrate copilot-like capabilities into this plugin, and it's now in a pretty functional state. I wanted to share it here in case anyone is interested or could help.

Here's my repo: https://github.com/OskarSzafer/open-cli-copilot

bamos commented 1 month ago

Hi everyone! I've been working on a project to integrate copilot-like capabilities into this plugin, and it's now in a pretty functional state. I wanted to share it here in case anyone is interested or could help.

Here's my repo: https://github.com/OskarSzafer/open-cli-copilot

Nice @OskarSzafer! Looks like you made it a little farther than me :) If I may say, some of the issues I noticed in mine that made me just switch back to the history lookup mode in here are present in your demo video: 1) the suggestions are much slower than the other non-AI options in here. It's really satisfying and helpful to see a new completion after every keystroke, 2) commands like git init are usually properly completed by the history search for me (and again suggested much faster), 3) I don't find the AI suggestions very helpful.

In my project, I hoped some more complex project/command line scenarios would make the LLM's suggestions more clearly helpful, but I unfortunately couldn't find any. LLM command completion seems not quite there and very different than the code completions, maybe since code has much more structure and predictability than commands.

Maybe there is some value in being able to synthesize extremely complex Bash commands and one-liners (/"golf") from a description. But for this, I think it's better to just have an alias calling into a larger model one time rather than doing it on every keystroke for every command (so I usually just query for this via a web interface since I usually just need to do it once maybe every few hours/days)