gptel: Avoid logging url-retrieve messages
- Use `read-passwd' to read the API key.
This commit is contained in:
parent
deeb606409
commit
86bf0c9f74
1 changed files with 14 additions and 6 deletions
14
gptel.el
14
gptel.el
|
@ -134,10 +134,12 @@ Return the response buffer."
|
||||||
;; :temperature 1.0
|
;; :temperature 1.0
|
||||||
;; :top_p 1.0
|
;; :top_p 1.0
|
||||||
:messages [,@prompts]))))
|
:messages [,@prompts]))))
|
||||||
|
(let ((inhibit-message t)
|
||||||
|
(message-log-max nil))
|
||||||
(pcase-let ((`(,_ . ,buffer)
|
(pcase-let ((`(,_ . ,buffer)
|
||||||
(aio-await
|
(aio-await
|
||||||
(aio-url-retrieve "https://api.openai.com/v1/chat/completions"))))
|
(aio-url-retrieve "https://api.openai.com/v1/chat/completions"))))
|
||||||
buffer)))
|
buffer))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(define-minor-mode gptel-mode
|
(define-minor-mode gptel-mode
|
||||||
|
@ -160,11 +162,17 @@ Ask for API-KEY if `gptel-api-key' is unset."
|
||||||
(read-string "Session name: " (generate-new-buffer-name gptel-default-session))
|
(read-string "Session name: " (generate-new-buffer-name gptel-default-session))
|
||||||
gptel-default-session)
|
gptel-default-session)
|
||||||
(or gptel-api-key
|
(or gptel-api-key
|
||||||
(read-string "OpenAI API key: "))))
|
(setq gptel-api-key
|
||||||
|
(read-passwd "OpenAI API key: ")))))
|
||||||
(unless api-key
|
(unless api-key
|
||||||
(user-error "No API key available"))
|
(user-error "No API key available"))
|
||||||
(with-current-buffer (get-buffer-create name)
|
(with-current-buffer (get-buffer-create name)
|
||||||
(unless (eq major-mode gptel-default-mode) (funcall gptel-default-mode))
|
(cond ;Set major mode
|
||||||
|
((eq major-mode gptel-default-mode))
|
||||||
|
((eq gptel-default-mode 'text-mode)
|
||||||
|
(text-mode)
|
||||||
|
(visual-line-mode 1))
|
||||||
|
(t (funcall gptel-default-mode)))
|
||||||
(unless gptel-mode (gptel-mode 1))
|
(unless gptel-mode (gptel-mode 1))
|
||||||
(if (bobp) (insert gptel-prompt-string))
|
(if (bobp) (insert gptel-prompt-string))
|
||||||
(pop-to-buffer (current-buffer))
|
(pop-to-buffer (current-buffer))
|
||||||
|
|
Loading…
Add table
Reference in a new issue