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

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

[nongnu] elpa/gptel 859e7c753f: gptel-ollama: Merge request options corr


From: ELPA Syncer
Subject: [nongnu] elpa/gptel 859e7c753f: gptel-ollama: Merge request options correctly (#473, #490)
Date: Fri, 13 Dec 2024 19:01:18 -0500 (EST)

branch: elpa/gptel
commit 859e7c753fe90c05ebfde06f6b1aee130b404da7
Author: Andrew De Angelis <bobodeangelis@gmail.com>
Commit: GitHub <noreply@github.com>

    gptel-ollama: Merge request options correctly (#473, #490)
    
    * gptel-ollama.el (gptel--request-data): Merge request options for
    an Ollama request specified by the model/backend configuration and
    gptel options (like `gptel-temperature') correctly.
---
 gptel-ollama.el | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/gptel-ollama.el b/gptel-ollama.el
index dc2a2da6b4..cd0b83e7b9 100644
--- a/gptel-ollama.el
+++ b/gptel-ollama.el
@@ -80,31 +80,27 @@ Intended for internal use only.")
     (push (list :role "system"
                 :content gptel--system-message)
           prompts))
-  (let ((prompts-plist
-         `(:model ,(gptel--model-name gptel-model)
-           :messages [,@prompts]
-           :stream ,(or (and gptel-stream gptel-use-curl
-                         (gptel-backend-stream gptel-backend))
-                     :json-false)))
-        options-plist)
-    (when gptel-temperature
+  (let* ((prompts-plist
+          (gptel--merge-plists
+           `(:model ,(gptel--model-name gptel-model)
+             :messages [,@prompts]
+             :stream ,(or (and gptel-stream gptel-use-curl
+                               (gptel-backend-stream gptel-backend))
+                          :json-false))
+           (gptel-backend-request-params gptel-backend)
+           (gptel--model-request-params  gptel-model)))
+         ;; the initial options (if any) from request params
+         (options-plist (plist-get prompts-plist :options)))
+
+    ;; if the temperature and max-tokens aren't set as
+    ;; backend/model-specific, use the global settings
+    (when (and gptel-temperature (not (plist-get options-plist :temperature)))
       (setq options-plist
-            (plist-put options-plist :temperature
-                       gptel-temperature)))
-    (when gptel-max-tokens
+            (plist-put options-plist :temperature gptel-temperature)))
+    (when (and gptel-max-tokens (not (plist-get options-plist :num_predict)))
       (setq options-plist
-            (plist-put options-plist :num_predict
-                       gptel-max-tokens)))
-    ;; FIXME: These options will be lost if there are model/backend-specific
-    ;; :options, since `gptel--merge-plists' does not merge plist values
-    ;; recursively.
-    (when options-plist
-      (plist-put prompts-plist :options options-plist))
-    ;; Merge request params with model and backend params.
-    (gptel--merge-plists
-     prompts-plist
-     (gptel-backend-request-params gptel-backend)
-     (gptel--model-request-params  gptel-model))))
+            (plist-put options-plist :num_predict gptel-max-tokens)))
+    (plist-put prompts-plist :options options-plist)))
 
 (cl-defmethod gptel--parse-list ((_backend gptel-ollama) prompt-list)
   (cl-loop for text in prompt-list



reply via email to

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