emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gptel 47e15bad16 1/2: gptel: Add gptel-post-request-hook


From: ELPA Syncer
Subject: [nongnu] elpa/gptel 47e15bad16 1/2: gptel: Add gptel-post-request-hook
Date: Sun, 29 Dec 2024 01:00:16 -0500 (EST)

branch: elpa/gptel
commit 47e15bad161e69efbadb84521965aa197ac0b7cd
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>

    gptel: Add gptel-post-request-hook
    
    * gptel.el (gptel-request, gptel-post-request-hook): Add hook that
    runs after the request is sent, and (possibly) before any response
    is received.  The intent of this hook is to run preparatory or
    reset code.  One application of this is the (forthcoming)
    implementation of "oneshot" settings, where model parameters can
    be set from the transient menu for the next response only.
---
 gptel.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gptel.el b/gptel.el
index 56f59bb418..b1b591cff7 100644
--- a/gptel.el
+++ b/gptel.el
@@ -261,6 +261,12 @@ The default for windows comes from Microsoft documentation 
located here:
 
https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa";
   :type 'natnum)
 
+(defcustom gptel-post-request-hook nil
+  "Hook run after sending a gptel request.
+
+This runs (possibly) before any response is received."
+  :type 'hook)
+
 (defcustom gptel-response-filter-functions
   (list #'gptel--convert-org)
   "Abnormal hook for transforming the response from an LLM.
@@ -1424,7 +1430,8 @@ be used to rerun or continue the request at a later time."
     (unless dry-run
       (funcall (if gptel-use-curl
                    #'gptel-curl-get-response #'gptel--url-get-response)
-               info callback))
+               info callback)
+      (run-hooks 'gptel-post-request-hook))
     (list stream info callback)))
 
 (defvar gptel--request-alist nil "Alist of active gptel requests.")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]