gptel: Fix prompt string handling in gptel-request
* gptel.el (gptel-request): When `gptel-request` is supplied a string, it creates the full prompt plist according to the OpenAI API. Fix by inserting it into a temp buffer and using the cl-generic dispatch to parse the buffer instead. This is a janky solution but the best possible one without defining another generic function just to handle prompt strings differently per API.
This commit is contained in:
parent
66d2bafad6
commit
3308449761
1 changed files with 12 additions and 8 deletions
20
gptel.el
20
gptel.el
|
@ -632,14 +632,18 @@ Model parameters can be let-bound around calls to this function."
|
||||||
((integerp position)
|
((integerp position)
|
||||||
(set-marker (make-marker) position buffer))))
|
(set-marker (make-marker) position buffer))))
|
||||||
(full-prompt
|
(full-prompt
|
||||||
(cond
|
(cond
|
||||||
((null prompt)
|
((null prompt)
|
||||||
(let ((gptel--system-message system))
|
(let ((gptel--system-message system))
|
||||||
(gptel--create-prompt start-marker)))
|
(gptel--create-prompt start-marker)))
|
||||||
((stringp prompt)
|
((stringp prompt)
|
||||||
`((:role "system" :content ,system)
|
;; FIXME Dear reader, welcome to Jank City:
|
||||||
(:role "user" :content ,prompt)))
|
(with-temp-buffer
|
||||||
((consp prompt) prompt)))
|
(let ((gptel--system-message system)
|
||||||
|
(gptel-backend (buffer-local-value 'gptel-backend buffer)))
|
||||||
|
(insert prompt)
|
||||||
|
(gptel--create-prompt))))
|
||||||
|
((consp prompt) prompt)))
|
||||||
(info (list :prompt full-prompt
|
(info (list :prompt full-prompt
|
||||||
:buffer buffer
|
:buffer buffer
|
||||||
:position start-marker)))
|
:position start-marker)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue