gptel: correct system message with gptel-request

gptel.el (gptel-request): when using `gptel-request', let-bind
`gptel--system-message' around call to `gptel--create-prompt' when
the prompt argument is null.  This allows `gptel-request' to be
used to send the buffer as a prompt with a different system
message from `gptel--system-message' for that buffer.

---------

Co-authored-by: Neil Fulwiler <neil@fulwiler.me>
This commit is contained in:
Neil Fulwiler 2023-07-13 18:31:18 -04:00 committed by GitHub
parent 9c4af204a3
commit 4356f6fbec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -402,7 +402,9 @@ Model parameters can be let-bound around calls to this function."
(set-marker (make-marker) position buffer))))
(full-prompt
(cond
((null prompt) (gptel--create-prompt start-marker))
((null prompt)
(let ((gptel--system-message system))
(gptel--create-prompt start-marker)))
((stringp prompt)
`((:role "system" :content ,system)
(:role "user" :content ,prompt)))