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)
|
||||
(set-marker (make-marker) position buffer))))
|
||||
(full-prompt
|
||||
(cond
|
||||
((null prompt)
|
||||
(let ((gptel--system-message system))
|
||||
(gptel--create-prompt start-marker)))
|
||||
((stringp prompt)
|
||||
`((:role "system" :content ,system)
|
||||
(:role "user" :content ,prompt)))
|
||||
((consp prompt) prompt)))
|
||||
(cond
|
||||
((null prompt)
|
||||
(let ((gptel--system-message system))
|
||||
(gptel--create-prompt start-marker)))
|
||||
((stringp prompt)
|
||||
;; FIXME Dear reader, welcome to Jank City:
|
||||
(with-temp-buffer
|
||||
(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
|
||||
:buffer buffer
|
||||
:position start-marker)))
|
||||
|
|
Loading…
Add table
Reference in a new issue