gptel-gemini: Simulate system-message for gemini

* gptel-gemini.el (gptel--parse-buffer): The Gemini API does not
provide an explicit system message parameter.  In the interest of
providing a uniform interface, simulate this in gptel by
prepending the first user message with `gptel--system-message`.
This commit is contained in:
Karthik Chikmagalur 2023-12-27 22:35:41 -08:00
parent 60cb406567
commit f571323174

View file

@ -26,6 +26,7 @@
(require 'gptel) (require 'gptel)
(require 'cl-generic) (require 'cl-generic)
(require 'map) (require 'map)
(require 'cl-macs)
(declare-function prop-match-value "text-property-search") (declare-function prop-match-value "text-property-search")
(declare-function text-property-search-backward "text-property-search") (declare-function text-property-search-backward "text-property-search")
@ -95,6 +96,10 @@
(regexp-quote (gptel-response-prefix-string)))))) (regexp-quote (gptel-response-prefix-string))))))
prompts) prompts)
(and max-entries (cl-decf max-entries))) (and max-entries (cl-decf max-entries)))
(cl-callf (lambda (msg) (concat gptel--system-message "\n\n" msg))
(thread-first (car prompts)
(plist-get :parts)
(plist-get :text)))
prompts)) prompts))
;;;###autoload ;;;###autoload