[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gptel 12d0a01891 04/24: gptel: Update inspect-query functi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gptel 12d0a01891 04/24: gptel: Update inspect-query functions for FSM |
Date: |
Mon, 20 Jan 2025 16:01:22 -0500 (EST) |
branch: elpa/gptel
commit 12d0a0189199322cfa0bde060a8994e2a3ce72a2
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
gptel: Update inspect-query functions for FSM
* gptel.el (gptel--continue-query, gptel--inspect-query): Update
to work with gptel's finite state machine. Now
`gptel--inspect-query' takes only the fsm as the first argument.
---
gptel.el | 38 ++++++++++++++++----------------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/gptel.el b/gptel.el
index 0074bea085..90a0733a4a 100644
--- a/gptel.el
+++ b/gptel.el
@@ -1737,20 +1737,21 @@ waiting for the response."
(gptel--update-status " Waiting..." 'warning)))
(declare-function json-pretty-print-buffer "json")
-(defun gptel--inspect-query (request-args &optional format)
- "Show REQUEST-ARGS, the full LLM query to be sent, in a buffer.
+(defun gptel--inspect-query (&optional request-fsm format)
+ "Show the full LLM query that will be sent in a buffer.
-This functions as a dry run of `gptel-send'. If FORMAT is
-the symbol json, show the encoded JSON query instead of the Lisp
-structure gptel uses.
+This functions as a dry run of `gptel-send'. The request data
+may be edited and the query continued from this buffer.
-The request data may be edited and the query continued from this
-buffer."
+REQUEST-FSM is the state of the request, as returned by
+`gptel-request'. If FORMAT is the symbol json, show the encoded
+JSON query instead of the Lisp structure gptel uses."
+ (unless request-fsm (setq request-fsm gptel--fsm-last))
(with-current-buffer (get-buffer-create "*gptel-query*")
(let* ((standard-output (current-buffer))
(inhibit-read-only t)
- (request-info (cadr request-args))
- (request-data (plist-get request-info :data)))
+ (request-data
+ (plist-get (gptel-fsm-info request-fsm) :data)))
(buffer-disable-undo)
(erase-buffer)
(if (eq format 'json)
@@ -1760,11 +1761,7 @@ buffer."
(lisp-data-mode)
(prin1 request-data)
(pp-buffer))
- (plist-put request-info :data nil)
- ;; HACK: Reuse `gptel--bounds' to store request args.
- ;; Not ideal, but less fragile than an overlay.
- (setq-local gptel-stream (car request-args)
- gptel--bounds (cdr request-args))
+ (setq-local gptel--fsm-last request-fsm)
(goto-char (point-min))
(view-mode 1)
(setq buffer-undo-list nil)
@@ -1796,16 +1793,13 @@ specified."
(condition-case-unless-debug nil
(when-let* ((data (if (eq major-mode 'lisp-data-mode)
(read (current-buffer))
- (gptel--json-read)))
- (info (car-safe gptel--bounds)))
- (plist-put info :data data)
- (apply (if gptel-use-curl
- #'gptel-curl-get-response
- #'gptel--url-get-response)
- gptel--bounds)
+ (gptel--json-read))))
+ (cl-assert (cl-typep gptel--fsm-last 'gptel-fsm))
+ (plist-put (gptel-fsm-info gptel--fsm-last) :data data)
+ (gptel--fsm-transition gptel--fsm-last) ;INIT -> WAIT
(quit-window))
(error
- (user-error "Could not read request data from buffer!")))))
+ (user-error "Can not resume request: could not read data from
buffer!")))))
(defun gptel--insert-response (response info)
"Insert the LLM RESPONSE into the gptel buffer.
- [nongnu] elpa/gptel 5a7a391678 12/24: gptel: Separate gptel-request and gptel-send handlers, (continued)
- [nongnu] elpa/gptel 5a7a391678 12/24: gptel: Separate gptel-request and gptel-send handlers, ELPA Syncer, 2025/01/20
- [nongnu] elpa/gptel 4ad0048f1f 14/24: gptel: Add a registry for tools, ELPA Syncer, 2025/01/20
- [nongnu] elpa/gptel 73b13b4d73 10/24: gptel: Activate tool use, ELPA Syncer, 2025/01/20
- [nongnu] elpa/gptel 45de52e845 18/24: gptel: Add controls to confirm/include tool calls, ELPA Syncer, 2025/01/20
- [nongnu] elpa/gptel eb96d04544 07/24: gptel: Add tool call parsing (only) to most backends, ELPA Syncer, 2025/01/20
- [nongnu] elpa/gptel e18e4bf897 11/24: gptel: Add a diagnostic display for latest request, ELPA Syncer, 2025/01/20
- [nongnu] elpa/gptel da66b37c75 24/24: testing: Update test submodule, ELPA Syncer, 2025/01/20
- [nongnu] elpa/gptel 63a6f89182 22/24: gptel: Handle Ollama + streaming + tool-use incompatibility, ELPA Syncer, 2025/01/20
- [nongnu] elpa/gptel 6f612f9102 23/24: gptel: Set tool-use capability flag for models, ELPA Syncer, 2025/01/20
- [nongnu] elpa/gptel 6324426b6e 08/24: gptel: Add tool definition and result parsers, ELPA Syncer, 2025/01/20
- [nongnu] elpa/gptel 12d0a01891 04/24: gptel: Update inspect-query functions for FSM,
ELPA Syncer <=
- [nongnu] elpa/gptel b3010047fc 20/24: gptel: Handle pending calls/call results in chat buffers, ELPA Syncer, 2025/01/20
- [nongnu] elpa/gptel 67a9b697c7 21/24: README: Add tool-use description, ELPA Syncer, 2025/01/20