Trimming LLM responses #336
-
I'm working on making a prompt/settings that I will bind to keys for completing a prose paragraph. The problem is that often, the models write their responses a few lines below my cursor, or with spaces in front. Is there a way using the post stream hook to trim the whitespace and have the LLM response begin from the cursor? I know it is probably pretty easily possible, I just don't know enough elisp to do this properly. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can do this from the post response hook: (defun gptel-trim-leading-whitespace (beg _)
"Delete leading whitespace before replies."
(unless gptel-mode
(save-excursion
(goto-char beg)
(delete-region
(point) (progn (skip-syntax-backward " ")
(point))))))
(add-hook 'gptel-post-response-functions #'gptel-trim-leading-whitespace) Should the default behavior of gptel in regular (i.e. non chat) be to not inject any whitespace? |
Beta Was this translation helpful? Give feedback.
You can do this from the post response hook:
Should the default behavior of gptel in regular (i.e. non chat) be to not inject any whitespace?