diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-03-06 17:33:41 +0100 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-03-06 17:34:28 +0100 |
| commit | 4e50a6e82d823687d372c7f9c86eb09b9ca6f130 (patch) | |
| tree | ab6538d932d01457a1e1e0eea635674c85d9b6bc /README.md | |
| parent | dff91598cadf349b9be8a5f2c24f75dae4d0acdc (diff) | |
| download | vim-ai-4e50a6e82d823687d372c7f9c86eb09b9ca6f130.tar.gz | |
custom prompts docu
Diffstat (limited to '')
| -rw-r--r-- | README.md | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -14,10 +14,10 @@ Complete text and chat with GPT in vim using OpenAI. ```sh # configure openai api key https://platform.openai.com/account/api-keys -echo "YOUR_OPENAPI_TOKEN" > ~/.config/openai.token +echo "YOUR_OPENAI_API_KEY" > ~/.config/openai.token # alternatively using environment variable -export OPENAI_API_TOKEN="YOUR_OPENAPI_TOKEN" +export OPENAI_API_KEY="YOUR_OPENAI_API_KEY" ``` Add plugin to your `.vimrc` using `vim-plug`: @@ -53,6 +53,26 @@ The plugin requires `python3` and `pip3` to install and run [openai-python](http `(visual selection)? :AIChat {instruction}?` - start a new conversation given the selection, the instruction or both +#### Custom conversation prompts + +You can edit and save the conversation to an `.aichat` file and restore it later. +This allows you to create re-usable custom prompts. For example: + +``` +# ./refactoring-prompt.aichat + +>>> system + +You are a Clean Code expert, I have the following code, please refactor it in a more clean and concise way so that my colleagues can maintain the code more easily. Also, explain why you want to refactor the code so that I can add the explanation to the Pull Request. + +>>> user + +[attach code] + +``` + +Supported chat roles are **`>>> system`**, **`>>> user`** and **`<<< assistant`** + ## Configuration ### Key bindings @@ -73,6 +93,10 @@ To customize and re-use prompts it is useful to put some context to the language vnoremap <leader>s :AIEdit fix grammar and spelling and use formal language<CR> nnoremap <leader>s :AIEdit fix grammar and spelling and use formal language<CR> +" key binding to trigger chat +vnoremap <leader>c :AIChat <CR> +nnoremap <leader>c :AIChat <CR> + " command with custom context (vim-ai functions: AIRun, AIEditRun, AIChatRun) command! -range -nargs=? AICode <line1>,<line2>call AIRun("Programming syntax is " . &filetype . ", " . <f-args>) ``` |