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

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

[nongnu] elpa/gptel 0d26b34526 029/273: gptel: Add a debug flag


From: ELPA Syncer
Subject: [nongnu] elpa/gptel 0d26b34526 029/273: gptel: Add a debug flag
Date: Wed, 1 May 2024 10:01:30 -0400 (EDT)

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

    gptel: Add a debug flag
    
    gptel.el (gptel--debug, gptel--url-parse-response): Add a debug
    flag that shows the http response.  Fix json parsing error.
    
    gptel-curl.el (gptel-curl--sentinel): Ditto.
---
 gptel-curl.el | 3 +++
 gptel.el      | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/gptel-curl.el b/gptel-curl.el
index 4f2348f36e..01b744227c 100644
--- a/gptel-curl.el
+++ b/gptel-curl.el
@@ -93,6 +93,9 @@ PROMPTS is the data to send, TOKEN is a unique identifier."
 
 PROCESS and STATUS are process parameters."
   (let ((proc-buf (process-buffer process)))
+    (when gptel--debug
+      (with-current-buffer proc-buf
+        (clone-buffer "*gptel-error*" 'show)))
     (if-let* ((ok-p (equal status "finished\n"))
               (proc-info (alist-get process gptel-curl--process-alist))
               (proc-token (plist-get proc-info :token))
diff --git a/gptel.el b/gptel.el
index ca6f18fcb6..d1c929c765 100644
--- a/gptel.el
+++ b/gptel.el
@@ -114,6 +114,7 @@ return the transformed string."
     (writing . "You are a large language model and a writing assistant. 
Respond concisely.")
     (chat . "You are a large language model and a conversation partner. 
Respond concisely."))
   "Prompt templates (directives).")
+(defvar gptel--debug nil)
 (defvar-local gptel--max-tokens nil)
 (defvar-local gptel--model "gpt-3.5-turbo")
 (defvar-local gptel--temperature 1.0)
@@ -296,9 +297,13 @@ Return the message received."
 (defun gptel--url-parse-response (response-buffer)
   "Parse response in RESPONSE-BUFFER."
   (when (buffer-live-p response-buffer)
+    (when gptel--debug
+      (with-current-buffer response-buffer
+        (clone-buffer "*gptel-error*" 'show)))
     (with-current-buffer response-buffer
       (if-let* ((status (buffer-substring (line-beginning-position) 
(line-end-position)))
                 ((string-match-p "200 OK" status))
+                (json-object-type 'plist)
                 (response (progn (forward-paragraph)
                                  (json-read)))
                 (content (map-nested-elt



reply via email to

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