[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gptel ffed97d2e4 05/11: gptel: Adjust persistence for dyna
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gptel ffed97d2e4 05/11: gptel: Adjust persistence for dynamic directives |
Date: |
Sat, 30 Nov 2024 07:00:04 -0500 (EST) |
branch: elpa/gptel
commit ffed97d2e4f5a74d2e2cf6a7216b06192ed60f1f
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
gptel: Adjust persistence for dynamic directives
* gptel.el (gptel--save-state): When saving state, save the static
value of the active gptel directive. This means dynamic
directives will be evaluated, and only the system message part of
directives that are templated conversations will be saved to the
file.
It's not clear yet how to correctly persist dynamic directives.
This limitation may be addressed in the future.
* gptel-org.el (gptel-org-set-properties): Similar adjustments for
Org mode chat buffers.
---
gptel-org.el | 6 +++++-
gptel.el | 6 ++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/gptel-org.el b/gptel-org.el
index 90260fbeb9..1888e8ad0c 100644
--- a/gptel-org.el
+++ b/gptel-org.el
@@ -49,6 +49,7 @@
(declare-function gptel--get-buffer-bounds "gptel")
(declare-function gptel-backend-name "gptel")
(declare-function gptel--parse-buffer "gptel")
+(declare-function gptel--parse-directive "gptel")
(declare-function org-entry-get "org")
(declare-function org-entry-put "org")
(declare-function org-with-wide-buffer "org-macs")
@@ -395,7 +396,10 @@ non-nil (default), display a message afterwards."
(org-entry-put pt "GPTEL_NUM_MESSAGES_TO_SEND"
(number-to-string gptel--num-messages-to-send)))
(org-entry-put pt "GPTEL_SYSTEM"
- (string-replace "\n" "\\n" gptel--system-message))
+ (and-let* ((msg (car-safe
+ (gptel--parse-directive
+ gptel--system-message))))
+ (string-replace "\n" "\\n" msg)))
(when gptel-max-tokens
(org-entry-put
pt "GPTEL_MAX_TOKENS" (number-to-string gptel-max-tokens)))
diff --git a/gptel.el b/gptel.el
index 21c097e7b6..599d5b8929 100644
--- a/gptel.el
+++ b/gptel.el
@@ -1107,9 +1107,11 @@ file."
(gptel-backend-name gptel-backend))
(unless (equal (default-value 'gptel-temperature) gptel-temperature)
(add-file-local-variable 'gptel-temperature gptel-temperature))
- (unless (string= (default-value 'gptel--system-message)
+ (unless (equal (default-value 'gptel--system-message)
gptel--system-message)
- (add-file-local-variable 'gptel--system-message
gptel--system-message))
+ (add-file-local-variable
+ 'gptel--system-message
+ (car-safe (gptel--parse-directive gptel--system-message))))
(when gptel-max-tokens
(add-file-local-variable 'gptel-max-tokens gptel-max-tokens))
(when (natnump gptel--num-messages-to-send)
- [nongnu] elpa/gptel updated (a84461245e -> 7cf8e3b19b), ELPA Syncer, 2024/11/30
- [nongnu] elpa/gptel 4ae9c1b24c 06/11: gptel-rewrite: Improve rewrite UI and feature, ELPA Syncer, 2024/11/30
- [nongnu] elpa/gptel c645444de9 09/11: README: Fix formatting errors, mention more packages, ELPA Syncer, 2024/11/30
- [nongnu] elpa/gptel 04da0a42af 10/11: gptel: Truncate function documentation to newline, ELPA Syncer, 2024/11/30
- [nongnu] elpa/gptel d177822a7f 01/11: README: Add a section about selecting backends explicitly (#467), ELPA Syncer, 2024/11/30
- [nongnu] elpa/gptel ffed97d2e4 05/11: gptel: Adjust persistence for dynamic directives,
ELPA Syncer <=
- [nongnu] elpa/gptel 41158decde 08/11: README: Reorder, adjust formatting, ELPA Syncer, 2024/11/30
- [nongnu] elpa/gptel 7cf8e3b19b 11/11: gptel: Fix gptel--parse-directive, ELPA Syncer, 2024/11/30
- [nongnu] elpa/gptel 10752576e4 02/11: gptel: Move system-message to gptel--request-data, ELPA Syncer, 2024/11/30
- [nongnu] elpa/gptel 67903a1ac5 04/11: gptel: Generalize gptel directives, ELPA Syncer, 2024/11/30
- [nongnu] elpa/gptel 0dacb474f8 03/11: gptel: Add generic gptel--parse-list function, ELPA Syncer, 2024/11/30
- [nongnu] elpa/gptel f887dadb49 07/11: gptel-rewrite: Rewrite directive handling changes, ELPA Syncer, 2024/11/30