gptel, gptel-curl: Allow protocol (https) to be set separately

This commit is contained in:
Karthik Chikmagalur 2023-10-23 10:45:59 -07:00
parent ed0bfc9ed1
commit 62a6020302
2 changed files with 6 additions and 2 deletions

View file

@ -41,7 +41,8 @@
"Produce list of arguments for calling Curl.
PROMPTS is the data to send, TOKEN is a unique identifier."
(let* ((url (format "https://%s/v1/chat/completions" gptel-host))
(let* ((url (format "%s://%s/v1/chat/completions"
gptel-protocol gptel-host))
(data (encode-coding-string
(json-encode (gptel--request-data prompts))
'utf-8))

View file

@ -86,6 +86,9 @@
:group 'gptel
:type 'string)
(defvar gptel-protocol "https"
"Protocol used to query `gptel-host'.")
(defcustom gptel-proxy ""
"Path to a proxy to use for gptel interactions.
Passed to curl via --proxy arg, for example \"proxy.yourorg.com:80\"
@ -774,7 +777,7 @@ the response is inserted into the current buffer after point."
(encode-coding-string
(json-encode (gptel--request-data (plist-get info :prompt)))
'utf-8)))
(url-retrieve (format "https://%s/v1/chat/completions" gptel-host)
(url-retrieve (format "%s://%s/v1/chat/completions" gptel-protocol gptel-host)
(lambda (_)
(pcase-let ((`(,response ,http-msg ,error)
(gptel--url-parse-response (current-buffer))))