From 4e50a6e82d823687d372c7f9c86eb09b9ca6f130 Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Mon, 6 Mar 2023 17:33:41 +0100 Subject: custom prompts docu --- README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 65a55df..c8adf61 100644 --- a/README.md +++ b/README.md @@ -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 s :AIEdit fix grammar and spelling and use formal language nnoremap s :AIEdit fix grammar and spelling and use formal language +" key binding to trigger chat +vnoremap c :AIChat +nnoremap c :AIChat + " command with custom context (vim-ai functions: AIRun, AIEditRun, AIChatRun) command! -range -nargs=? AICode ,call AIRun("Programming syntax is " . &filetype . ", " . ) ``` -- cgit v1.2.3