Skip to content

Leverage local LLM via Vim to boost bug breading within your code ;-P

License

Notifications You must be signed in to change notification settings

vim-utilities/proompter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proompter

Leverage local LLM via Vim to boost bug breading within your code

Byte size of Proompter Open Issues Open Pull Requests Latest commitsGitHub Actions Build StatusLicense



Requirements

This repository requires the Vim text editor to be installed the source code is available on GitHub -- vim/vim, and most GNU Linux package managers are able to install Vim directly, eg...

  • Arch based Operating Systems
    sudo packman -Syy
    sudo packman -S vim
  • Debian derived Distributions
    sudo apt-get update
    sudo apt-get install vim

... Additionally for local LLM interactions this plugin expects ollama to be installed and running, as well as Python run-time to facilitate scripts/proompter-channel-proxy.py service.


Development dependencies

  • Vim Doc for help from doc-comments
    git clone https://github.com/vim-utilities/vimdoc
    pushd vimdoc
    python setup.py config
    python setup.py build
    pipx install .
    popd

    Execute with vimdoc .

    Note; until certain bugs are fixed upstream it is necessary to use the patched version of vimdoc which handles longer lines, and Vim 8 parameters a bit more correctly.

  • Vader for testing code
    call plug#begin('~/.vim/plugged')
      Plug 'junegunn/vader.vim'
    call plug#end()

    Execute with scripts/vader-run-tests.sh --cicd --test units


Quick Start

List available user paths for SystemD services

systemd-analyze --user unit-paths | grep $HOME

Example output

~/.config/systemd/user.control
~/.config/systemd/user
~/.config/kdedefaults/systemd/user
~/.local/share/systemd/user

Install with Vim package manager of choice

Plug 'vim-utilities/proompter' {
     \   'do': 'scripts/proompter-channel-proxy.py --install-systemd "' . $HOME . '/.local/share/systemd/user/proompter-channel-proxy.service"'
     \ }

Note: if installing manually, such as cloning via Git, then you may invoke the proxy installation directly;

scripts/proompter-channel-proxy.py --install-systemd "$HOME/.local/share/systemd/user/proompter-channel-proxy.service"

Dev tip: if modifying the installed SystemD configuration you may pop warnings, about changes detected on disk here's how to fix that;

systemctl --user daemon-reload


Ensure the Ollama service is running

systemctl is-active --quiet ollama.service || {
  sudo systemctl restart ollama.service
}

Ensure the Vim channel proxy is running

systemctl --user is-active --quiet proompter-channel-proxy.service || {
  systemctl --user proompter-channel-proxy.service
}

Usage

Currently no Motions or Commands are provided, and such customization is an exercise for each entity using this plugin. Instead there are a kit of helper functions, and some examples/, for creating your own Vim/LLM integration experience!


Author or select a callback

Tip: find example callback functions within;

  • autoload/proompter/callback/channel.vim
  • autoload/proompter/callback/prompt.vim
function! MyProompterLineStreamCallback(channel_response, api_response, ...) abort
  let l:http_response = proompter#parse#HTTPResponse(a:api_response)
  for l:http_body_data in l:http_response.body
    let l:api_data = proompter#parse#MessageOrResponseFromAPI(l:http_body_data)
    echoe 'l:api_data ->' l:api_data
  endfor
endfunction

Configure Proompter

let g:proompter = {
      \   'select': {
      \     'model_name': 'codellama',
      \   },
      \   'api': {
      \     'url': 'http://127.0.0.1:11434/api/generate',
      \   },
      \   'channel': {
      \     'address': '127.0.0.1:11435',
      \     'options': {
      \       'mode': 'raw',
      \       'callback': function('MyProompterLineStreamCallback'),
      \     },
      \   },
      \   'models': {
      \     'codellama': {
      \       'data': {
      \         'prompt': '<<SYS>>Pretend you are a senior software engineer<</SYS>>',
      \         'raw': v:false,
      \         'stream': v:true,
      \       },
      \     },
      \   },
      \ }

Tip: check :help proompter-configuration for some more advanced example(s)


Notes

This repository may not be feature complete and/or fully functional, Pull Requests that add features or fix bugs are certainly welcomed.

Tip: check the CHANGELOG.md for features and/or bugs that may want attentions of those so inclined.

Most of the code and documentation, at least up to tagged version 0.0.1, is authored by a human. LLMs were no help with Vim script.


Contributing

Options for contributing to Proompter and Vim Utilities


Forking

Start making a Fork of this repository to an account that you have write permissions for.

cd ~/git/hub/vim-utilities/proompter

git remote add fork [email protected]:<NAME>/proompter.git
  • Adjust your package manager configuration

    Plug '~/git/hub/vim-utilities/proompter' { 'do': '' }
  • Commit your changes and push to your fork, eg. to fix an issue...

cd ~/git/hub/vim-utilities/proompter


git commit -F- <<'EOF'
:bug: Fixes #42 Issue


**Edits**


- `<SCRIPT-NAME>` script, fixes some bug reported in issue
EOF


git push fork main

Note, the -u option may be used to set fork as the default remote, eg. git push -u fork main however, this will also default the fork remote for pulling from too! Meaning that pulling updates from origin must be done explicitly, eg. git pull origin main

  • Then on GitHub submit a Pull Request through the Web-UI, the URL syntax is https://github.com/<NAME>/<REPO>/pull/new/<BRANCH>

Note; to decrease the chances of your Pull Request needing modifications before being accepted, please check the dot-github repository for detailed contributing guidelines.


Sponsor

Thanks for even considering it!

Via Liberapay you may sponsor__shields_io__liberapay on a repeating basis.

Regardless of if you're able to financially support projects such as proompter that vim-utilities maintains, please consider sharing projects that are useful with others, because one of the goals of maintaining Open Source repositories is to provide value to the community.


Attribution


License

This project is licensed based on use-case

Commercial and/or proprietary use

If a project is either commercial or (||) proprietary, then please contact the author for pricing and licensing options to make use of code and/or features from this repository.


Non-commercial and FOSS use

If a project is both non-commercial and (&&) published with a license compatible with AGPL-3.0, then it may utilize code from this repository under the following terms.

Leverage local LLM via Vim to boost bug breading within your code
Copyright (C) 2024 S0AndS0

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

For further details review full length version of AGPL-3.0 License.