Skip to content
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

Autocomplete online cli #512

Open
lzumot opened this issue Jun 14, 2024 · 1 comment
Open

Autocomplete online cli #512

lzumot opened this issue Jun 14, 2024 · 1 comment

Comments

@lzumot
Copy link

lzumot commented Jun 14, 2024

LLM can generate suggested completions in the cli based on written commands or context of previous command and current directory/files using the completion and fim functions but without needing to use FILL. Suggestions use different color to the current text and tab or other button allows toggling suggestions, shift enter accepts suggestion.

@lzumot
Copy link
Author

lzumot commented Jun 23, 2024

# basic and flawed first implementation 
# General autocomplete function that uses llm to generate suggestions  
_llm_general_autocomplete() {  
    # Get the current word and the entire line input up to the cursor  
    local current_word="${COMP_WORDS[COMP_CWORD]}"  
    local line_input="${COMP_LINE}"  
  
    # Call llm with the entire line input to get suggestions  
    # Adjust the command to fit the requirements of your llm setup  
    local suggestions=$(llm -m gpt-3.5-turbo "Suggest bash commands or arguments for: '$line_input'")  
  
    # Convert llm output into an array, assuming newline-separated suggestions  
    local IFS=$'\n'  
    COMPREPLY=($(compgen -W "$suggestions" -- "$current_word"))  
}  
  
# Use Bash complete to specify the autocomplete function for all commands  
complete -F _llm_general_autocomplete -D  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant