-
Notifications
You must be signed in to change notification settings - Fork 405
Commonly requested features
How to achieve some commonly requested gptel behavior.
You can use gptel-highlight-mode to highlight text regions recognized as part of the LLM response, but there is no built-in way to edit the "role" of a region. You can use this command to change the role of a text region:
(defun gptel-mark-region-role (start end role)
"Mark region from START to END with the llm or user role."
(interactive (list (region-beginning) (region-end)
(completing-read "Mark region role as: " '(response prompt))))
(if (or (not transient-mark-mode)
(use-region-p))
(with-silent-modifications
(put-text-property start end 'gptel (and (equal role "response") 'response))
(message "Region marked as %s" role))
(message "No region specified, action canceled")))Any options you set from gptel's transient menu (except for the model parameters) are only active for the next query. If you want these flags to be persistent, you can press C-x s when in the transient menu:

Now options you choose will remain set until you change them. Pressing C-x C-s will save them across Emacs sessions.
However, you still have to bring up the menu to send a query with these saved options. You can replace your usage of gptel-send with the following command if you want these options to be applied without having to bring up the menu:
(defun gptel-send-with-options (&optional arg)
"Send query. With prefix ARG open gptel's menu instead."
(interactive "P")
(if arg
(call-interactively 'gptel-menu)
(gptel--suffix-send (transient-args 'gptel-menu))))