gptel-transient: Adjust several menu options
* gptel-transient.el (gptel-menu, gptel-system-prompt--setup, gptel-system-prompt, gptel--infix-temperature, transient-format-value, gptel--additional-directive, gptel--suffix-system-message): Tweak to the "additional directive" overlay display. `gptel-menu` changes based on feedback from #249 (thanks to @jwr): - Keys to set the system message are remapped from "h" to "s" (mnemonic) - `gptel--infix-temperature` is now hidden by default and requires enabling `gptel-expert-commands`
This commit is contained in:
parent
7d19874d4c
commit
65dd461f4d
1 changed files with 16 additions and 13 deletions
|
@ -123,19 +123,19 @@ which see."
|
|||
gptel--system-message (max (- (window-width) 6) 14) nil nil t)))
|
||||
[""
|
||||
"Instructions"
|
||||
("h" "Set system message" gptel-system-prompt :transient t)
|
||||
("s" "Set system message" gptel-system-prompt :transient t)
|
||||
(gptel--additional-directive :if (lambda () gptel-expert-commands))]]
|
||||
[["Model Parameters"
|
||||
(gptel--infix-provider)
|
||||
;; (gptel--infix-model)
|
||||
(gptel--infix-max-tokens)
|
||||
(gptel--infix-num-messages-to-send)
|
||||
(gptel--infix-temperature)]
|
||||
(gptel--infix-temperature :if (lambda () gptel-expert-commands))]
|
||||
["Prompt from"
|
||||
("p" "Minibuffer instead" "p")
|
||||
("y" "Kill-ring instead" "y")
|
||||
""
|
||||
("i" "Replace/Delete prompt" "i")]
|
||||
("i" "Respond in place" "i")]
|
||||
["Response to"
|
||||
("m" "Minibuffer instead" "m")
|
||||
("g" "gptel session" "g"
|
||||
|
@ -214,7 +214,7 @@ which see."
|
|||
'gptel-system-prompt
|
||||
(cl-loop for (type . prompt) in gptel-directives
|
||||
;; Avoid clashes with the custom directive key
|
||||
with unused-keys = (delete ?h (number-sequence ?a ?z))
|
||||
with unused-keys = (delete ?s (number-sequence ?a ?z))
|
||||
with width = (window-width)
|
||||
for name = (symbol-name type)
|
||||
for key = (seq-find (lambda (k) (member k unused-keys)) name (seq-first unused-keys))
|
||||
|
@ -268,9 +268,11 @@ More extensive system messages can be useful for specific tasks.
|
|||
|
||||
Customize `gptel-directives' for task-specific prompts."
|
||||
[:description
|
||||
(lambda () (format "Current directive: %s"
|
||||
(truncate-string-to-width
|
||||
gptel--system-message 100 nil nil t)))
|
||||
(lambda () (format "System Message: %s"
|
||||
(string-replace
|
||||
"\n" "⮐"
|
||||
(truncate-string-to-width
|
||||
gptel--system-message 100 nil nil t))))
|
||||
:class transient-column
|
||||
:setup-children gptel-system-prompt--setup
|
||||
:pad-keys t])
|
||||
|
@ -411,11 +413,11 @@ responses."
|
|||
|
||||
(transient-define-infix gptel--infix-temperature ()
|
||||
"Temperature of request."
|
||||
:description "Randomness (0 - 2.0)"
|
||||
:description "Temperature (0 - 2.0)"
|
||||
:class 'transient-lisp-variable
|
||||
:variable 'gptel-temperature
|
||||
:key "-t"
|
||||
:prompt "Set temperature (0.0-2.0, leave empty for default): "
|
||||
:prompt "Temperature controls the response randomness (0.0-2.0, leave empty for default): "
|
||||
:reader 'gptel--transient-read-variable)
|
||||
|
||||
;; ** Infix for the refactor/rewrite system message
|
||||
|
@ -456,7 +458,8 @@ Also format its value in the Transient menu."
|
|||
(ov (oref obj overlay))
|
||||
(argument (oref obj argument)))
|
||||
;; Making an overlay
|
||||
(when (and value (not (string-empty-p value)))
|
||||
(if (or (not value) (string-empty-p value))
|
||||
(when ov (delete-overlay ov))
|
||||
(oset obj overlay (gptel--instructions-make-overlay value ov))
|
||||
(letrec ((ov-clear-hook
|
||||
(lambda () (when-let* ((ov (oref obj overlay))
|
||||
|
@ -467,7 +470,7 @@ Also format its value in the Transient menu."
|
|||
(add-hook 'transient-exit-hook ov-clear-hook)))
|
||||
;; Updating transient menu display
|
||||
(if value
|
||||
(propertize (concat argument (truncate-string-to-width value 15 nil nil "..."))
|
||||
(propertize (concat argument (truncate-string-to-width value 25 nil nil "..."))
|
||||
'face 'transient-value)
|
||||
(propertize
|
||||
(concat "(" (symbol-name (oref obj display-nil)) ")")
|
||||
|
@ -500,7 +503,7 @@ Or in an extended conversation:
|
|||
:format " %k %d %v"
|
||||
:key "d"
|
||||
:argument ":"
|
||||
:description "Additional directive"
|
||||
:description "Add directive"
|
||||
:transient t)
|
||||
|
||||
(defun gptel--additional-directive-get (args)
|
||||
|
@ -736,7 +739,7 @@ This uses the prompts in the variable
|
|||
"Edit LLM directives."
|
||||
:transient 'transient--do-exit
|
||||
:description "Set custom directives"
|
||||
:key "h"
|
||||
:key "s"
|
||||
(interactive)
|
||||
(let ((orig-buf (current-buffer))
|
||||
(msg-start (make-marker)))
|
||||
|
|
Loading…
Add table
Reference in a new issue