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
|
||||
gptel--system-message (max (- (window-width) 14) 20) nil nil t)))
|
||||
("h" "Set directives for chat" gptel-system-prompt)]
|
||||
[["Parameters"
|
||||
[["Session Parameters"
|
||||
(gptel--infix-max-tokens)
|
||||
(gptel--infix-num-messages-to-send)
|
||||
(gptel--infix-temperature)
|
||||
|
@ -147,7 +147,7 @@ will get progressively longer!"
|
|||
:description "GPT Model: "
|
||||
:class 'transient-lisp-variable
|
||||
:variable 'gptel--model
|
||||
:key "M"
|
||||
:key "m"
|
||||
:choices '("gpt-3.5-turbo-0301" "gpt-3.5-turbo")
|
||||
:reader (lambda (prompt &rest _)
|
||||
(completing-read
|
||||
|
@ -166,7 +166,7 @@ will get progressively longer!"
|
|||
|
||||
(transient-define-suffix gptel--suffix-send-existing ()
|
||||
"Send query in existing chat session."
|
||||
:if (lambda () (use-region-p))
|
||||
:if #'use-region-p
|
||||
:key "E"
|
||||
:description "Send in existing session"
|
||||
(interactive)
|
||||
|
@ -181,15 +181,19 @@ will get progressively longer!"
|
|||
(with-current-buffer buf
|
||||
(goto-char (point-max))
|
||||
(insert prompt)
|
||||
(pop-to-buffer buf))))
|
||||
(gptel-send))
|
||||
(pop-to-buffer buf)))
|
||||
|
||||
(transient-define-suffix gptel--suffix-send-new ()
|
||||
"Send query in new session."
|
||||
:if (lambda () (use-region-p))
|
||||
:if #'use-region-p
|
||||
:description "Send in new session"
|
||||
:key "N"
|
||||
(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 ()
|
||||
"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.
|
||||
|
||||
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
|
||||
(read-string "Session name: " (generate-new-buffer-name gptel-default-session))
|
||||
gptel-default-session)
|
||||
|
|
Loading…
Add table
Reference in a new issue