branch: elpa/gptel
commit 73ee1f0f61187b7dd2640bd8192955e43922bf4f
Author: neilenm <neil...@amazon.com>
Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>

    gptel-bedrock: Plumb request-params all the way through (#990)
    
    * gptel-bedrock.el (gptel--request-data): Commit
    3d5fecc90031e30fdf633181a686cf6422f011a1 added partial support for
    passing `request-params' through to the AWS Bedrock backend. This
    commit plumbs it all the way through to `gptel--request-data'.
---
 gptel-bedrock.el | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/gptel-bedrock.el b/gptel-bedrock.el
index 2b6609a749..e2973d7568 100644
--- a/gptel-bedrock.el
+++ b/gptel-bedrock.el
@@ -59,13 +59,22 @@
 
 (cl-defmethod gptel--request-data ((backend gptel-bedrock) prompts)
   "Prepare request data for AWS Bedrock BACKEND from PROMPTS."
-  (nconc
-   `(:messages [,@prompts] :inferenceConfig (:maxTokens ,(or gptel-max-tokens 
500)))
-   (when gptel--system-message `(:system [(:text ,gptel--system-message)]))
-   (when gptel-temperature `(:temperature ,gptel-temperature))
-   (when (and gptel-use-tools gptel-tools)
-     `(:toolConfig (:toolChoice ,(if (eq gptel-use-tools 'force) '(:any '()) 
'(:auto '()))
-                    :tools ,(gptel--parse-tools backend gptel-tools))))))
+  ;; First, build the core Bedrock request data structure.
+  (let ((base-request-data
+         (nconc
+          `(:messages [,@prompts] :inferenceConfig (:maxTokens ,(or 
gptel-max-tokens 500)))
+          (when gptel--system-message `(:system [(:text 
,gptel--system-message)]))
+          (when gptel-temperature `(:temperature ,gptel-temperature))
+          (when (and gptel-use-tools gptel-tools)
+            `(:toolConfig (:toolChoice ,(if (eq gptel-use-tools 'force) '(:any 
'()) '(:auto '()))
+                           :tools ,(gptel--parse-tools backend 
gptel-tools)))))))
+
+    ;; Finally, merge all potential :request-params sources.
+    (gptel--merge-plists
+     base-request-data               ; The core data we just built
+     gptel--request-params           ; Global/buffer-local 
gptel--request-params
+     (gptel-backend-request-params backend) ; From `gptel-make-bedrock` call
+     (gptel--model-request-params gptel-model)))) ; From the model's properties
 
 (cl-defmethod gptel--parse-tools ((_backend gptel-bedrock) tools)
   "Parse TOOLS and return a list of ToolSpecification objects.

Reply via email to