This is the result of experiments with the visual-mode and command-line mode in vi. By combining a bash utility wrapping AI CLIs with the flow "Selection -> Run Shell Command on Selection -> Replace Selection", you gain powerful AI capabilities.
See my blog post Follow up "vim llm = 🔥": small things that awww
It works on VIM, NeoVIM, Emacs and even VSCode.
Prompts included
- code/comment: Add comments to code
- code/explain: Explain a piece of code by adding comments
- code/fill: Replace the //fill keywords with the missing code logic
- code/fix: Fix errors in code syntax or logic
- code/name: Rename code symbols for clarity
- email/draft: Create an email from instructions or notes
- email/reply: Reply to an email in the sender language
- personal/mealplan: Generate a meal plan for the next 7 days
- translate/english: Translate text to English
- translate/french: Translate text to French
Explore a myriad of models, both local and via robust APIs such as OpenAI and Together.
- LLM-CLI: A robust CLI tool and Python library for interfacing with LLMs, catering to both remote APIs and local installations.
For those willing to try large open-source models, consider adding llm-together.
- Ollama: A straightforward approach to working with Llama 2 and other open-source language models on a local setup.
Note: It's advisable to start with Mistral 7B OpenOrca unless you're equipped to handle more resource-intensive models.
To efficiently call upon lm
(representing llm) or oll
(representing ollama) from your terminal or editor, integrate the main directory of this project into your $PATH.
Incorporate the following line into your .zshrc
or .bashrc
:
export PATH=$PATH:<path-to-the-project-directory>
Engage with the wrappers directly:
# Quick translation to French:
lm translate/french "Hello there! How are you today?"
# For a multi-line input, use Ctrl-D post entry to initiate the process:
echo "$(cat)" | llm translate/french
The text you select serves as the context for the LLM's prompts, which in turn, will be replaced by the LLM's output.
- Initiate a region selection in visual mode.
- Transition to the command-line mode with
:
followed by!
. - Enter
lm [prompt-name]
to activate llm-cli oroll [prompt-name]
to call ollama.
Examples for clarity:
lm -h # Displays available prompts
oll -h # Likewise
lm code/fill # Engage llm to utilize the 'code/fill' prompt
oll translate/french # Translation to French using Ollama CLI
Add your own bash scripts or directories under the prompts
folder, and they'll be integrated into the prompt list.
Feel free to contribute your own prompts to this repository. I'll be happy to add new ones.
We share our experiments and our journey through our newsletter Modern Chaos
Modern chaos is a newsletter exploring tech and AI through the journey of a dev agency shifting from services to product design. We share our notes, analysis and experiments.