summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Bielik <mx.bielik@gmail.com>2023-04-05 18:53:43 +0200
committerMartin Bielik <mx.bielik@gmail.com>2023-04-05 18:53:43 +0200
commita37328c59c5e42c5286f0032cece05e3ddc1e692 (patch)
tree3431e6a187b6e037b136c21638755b9b2760bb0f
parentc97fbfdccb65334243f91bb574b7fb00740726dc (diff)
downloadvim-ai-a37328c59c5e42c5286f0032cece05e3ddc1e692.tar.gz
chat engine docu, defaults
-rw-r--r--README.md39
-rw-r--r--doc/vim-ai.txt3
-rw-r--r--plugin/vim-ai.vim17
3 files changed, 42 insertions, 17 deletions
diff --git a/README.md b/README.md
index f92377c..b7d9577 100644
--- a/README.md
+++ b/README.md
@@ -105,7 +105,6 @@ nnoremap <leader>c :AIChat<CR>
nnoremap <leader>r :AIRedo<CR>
```
-
### Interface configuration
Default interface configuration:
@@ -155,7 +154,9 @@ Below are listed available options along with default values:
```vim
" :AI
" - https://platform.openai.com/docs/api-reference/completions
+" - see how to configure chat engine for completion in the section below
let g:vim_ai_complete = {
+\ "engine": "complete",
\ "options": {
\ "model": "text-davinci-003",
\ "max_tokens": 1000,
@@ -166,7 +167,9 @@ let g:vim_ai_complete = {
" :AIEdit
" - https://platform.openai.com/docs/api-reference/completions
+" - see how to configure chat engine for edits in the section below
let g:vim_ai_edit = {
+\ "engine": "complete",
\ "options": {
\ "model": "text-davinci-003",
\ "max_tokens": 1000,
@@ -183,10 +186,44 @@ let g:vim_ai_chat = {
\ "max_tokens": 1000,
\ "temperature": 1,
\ "request_timeout": 10,
+\ "initial_prompt": "",
\ },
\}
```
+### Using chat engine for completion and edits
+
+It is possible to configure chat models, such as `gpt-3.5-turbo`, to be used in `:AI` and `:AIEdit` commands.
+These models are cheaper, but currently less suitable for code editing/completion, as they respond with human-like text and commentary.
+
+Depending on the use case, a good initial prompt can help to instruct the chat model to respond in the desired way:
+
+```vim
+let initial_prompt =<< trim END
+>>> system
+
+You are going to play a role of a completion engine with following parameters:
+Task: Provide compact code/text completion, generation, transformation or explanation
+Topic: general programming and text editing
+Style: Plain result without any commentary, unless commentary is necessary
+Audience: Users of text editor and programmers that need to transform/generate text
+END
+
+let chat_engine_config = {
+\ "engine": "chat",
+\ "options": {
+\ "model": "gpt-3.5-turbo",
+\ "max_tokens": 1000,
+\ "temperature": 0.1,
+\ "request_timeout": 20,
+\ "initial_prompt": initial_prompt,
+\ },
+\}
+
+let g:vim_ai_complete = chat_engine_config
+let g:vim_ai_complete = chat_engine_config
+```
+
### Custom commands
To customize and re-use prompts it is useful to put some context in it. You can do it by prepending text to AI commands.
diff --git a/doc/vim-ai.txt b/doc/vim-ai.txt
index d9c3eeb..ea8af3f 100644
--- a/doc/vim-ai.txt
+++ b/doc/vim-ai.txt
@@ -22,6 +22,7 @@ https://github.com/madox2/vim-ai
Options: >
let g:vim_ai_complete = {
+ \ "engine": "complete",
\ "options": {
\ "model": "text-davinci-003",
\ "max_tokens": 1000,
@@ -41,6 +42,7 @@ https://platform.openai.com/docs/api-reference/completions
Options: >
let g:vim_ai_edit = {
+ \ "engine": "complete",
\ "options": {
\ "model": "text-davinci-003",
\ "max_tokens": 1000,
@@ -65,6 +67,7 @@ Options: >
\ "max_tokens": 1000,
\ "temperature": 1,
\ "request_timeout": 10,
+ \ "initial_prompt": "",
\ },
\ "ui": {
\ "open_chat_command": "below new | call vim_ai#MakeScratchWindow()",
diff --git a/plugin/vim-ai.vim b/plugin/vim-ai.vim
index c2b5faf..1a7695e 100644
--- a/plugin/vim-ai.vim
+++ b/plugin/vim-ai.vim
@@ -16,27 +16,13 @@ let g:vim_ai_edit_default = {
\ "request_timeout": 20,
\ },
\}
-let s:vim_ai_chat_initial_prompt =<< trim END
->>> user
-
-You are going to play a role of completion engine with following parameters:
-Task: Provide compact code/text completion, generation, transformation or explanation
-Topic: general programming and text editing
-Style: Plain result without any commentary, unless commentary is necessary
-Audience: Users of text editor and programmers that need to transform/generate text
-
-<<< assistant
-
-Okay
-END
let g:vim_ai_chat_default = {
-\ "engine": "chat",
\ "options": {
\ "model": "gpt-3.5-turbo",
\ "max_tokens": 1000,
\ "temperature": 1,
\ "request_timeout": 20,
-\ "initial_prompt": s:vim_ai_chat_initial_prompt,
+\ "initial_prompt": "",
\ },
\ "ui": {
\ "open_chat_command": "below new | call vim_ai#MakeScratchWindow()"
@@ -142,7 +128,6 @@ function! AIChatRun(is_selection, ...) range
let s:last_instruction = instruction
let s:last_is_selection = a:is_selection
- let engine = g:vim_ai_chat['engine']
let options = g:vim_ai_chat['options']
execute "py3file " . s:chat_py
set nopaste