gptel-transient: Improve "send in existing/new session" option
gptel-transient.el (gptel-send-menu, gptel--suffix-send-existing, gptel--suffix-send-new, gptel--infix-model): Make menu keybindings more uniform and improve descriptions. Suffixes to send queries in existing/new sessions will now automatically send them instead of just yanking the text into these sessions.
This commit is contained in:
parent
9da22155de
commit
cd6d90b24d
2 changed files with 12 additions and 7 deletions
|
@ -37,7 +37,7 @@
|
||||||
(truncate-string-to-width
|
(truncate-string-to-width
|
||||||
gptel--system-message (max (- (window-width) 14) 20) nil nil t)))
|
gptel--system-message (max (- (window-width) 14) 20) nil nil t)))
|
||||||
("h" "Set directives for chat" gptel-system-prompt)]
|
("h" "Set directives for chat" gptel-system-prompt)]
|
||||||
[["Parameters"
|
[["Session Parameters"
|
||||||
(gptel--infix-max-tokens)
|
(gptel--infix-max-tokens)
|
||||||
(gptel--infix-num-messages-to-send)
|
(gptel--infix-num-messages-to-send)
|
||||||
(gptel--infix-temperature)
|
(gptel--infix-temperature)
|
||||||
|
@ -147,7 +147,7 @@ will get progressively longer!"
|
||||||
:description "GPT Model: "
|
:description "GPT Model: "
|
||||||
:class 'transient-lisp-variable
|
:class 'transient-lisp-variable
|
||||||
:variable 'gptel--model
|
:variable 'gptel--model
|
||||||
:key "M"
|
:key "m"
|
||||||
:choices '("gpt-3.5-turbo-0301" "gpt-3.5-turbo")
|
:choices '("gpt-3.5-turbo-0301" "gpt-3.5-turbo")
|
||||||
:reader (lambda (prompt &rest _)
|
:reader (lambda (prompt &rest _)
|
||||||
(completing-read
|
(completing-read
|
||||||
|
@ -166,7 +166,7 @@ will get progressively longer!"
|
||||||
|
|
||||||
(transient-define-suffix gptel--suffix-send-existing ()
|
(transient-define-suffix gptel--suffix-send-existing ()
|
||||||
"Send query in existing chat session."
|
"Send query in existing chat session."
|
||||||
:if (lambda () (use-region-p))
|
:if #'use-region-p
|
||||||
:key "E"
|
:key "E"
|
||||||
:description "Send in existing session"
|
:description "Send in existing session"
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -181,15 +181,19 @@ will get progressively longer!"
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(insert prompt)
|
(insert prompt)
|
||||||
(pop-to-buffer buf))))
|
(gptel-send))
|
||||||
|
(pop-to-buffer buf)))
|
||||||
|
|
||||||
(transient-define-suffix gptel--suffix-send-new ()
|
(transient-define-suffix gptel--suffix-send-new ()
|
||||||
"Send query in new session."
|
"Send query in new session."
|
||||||
:if (lambda () (use-region-p))
|
:if #'use-region-p
|
||||||
:description "Send in new session"
|
:description "Send in new session"
|
||||||
:key "N"
|
:key "N"
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((current-prefix-arg t)) (call-interactively #'gptel)))
|
(let* ((current-prefix-arg t)
|
||||||
|
(buf (call-interactively #'gptel)))
|
||||||
|
(and (bufferp buf)
|
||||||
|
(with-current-buffer buf (gptel-send)))))
|
||||||
|
|
||||||
(transient-define-suffix gptel--suffix-system-message ()
|
(transient-define-suffix gptel--suffix-system-message ()
|
||||||
"Set directives sent to ChatGPT."
|
"Set directives sent to ChatGPT."
|
||||||
|
|
3
gptel.el
3
gptel.el
|
@ -315,7 +315,8 @@ With a prefix arg, query for a (new) session name.
|
||||||
|
|
||||||
Ask for API-KEY if `gptel-api-key' is unset.
|
Ask for API-KEY if `gptel-api-key' is unset.
|
||||||
|
|
||||||
If region is active, use it as the INITIAL prompt."
|
If region is active, use it as the INITIAL prompt. Returns the
|
||||||
|
buffer created or switched to."
|
||||||
(interactive (list (if current-prefix-arg
|
(interactive (list (if current-prefix-arg
|
||||||
(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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue