Skip to content

Commit ca3887b

Browse files
author
skywind3000
committed
Add support for specifying OpenAI request URL in gptcommit.vim plugin
- Added a new option `g:gpt_commit_url` to the plugin's options - If the URL is specified, it will be passed to the gptcommit.py script as the `--url` argument - The script will use this URL for making requests to the OpenAI API
1 parent 0c92af5 commit ca3887b

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Generate proper git commit message using ChatGPT in Vim:
44

55
![](https://skywind3000.github.io/images/p/misc/2024/gptcommit1.gif)
66

7+
This plugin provides a `:GptCommit` command to generate commit message and append in the current buffer.
78

89
## Quick start
910

@@ -46,6 +47,8 @@ If the bang (`!`) is included, `:GptCommand` will not append any text to the cur
4647
:echo @*
4748
```
4849

50+
You will see the result in the command line.
51+
4952
## Options
5053

5154
| Name | Required | Default | Description |
@@ -57,6 +60,7 @@ If the bang (`!`) is included, `:GptCommand` will not append any text to the cur
5760
| g:gpt_commit_model | - | `'gpt-3.5-turbo'` | ChatGPT model |
5861
| g:gpt_commit_staged | - | `1` | set to 1 to use staged diff |
5962
| g:gpt_commit_max_line | - | `160` | max diff lines to reference |
63+
| g:gpt_commit_url | - | `''` | openai request url |
6064

6165
## Script
6266

@@ -79,3 +83,14 @@ available options:
7983

8084
## Credit
8185

86+
If you find this plugin amusing, you might also be interested in my other vim plugins, such as:
87+
88+
- [asynctasks.vim](https://github.com/skywind3000/asynctasks.vim): Modern Task System for Project Building/Testing/Deploying.
89+
- [vim-auto-popmenu](https://github.com/skywind3000/vim-auto-popmenu): Display the Completion Menu Automantically.
90+
- [vim-color-export](https://github.com/skywind3000/vim-color-export): A tool to backport NeoVim colorschemes to Vim.
91+
- [vim-color-patch](https://github.com/skywind3000/vim-color-patch): Load colorscheme patch script automatically.
92+
- [vim-navigator](https://github.com/skywind3000/vim-navigator): Navigate Your Commands Easily.
93+
- [vim-rt-format](https://github.com/skywind3000/vim-rt-format): Prettify Current Line on Enter.
94+
- [vim-quickui](https://github.com/skywind3000/vim-quickui): The missing UI extensions for Vim 8.2 (and NeoVim 0.4).
95+
96+

autoload/gptcommit/gpt.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ function! gptcommit#gpt#generate(path) abort
6060
if get(g:, 'gpt_commit_fake', 0)
6161
let args += ['--fake']
6262
endif
63+
let url = get(g:, 'gpt_commit_url', '')
64+
if url != ''
65+
let args += ['--url=' .. url]
66+
endif
6367
let path = a:path
6468
if has('win32') || has('win64') || has('win95') || has('win16')
6569
let path = tr(path, '\', '/')

bin/gptcommit.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ def main(argv = None):
350350
prompt = options['prompt']
351351
if prompt:
352352
OPTIONS['prompt'] = prompt
353+
if 'url' in options:
354+
url = options['url']
355+
if url:
356+
OPTIONS['url'] = url
353357
if args:
354358
OPTIONS['path'] = os.path.abspath(args[0])
355359
if not os.path.exists(args[0]):
@@ -376,6 +380,8 @@ def main(argv = None):
376380
if proxy.startswith('socks5://'):
377381
proxy = 'socks5h://' + proxy[9:]
378382
opts['proxy'] = proxy
383+
if 'url' in OPTIONS:
384+
opts['url'] = OPTIONS['url']
379385
if 'fake' not in options:
380386
obj = chatgpt_request(msgs, OPTIONS['key'], opts)
381387
else:

0 commit comments

Comments
 (0)