Skip to content

Commit 4fcc42e

Browse files
author
skywind3000
committed
Refactor gptcommit.py to dynamically form the API URL based on the provided options and update a test case function with new URL and additional arguments.
1 parent 920ae88 commit 4fcc42e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bin/gptcommit.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#----------------------------------------------------------------------
2020
def chatgpt_request(messages, apikey, opts):
2121
import urllib, urllib.request, json
22-
url = opts.get('url', "https://api.openai.com/v1/chat/completions")
22+
url = opts.get('url', 'https://api.openai.com').rstrip('/')
23+
url = url + "/v1/chat/completions"
2324
proxy = opts.get('proxy', None)
2425
timeout = opts.get('timeout', 20000)
2526
d = {'messages': messages}
@@ -484,10 +485,11 @@ def test3():
484485
return 0
485486
def test4():
486487
apikey = open(os.path.expanduser(keyfile), 'r').read().strip('\r\n\t ')
487-
# print(apikey)
488+
print(apikey)
488489
proxy = '--proxy=socks5h://127.0.0.1:1080'
489490
args = []
490-
args = ['--key=' + apikey, proxy, 'c:/share/vim/lib']
491+
args += ['--url=' + 'https://api.v3.cm/v1/chat/completions']
492+
args += ['--key=' + apikey, proxy, 'c:/share/vim/lib']
491493
# args = ['--key=' + apikey, 'c:/share/plugin']
492494
# args = ['-h']
493495
main(args)

0 commit comments

Comments
 (0)