emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gptel 3308449761 133/273: gptel: Fix prompt string handlin


From: ELPA Syncer
Subject: [nongnu] elpa/gptel 3308449761 133/273: gptel: Fix prompt string handling in gptel-request
Date: Wed, 1 May 2024 10:02:13 -0400 (EDT)

branch: elpa/gptel
commit 33084497619f159997f605f4bcdb39c75f887ec7
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>

    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.
---
 gptel.el | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/gptel.el b/gptel.el
index 3d019069c3..95c9fde84d 100644
--- a/gptel.el
+++ b/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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]