Skip to content

Commit

Permalink
Refactor gptcommit.py to dynamically form the API URL based on the pr…
Browse files Browse the repository at this point in the history
…ovided options and update a test case function with new URL and additional arguments.
  • Loading branch information
skywind3000 committed Mar 21, 2024
1 parent 920ae88 commit 4fcc42e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/gptcommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#----------------------------------------------------------------------
def chatgpt_request(messages, apikey, opts):
import urllib, urllib.request, json
url = opts.get('url', "https://api.openai.com/v1/chat/completions")
url = opts.get('url', 'https://api.openai.com').rstrip('/')
url = url + "/v1/chat/completions"
proxy = opts.get('proxy', None)
timeout = opts.get('timeout', 20000)
d = {'messages': messages}
Expand Down Expand Up @@ -484,10 +485,11 @@ def test3():
return 0
def test4():
apikey = open(os.path.expanduser(keyfile), 'r').read().strip('\r\n\t ')
# print(apikey)
print(apikey)
proxy = '--proxy=socks5h://127.0.0.1:1080'
args = []
args = ['--key=' + apikey, proxy, 'c:/share/vim/lib']
args += ['--url=' + 'https://api.v3.cm/v1/chat/completions']
args += ['--key=' + apikey, proxy, 'c:/share/vim/lib']
# args = ['--key=' + apikey, 'c:/share/plugin']
# args = ['-h']
main(args)
Expand Down

0 comments on commit 4fcc42e

Please sign in to comment.