[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gptel a660e13a8b 106/273: gptel, gptel-transient: Fix read
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gptel a660e13a8b 106/273: gptel, gptel-transient: Fix read temperature from minibuffer (#85) |
Date: |
Wed, 1 May 2024 10:02:09 -0400 (EDT) |
branch: elpa/gptel
commit a660e13a8bdea101d56cdbab0cb10731b8b8f1fa
Author: Tianshu Wang <wang@tianshu.me>
Commit: GitHub <noreply@github.com>
gptel, gptel-transient: Fix read temperature from minibuffer (#85)
gptel-transient.el (gtel--transient-read-variable): Use a custom transient
infix reader.
gptel.el (gptel--request-data): Don't use `gptel--numberize'.
---
gptel-transient.el | 13 ++++++++-----
gptel.el | 11 +++++------
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/gptel-transient.el b/gptel-transient.el
index 9894be0f82..7a3daa622d 100644
--- a/gptel-transient.el
+++ b/gptel-transient.el
@@ -230,6 +230,10 @@ Customize `gptel-directives' for task-specific prompts."
;; ** Infixes for model parameters
+(defun gptel--transient-read-variable (prompt initial-input history)
+ "Read value from minibuffer and interpret the result as a Lisp object."
+ (read-from-minibuffer prompt initial-input read-expression-map t history))
+
(transient-define-infix gptel--infix-num-messages-to-send ()
"Number of recent messages to send with each exchange.
@@ -242,7 +246,7 @@ include."
:variable 'gptel--num-messages-to-send
:key "n"
:prompt "Number of past messages to include for context (leave empty for
all): "
- :reader 'transient-read-number-N0)
+ :reader 'gptel--transient-read-variable)
(transient-define-infix gptel--infix-max-tokens ()
"Max tokens per response.
@@ -259,7 +263,7 @@ will get progressively longer!"
:variable 'gptel-max-tokens
:key "<"
:prompt "Response length in tokens (leave empty: default, 80-200: short,
200-500: long): "
- :reader 'transient-read-number-N+)
+ :reader 'gptel--transient-read-variable)
(transient-define-infix gptel--infix-model ()
"AI Model for Chat."
@@ -279,9 +283,8 @@ will get progressively longer!"
:class 'transient-lisp-variable
:variable 'gptel-temperature
:key "t"
- :reader (lambda (&rest _)
- (read-from-minibuffer "Set temperature (0.0-2.0, leave empty for
default): "
- (number-to-string gptel-temperature))))
+ :prompt "Set temperature (0.0-2.0, leave empty for default): "
+ :reader 'gptel--transient-read-variable)
;; ** Infix for the refactor/rewrite system message
diff --git a/gptel.el b/gptel.el
index ba7ca40f10..87591918a7 100644
--- a/gptel.el
+++ b/gptel.el
@@ -263,7 +263,7 @@ By default, `gptel-host' is used as HOST and \"apikey\" as
USER."
secret)
(user-error "No `gptel-api-key' found in the auth source")))
-;; FIXME Should we utf-8 encode the api-key here?
+;; FIXME Should we utf-8 encode the api-key here?
(defun gptel--api-key ()
"Get api key from `gptel-api-key'."
(pcase gptel-api-key
@@ -496,7 +496,7 @@ Model parameters can be let-bound around calls to this
function."
(set-marker (make-marker) position buffer))))
(full-prompt
(cond
- ((null prompt)
+ ((null prompt)
(let ((gptel--system-message system))
(gptel--create-prompt start-marker)))
((stringp prompt)
@@ -630,8 +630,7 @@ there."
(goto-char (point-max))))
(t (goto-char (or prompt-end (point-max)))))
(let ((max-entries (and gptel--num-messages-to-send
- (* 2 (gptel--numberize
- gptel--num-messages-to-send))))
+ (* 2 gptel--num-messages-to-send)))
(prop) (prompts))
(while (and
(or (not max-entries) (>= max-entries 0))
@@ -659,9 +658,9 @@ there."
:messages [,@prompts]
:stream ,(or (and gptel-stream gptel-use-curl) :json-false))))
(when gptel-temperature
- (plist-put prompts-plist :temperature (gptel--numberize
gptel-temperature)))
+ (plist-put prompts-plist :temperature gptel-temperature))
(when gptel-max-tokens
- (plist-put prompts-plist :max_tokens (gptel--numberize
gptel-max-tokens)))
+ (plist-put prompts-plist :max_tokens gptel-max-tokens))
prompts-plist))
;; TODO: Use `run-hook-wrapped' with an accumulator instead to handle
- [nongnu] elpa/gptel 149261ee79 211/273: gptel-transient: Avoid clashes with the custom directive key (#219), (continued)
- [nongnu] elpa/gptel 149261ee79 211/273: gptel-transient: Avoid clashes with the custom directive key (#219), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel dd5833eef3 023/273: gptel: Improve gptel-mode setup, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 3d0df72bd3 027/273: gptel-transient: linting for MELPA, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 2982ede17d 255/273: gptel-org: Add gptel-org, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 9bc54bed9c 244/273: gptel-transient: Remove "-ts" suffix from major mode (#259), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 9a5a4a60d5 248/273: README: Mention wiki entry on saving transient flags, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 8dbcbbb908 256/273: gptel-org: Move session save/restore code for Org, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 1b47235e25 071/273: README: Add section on gptel-request, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel bb8b37d8c0 100/273: gptel, gptel-curl: Fix byte-compile warnings, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 219e163dc7 091/273: gptel-curl: Add gptel-abort, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel a660e13a8b 106/273: gptel, gptel-transient: Fix read temperature from minibuffer (#85),
ELPA Syncer <=
- [nongnu] elpa/gptel c0ffce0849 110/273: gptel: Fix reading bounds in org files (#98), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 648fa228a1 115/273: gptel: Fix check for markdown-mode (#109), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 63027083cd 125/273: README: Update additional customization section, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 57a70c23cb 131/273: gptel: Skip to end of word before sending, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 1434bbac7b 122/273: gptel-ollama, gptel-openai: Add example of backend creation, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 8973498378 151/273: gptel: Add minimal status indicator via mode-line-process, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 3dd00a7457 145/273: gptel-gemini: Add streaming responses, simplify configuration, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 8d3e08faa8 157/273: gptel: Don't use called-interactively-p, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel febeada960 172/273: gptel: Make gptel-backend customizable, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 612aea3456 178/273: gptel: Make gptel-post-response-* easier to use, ELPA Syncer, 2024/05/01