-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
31 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function ai#RunWithInitialPrompt(func, prompt, range, ...) range | ||
let l:config = { | ||
\ "options": { | ||
\ "initial_prompt": ">>> system\n" . a:prompt, | ||
\ }, | ||
\} | ||
let l:prompt = a:0 ? a:1 : '' | ||
call call(a:func, [a:range, l:config, l:prompt]) | ||
endfunction | ||
function ai#GitCommitMessage() | ||
let l:diff = system('git --no-pager diff --staged') | ||
let l:prompt = "generate a short git commit message from the diff below, using conventional commit format:\n" . l:diff | ||
let l:range = 0 | ||
let l:config = { | ||
\ "engine": "chat", | ||
\ "options": { | ||
\ "endpoint_url": g:openai_proxy_url, | ||
\ "model": "gpt-4", | ||
\ "initial_prompt": ">>> system\nyou are a code assistant", | ||
\ "temperature": 1, | ||
\ }, | ||
\} | ||
call vim_ai#AIRun(l:range, l:config, l:prompt) | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
command -nargs=0 -buffer AICommitMessage call ai#GitCommitMessage() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters