Skip to content

Trimming LLM responses #336

Answered by karthink
ProjectMoon asked this question in Q&A
Jun 30, 2024 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

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?

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@ProjectMoon
Comment options

@karthink
Comment options

@ProjectMoon
Comment options

@ProjectMoon
Comment options

Answer selected by ProjectMoon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants