zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
30.33k stars 1.85k 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 2 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 :)