branch: elpa/gptel
commit 4817e6cbc2caf44ff334b92928f57d2a31e623d4
Author: James Hood-Smith <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>
gptel-bedrock: Support system prompt and tool caching
* gptel-bedrock.el (gptel--request-data): When `gptel-cache' is
`t' or includes the symbols `system' or `tool', a :cachePoint
block is now appended to the tools array in :toolConfig' enabling
Bedrock's prompt caching for the system message and/or tools.
---
gptel-bedrock.el | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/gptel-bedrock.el b/gptel-bedrock.el
index 8286440f8a..f4399e3364 100644
--- a/gptel-bedrock.el
+++ b/gptel-bedrock.el
@@ -84,11 +84,17 @@ back to the LLM)."
(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--system-message
+ `(:system [(:text ,gptel--system-message)
+ ,@(when (or (eq gptel-cache t) (memq 'system
gptel-cache))
+ '((:cachePoint (:type "default"))))]))
(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)))))))
+ :tools ,(let ((tools (gptel--parse-tools backend
gptel-tools)))
+ (if (or (eq gptel-cache t) (memq 'tool
gptel-cache))
+ (vconcat tools [(:cachePoint (:type
"default"))])
+ tools))))))))
;; Finally, merge all potential :request-params sources.
(gptel--merge-plists