branch: elpa/gptel
commit c3da255ad440c278fce536f74158e0c6c384c183
Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>

    gptel-gemini: Add system message feature
    
    * gptel-gemini.el (gptel--request-data, gptel--parse-buffer):
    The Gemini API now allows for system messages.  Add it and undo
    the previous method of prepending it to the user prompt.
---
 gptel-gemini.el | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/gptel-gemini.el b/gptel-gemini.el
index 0b3d6a5a64..8b7d1ba6ae 100644
--- a/gptel-gemini.el
+++ b/gptel-gemini.el
@@ -61,7 +61,8 @@
 (cl-defmethod gptel--request-data ((_backend gptel-gemini) prompts)
   "JSON encode PROMPTS for sending to Gemini."
   (let ((prompts-plist
-         `(:contents [,@prompts]
+         `(:system_instruction (:parts (:text ,gptel--system-message))
+           :contents [,@prompts]
            :safetySettings [(:category "HARM_CATEGORY_HARASSMENT"
                              :threshold "BLOCK_NONE")
                             (:category "HARM_CATEGORY_SEXUALLY_EXPLICIT"
@@ -110,10 +111,6 @@
                   (list :text (string-trim
                                (buffer-substring-no-properties (point-min) 
(point-max)))))
             prompts))
-    (cl-callf (lambda (msg) (concat gptel--system-message "\n\n" msg))
-        (thread-first (car prompts)
-                      (plist-get :parts)
-                      (plist-get :text)))
     prompts))
 
 (cl-defmethod gptel--wrap-user-prompt ((_backend gptel-gemini) prompts)

Reply via email to